install.sh 43 KB

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