install.sh 41 KB

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