install.sh 42 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016
  1. #!/bin/bash
  2. # Author: yeho <lj2007331 AT gmail.com>
  3. # BLOG: https://blog.linuxeye.cn
  4. #
  5. # Notes: OneinStack for CentOS/RadHat 6+ Debian 7+ and Ubuntu 12+
  6. #
  7. # Project home page:
  8. # https://oneinstack.com
  9. # https://github.com/lj2007331/oneinstack
  10. export PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
  11. clear
  12. printf "
  13. #######################################################################
  14. # OneinStack for CentOS/RadHat 6+ Debian 7+ and Ubuntu 12+ #
  15. # For more information please visit https://oneinstack.com #
  16. #######################################################################
  17. "
  18. # Check if user is root
  19. [ $(id -u) != "0" ] && { echo "${CFAILURE}Error: You must be root to run this script${CEND}"; exit 1; }
  20. oneinstack_dir=$(dirname "`readlink -f $0`")
  21. pushd ${oneinstack_dir} > /dev/null
  22. . ./versions.txt
  23. . ./options.conf
  24. . ./include/color.sh
  25. . ./include/check_os.sh
  26. . ./include/check_dir.sh
  27. . ./include/download.sh
  28. . ./include/get_char.sh
  29. ssh_port=22
  30. phpcache_option=1
  31. dbrootpwd=`< /dev/urandom tr -dc A-Za-z0-9 | head -c8`
  32. xcachepwd=`< /dev/urandom tr -dc A-Za-z0-9 | head -c8`
  33. dbinstallmethod=1
  34. version() {
  35. echo "version: 1.7"
  36. echo "updated date: 2018-03-22"
  37. }
  38. showhelp() {
  39. version
  40. echo "Usage: $0 command ...[parameters]....
  41. --help, -h Show this help message
  42. --version, -v Show version info
  43. --nginx_option [1-3] Install Nginx server version
  44. --apache_option [1-2] Install Apache server version
  45. --php_option [1-7] Install PHP version
  46. --phpcache_option [1-4] Install PHP opcode cache, default: 1 opcache
  47. --php_extensions [ext name] Install PHP extension, include zendguardloader,ioncube,imagick,gmagick
  48. --tomcat_option [1-2] Install Tomcat version
  49. --jdk_option [1-2] Install JDK version
  50. --db_option [1-13] Install DB version
  51. --dbinstallmethod [1-2] DB install method, default: 1 binary install
  52. --dbrootpwd [password] DB super password
  53. --pureftpd Install Pure-Ftpd
  54. --redis Install Redis
  55. --memcached Install Memcached
  56. --phpmyadmin Install phpMyAdmin
  57. --hhvm Install HHVM
  58. --ssh_port [22] SSH port, default: 22
  59. --iptables Enable iptables
  60. --reboot Restart the server after installation
  61. "
  62. }
  63. ARG_NUM=$#
  64. TEMP=`getopt -o hvV --long help,version,nginx_option:,apache_option:,php_option:,phpcache_option:,php_extensions:,tomcat_option:,jdk_option:,db_option:,dbrootpwd:,dbinstallmethod:,pureftpd,redis,memcached,phpmyadmin,hhvm,ssh_port:,iptables,reboot -- "$@" 2>/dev/null`
  65. [ $? != 0 ] && echo "${CWARNING}ERROR: unknown argument! ${CEND}" && showhelp && exit 1
  66. eval set -- "${TEMP}"
  67. while :; do
  68. [ -z "$1" ] && break;
  69. case "$1" in
  70. -h|--help)
  71. showhelp; exit 0
  72. ;;
  73. -v|-V|--version)
  74. version; exit 0
  75. ;;
  76. --nginx_option)
  77. nginx_option=$2; shift 2
  78. [[ ! ${nginx_option} =~ ^[1-3]$ ]] && { echo "${CWARNING}nginx_option input error! Please only input number 1~3${CEND}"; exit 1; }
  79. web_yn=y
  80. [ -e "${nginx_install_dir}/sbin/nginx" ] && { echo "${CWARNING}Nginx already installed! ${CEND}"; nginx_option=Other; }
  81. [ -e "${tengine_install_dir}/sbin/nginx" ] && { echo "${CWARNING}Tengine already installed! ${CEND}"; nginx_option=Other; }
  82. [ -e "${openresty_install_dir}/nginx/sbin/nginx" ] && { echo "${CWARNING}OpenResty already installed! ${CEND}"; nginx_option=Other; }
  83. ;;
  84. --apache_option)
  85. apache_option=$2; shift 2
  86. [[ ! ${apache_option} =~ ^[1-2]$ ]] && { echo "${CWARNING}apache_option input error! Please only input number 1~2${CEND}"; exit 1; }
  87. web_yn=y
  88. [ -e "${apache_install_dir}/conf/httpd.conf" ] && { echo "${CWARNING}Aapche already installed! ${CEND}"; apache_option=Other; }
  89. ;;
  90. --php_option)
  91. php_option=$2; shift 2
  92. [[ ! ${php_option} =~ ^[1-7]$ ]] && { echo "${CWARNING}php_option input error! Please only input number 1~7${CEND}"; exit 1; }
  93. php_yn=y
  94. [ -e "${php_install_dir}/bin/phpize" ] && { echo "${CWARNING}PHP already installed! ${CEND}"; php_yn=Other; }
  95. ;;
  96. --phpcache_option)
  97. [[ ! ${phpcache_option} =~ ^[1-4]$ ]] && { echo "${CWARNING}phpcache_option input error! Please only input number 1~4${CEND}"; exit 1; }
  98. phpcache_option=$2; shift 2
  99. ;;
  100. --php_extensions)
  101. php_extensions=$2; shift 2
  102. [ -n "`echo ${php_extensions} | grep -w zendguardloader`" ] && zendguardloader_yn=y
  103. [ -n "`echo ${php_extensions} | grep -w ioncube`" ] && ioncube_yn=y
  104. [ -n "`echo ${php_extensions} | grep -w imagick`" ] && magick_option=1
  105. [ -n "`echo ${php_extensions} | grep -w gmagick`" ] && magick_option=2
  106. ;;
  107. --tomcat_option)
  108. tomcat_option=$2; shift 2
  109. [[ ! ${tomcat_option} =~ ^[1-3]$ ]] && { echo "${CWARNING}tomcat_option input error! Please only input number 1~3${CEND}"; exit 1; }
  110. web_yn=y
  111. [ -e "$tomcat_install_dir/conf/server.xml" ] && { echo "${CWARNING}Tomcat already installed! ${CEND}" ; tomcat_option=Other; }
  112. ;;
  113. --jdk_option)
  114. jdk_option=$2; shift 2
  115. [[ ! ${jdk_option} =~ ^[1-2]$ ]] && { echo "${CWARNING}jdk_option input error! Please only input number 1~2${CEND}"; exit 1; }
  116. ;;
  117. --db_option)
  118. db_option=$2; shift 2
  119. [[ ! "${db_option}" =~ ^[1-9]$|^1[0-3]$ ]] && { echo "${CWARNING}db_option input error! Please only input number 1~13${CEND}"; exit 1; }
  120. db_yn=y
  121. if [ "${db_option}" == '12' ]; then
  122. [ -e "${pgsql_install_dir}/bin/psql" ] && { echo "${CWARNING}PostgreSQL already installed! ${CEND}"; db_yn=Other; }
  123. elif [ "${db_option}" == '13' ]; then
  124. [ -e "${mongo_install_dir}/bin/mongo" ] && { echo "${CWARNING}MongoDB already installed! ${CEND}"; db_yn=Other; }
  125. else
  126. [ -d "${db_install_dir}/support-files" ] && { echo "${CWARNING}MySQL already installed! ${CEND}"; db_yn=Other; }
  127. fi
  128. ;;
  129. --dbrootpwd)
  130. dbrootpwd=$2; shift 2
  131. if [ "${db_yn}" == 'y' ]; then
  132. if [ "${db_option}" == '12' ]; then
  133. sed -i "s+^dbpostgrespwd.*+dbpostgrespwd='$dbrootpwd'+" ./options.conf
  134. dbpostgrespwd="$dbrootpwd"
  135. elif [ "${db_option}" == '13' ]; then
  136. sed -i "s+^dbmongopwd.*+dbmongopwd='$dbrootpwd'+" ./options.conf
  137. dbmongopwd="$dbrootpwd"
  138. else
  139. sed -i "s+^dbrootpwd.*+dbrootpwd='$dbrootpwd'+" ./options.conf
  140. fi
  141. fi
  142. ;;
  143. --dbinstallmethod)
  144. dbinstallmethod=$2; shift 2
  145. [[ ! ${dbinstallmethod} =~ ^[1-2]$ ]] && { echo "${CWARNING}dbinstallmethod input error! Please only input number 1~2${CEND}"; exit 1; }
  146. ;;
  147. --pureftpd)
  148. ftp_yn=y; shift 1
  149. [ -e "${pureftpd_install_dir}/sbin/pure-ftpwho" ] && { echo "${CWARNING}Pure-FTPd already installed! ${CEND}"; ftp_yn=Other; }
  150. ;;
  151. --redis)
  152. redis_yn=y; shift 1
  153. ;;
  154. --memcached)
  155. memcached_yn=y; shift 1
  156. ;;
  157. --phpmyadmin)
  158. phpmyadmin_yn=y; shift 1
  159. [ -d "${wwwroot_dir}/default/phpMyAdmin" ] && { echo "${CWARNING}phpMyAdmin already installed! ${CEND}"; phpmyadmin_yn=Other; }
  160. ;;
  161. --hhvm)
  162. hhvm_yn=y; shift 1
  163. [ -e "/usr/bin/hhvm" ] && { echo "${CWARNING}HHVM already installed! ${CEND}"; hhvm_yn=Other; }
  164. ;;
  165. --ssh_port)
  166. ssh_port=$2; shift 2
  167. [ ${ssh_port} -ne 22 >/dev/null 2>&1 -o ${ssh_port} -lt 1024 >/dev/null 2>&1 -a ${ssh_port} -gt 65535 >/dev/null 2>&1 ] && { echo "${CWARNING}ssh_port input error! Input range: 22,1025~65534${CEND}"; exit 1; }
  168. ;;
  169. --iptables)
  170. iptables_yn=y; shift 1
  171. ;;
  172. --reboot)
  173. reboot_yn=y; shift 1
  174. ;;
  175. --)
  176. shift
  177. ;;
  178. *)
  179. echo "${CWARNING}ERROR: unknown argument! ${CEND}" && showhelp && exit 1
  180. ;;
  181. esac
  182. done
  183. mkdir -p ${wwwroot_dir}/default ${wwwlogs_dir}
  184. [ -d /data ] && chmod 755 /data
  185. # Use default SSH port 22. If you use another SSH port on your server
  186. if [ -e "/etc/ssh/sshd_config" ]; then
  187. if [ ${ARG_NUM} == 0 ]; then
  188. [ -z "`grep ^Port /etc/ssh/sshd_config`" ] && now_ssh_port=22 || now_ssh_port=`grep ^Port /etc/ssh/sshd_config | awk '{print $2}'`
  189. while :; do echo
  190. read -p "Please input SSH port(Default: ${now_ssh_port}): " ssh_port
  191. [ -z "${ssh_port}" ] && ssh_port=${now_ssh_port}
  192. if [ ${ssh_port} -eq 22 >/dev/null 2>&1 -o ${ssh_port} -gt 1024 >/dev/null 2>&1 -a ${ssh_port} -lt 65535 >/dev/null 2>&1 ]; then
  193. break
  194. else
  195. echo "${CWARNING}input error! Input range: 22,1025~65534${CEND}"
  196. fi
  197. done
  198. fi
  199. if [ -z "`grep ^Port /etc/ssh/sshd_config`" -a "${ssh_port}" != '22' ]; then
  200. sed -i "s@^#Port.*@&\nPort ${ssh_port}@" /etc/ssh/sshd_config
  201. elif [ -n "`grep ^Port /etc/ssh/sshd_config`" ]; then
  202. sed -i "s@^Port.*@Port ${ssh_port}@" /etc/ssh/sshd_config
  203. fi
  204. fi
  205. if [ ${ARG_NUM} == 0 ]; then
  206. # check iptables
  207. while :; do echo
  208. read -p "Do you want to enable iptables? [y/n]: " iptables_yn
  209. if [[ ! ${iptables_yn} =~ ^[y,n]$ ]]; then
  210. echo "${CWARNING}input error! Please only input 'y' or 'n'${CEND}"
  211. else
  212. break
  213. fi
  214. done
  215. # check Web server
  216. while :; do echo
  217. read -p "Do you want to install Web server? [y/n]: " web_yn
  218. if [[ ! ${web_yn} =~ ^[y,n]$ ]]; then
  219. echo "${CWARNING}input error! Please only input 'y' or 'n'${CEND}"
  220. else
  221. if [ "${web_yn}" == 'y' ]; then
  222. # Nginx/Tegine/OpenResty
  223. while :; do echo
  224. echo 'Please select Nginx server:'
  225. echo -e "\t${CMSG}1${CEND}. Install Nginx"
  226. echo -e "\t${CMSG}2${CEND}. Install Tengine"
  227. echo -e "\t${CMSG}3${CEND}. Install OpenResty"
  228. echo -e "\t${CMSG}4${CEND}. Do not install"
  229. read -p "Please input a number:(Default 1 press Enter) " nginx_option
  230. [ -z "${nginx_option}" ] && nginx_option=1
  231. if [[ ! ${nginx_option} =~ ^[1-4]$ ]]; then
  232. echo "${CWARNING}input error! Please only input number 1~4${CEND}"
  233. else
  234. [ "${nginx_option}" != '4' -a -e "${nginx_install_dir}/sbin/nginx" ] && { echo "${CWARNING}Nginx already installed! ${CEND}"; nginx_option=Other; }
  235. [ "${nginx_option}" != '4' -a -e "${tengine_install_dir}/sbin/nginx" ] && { echo "${CWARNING}Tengine already installed! ${CEND}"; nginx_option=Other; }
  236. [ "${nginx_option}" != '4' -a -e "${openresty_install_dir}/nginx/sbin/nginx" ] && { echo "${CWARNING}OpenResty already installed! ${CEND}"; nginx_option=Other; }
  237. break
  238. fi
  239. done
  240. # Apache
  241. while :; do echo
  242. echo 'Please select Apache server:'
  243. echo -e "\t${CMSG}1${CEND}. Install Apache-2.4"
  244. echo -e "\t${CMSG}2${CEND}. Install Apache-2.2"
  245. echo -e "\t${CMSG}3${CEND}. Do not install"
  246. read -p "Please input a number:(Default 3 press Enter) " apache_option
  247. [ -z "${apache_option}" ] && apache_option=3
  248. if [[ ! ${apache_option} =~ ^[1-3]$ ]]; then
  249. echo "${CWARNING}input error! Please only input number 1~3${CEND}"
  250. else
  251. [ "${apache_option}" != '3' -a -e "${apache_install_dir}/conf/httpd.conf" ] && { echo "${CWARNING}Aapche already installed! ${CEND}"; apache_option=Other; }
  252. break
  253. fi
  254. done
  255. # Tomcat
  256. while :; do echo
  257. echo 'Please select tomcat server:'
  258. echo -e "\t${CMSG}1${CEND}. Install Tomcat-8"
  259. echo -e "\t${CMSG}2${CEND}. Install Tomcat-7"
  260. echo -e "\t${CMSG}3${CEND}. Install Tomcat-6"
  261. echo -e "\t${CMSG}4${CEND}. Do not install"
  262. read -p "Please input a number:(Default 4 press Enter) " tomcat_option
  263. [ -z "${tomcat_option}" ] && tomcat_option=4
  264. if [[ ! ${tomcat_option} =~ ^[1-4]$ ]]; then
  265. echo "${CWARNING}input error! Please only input number 1~4${CEND}"
  266. else
  267. [ "${tomcat_option}" != '4' -a -e "$tomcat_install_dir/conf/server.xml" ] && { echo "${CWARNING}Tomcat already installed! ${CEND}" ; tomcat_option=Other; }
  268. if [ "${tomcat_option}" == '1' ]; then
  269. while :; do echo
  270. echo 'Please select JDK version:'
  271. echo -e "\t${CMSG}1${CEND}. Install JDK-1.8"
  272. echo -e "\t${CMSG}2${CEND}. Install JDK-1.7"
  273. read -p "Please input a number:(Default 2 press Enter) " jdk_option
  274. [ -z "${jdk_option}" ] && jdk_option=2
  275. if [[ ! ${jdk_option} =~ ^[1-2]$ ]]; then
  276. echo "${CWARNING}input error! Please only input number 1~2${CEND}"
  277. else
  278. break
  279. fi
  280. done
  281. elif [ "${tomcat_option}" == '2' ]; then
  282. while :; do echo
  283. echo 'Please select JDK version:'
  284. echo -e "\t${CMSG}1${CEND}. Install JDK-1.8"
  285. echo -e "\t${CMSG}2${CEND}. Install JDK-1.7"
  286. echo -e "\t${CMSG}3${CEND}. Install JDK-1.6"
  287. read -p "Please input a number:(Default 2 press Enter) " jdk_option
  288. [ -z "${jdk_option}" ] && jdk_option=2
  289. if [[ ! ${jdk_option} =~ ^[1-3]$ ]]; then
  290. echo "${CWARNING}input error! Please only input number 1~3${CEND}"
  291. else
  292. break
  293. fi
  294. done
  295. elif [ "${tomcat_option}" == '3' ]; then
  296. while :; do echo
  297. echo 'Please select JDK version:'
  298. echo -e "\t${CMSG}2${CEND}. Install JDK-1.7"
  299. echo -e "\t${CMSG}3${CEND}. Install JDK-1.6"
  300. read -p "Please input a number:(Default 2 press Enter) " jdk_option
  301. [ -z "${jdk_option}" ] && jdk_option=2
  302. if [[ ! ${jdk_option} =~ ^[2-3]$ ]]; then
  303. echo "${CWARNING}input error! Please only input number 2~3${CEND}"
  304. else
  305. break
  306. fi
  307. done
  308. fi
  309. break
  310. fi
  311. done
  312. fi
  313. break
  314. fi
  315. done
  316. # choice database
  317. while :; do echo
  318. read -p "Do you want to install Database? [y/n]: " db_yn
  319. if [[ ! ${db_yn} =~ ^[y,n]$ ]]; then
  320. echo "${CWARNING}input error! Please only input 'y' or 'n'${CEND}"
  321. else
  322. if [ "${db_yn}" == 'y' ]; then
  323. while :; do echo
  324. echo 'Please select a version of the Database:'
  325. echo -e "\t${CMSG} 1${CEND}. Install MySQL-5.7"
  326. echo -e "\t${CMSG} 2${CEND}. Install MySQL-5.6"
  327. echo -e "\t${CMSG} 3${CEND}. Install MySQL-5.5"
  328. echo -e "\t${CMSG} 4${CEND}. Install MariaDB-10.2"
  329. echo -e "\t${CMSG} 5${CEND}. Install MariaDB-10.1"
  330. echo -e "\t${CMSG} 6${CEND}. Install MariaDB-10.0"
  331. echo -e "\t${CMSG} 7${CEND}. Install MariaDB-5.5"
  332. echo -e "\t${CMSG} 8${CEND}. Install Percona-5.7"
  333. echo -e "\t${CMSG} 9${CEND}. Install Percona-5.6"
  334. echo -e "\t${CMSG}10${CEND}. Install Percona-5.5"
  335. echo -e "\t${CMSG}11${CEND}. Install AliSQL-5.6"
  336. echo -e "\t${CMSG}12${CEND}. Install PostgreSQL"
  337. echo -e "\t${CMSG}13${CEND}. Install MongoDB"
  338. read -p "Please input a number:(Default 2 press Enter) " db_option
  339. [ -z "${db_option}" ] && db_option=2
  340. [ "${db_option}" == '13' -a "$OS_BIT" == '32' ] && { echo "${CWARNING}By not supporting 32-bit! ${CEND}"; continue; }
  341. if [[ "${db_option}" =~ ^[1-9]$|^1[0-3]$ ]]; then
  342. if [ "${db_option}" == '12' ]; then
  343. [ -e "${pgsql_install_dir}/bin/psql" ] && { echo "${CWARNING}PostgreSQL already installed! ${CEND}"; db_yn=Other; break; }
  344. elif [ "${db_option}" == '13' ]; then
  345. [ -e "${mongo_install_dir}/bin/mongo" ] && { echo "${CWARNING}MongoDB already installed! ${CEND}"; db_yn=Other; break; }
  346. else
  347. [ -d "${db_install_dir}/support-files" ] && { echo "${CWARNING}MySQL already installed! ${CEND}"; db_yn=Other; break; }
  348. fi
  349. while :; do
  350. if [ "${db_option}" == '12' ]; then
  351. read -p "Please input the postgres password of database(default: ${dbrootpwd}): " dbrootpwd
  352. else
  353. read -p "Please input the root password of database(default: ${dbrootpwd}): " dbrootpwd
  354. fi
  355. [ -z "${dbrootpwd}" ] && dbrootpwd=${dbrootpwd}
  356. [ -n "`echo $dbrootpwd | grep '[+|&]'`" ] && { echo "${CWARNING}input error,not contain a plus sign (+) and & ${CEND}"; continue; }
  357. if (( ${#dbrootpwd} >= 5 )); then
  358. if [ "${db_option}" == '12' ]; then
  359. sed -i "s+^dbpostgrespwd.*+dbpostgrespwd='$dbrootpwd'+" ./options.conf
  360. dbpostgrespwd="$dbrootpwd"
  361. elif [ "${db_option}" == '13' ]; then
  362. sed -i "s+^dbmongopwd.*+dbmongopwd='$dbrootpwd'+" ./options.conf
  363. dbmongopwd="$dbrootpwd"
  364. else
  365. sed -i "s+^dbrootpwd.*+dbrootpwd='$dbrootpwd'+" ./options.conf
  366. fi
  367. break
  368. else
  369. echo "${CWARNING}password least 5 characters! ${CEND}"
  370. fi
  371. done
  372. # choose install methods
  373. if [[ "${db_option}" =~ ^[1-9]$|^10$ ]]; then
  374. while :; do echo
  375. echo "Please choose installation of the database:"
  376. echo -e "\t${CMSG}1${CEND}. Install database from binary package."
  377. echo -e "\t${CMSG}2${CEND}. Install database from source package."
  378. read -p "Please input a number:(Default 1 press Enter) " dbinstallmethod
  379. [ -z "${dbinstallmethod}" ] && dbinstallmethod=1
  380. if [[ ! ${dbinstallmethod} =~ ^[1-2]$ ]]; then
  381. echo "${CWARNING}input error! Please only input number 1~2${CEND}"
  382. else
  383. break
  384. fi
  385. done
  386. fi
  387. break
  388. else
  389. echo "${CWARNING}input error! Please only input number 1~13${CEND}"
  390. fi
  391. done
  392. fi
  393. break
  394. fi
  395. done
  396. # check PHP
  397. while :; do echo
  398. read -p "Do you want to install PHP? [y/n]: " php_yn
  399. if [[ ! ${php_yn} =~ ^[y,n]$ ]]; then
  400. echo "${CWARNING}input error! Please only input 'y' or 'n'${CEND}"
  401. else
  402. if [ "${php_yn}" == 'y' ]; then
  403. [ -e "${php_install_dir}/bin/phpize" ] && { echo "${CWARNING}PHP already installed! ${CEND}"; php_yn=Other; break; }
  404. while :; do echo
  405. echo 'Please select a version of the PHP:'
  406. echo -e "\t${CMSG}1${CEND}. Install php-5.3"
  407. echo -e "\t${CMSG}2${CEND}. Install php-5.4"
  408. echo -e "\t${CMSG}3${CEND}. Install php-5.5"
  409. echo -e "\t${CMSG}4${CEND}. Install php-5.6"
  410. echo -e "\t${CMSG}5${CEND}. Install php-7.0"
  411. echo -e "\t${CMSG}6${CEND}. Install php-7.1"
  412. echo -e "\t${CMSG}7${CEND}. Install php-7.2"
  413. read -p "Please input a number:(Default 5 press Enter) " php_option
  414. [ -z "${php_option}" ] && php_option=5
  415. if [[ ! ${php_option} =~ ^[1-7]$ ]]; then
  416. echo "${CWARNING}input error! Please only input number 1~7${CEND}"
  417. else
  418. while :; do echo
  419. read -p "Do you want to install opcode cache of the PHP? [y/n]: " phpcache_yn
  420. if [[ ! ${phpcache_yn} =~ ^[y,n]$ ]]; then
  421. echo "${CWARNING}input error! Please only input 'y' or 'n'${CEND}"
  422. else
  423. if [ "${phpcache_yn}" == 'y' ]; then
  424. if [ ${php_option} == 1 ]; then
  425. while :; do
  426. echo 'Please select a opcode cache of the PHP:'
  427. echo -e "\t${CMSG}1${CEND}. Install Zend OPcache"
  428. echo -e "\t${CMSG}2${CEND}. Install XCache"
  429. echo -e "\t${CMSG}3${CEND}. Install APCU"
  430. echo -e "\t${CMSG}4${CEND}. Install eAccelerator-0.9"
  431. read -p "Please input a number:(Default 1 press Enter) " phpcache_option
  432. [ -z "${phpcache_option}" ] && phpcache_option=1
  433. if [[ ! ${phpcache_option} =~ ^[1-4]$ ]]; then
  434. echo "${CWARNING}input error! Please only input number 1~4${CEND}"
  435. else
  436. break
  437. fi
  438. done
  439. fi
  440. if [ ${php_option} == 2 ]; then
  441. while :; do
  442. echo 'Please select a opcode cache of the PHP:'
  443. echo -e "\t${CMSG}1${CEND}. Install Zend OPcache"
  444. echo -e "\t${CMSG}2${CEND}. Install XCache"
  445. echo -e "\t${CMSG}3${CEND}. Install APCU"
  446. echo -e "\t${CMSG}4${CEND}. Install eAccelerator-1.0-dev"
  447. read -p "Please input a number:(Default 1 press Enter) " phpcache_option
  448. [ -z "${phpcache_option}" ] && phpcache_option=1
  449. if [[ ! ${phpcache_option} =~ ^[1-4]$ ]]; then
  450. echo "${CWARNING}input error! Please only input number 1~4${CEND}"
  451. else
  452. break
  453. fi
  454. done
  455. fi
  456. if [ ${php_option} == 3 ]; then
  457. while :; do
  458. echo 'Please select a opcode cache of the PHP:'
  459. echo -e "\t${CMSG}1${CEND}. Install Zend OPcache"
  460. echo -e "\t${CMSG}2${CEND}. Install XCache"
  461. echo -e "\t${CMSG}3${CEND}. Install APCU"
  462. read -p "Please input a number:(Default 1 press Enter) " phpcache_option
  463. [ -z "${phpcache_option}" ] && phpcache_option=1
  464. if [[ ! ${phpcache_option} =~ ^[1-3]$ ]]; then
  465. echo "${CWARNING}input error! Please only input number 1~3${CEND}"
  466. else
  467. break
  468. fi
  469. done
  470. fi
  471. if [ ${php_option} == 4 ]; then
  472. while :; do
  473. echo 'Please select a opcode cache of the PHP:'
  474. echo -e "\t${CMSG}1${CEND}. Install Zend OPcache"
  475. echo -e "\t${CMSG}2${CEND}. Install XCache"
  476. echo -e "\t${CMSG}3${CEND}. Install APCU"
  477. read -p "Please input a number:(Default 1 press Enter) " phpcache_option
  478. [ -z "${phpcache_option}" ] && phpcache_option=1
  479. if [[ ! ${phpcache_option} =~ ^[1-3]$ ]]; then
  480. echo "${CWARNING}input error! Please only input number 1~3${CEND}"
  481. else
  482. break
  483. fi
  484. done
  485. fi
  486. if [[ ${php_option} =~ ^[5-6]$ ]]; then
  487. while :; do
  488. echo 'Please select a opcode cache of the PHP:'
  489. echo -e "\t${CMSG}1${CEND}. Install Zend OPcache"
  490. echo -e "\t${CMSG}3${CEND}. Install APCU"
  491. read -p "Please input a number:(Default 1 press Enter) " phpcache_option
  492. [ -z "${phpcache_option}" ] && phpcache_option=1
  493. if [[ ! ${phpcache_option} =~ ^[1,3]$ ]]; then
  494. echo "${CWARNING}input error! Please only input number 1,3${CEND}"
  495. else
  496. break
  497. fi
  498. done
  499. fi
  500. [ ${php_option} == 7 ] && phpcache_option=1
  501. fi
  502. break
  503. fi
  504. done
  505. if [ "${phpcache_option}" == '2' ]; then
  506. while :; do
  507. read -p "Please input xcache admin password(default: ${xcachepwd}): " xcachepwd
  508. [ -z "${xcachepwd}" ] && xcachepwd=${xcachepwd}
  509. (( ${#xcachepwd} >= 5 )) && { xcachepwd_md5=`echo -n "${xcachepwd}" | md5sum | awk '{print $1}'` ; break ; } || echo "${CFAILURE}xcache admin password least 5 characters! ${CEND}"
  510. done
  511. fi
  512. if [[ ${php_option} =~ ^[1-4]$ ]] && [ "${phpcache_option}" != '1' -a "${armplatform}" != "y" ]; then
  513. while :; do echo
  514. read -p "Do you want to install ZendGuardLoader? [y/n]: " zendguardloader_yn
  515. if [[ ! ${zendguardloader_yn} =~ ^[y,n]$ ]]; then
  516. echo "${CWARNING}input error! Please only input 'y' or 'n'${CEND}"
  517. else
  518. break
  519. fi
  520. done
  521. fi
  522. # ionCube
  523. if [ "${TARGET_ARCH}" != "arm64" ]; then
  524. while :; do echo
  525. read -p "Do you want to install ionCube? [y/n]: " ioncube_yn
  526. if [[ ! ${ioncube_yn} =~ ^[y,n]$ ]]; then
  527. echo "${CWARNING}input error! Please only input 'y' or 'n'${CEND}"
  528. else
  529. break
  530. fi
  531. done
  532. fi
  533. # ImageMagick or GraphicsMagick
  534. while :; do echo
  535. read -p "Do you want to install ImageMagick or GraphicsMagick? [y/n]: " magick_yn
  536. if [[ ! ${magick_yn} =~ ^[y,n]$ ]]; then
  537. echo "${CWARNING}input error! Please only input 'y' or 'n'${CEND}"
  538. else
  539. break
  540. fi
  541. done
  542. if [ "${magick_yn}" == 'y' ]; then
  543. while :; do
  544. echo 'Please select ImageMagick or GraphicsMagick:'
  545. echo -e "\t${CMSG}1${CEND}. Install ImageMagick"
  546. echo -e "\t${CMSG}2${CEND}. Install GraphicsMagick"
  547. read -p "Please input a number:(Default 1 press Enter) " magick_option
  548. [ -z "${magick_option}" ] && magick_option=1
  549. if [[ ! ${magick_option} =~ ^[1-2]$ ]]; then
  550. echo "${CWARNING}input error! Please only input number 1~2${CEND}"
  551. else
  552. break
  553. fi
  554. done
  555. fi
  556. break
  557. fi
  558. done
  559. fi
  560. break
  561. fi
  562. done
  563. # check Pureftpd
  564. while :; do echo
  565. read -p "Do you want to install Pure-FTPd? [y/n]: " ftp_yn
  566. if [[ ! ${ftp_yn} =~ ^[y,n]$ ]]; then
  567. echo "${CWARNING}input error! Please only input 'y' or 'n'${CEND}"
  568. else
  569. [ "${ftp_yn}" == 'y' -a -e "${pureftpd_install_dir}/sbin/pure-ftpwho" ] && { echo "${CWARNING}Pure-FTPd already installed! ${CEND}"; ftp_yn=Other; }
  570. break
  571. fi
  572. done
  573. # check phpMyAdmin
  574. if [[ ${php_option} =~ ^[1-7]$ ]] || [ -e "${php_install_dir}/bin/phpize" ]; then
  575. while :; do echo
  576. read -p "Do you want to install phpMyAdmin? [y/n]: " phpmyadmin_yn
  577. if [[ ! ${phpmyadmin_yn} =~ ^[y,n]$ ]]; then
  578. echo "${CWARNING}input error! Please only input 'y' or 'n'${CEND}"
  579. else
  580. [ "${phpmyadmin_yn}" == 'y' -a -d "${wwwroot_dir}/default/phpMyAdmin" ] && { echo "${CWARNING}phpMyAdmin already installed! ${CEND}"; phpmyadmin_yn=Other; }
  581. break
  582. fi
  583. done
  584. fi
  585. # check redis
  586. while :; do echo
  587. read -p "Do you want to install redis? [y/n]: " redis_yn
  588. if [[ ! ${redis_yn} =~ ^[y,n]$ ]]; then
  589. echo "${CWARNING}input error! Please only input 'y' or 'n'${CEND}"
  590. else
  591. break
  592. fi
  593. done
  594. # check memcached
  595. while :; do echo
  596. read -p "Do you want to install memcached? [y/n]: " memcached_yn
  597. if [[ ! ${memcached_yn} =~ ^[y,n]$ ]]; then
  598. echo "${CWARNING}input error! Please only input 'y' or 'n'${CEND}"
  599. else
  600. break
  601. fi
  602. done
  603. while :; do echo
  604. read -p "Do you want to install HHVM? [y/n]: " hhvm_yn
  605. if [[ ! ${hhvm_yn} =~ ^[y,n]$ ]]; then
  606. echo "${CWARNING}input error! Please only input 'y' or 'n'${CEND}"
  607. else
  608. if [ "${hhvm_yn}" == 'y' ]; then
  609. [ -e "/usr/bin/hhvm" ] && { echo "${CWARNING}HHVM already installed! ${CEND}"; hhvm_yn=Other; break; }
  610. if [ "$OS" == 'CentOS' -a "$OS_BIT" == '64' ] && [ -n "`grep -E ' 7\.| 6\.[5-9]' /etc/redhat-release`" ]; then
  611. break
  612. else
  613. echo
  614. echo "${CWARNING}HHVM only support CentOS6.5+ 64bit, CentOS7 64bit! ${CEND}"
  615. echo "Press Ctrl+c to cancel or Press any key to continue..."
  616. char=`get_char`
  617. hhvm_yn=Other
  618. fi
  619. fi
  620. break
  621. fi
  622. done
  623. fi
  624. # get the IP information
  625. IPADDR=`./include/get_ipaddr.py`
  626. PUBLIC_IPADDR=`./include/get_public_ipaddr.py`
  627. IPADDR_COUNTRY_ISP=`./include/get_ipaddr_state.py $PUBLIC_IPADDR`
  628. IPADDR_COUNTRY=`echo $IPADDR_COUNTRY_ISP | awk '{print $1}'`
  629. # Check download source packages
  630. . ./include/check_download.sh
  631. downloadDepsSrc=1
  632. checkDownload 2>&1 | tee -a ${oneinstack_dir}/install.log
  633. # del openssl for jcloud
  634. [ -e "/usr/local/bin/openssl" ] && rm -rf /usr/local/bin/openssl
  635. [ -e "/usr/local/include/openssl" ] && rm -rf /usr/local/include/openssl
  636. # Check binary dependencies packages
  637. . ./include/check_sw.sh
  638. case "${OS}" in
  639. "CentOS")
  640. installDepsCentOS 2>&1 | tee ${oneinstack_dir}/install.log
  641. ;;
  642. "Debian")
  643. installDepsDebian 2>&1 | tee ${oneinstack_dir}/install.log
  644. ;;
  645. "Ubuntu")
  646. installDepsUbuntu 2>&1 | tee ${oneinstack_dir}/install.log
  647. ;;
  648. esac
  649. # init
  650. startTime=`date +%s`
  651. . ./include/memory.sh
  652. case "${OS}" in
  653. "CentOS")
  654. . include/init_CentOS.sh 2>&1 | tee -a ${oneinstack_dir}/install.log
  655. [ -n "$(gcc --version | head -n1 | grep '4\.1\.')" ] && export CC="gcc44" CXX="g++44"
  656. ;;
  657. "Debian")
  658. . include/init_Debian.sh 2>&1 | tee -a ${oneinstack_dir}/install.log
  659. ;;
  660. "Ubuntu")
  661. . include/init_Ubuntu.sh 2>&1 | tee -a ${oneinstack_dir}/install.log
  662. ;;
  663. esac
  664. # Install dependencies from source package
  665. installDepsBySrc 2>&1 | tee -a ${oneinstack_dir}/install.log
  666. # Jemalloc
  667. if [[ ${nginx_option} =~ ^[1-3]$ ]] || [ "${db_yn}" == 'y' ]; then
  668. . include/jemalloc.sh
  669. Install_Jemalloc | tee -a ${oneinstack_dir}/install.log
  670. fi
  671. # openSSL
  672. . ./include/openssl.sh
  673. if [[ ${tomcat_option} =~ ^[1-3]$ ]] || [[ ${apache_option} =~ ^[1-2]$ ]] || [[ ${php_option} =~ ^[1-7]$ ]]; then
  674. Install_openSSL102 | tee -a ${oneinstack_dir}/install.log
  675. fi
  676. # Database
  677. case "${db_option}" in
  678. 1)
  679. if [ "${dbinstallmethod}" == "2" ]; then
  680. . include/boost.sh
  681. installBoost 2>&1 | tee -a ${oneinstack_dir}/install.log
  682. fi
  683. . include/mysql-5.7.sh
  684. Install_MySQL57 2>&1 | tee -a ${oneinstack_dir}/install.log
  685. ;;
  686. 2)
  687. . include/mysql-5.6.sh
  688. Install_MySQL56 2>&1 | tee -a ${oneinstack_dir}/install.log
  689. ;;
  690. 3)
  691. . include/mysql-5.5.sh
  692. Install_MySQL55 2>&1 | tee -a ${oneinstack_dir}/install.log
  693. ;;
  694. 4)
  695. if [ "${dbinstallmethod}" == "2" ]; then
  696. . include/boost.sh
  697. installBoost 2>&1 | tee -a ${oneinstack_dir}/install.log
  698. fi
  699. . include/mariadb-10.2.sh
  700. Install_MariaDB102 2>&1 | tee -a ${oneinstack_dir}/install.log
  701. ;;
  702. 5)
  703. if [ "${dbinstallmethod}" == "2" ]; then
  704. . include/boost.sh
  705. installBoost 2>&1 | tee -a ${oneinstack_dir}/install.log
  706. fi
  707. . include/mariadb-10.1.sh
  708. Install_MariaDB101 2>&1 | tee -a ${oneinstack_dir}/install.log
  709. ;;
  710. 6)
  711. . include/mariadb-10.0.sh
  712. Install_MariaDB100 2>&1 | tee -a ${oneinstack_dir}/install.log
  713. ;;
  714. 7)
  715. . include/mariadb-5.5.sh
  716. Install_MariaDB55 2>&1 | tee -a ${oneinstack_dir}/install.log
  717. ;;
  718. 8)
  719. if [ "${dbinstallmethod}" == "2" ]; then
  720. . include/boost.sh
  721. installBoost 2>&1 | tee -a ${oneinstack_dir}/install.log
  722. fi
  723. . include/percona-5.7.sh
  724. Install_Percona57 2>&1 | tee -a ${oneinstack_dir}/install.log
  725. ;;
  726. 9)
  727. . include/percona-5.6.sh
  728. Install_Percona56 2>&1 | tee -a ${oneinstack_dir}/install.log
  729. ;;
  730. 10)
  731. . include/percona-5.5.sh
  732. Install_Percona55 2>&1 | tee -a ${oneinstack_dir}/install.log
  733. ;;
  734. 11)
  735. . include/alisql-5.6.sh
  736. Install_AliSQL56 2>&1 | tee -a ${oneinstack_dir}/install.log
  737. ;;
  738. 12)
  739. . include/postgresql.sh
  740. Install_PostgreSQL 2>&1 | tee -a ${oneinstack_dir}/install.log
  741. ;;
  742. 13)
  743. . include/mongodb.sh
  744. Install_MongoDB 2>&1 | tee -a ${oneinstack_dir}/install.log
  745. ;;
  746. esac
  747. # Apache
  748. if [ "${apache_option}" == '1' ]; then
  749. . include/apache-2.4.sh
  750. Install_Apache24 2>&1 | tee -a ${oneinstack_dir}/install.log
  751. elif [ "${apache_option}" == '2' ]; then
  752. . include/apache-2.2.sh
  753. Install_Apache22 2>&1 | tee -a ${oneinstack_dir}/install.log
  754. fi
  755. # PHP
  756. case "${php_option}" in
  757. 1)
  758. . include/php-5.3.sh
  759. Install_PHP53 2>&1 | tee -a ${oneinstack_dir}/install.log
  760. ;;
  761. 2)
  762. . include/php-5.4.sh
  763. Install_PHP54 2>&1 | tee -a ${oneinstack_dir}/install.log
  764. ;;
  765. 3)
  766. . include/php-5.5.sh
  767. Install_PHP55 2>&1 | tee -a ${oneinstack_dir}/install.log
  768. ;;
  769. 4)
  770. . include/php-5.6.sh
  771. Install_PHP56 2>&1 | tee -a ${oneinstack_dir}/install.log
  772. ;;
  773. 5)
  774. . include/php-7.0.sh
  775. Install_PHP70 2>&1 | tee -a ${oneinstack_dir}/install.log
  776. ;;
  777. 6)
  778. . include/php-7.1.sh
  779. Install_PHP71 2>&1 | tee -a ${oneinstack_dir}/install.log
  780. ;;
  781. 7)
  782. . include/php-7.2.sh
  783. Install_PHP72 2>&1 | tee -a ${oneinstack_dir}/install.log
  784. ;;
  785. esac
  786. # pecl_pgsql
  787. if [ "${db_option}" == '12' -a -e "${php_install_dir}/bin/phpize" ]; then
  788. . include/pecl_pgsql.sh
  789. Install_pecl-pgsql 2>&1 | tee -a ${oneinstack_dir}/install.log
  790. fi
  791. # pecl_mongodb
  792. if [ "${db_option}" == '13' -a -e "${php_install_dir}/bin/phpize" ]; then
  793. . include/pecl_mongodb.sh
  794. Install_pecl-mongodb 2>&1 | tee -a ${oneinstack_dir}/install.log
  795. fi
  796. # ImageMagick or GraphicsMagick
  797. if [ "${magick_option}" == '1' ]; then
  798. . include/ImageMagick.sh
  799. [ ! -d "/usr/local/imagemagick" ] && Install_ImageMagick 2>&1 | tee -a ${oneinstack_dir}/install.log
  800. [ ! -e "`${php_install_dir}/bin/php-config --extension-dir`/imagick.so" ] && Install_php-imagick 2>&1 | tee -a ${oneinstack_dir}/install.log
  801. elif [ "${magick_option}" == '2' ]; then
  802. . include/GraphicsMagick.sh
  803. [ ! -d "/usr/local/graphicsmagick" ] && Install_GraphicsMagick 2>&1 | tee -a ${oneinstack_dir}/install.log
  804. [ ! -e "`${php_install_dir}/bin/php-config --extension-dir`/gmagick.so" ] && Install_php-gmagick 2>&1 | tee -a ${oneinstack_dir}/install.log
  805. fi
  806. # ionCube
  807. if [ "${ioncube_yn}" == 'y' ]; then
  808. . include/ioncube.sh
  809. Install_ionCube 2>&1 | tee -a ${oneinstack_dir}/install.log
  810. fi
  811. # PHP opcode cache
  812. case "${phpcache_option}" in
  813. 1)
  814. if [[ "${php_option}" =~ ^[1,2]$ ]]; then
  815. . include/zendopcache.sh
  816. Install_ZendOPcache 2>&1 | tee -a ${oneinstack_dir}/install.log
  817. fi
  818. ;;
  819. 2)
  820. . include/xcache.sh
  821. Install_XCache 2>&1 | tee -a ${oneinstack_dir}/install.log
  822. ;;
  823. 3)
  824. . include/apcu.sh
  825. Install_APCU 2>&1 | tee -a ${oneinstack_dir}/install.log
  826. ;;
  827. 4)
  828. if [[ "${php_option}" =~ ^[1,2]$ ]]; then
  829. . include/eaccelerator.sh
  830. Install_eAccelerator 2>&1 | tee -a ${oneinstack_dir}/install.log
  831. fi
  832. ;;
  833. esac
  834. # ZendGuardLoader (php <= 5.6)
  835. if [ "${zendguardloader_yn}" == 'y' ]; then
  836. . include/ZendGuardLoader.sh
  837. Install_ZendGuardLoader 2>&1 | tee -a ${oneinstack_dir}/install.log
  838. fi
  839. # Web server
  840. case "${nginx_option}" in
  841. 1)
  842. . include/nginx.sh
  843. Install_Nginx 2>&1 | tee -a ${oneinstack_dir}/install.log
  844. ;;
  845. 2)
  846. . include/tengine.sh
  847. Install_Tengine 2>&1 | tee -a ${oneinstack_dir}/install.log
  848. ;;
  849. 3)
  850. . include/openresty.sh
  851. Install_OpenResty 2>&1 | tee -a ${oneinstack_dir}/install.log
  852. ;;
  853. esac
  854. # JDK
  855. case "${jdk_option}" in
  856. 1)
  857. . include/jdk-1.8.sh
  858. Install-JDK18 2>&1 | tee -a ${oneinstack_dir}/install.log
  859. ;;
  860. 2)
  861. . include/jdk-1.7.sh
  862. Install-JDK17 2>&1 | tee -a ${oneinstack_dir}/install.log
  863. ;;
  864. 3)
  865. . include/jdk-1.6.sh
  866. Install-JDK16 2>&1 | tee -a ${oneinstack_dir}/install.log
  867. ;;
  868. esac
  869. case "${tomcat_option}" in
  870. 1)
  871. . include/tomcat-8.sh
  872. Install_Tomcat8 2>&1 | tee -a ${oneinstack_dir}/install.log
  873. ;;
  874. 2)
  875. . include/tomcat-7.sh
  876. Install_Tomcat7 2>&1 | tee -a ${oneinstack_dir}/install.log
  877. ;;
  878. 3)
  879. . include/tomcat-6.sh
  880. Install_Tomcat6 2>&1 | tee -a ${oneinstack_dir}/install.log
  881. ;;
  882. esac
  883. # Pure-FTPd
  884. if [ "${ftp_yn}" == 'y' ]; then
  885. . include/pureftpd.sh
  886. Install_PureFTPd 2>&1 | tee -a ${oneinstack_dir}/install.log
  887. fi
  888. # phpMyAdmin
  889. if [ "${phpmyadmin_yn}" == 'y' ]; then
  890. . include/phpmyadmin.sh
  891. Install_phpMyAdmin 2>&1 | tee -a ${oneinstack_dir}/install.log
  892. fi
  893. # redis
  894. if [ "${redis_yn}" == 'y' ]; then
  895. . include/redis.sh
  896. [ ! -d "${redis_install_dir}" ] && Install_redis-server 2>&1 | tee -a ${oneinstack_dir}/install.log
  897. [ -e "${php_install_dir}/bin/phpize" ] && [ ! -e "$(${php_install_dir}/bin/php-config --extension-dir)/redis.so" ] && Install_php-redis 2>&1 | tee -a ${oneinstack_dir}/install.log
  898. fi
  899. # memcached
  900. if [ "${memcached_yn}" == 'y' ]; then
  901. . include/memcached.sh
  902. [ ! -d "${memcached_install_dir}/include/memcached" ] && Install_memcached 2>&1 | tee -a ${oneinstack_dir}/install.log
  903. [ -e "${php_install_dir}/bin/phpize" ] && [ ! -e "$(${php_install_dir}/bin/php-config --extension-dir)/memcache.so" ] && Install_php-memcache 2>&1 | tee -a ${oneinstack_dir}/install.log
  904. [ -e "${php_install_dir}/bin/phpize" ] && [ ! -e "$(${php_install_dir}/bin/php-config --extension-dir)/memcached.so" ] && Install_php-memcached 2>&1 | tee -a ${oneinstack_dir}/install.log
  905. fi
  906. # index example
  907. if [ ! -e "${wwwroot_dir}/default/index.html" -a "${web_yn}" == 'y' ]; then
  908. . include/demo.sh
  909. DEMO 2>&1 | tee -a ${oneinstack_dir}/install.log
  910. fi
  911. # get web_install_dir and db_install_dir
  912. . include/check_dir.sh
  913. # HHVM
  914. if [ "${hhvm_yn}" == 'y' ] && [ "$OS" == 'CentOS' -a "$OS_BIT" == '64' ] && [ -n "`grep -E ' 7\.| 6\.[5-9]' /etc/redhat-release`" ]; then
  915. . include/hhvm_CentOS.sh
  916. Install_hhvm_CentOS 2>&1 | tee -a ${oneinstack_dir}/install.log
  917. fi
  918. # Starting DB
  919. [ -d "/etc/mysql" ] && /bin/mv /etc/mysql{,_bk}
  920. [ -d "${db_install_dir}/support-files" -a -z "$(ps -ef | grep -v grep | grep mysql)" ] && /etc/init.d/mysqld start
  921. endTime=`date +%s`
  922. ((installTime=($endTime-$startTime)/60))
  923. echo "####################Congratulations########################"
  924. echo "Total OneinStack Install Time: ${CQUESTION}${installTime}${CEND} minutes"
  925. [ "${web_yn}" == 'y' -a "${nginx_option}" != '4' -a "${apache_option}" == '3' ] && echo -e "\n$(printf "%-32s" "Nginx install dir":)${CMSG}${web_install_dir}${CEND}"
  926. [ "${web_yn}" == 'y' -a "${nginx_option}" != '4' -a "${apache_option}" != '3' ] && echo -e "\n$(printf "%-32s" "Nginx install dir":)${CMSG}${web_install_dir}${CEND}\n$(printf "%-32s" "Apache install dir":)${CMSG}${apache_install_dir}${CEND}"
  927. [ "${web_yn}" == 'y' -a "${nginx_option}" == '4' -a "${apache_option}" != '3' ] && echo -e "\n$(printf "%-32s" "Apache install dir":)${CMSG}${apache_install_dir}${CEND}"
  928. [[ "${tomcat_option}" =~ ^[1,2]$ ]] && echo -e "\n$(printf "%-32s" "Tomcat install dir":)${CMSG}${tomcat_install_dir}${CEND}"
  929. [[ "${db_option}" =~ ^[1-9]$|^1[0-1]$ ]] && echo -e "\n$(printf "%-32s" "Database install dir:")${CMSG}${db_install_dir}${CEND}"
  930. [[ "${db_option}" =~ ^[1-9]$|^1[0-1]$ ]] && echo "$(printf "%-32s" "Database data dir:")${CMSG}${db_data_dir}${CEND}"
  931. [[ "${db_option}" =~ ^[1-9]$|^1[0-1]$ ]] && echo "$(printf "%-32s" "Database user:")${CMSG}root${CEND}"
  932. [[ "${db_option}" =~ ^[1-9]$|^1[0-1]$ ]] && echo "$(printf "%-32s" "Database password:")${CMSG}${dbrootpwd}${CEND}"
  933. [ "${db_option}" == '12' ] && echo -e "\n$(printf "%-32s" "PostgreSQL install dir:")${CMSG}${pgsql_install_dir}${CEND}"
  934. [ "${db_option}" == '12' ] && echo "$(printf "%-32s" "PostgreSQL data dir:")${CMSG}${pgsql_data_dir}${CEND}"
  935. [ "${db_option}" == '12' ] && echo "$(printf "%-32s" "PostgreSQL user:")${CMSG}postgres${CEND}"
  936. [ "${db_option}" == '12' ] && echo "$(printf "%-32s" "postgres password:")${CMSG}${dbpostgrespwd}${CEND}"
  937. [ "${db_option}" == '13' ] && echo -e "\n$(printf "%-32s" "MongoDB install dir:")${CMSG}${mongo_install_dir}${CEND}"
  938. [ "${db_option}" == '13' ] && echo "$(printf "%-32s" "MongoDB data dir:")${CMSG}${mongo_data_dir}${CEND}"
  939. [ "${db_option}" == '13' ] && echo "$(printf "%-32s" "MongoDB user:")${CMSG}root${CEND}"
  940. [ "${db_option}" == '13' ] && echo "$(printf "%-32s" "MongoDB password:")${CMSG}${dbmongopwd}${CEND}"
  941. [ "${php_yn}" == 'y' ] && echo -e "\n$(printf "%-32s" "PHP install dir:")${CMSG}${php_install_dir}${CEND}"
  942. [ "${phpcache_option}" == '1' ] && echo "$(printf "%-32s" "Opcache Control Panel URL:")${CMSG}http://${IPADDR}/ocp.php${CEND}"
  943. [ "${phpcache_option}" == '2' ] && echo "$(printf "%-32s" "xcache Control Panel URL:")${CMSG}http://${IPADDR}/xcache${CEND}"
  944. [ "${phpcache_option}" == '2' ] && echo "$(printf "%-32s" "xcache user:")${CMSG}admin${CEND}"
  945. [ "${phpcache_option}" == '2' ] && echo "$(printf "%-32s" "xcache password:")${CMSG}${xcachepwd}${CEND}"
  946. [ "${phpcache_option}" == '3' ] && echo "$(printf "%-32s" "APC Control Panel URL:")${CMSG}http://${IPADDR}/apc.php${CEND}"
  947. [ "${phpcache_option}" == '4' ] && echo "$(printf "%-32s" "eAccelerator Control Panel URL:")${CMSG}http://${IPADDR}/control.php${CEND}"
  948. [ "${phpcache_option}" == '4' ] && echo "$(printf "%-32s" "eAccelerator user:")${CMSG}admin${CEND}"
  949. [ "${phpcache_option}" == '4' ] && echo "$(printf "%-32s" "eAccelerator password:")${CMSG}eAccelerator${CEND}"
  950. [ "${ftp_yn}" == 'y' ] && echo -e "\n$(printf "%-32s" "Pure-FTPd install dir:")${CMSG}${pureftpd_install_dir}${CEND}"
  951. [ "${ftp_yn}" == 'y' ] && echo "$(printf "%-32s" "Create FTP virtual script:")${CMSG}./pureftpd_vhost.sh${CEND}"
  952. [ "${phpmyadmin_yn}" == 'y' ] && echo -e "\n$(printf "%-32s" "phpMyAdmin dir:")${CMSG}${wwwroot_dir}/default/phpMyAdmin${CEND}"
  953. [ "${phpmyadmin_yn}" == 'y' ] && echo "$(printf "%-32s" "phpMyAdmin Control Panel URL:")${CMSG}http://${IPADDR}/phpMyAdmin${CEND}"
  954. [ "${redis_yn}" == 'y' ] && echo -e "\n$(printf "%-32s" "redis install dir:")${CMSG}${redis_install_dir}${CEND}"
  955. [ "${memcached_yn}" == 'y' ] && echo -e "\n$(printf "%-32s" "memcached install dir:")${CMSG}${memcached_install_dir}${CEND}"
  956. [ "${web_yn}" == 'y' ] && echo -e "\n$(printf "%-32s" "Index URL:")${CMSG}http://${IPADDR}/${CEND}"
  957. if [ ${ARG_NUM} == 0 ]; then
  958. while :; do echo
  959. echo "${CMSG}Please restart the server and see if the services start up fine.${CEND}"
  960. read -p "Do you want to restart OS ? [y/n]: " restart_yn
  961. if [[ ! "${restart_yn}" =~ ^[y,n]$ ]]; then
  962. echo "${CWARNING}input error! Please only input 'y' or 'n'${CEND}"
  963. else
  964. break
  965. fi
  966. done
  967. fi
  968. [ "${restart_yn}" == 'y' ] && reboot