install.sh 43 KB

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