install.sh 42 KB

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