install.sh 43 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041
  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. [ "$OS" == 'CentOS' ] && yum -y -q install wget
  655. [[ "${OS}" =~ ^Ubuntu$|^Debian$ ]] && apt -y -q install wget
  656. checkDownload 2>&1 | tee -a ${oneinstack_dir}/install.log
  657. # del openssl for jcloud
  658. [ -e "/usr/local/bin/openssl" ] && rm -rf /usr/local/bin/openssl
  659. [ -e "/usr/local/include/openssl" ] && rm -rf /usr/local/include/openssl
  660. # get OS Memory
  661. . ./include/memory.sh
  662. if [ ! -e ~/.oneinstack ]; then
  663. # Check binary dependencies packages
  664. . ./include/check_sw.sh
  665. case "${OS}" in
  666. "CentOS")
  667. installDepsCentOS 2>&1 | tee ${oneinstack_dir}/install.log
  668. . include/init_CentOS.sh 2>&1 | tee -a ${oneinstack_dir}/install.log
  669. [ -n "$(gcc --version | head -n1 | grep '4\.1\.')" ] && export CC="gcc44" CXX="g++44"
  670. ;;
  671. "Debian")
  672. installDepsDebian 2>&1 | tee ${oneinstack_dir}/install.log
  673. . include/init_Debian.sh 2>&1 | tee -a ${oneinstack_dir}/install.log
  674. ;;
  675. "Ubuntu")
  676. installDepsUbuntu 2>&1 | tee ${oneinstack_dir}/install.log
  677. . include/init_Ubuntu.sh 2>&1 | tee -a ${oneinstack_dir}/install.log
  678. ;;
  679. esac
  680. # Install dependencies from source package
  681. installDepsBySrc 2>&1 | tee -a ${oneinstack_dir}/install.log
  682. fi
  683. # start Time
  684. startTime=`date +%s`
  685. # Jemalloc
  686. if [[ ${nginx_option} =~ ^[1-3]$ ]] || [ "${db_yn}" == 'y' ]; then
  687. . include/jemalloc.sh
  688. Install_Jemalloc | tee -a ${oneinstack_dir}/install.log
  689. fi
  690. # openSSL
  691. . ./include/openssl.sh
  692. if [[ ${tomcat_option} =~ ^[1-4]$ ]] || [[ ${apache_option} =~ ^[1-2]$ ]] || [[ ${php_option} =~ ^[1-7]$ ]]; then
  693. Install_openSSL102 | tee -a ${oneinstack_dir}/install.log
  694. fi
  695. # Database
  696. case "${db_option}" in
  697. 1)
  698. if [ "${dbinstallmethod}" == "2" ]; then
  699. . include/boost.sh
  700. installBoost 2>&1 | tee -a ${oneinstack_dir}/install.log
  701. fi
  702. . include/mysql-5.7.sh
  703. Install_MySQL57 2>&1 | tee -a ${oneinstack_dir}/install.log
  704. ;;
  705. 2)
  706. . include/mysql-5.6.sh
  707. Install_MySQL56 2>&1 | tee -a ${oneinstack_dir}/install.log
  708. ;;
  709. 3)
  710. . include/mysql-5.5.sh
  711. Install_MySQL55 2>&1 | tee -a ${oneinstack_dir}/install.log
  712. ;;
  713. 4)
  714. if [ "${dbinstallmethod}" == "2" ]; then
  715. . include/boost.sh
  716. installBoost 2>&1 | tee -a ${oneinstack_dir}/install.log
  717. fi
  718. . include/mariadb-10.2.sh
  719. Install_MariaDB102 2>&1 | tee -a ${oneinstack_dir}/install.log
  720. ;;
  721. 5)
  722. if [ "${dbinstallmethod}" == "2" ]; then
  723. . include/boost.sh
  724. installBoost 2>&1 | tee -a ${oneinstack_dir}/install.log
  725. fi
  726. . include/mariadb-10.1.sh
  727. Install_MariaDB101 2>&1 | tee -a ${oneinstack_dir}/install.log
  728. ;;
  729. 6)
  730. . include/mariadb-10.0.sh
  731. Install_MariaDB100 2>&1 | tee -a ${oneinstack_dir}/install.log
  732. ;;
  733. 7)
  734. . include/mariadb-5.5.sh
  735. Install_MariaDB55 2>&1 | tee -a ${oneinstack_dir}/install.log
  736. ;;
  737. 8)
  738. if [ "${dbinstallmethod}" == "2" ]; then
  739. . include/boost.sh
  740. installBoost 2>&1 | tee -a ${oneinstack_dir}/install.log
  741. fi
  742. . include/percona-5.7.sh
  743. Install_Percona57 2>&1 | tee -a ${oneinstack_dir}/install.log
  744. ;;
  745. 9)
  746. . include/percona-5.6.sh
  747. Install_Percona56 2>&1 | tee -a ${oneinstack_dir}/install.log
  748. ;;
  749. 10)
  750. . include/percona-5.5.sh
  751. Install_Percona55 2>&1 | tee -a ${oneinstack_dir}/install.log
  752. ;;
  753. 11)
  754. . include/alisql-5.6.sh
  755. Install_AliSQL56 2>&1 | tee -a ${oneinstack_dir}/install.log
  756. ;;
  757. 12)
  758. . include/postgresql.sh
  759. Install_PostgreSQL 2>&1 | tee -a ${oneinstack_dir}/install.log
  760. ;;
  761. 13)
  762. . include/mongodb.sh
  763. Install_MongoDB 2>&1 | tee -a ${oneinstack_dir}/install.log
  764. ;;
  765. esac
  766. # Apache
  767. if [ "${apache_option}" == '1' ]; then
  768. . include/apache-2.4.sh
  769. Install_Apache24 2>&1 | tee -a ${oneinstack_dir}/install.log
  770. elif [ "${apache_option}" == '2' ]; then
  771. . include/apache-2.2.sh
  772. Install_Apache22 2>&1 | tee -a ${oneinstack_dir}/install.log
  773. fi
  774. # PHP
  775. case "${php_option}" in
  776. 1)
  777. . include/php-5.3.sh
  778. Install_PHP53 2>&1 | tee -a ${oneinstack_dir}/install.log
  779. ;;
  780. 2)
  781. . include/php-5.4.sh
  782. Install_PHP54 2>&1 | tee -a ${oneinstack_dir}/install.log
  783. ;;
  784. 3)
  785. . include/php-5.5.sh
  786. Install_PHP55 2>&1 | tee -a ${oneinstack_dir}/install.log
  787. ;;
  788. 4)
  789. . include/php-5.6.sh
  790. Install_PHP56 2>&1 | tee -a ${oneinstack_dir}/install.log
  791. ;;
  792. 5)
  793. . include/php-7.0.sh
  794. Install_PHP70 2>&1 | tee -a ${oneinstack_dir}/install.log
  795. ;;
  796. 6)
  797. . include/php-7.1.sh
  798. Install_PHP71 2>&1 | tee -a ${oneinstack_dir}/install.log
  799. ;;
  800. 7)
  801. . include/php-7.2.sh
  802. Install_PHP72 2>&1 | tee -a ${oneinstack_dir}/install.log
  803. ;;
  804. esac
  805. # pecl_pgsql
  806. if [ "${db_option}" == '12' -a -e "${php_install_dir}/bin/phpize" ]; then
  807. . include/pecl_pgsql.sh
  808. Install_pecl-pgsql 2>&1 | tee -a ${oneinstack_dir}/install.log
  809. fi
  810. # pecl_mongodb
  811. if [ "${db_option}" == '13' -a -e "${php_install_dir}/bin/phpize" ]; then
  812. . include/pecl_mongodb.sh
  813. Install_pecl-mongodb 2>&1 | tee -a ${oneinstack_dir}/install.log
  814. fi
  815. # ImageMagick or GraphicsMagick
  816. if [ "${magick_option}" == '1' ]; then
  817. . include/ImageMagick.sh
  818. [ ! -d "${imagick_install_dir}" ] && Install_ImageMagick 2>&1 | tee -a ${oneinstack_dir}/install.log
  819. [ ! -e "`${php_install_dir}/bin/php-config --extension-dir`/imagick.so" ] && Install_php-imagick 2>&1 | tee -a ${oneinstack_dir}/install.log
  820. elif [ "${magick_option}" == '2' ]; then
  821. . include/GraphicsMagick.sh
  822. [ ! -d "${gmagick_install_dir}" ] && Install_GraphicsMagick 2>&1 | tee -a ${oneinstack_dir}/install.log
  823. [ ! -e "`${php_install_dir}/bin/php-config --extension-dir`/gmagick.so" ] && Install_php-gmagick 2>&1 | tee -a ${oneinstack_dir}/install.log
  824. fi
  825. # ionCube
  826. if [ "${ioncube_yn}" == 'y' ]; then
  827. . include/ioncube.sh
  828. Install_ionCube 2>&1 | tee -a ${oneinstack_dir}/install.log
  829. fi
  830. # PHP opcode cache
  831. case "${phpcache_option}" in
  832. 1)
  833. if [[ "${php_option}" =~ ^[1,2]$ ]]; then
  834. . include/zendopcache.sh
  835. Install_ZendOPcache 2>&1 | tee -a ${oneinstack_dir}/install.log
  836. fi
  837. ;;
  838. 2)
  839. . include/xcache.sh
  840. Install_XCache 2>&1 | tee -a ${oneinstack_dir}/install.log
  841. ;;
  842. 3)
  843. . include/apcu.sh
  844. Install_APCU 2>&1 | tee -a ${oneinstack_dir}/install.log
  845. ;;
  846. 4)
  847. if [[ "${php_option}" =~ ^[1,2]$ ]]; then
  848. . include/eaccelerator.sh
  849. Install_eAccelerator 2>&1 | tee -a ${oneinstack_dir}/install.log
  850. fi
  851. ;;
  852. esac
  853. # ZendGuardLoader (php <= 5.6)
  854. if [ "${zendguardloader_yn}" == 'y' ]; then
  855. . include/ZendGuardLoader.sh
  856. Install_ZendGuardLoader 2>&1 | tee -a ${oneinstack_dir}/install.log
  857. fi
  858. # Web server
  859. case "${nginx_option}" in
  860. 1)
  861. . include/nginx.sh
  862. Install_Nginx 2>&1 | tee -a ${oneinstack_dir}/install.log
  863. ;;
  864. 2)
  865. . include/tengine.sh
  866. Install_Tengine 2>&1 | tee -a ${oneinstack_dir}/install.log
  867. ;;
  868. 3)
  869. . include/openresty.sh
  870. Install_OpenResty 2>&1 | tee -a ${oneinstack_dir}/install.log
  871. ;;
  872. esac
  873. # JDK
  874. case "${jdk_option}" in
  875. 1)
  876. . include/jdk-9.sh
  877. Install-JDK9 2>&1 | tee -a ${oneinstack_dir}/install.log
  878. ;;
  879. 2)
  880. . include/jdk-1.8.sh
  881. Install-JDK18 2>&1 | tee -a ${oneinstack_dir}/install.log
  882. ;;
  883. 3)
  884. . include/jdk-1.7.sh
  885. Install-JDK17 2>&1 | tee -a ${oneinstack_dir}/install.log
  886. ;;
  887. 4)
  888. . include/jdk-1.6.sh
  889. Install-JDK16 2>&1 | tee -a ${oneinstack_dir}/install.log
  890. ;;
  891. esac
  892. case "${tomcat_option}" in
  893. 1)
  894. . include/tomcat-9.sh
  895. Install_Tomcat9 2>&1 | tee -a ${oneinstack_dir}/install.log
  896. ;;
  897. 2)
  898. . include/tomcat-8.sh
  899. Install_Tomcat8 2>&1 | tee -a ${oneinstack_dir}/install.log
  900. ;;
  901. 3)
  902. . include/tomcat-7.sh
  903. Install_Tomcat7 2>&1 | tee -a ${oneinstack_dir}/install.log
  904. ;;
  905. 4)
  906. . include/tomcat-6.sh
  907. Install_Tomcat6 2>&1 | tee -a ${oneinstack_dir}/install.log
  908. ;;
  909. esac
  910. # Pure-FTPd
  911. if [ "${ftp_yn}" == 'y' ]; then
  912. . include/pureftpd.sh
  913. Install_PureFTPd 2>&1 | tee -a ${oneinstack_dir}/install.log
  914. fi
  915. # phpMyAdmin
  916. if [ "${phpmyadmin_yn}" == 'y' ]; then
  917. . include/phpmyadmin.sh
  918. Install_phpMyAdmin 2>&1 | tee -a ${oneinstack_dir}/install.log
  919. fi
  920. # redis
  921. if [ "${redis_yn}" == 'y' ]; then
  922. . include/redis.sh
  923. [ ! -d "${redis_install_dir}" ] && Install_redis-server 2>&1 | tee -a ${oneinstack_dir}/install.log
  924. [ -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
  925. fi
  926. # memcached
  927. if [ "${memcached_yn}" == 'y' ]; then
  928. . include/memcached.sh
  929. [ ! -d "${memcached_install_dir}/include/memcached" ] && Install_memcached 2>&1 | tee -a ${oneinstack_dir}/install.log
  930. [ -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
  931. [ -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
  932. fi
  933. # index example
  934. if [ ! -e "${wwwroot_dir}/default/index.html" -a "${web_yn}" == 'y' ]; then
  935. . include/demo.sh
  936. DEMO 2>&1 | tee -a ${oneinstack_dir}/install.log
  937. fi
  938. # get web_install_dir and db_install_dir
  939. . include/check_dir.sh
  940. # HHVM
  941. if [ "${hhvm_yn}" == 'y' ] && [ "$OS" == 'CentOS' -a "$OS_BIT" == '64' ] && [ -n "`grep -E ' 7\.| 6\.[5-9]' /etc/redhat-release`" ]; then
  942. . include/hhvm_CentOS.sh
  943. Install_hhvm_CentOS 2>&1 | tee -a ${oneinstack_dir}/install.log
  944. fi
  945. # Starting DB
  946. [ -d "/etc/mysql" ] && /bin/mv /etc/mysql{,_bk}
  947. [ -d "${db_install_dir}/support-files" -a -z "$(ps -ef | grep -v grep | grep mysql)" ] && /etc/init.d/mysqld start
  948. endTime=`date +%s`
  949. ((installTime=($endTime-$startTime)/60))
  950. echo "####################Congratulations########################"
  951. echo "Total OneinStack Install Time: ${CQUESTION}${installTime}${CEND} minutes"
  952. [ "${web_yn}" == 'y' ] && [[ "${nginx_option}" =~ ^[1-3]$ ]] && echo -e "\n$(printf "%-32s" "Nginx install dir":)${CMSG}${web_install_dir}${CEND}"
  953. [ "${web_yn}" == 'y' ] && [[ "${apache_option}" =~ ^[1,2]$ ]] && echo -e "\n$(printf "%-32s" "Apache install dir":)${CMSG}${apache_install_dir}${CEND}"
  954. [[ "${tomcat_option}" =~ ^[1,2]$ ]] && echo -e "\n$(printf "%-32s" "Tomcat install dir":)${CMSG}${tomcat_install_dir}${CEND}"
  955. [[ "${db_option}" =~ ^[1-9]$|^1[0-1]$ ]] && echo -e "\n$(printf "%-32s" "Database install dir:")${CMSG}${db_install_dir}${CEND}"
  956. [[ "${db_option}" =~ ^[1-9]$|^1[0-1]$ ]] && echo "$(printf "%-32s" "Database data dir:")${CMSG}${db_data_dir}${CEND}"
  957. [[ "${db_option}" =~ ^[1-9]$|^1[0-1]$ ]] && echo "$(printf "%-32s" "Database user:")${CMSG}root${CEND}"
  958. [[ "${db_option}" =~ ^[1-9]$|^1[0-1]$ ]] && echo "$(printf "%-32s" "Database password:")${CMSG}${dbrootpwd}${CEND}"
  959. [ "${db_option}" == '12' ] && echo -e "\n$(printf "%-32s" "PostgreSQL install dir:")${CMSG}${pgsql_install_dir}${CEND}"
  960. [ "${db_option}" == '12' ] && echo "$(printf "%-32s" "PostgreSQL data dir:")${CMSG}${pgsql_data_dir}${CEND}"
  961. [ "${db_option}" == '12' ] && echo "$(printf "%-32s" "PostgreSQL user:")${CMSG}postgres${CEND}"
  962. [ "${db_option}" == '12' ] && echo "$(printf "%-32s" "postgres password:")${CMSG}${dbpostgrespwd}${CEND}"
  963. [ "${db_option}" == '13' ] && echo -e "\n$(printf "%-32s" "MongoDB install dir:")${CMSG}${mongo_install_dir}${CEND}"
  964. [ "${db_option}" == '13' ] && echo "$(printf "%-32s" "MongoDB data dir:")${CMSG}${mongo_data_dir}${CEND}"
  965. [ "${db_option}" == '13' ] && echo "$(printf "%-32s" "MongoDB user:")${CMSG}root${CEND}"
  966. [ "${db_option}" == '13' ] && echo "$(printf "%-32s" "MongoDB password:")${CMSG}${dbmongopwd}${CEND}"
  967. [ "${php_yn}" == 'y' ] && echo -e "\n$(printf "%-32s" "PHP install dir:")${CMSG}${php_install_dir}${CEND}"
  968. [ "${php_yn}" == 'y' -a "${phpcache_option}" == '1' ] && echo "$(printf "%-32s" "Opcache Control Panel URL:")${CMSG}http://${IPADDR}/ocp.php${CEND}"
  969. [ "${phpcache_option}" == '2' ] && echo "$(printf "%-32s" "xcache Control Panel URL:")${CMSG}http://${IPADDR}/xcache${CEND}"
  970. [ "${phpcache_option}" == '2' ] && echo "$(printf "%-32s" "xcache user:")${CMSG}admin${CEND}"
  971. [ "${phpcache_option}" == '2' ] && echo "$(printf "%-32s" "xcache password:")${CMSG}${xcachepwd}${CEND}"
  972. [ "${phpcache_option}" == '3' ] && echo "$(printf "%-32s" "APC Control Panel URL:")${CMSG}http://${IPADDR}/apc.php${CEND}"
  973. [ "${phpcache_option}" == '4' ] && echo "$(printf "%-32s" "eAccelerator Control Panel URL:")${CMSG}http://${IPADDR}/control.php${CEND}"
  974. [ "${phpcache_option}" == '4' ] && echo "$(printf "%-32s" "eAccelerator user:")${CMSG}admin${CEND}"
  975. [ "${phpcache_option}" == '4' ] && echo "$(printf "%-32s" "eAccelerator password:")${CMSG}eAccelerator${CEND}"
  976. [ "${ftp_yn}" == 'y' ] && echo -e "\n$(printf "%-32s" "Pure-FTPd install dir:")${CMSG}${pureftpd_install_dir}${CEND}"
  977. [ "${ftp_yn}" == 'y' ] && echo "$(printf "%-32s" "Create FTP virtual script:")${CMSG}./pureftpd_vhost.sh${CEND}"
  978. [ "${phpmyadmin_yn}" == 'y' ] && echo -e "\n$(printf "%-32s" "phpMyAdmin dir:")${CMSG}${wwwroot_dir}/default/phpMyAdmin${CEND}"
  979. [ "${phpmyadmin_yn}" == 'y' ] && echo "$(printf "%-32s" "phpMyAdmin Control Panel URL:")${CMSG}http://${IPADDR}/phpMyAdmin${CEND}"
  980. [ "${redis_yn}" == 'y' ] && echo -e "\n$(printf "%-32s" "redis install dir:")${CMSG}${redis_install_dir}${CEND}"
  981. [ "${memcached_yn}" == 'y' ] && echo -e "\n$(printf "%-32s" "memcached install dir:")${CMSG}${memcached_install_dir}${CEND}"
  982. [ "${web_yn}" == 'y' ] && echo -e "\n$(printf "%-32s" "Index URL:")${CMSG}http://${IPADDR}/${CEND}"
  983. if [ ${ARG_NUM} == 0 ]; then
  984. while :; do echo
  985. echo "${CMSG}Please restart the server and see if the services start up fine.${CEND}"
  986. read -p "Do you want to restart OS ? [y/n]: " reboot_yn
  987. if [[ ! "${reboot_yn}" =~ ^[y,n]$ ]]; then
  988. echo "${CWARNING}input error! Please only input 'y' or 'n'${CEND}"
  989. else
  990. break
  991. fi
  992. done
  993. fi
  994. [ "${reboot_yn}" == 'y' ] && reboot