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/RedHat 6+ Debian 7+ and Ubuntu 12+
  6. #
  7. # Project home page:
  8. # https://oneinstack.com
  9. # https://github.com/lj2007331/oneinstack
  10. export PATH=/sbin:/bin:/usr/sbin:/usr/bin:/usr/local/sbin:/usr/local/bin
  11. clear
  12. printf "
  13. #######################################################################
  14. # OneinStack for CentOS/RedHat 6+ Debian 7+ and Ubuntu 12+ #
  15. # For more information please visit https://oneinstack.com #
  16. #######################################################################
  17. "
  18. # Check if user is root
  19. [ $(id -u) != "0" ] && { echo "${CFAILURE}Error: You must be root to run this script${CEND}"; exit 1; }
  20. oneinstack_dir=$(dirname "`readlink -f $0`")
  21. pushd ${oneinstack_dir} > /dev/null
  22. . ./versions.txt
  23. . ./options.conf
  24. . ./include/color.sh
  25. . ./include/check_os.sh
  26. . ./include/check_dir.sh
  27. . ./include/download.sh
  28. . ./include/get_char.sh
  29. ssh_port=22
  30. dbrootpwd=`< /dev/urandom tr -dc A-Za-z0-9 | head -c8`
  31. dbpostgrespwd=`< /dev/urandom tr -dc A-Za-z0-9 | head -c8`
  32. dbmongopwd=`< /dev/urandom tr -dc A-Za-z0-9 | head -c8`
  33. xcachepwd=`< /dev/urandom tr -dc A-Za-z0-9 | head -c8`
  34. dbinstallmethod=1
  35. version() {
  36. echo "version: 1.7"
  37. echo "updated date: 2018-04-20"
  38. }
  39. showhelp() {
  40. version
  41. echo "Usage: $0 command ...[parameters]....
  42. --help, -h Show this help message, More: https://oneinstack.com/auto
  43. --version, -v Show version info
  44. --nginx_option [1-3] Install Nginx server version
  45. --apache_option [1-2] Install Apache server version
  46. --php_option [1-7] Install PHP version
  47. --phpcache_option [1-4] Install PHP opcode cache, default: 1 opcache
  48. --php_extensions [ext name] Install PHP extension, include zendguardloader,ioncube,imagick,gmagick,redis,memcached,memcache
  49. --tomcat_option [1-4] Install Tomcat version
  50. --jdk_option [1-4] Install JDK version
  51. --db_option [1-15] Install DB version
  52. --dbinstallmethod [1-2] DB install method, default: 1 binary install
  53. --dbrootpwd [password] DB super password
  54. --pureftpd Install Pure-Ftpd
  55. --redis Install Redis
  56. --memcached Install Memcached
  57. --phpmyadmin Install phpMyAdmin
  58. --hhvm Install HHVM
  59. --ssh_port [22] SSH port, default: 22
  60. --iptables Enable iptables
  61. --reboot Restart the server after installation
  62. "
  63. }
  64. ARG_NUM=$#
  65. TEMP=`getopt -o hvV --long help,version,nginx_option:,apache_option:,php_option:,phpcache_option:,php_extensions:,tomcat_option:,jdk_option:,db_option:,dbrootpwd:,dbinstallmethod:,pureftpd,redis,memcached,phpmyadmin,hhvm,ssh_port:,iptables,reboot -- "$@" 2>/dev/null`
  66. [ $? != 0 ] && echo "${CWARNING}ERROR: unknown argument! ${CEND}" && showhelp && exit 1
  67. eval set -- "${TEMP}"
  68. while :; do
  69. [ -z "$1" ] && break;
  70. case "$1" in
  71. -h|--help)
  72. showhelp; exit 0
  73. ;;
  74. -v|-V|--version)
  75. version; exit 0
  76. ;;
  77. --nginx_option)
  78. nginx_option=$2; shift 2
  79. [[ ! ${nginx_option} =~ ^[1-3]$ ]] && { echo "${CWARNING}nginx_option input error! Please only input number 1~3${CEND}"; exit 1; }
  80. web_yn=y
  81. [ -e "${nginx_install_dir}/sbin/nginx" ] && { echo "${CWARNING}Nginx already installed! ${CEND}"; nginx_option=Other; }
  82. [ -e "${tengine_install_dir}/sbin/nginx" ] && { echo "${CWARNING}Tengine already installed! ${CEND}"; nginx_option=Other; }
  83. [ -e "${openresty_install_dir}/nginx/sbin/nginx" ] && { echo "${CWARNING}OpenResty already installed! ${CEND}"; nginx_option=Other; }
  84. ;;
  85. --apache_option)
  86. apache_option=$2; shift 2
  87. [[ ! ${apache_option} =~ ^[1-2]$ ]] && { echo "${CWARNING}apache_option input error! Please only input number 1~2${CEND}"; exit 1; }
  88. web_yn=y
  89. [ -e "${apache_install_dir}/conf/httpd.conf" ] && { echo "${CWARNING}Aapche already installed! ${CEND}"; apache_option=Other; }
  90. ;;
  91. --php_option)
  92. php_option=$2; shift 2
  93. [[ ! ${php_option} =~ ^[1-7]$ ]] && { echo "${CWARNING}php_option input error! Please only input number 1~7${CEND}"; exit 1; }
  94. php_yn=y
  95. [ -e "${php_install_dir}/bin/phpize" ] && { echo "${CWARNING}PHP already installed! ${CEND}"; php_option=Other; }
  96. ;;
  97. --phpcache_option)
  98. phpcache_option=$2; shift 2
  99. ;;
  100. --php_extensions)
  101. php_extensions=$2; shift 2
  102. [ -n "`echo ${php_extensions} | grep -w zendguardloader`" ] && zendguardloader_yn=y
  103. [ -n "`echo ${php_extensions} | grep -w ioncube`" ] && ioncube_yn=y
  104. [ -n "`echo ${php_extensions} | grep -w imagick`" ] && magick_option=1
  105. [ -n "`echo ${php_extensions} | grep -w gmagick`" ] && magick_option=2
  106. [ -n "`echo ${php_extensions} | grep -w redis`" ] && redis_pecl=1
  107. [ -n "`echo ${php_extensions} | grep -w memcached`" ] && memcached_pecl=1
  108. [ -n "`echo ${php_extensions} | grep -w memcache`" ] && memcache_pecl=1
  109. ;;
  110. --tomcat_option)
  111. tomcat_option=$2; shift 2
  112. [[ ! ${tomcat_option} =~ ^[1-4]$ ]] && { echo "${CWARNING}tomcat_option input error! Please only input number 1~4${CEND}"; exit 1; }
  113. web_yn=y
  114. [ -e "$tomcat_install_dir/conf/server.xml" ] && { echo "${CWARNING}Tomcat already installed! ${CEND}" ; tomcat_option=Other; }
  115. ;;
  116. --jdk_option)
  117. jdk_option=$2; shift 2
  118. [[ ! ${jdk_option} =~ ^[1-4]$ ]] && { echo "${CWARNING}jdk_option input error! Please only input number 1~4${CEND}"; exit 1; }
  119. ;;
  120. --db_option)
  121. db_option=$2; shift 2
  122. db_yn=y
  123. if [[ "${db_option}" =~ ^[1-9]$|^1[0-3]$ ]]; then
  124. [ -d "${db_install_dir}/support-files" ] && { echo "${CWARNING}MySQL already installed! ${CEND}"; db_option=Other; }
  125. elif [ "${db_option}" == '14' ]; then
  126. [ -e "${pgsql_install_dir}/bin/psql" ] && { echo "${CWARNING}PostgreSQL already installed! ${CEND}"; db_option=Other; }
  127. elif [ "${db_option}" == '15' ]; then
  128. [ -e "${mongo_install_dir}/bin/mongo" ] && { echo "${CWARNING}MongoDB already installed! ${CEND}"; db_option=Other; }
  129. else
  130. echo "${CWARNING}db_option input error! Please only input number 1~15${CEND}"
  131. exit 1
  132. fi
  133. ;;
  134. --dbrootpwd)
  135. dbrootpwd=$2; shift 2
  136. dbpostgrespwd="${dbrootpwd}"
  137. dbmongopwd="${dbrootpwd}"
  138. ;;
  139. --dbinstallmethod)
  140. dbinstallmethod=$2; shift 2
  141. [[ ! ${dbinstallmethod} =~ ^[1-2]$ ]] && { echo "${CWARNING}dbinstallmethod input error! Please only input number 1~2${CEND}"; exit 1; }
  142. ;;
  143. --pureftpd)
  144. ftp_yn=y; shift 1
  145. [ -e "${pureftpd_install_dir}/sbin/pure-ftpwho" ] && { echo "${CWARNING}Pure-FTPd already installed! ${CEND}"; ftp_yn=Other; }
  146. ;;
  147. --redis)
  148. redis_yn=y; shift 1
  149. ;;
  150. --memcached)
  151. memcached_yn=y; shift 1
  152. ;;
  153. --phpmyadmin)
  154. phpmyadmin_yn=y; shift 1
  155. [ -d "${wwwroot_dir}/default/phpMyAdmin" ] && { echo "${CWARNING}phpMyAdmin already installed! ${CEND}"; phpmyadmin_yn=Other; }
  156. ;;
  157. --hhvm)
  158. hhvm_yn=y; shift 1
  159. [ -e "/usr/bin/hhvm" ] && { echo "${CWARNING}HHVM already installed! ${CEND}"; hhvm_yn=Other; }
  160. ;;
  161. --ssh_port)
  162. ssh_port=$2; shift 2
  163. [ ${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; }
  164. ;;
  165. --iptables)
  166. iptables_yn=y; shift 1
  167. ;;
  168. --reboot)
  169. reboot_yn=y; shift 1
  170. ;;
  171. --)
  172. shift
  173. ;;
  174. *)
  175. echo "${CWARNING}ERROR: unknown argument! ${CEND}" && showhelp && exit 1
  176. ;;
  177. esac
  178. done
  179. mkdir -p ${wwwroot_dir}/default ${wwwlogs_dir}
  180. [ -d /data ] && chmod 755 /data
  181. # Use default SSH port 22. If you use another SSH port on your server
  182. if [ -e "/etc/ssh/sshd_config" ]; then
  183. if [ ${ARG_NUM} == 0 ]; then
  184. [ -z "`grep ^Port /etc/ssh/sshd_config`" ] && now_ssh_port=22 || now_ssh_port=`grep ^Port /etc/ssh/sshd_config | awk '{print $2}'`
  185. while :; do echo
  186. read -e -p "Please input SSH port(Default: ${now_ssh_port}): " ssh_port
  187. [ -z "${ssh_port}" ] && ssh_port=${now_ssh_port}
  188. 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
  189. break
  190. else
  191. echo "${CWARNING}input error! Input range: 22,1025~65534${CEND}"
  192. fi
  193. done
  194. fi
  195. if [ -z "`grep ^Port /etc/ssh/sshd_config`" -a "${ssh_port}" != '22' ]; then
  196. sed -i "s@^#Port.*@&\nPort ${ssh_port}@" /etc/ssh/sshd_config
  197. elif [ -n "`grep ^Port /etc/ssh/sshd_config`" ]; then
  198. sed -i "s@^Port.*@Port ${ssh_port}@" /etc/ssh/sshd_config
  199. fi
  200. fi
  201. if [ ${ARG_NUM} == 0 ]; then
  202. # check iptables
  203. while :; do echo
  204. read -e -p "Do you want to enable iptables? [y/n]: " iptables_yn
  205. if [[ ! ${iptables_yn} =~ ^[y,n]$ ]]; then
  206. echo "${CWARNING}input error! Please only input 'y' or 'n'${CEND}"
  207. else
  208. break
  209. fi
  210. done
  211. # check Web server
  212. while :; do echo
  213. read -e -p "Do you want to install Web server? [y/n]: " web_yn
  214. if [[ ! ${web_yn} =~ ^[y,n]$ ]]; then
  215. echo "${CWARNING}input error! Please only input 'y' or 'n'${CEND}"
  216. else
  217. if [ "${web_yn}" == 'y' ]; then
  218. # Nginx/Tegine/OpenResty
  219. while :; do echo
  220. echo 'Please select Nginx server:'
  221. echo -e "\t${CMSG}1${CEND}. Install Nginx"
  222. echo -e "\t${CMSG}2${CEND}. Install Tengine"
  223. echo -e "\t${CMSG}3${CEND}. Install OpenResty"
  224. echo -e "\t${CMSG}4${CEND}. Do not install"
  225. read -e -p "Please input a number:(Default 1 press Enter) " nginx_option
  226. [ -z "${nginx_option}" ] && nginx_option=1
  227. if [[ ! ${nginx_option} =~ ^[1-4]$ ]]; then
  228. echo "${CWARNING}input error! Please only input number 1~4${CEND}"
  229. else
  230. [ "${nginx_option}" != '4' -a -e "${nginx_install_dir}/sbin/nginx" ] && { echo "${CWARNING}Nginx already installed! ${CEND}"; nginx_option=Other; }
  231. [ "${nginx_option}" != '4' -a -e "${tengine_install_dir}/sbin/nginx" ] && { echo "${CWARNING}Tengine already installed! ${CEND}"; nginx_option=Other; }
  232. [ "${nginx_option}" != '4' -a -e "${openresty_install_dir}/nginx/sbin/nginx" ] && { echo "${CWARNING}OpenResty already installed! ${CEND}"; nginx_option=Other; }
  233. break
  234. fi
  235. done
  236. # Apache
  237. while :; do echo
  238. echo 'Please select Apache server:'
  239. echo -e "\t${CMSG}1${CEND}. Install Apache-2.4"
  240. echo -e "\t${CMSG}2${CEND}. Install Apache-2.2"
  241. echo -e "\t${CMSG}3${CEND}. Do not install"
  242. read -e -p "Please input a number:(Default 3 press Enter) " apache_option
  243. [ -z "${apache_option}" ] && apache_option=3
  244. if [[ ! ${apache_option} =~ ^[1-3]$ ]]; then
  245. echo "${CWARNING}input error! Please only input number 1~3${CEND}"
  246. else
  247. [ "${apache_option}" != '3' -a -e "${apache_install_dir}/conf/httpd.conf" ] && { echo "${CWARNING}Aapche already installed! ${CEND}"; apache_option=Other; }
  248. break
  249. fi
  250. done
  251. # Tomcat
  252. while :; do echo
  253. echo 'Please select tomcat server:'
  254. echo -e "\t${CMSG}1${CEND}. Install Tomcat-9"
  255. echo -e "\t${CMSG}2${CEND}. Install Tomcat-8"
  256. echo -e "\t${CMSG}3${CEND}. Install Tomcat-7"
  257. echo -e "\t${CMSG}4${CEND}. Install Tomcat-6"
  258. echo -e "\t${CMSG}5${CEND}. Do not install"
  259. read -e -p "Please input a number:(Default 5 press Enter) " tomcat_option
  260. [ -z "${tomcat_option}" ] && tomcat_option=5
  261. if [[ ! ${tomcat_option} =~ ^[1-5]$ ]]; then
  262. echo "${CWARNING}input error! Please only input number 1~5${CEND}"
  263. else
  264. [ "${tomcat_option}" != '5' -a -e "$tomcat_install_dir/conf/server.xml" ] && { echo "${CWARNING}Tomcat already installed! ${CEND}" ; tomcat_option=Other; }
  265. if [ "${tomcat_option}" == '1' ]; then
  266. while :; do echo
  267. echo 'Please select JDK version:'
  268. echo -e "\t${CMSG}1${CEND}. Install JDK-10"
  269. echo -e "\t${CMSG}2${CEND}. Install JDK-1.8"
  270. read -e -p "Please input a number:(Default 1 press Enter) " jdk_option
  271. [ -z "${jdk_option}" ] && jdk_option=1
  272. if [[ ! ${jdk_option} =~ ^[1-2]$ ]]; then
  273. echo "${CWARNING}input error! Please only input number 1~2${CEND}"
  274. else
  275. break
  276. fi
  277. done
  278. elif [ "${tomcat_option}" == '2' ]; then
  279. while :; do echo
  280. echo 'Please select JDK version:'
  281. echo -e "\t${CMSG}1${CEND}. Install JDK-10"
  282. echo -e "\t${CMSG}2${CEND}. Install JDK-1.8"
  283. echo -e "\t${CMSG}3${CEND}. Install JDK-1.7"
  284. read -e -p "Please input a number:(Default 2 press Enter) " jdk_option
  285. [ -z "${jdk_option}" ] && jdk_option=2
  286. if [[ ! ${jdk_option} =~ ^[1-3]$ ]]; then
  287. echo "${CWARNING}input error! Please only input number 1~3${CEND}"
  288. else
  289. break
  290. fi
  291. done
  292. elif [ "${tomcat_option}" == '3' ]; then
  293. while :; do echo
  294. echo 'Please select JDK version:'
  295. echo -e "\t${CMSG}2${CEND}. Install JDK-1.8"
  296. echo -e "\t${CMSG}3${CEND}. Install JDK-1.7"
  297. echo -e "\t${CMSG}4${CEND}. Install JDK-1.6"
  298. read -e -p "Please input a number:(Default 3 press Enter) " jdk_option
  299. [ -z "${jdk_option}" ] && jdk_option=3
  300. if [[ ! ${jdk_option} =~ ^[2-4]$ ]]; then
  301. echo "${CWARNING}input error! Please only input number 2~4${CEND}"
  302. else
  303. break
  304. fi
  305. done
  306. elif [ "${tomcat_option}" == '4' ]; then
  307. while :; do echo
  308. echo 'Please select JDK version:'
  309. echo -e "\t${CMSG}3${CEND}. Install JDK-1.7"
  310. echo -e "\t${CMSG}4${CEND}. Install JDK-1.6"
  311. read -e -p "Please input a number:(Default 4 press Enter) " jdk_option
  312. [ -z "${jdk_option}" ] && jdk_option=4
  313. if [[ ! ${jdk_option} =~ ^[3-4]$ ]]; then
  314. echo "${CWARNING}input error! Please only input number 3~4${CEND}"
  315. else
  316. break
  317. fi
  318. done
  319. fi
  320. break
  321. fi
  322. done
  323. fi
  324. break
  325. fi
  326. done
  327. # choice database
  328. while :; do echo
  329. read -e -p "Do you want to install Database? [y/n]: " db_yn
  330. if [[ ! ${db_yn} =~ ^[y,n]$ ]]; then
  331. echo "${CWARNING}input error! Please only input 'y' or 'n'${CEND}"
  332. else
  333. if [ "${db_yn}" == 'y' ]; then
  334. while :; do echo
  335. echo 'Please select a version of the Database:'
  336. echo -e "\t${CMSG} 1${CEND}. Install MySQL-8.0"
  337. echo -e "\t${CMSG} 2${CEND}. Install MySQL-5.7"
  338. echo -e "\t${CMSG} 3${CEND}. Install MySQL-5.6"
  339. echo -e "\t${CMSG} 4${CEND}. Install MySQL-5.5"
  340. echo -e "\t${CMSG} 5${CEND}. Install MariaDB-10.3"
  341. echo -e "\t${CMSG} 6${CEND}. Install MariaDB-10.2"
  342. echo -e "\t${CMSG} 7${CEND}. Install MariaDB-10.1"
  343. echo -e "\t${CMSG} 8${CEND}. Install MariaDB-10.0"
  344. echo -e "\t${CMSG} 9${CEND}. Install MariaDB-5.5"
  345. echo -e "\t${CMSG}10${CEND}. Install Percona-5.7"
  346. echo -e "\t${CMSG}11${CEND}. Install Percona-5.6"
  347. echo -e "\t${CMSG}12${CEND}. Install Percona-5.5"
  348. echo -e "\t${CMSG}13${CEND}. Install AliSQL-5.6"
  349. echo -e "\t${CMSG}14${CEND}. Install PostgreSQL"
  350. echo -e "\t${CMSG}15${CEND}. Install MongoDB"
  351. read -e -p "Please input a number:(Default 2 press Enter) " db_option
  352. [ -z "${db_option}" ] && db_option=2
  353. [[ "${db_option}" =~ ^5$|^15$ ]] && [ "${OS_BIT}" == '32' ] && { echo "${CWARNING}By not supporting 32-bit! ${CEND}"; continue; }
  354. if [[ "${db_option}" =~ ^[1-9]$|^1[0-5]$ ]]; then
  355. if [ "${db_option}" == '14' ]; then
  356. [ -e "${pgsql_install_dir}/bin/psql" ] && { echo "${CWARNING}PostgreSQL already installed! ${CEND}"; db_option=Other; break; }
  357. elif [ "${db_option}" == '15' ]; then
  358. [ -e "${mongo_install_dir}/bin/mongo" ] && { echo "${CWARNING}MongoDB already installed! ${CEND}"; db_option=Other; break; }
  359. else
  360. [ -d "${db_install_dir}/support-files" ] && { echo "${CWARNING}MySQL already installed! ${CEND}"; db_option=Other; break; }
  361. fi
  362. while :; do
  363. if [ "${db_option}" == '14' ]; then
  364. read -e -p "Please input the postgres password of PostgreSQL(default: ${dbpostgrespwd}): " dbpwd
  365. [ -z "${dbpwd}" ] && dbpwd=${dbpostgrespwd}
  366. elif [ "${db_option}" == '15' ]; then
  367. read -e -p "Please input the root password of MongoDB(default: ${dbmongopwd}): " dbpwd
  368. [ -z "${dbpwd}" ] && dbpwd=${dbmongopwd}
  369. else
  370. read -e -p "Please input the root password of MySQL(default: ${dbrootpwd}): " dbpwd
  371. [ -z "${dbpwd}" ] && dbpwd=${dbrootpwd}
  372. fi
  373. [ -n "`echo ${dbpwd} | grep '[+|&]'`" ] && { echo "${CWARNING}input error,not contain a plus sign (+) and & ${CEND}"; continue; }
  374. if (( ${#dbpwd} >= 5 )); then
  375. if [ "${db_option}" == '14' ]; then
  376. dbpostgrespwd=${dbpwd}
  377. elif [ "${db_option}" == '15' ]; then
  378. dbmongopwd=${dbpwd}
  379. else
  380. dbrootpwd=${dbpwd}
  381. fi
  382. break
  383. else
  384. echo "${CWARNING}password least 5 characters! ${CEND}"
  385. fi
  386. done
  387. # choose install methods
  388. if [[ "${db_option}" =~ ^[1-9]$|^1[0-2]$ ]]; then
  389. while :; do echo
  390. echo "Please choose installation of the database:"
  391. echo -e "\t${CMSG}1${CEND}. Install database from binary package."
  392. echo -e "\t${CMSG}2${CEND}. Install database from source package."
  393. read -e -p "Please input a number:(Default 1 press Enter) " dbinstallmethod
  394. [ -z "${dbinstallmethod}" ] && dbinstallmethod=1
  395. if [[ ! ${dbinstallmethod} =~ ^[1-2]$ ]]; then
  396. echo "${CWARNING}input error! Please only input number 1~2${CEND}"
  397. else
  398. [ "${db_option}" == '5' -a "${LIBC_YN}" != '0' -a "$dbinstallmethod" == '1' ] && { echo "${CWARNING}MariaDB-10.3 binaries require GLIBC 2.14 or higher! ${CEND}"; continue; }
  399. break
  400. fi
  401. done
  402. fi
  403. break
  404. else
  405. echo "${CWARNING}input error! Please only input number 1~15${CEND}"
  406. fi
  407. done
  408. fi
  409. break
  410. fi
  411. done
  412. # check PHP
  413. while :; do echo
  414. read -e -p "Do you want to install PHP? [y/n]: " php_yn
  415. if [[ ! ${php_yn} =~ ^[y,n]$ ]]; then
  416. echo "${CWARNING}input error! Please only input 'y' or 'n'${CEND}"
  417. else
  418. if [ "${php_yn}" == 'y' ]; then
  419. [ -e "${php_install_dir}/bin/phpize" ] && { echo "${CWARNING}PHP already installed! ${CEND}"; php_option=Other; break; }
  420. while :; do echo
  421. echo 'Please select a version of the PHP:'
  422. echo -e "\t${CMSG}1${CEND}. Install php-5.3"
  423. echo -e "\t${CMSG}2${CEND}. Install php-5.4"
  424. echo -e "\t${CMSG}3${CEND}. Install php-5.5"
  425. echo -e "\t${CMSG}4${CEND}. Install php-5.6"
  426. echo -e "\t${CMSG}5${CEND}. Install php-7.0"
  427. echo -e "\t${CMSG}6${CEND}. Install php-7.1"
  428. echo -e "\t${CMSG}7${CEND}. Install php-7.2"
  429. read -e -p "Please input a number:(Default 5 press Enter) " php_option
  430. [ -z "${php_option}" ] && php_option=5
  431. if [[ ! ${php_option} =~ ^[1-7]$ ]]; then
  432. echo "${CWARNING}input error! Please only input number 1~7${CEND}"
  433. else
  434. while :; do echo
  435. read -e -p "Do you want to install opcode cache of the PHP? [y/n]: " phpcache_yn
  436. if [[ ! ${phpcache_yn} =~ ^[y,n]$ ]]; then
  437. echo "${CWARNING}input error! Please only input 'y' or 'n'${CEND}"
  438. else
  439. if [ "${phpcache_yn}" == 'y' ]; then
  440. if [ ${php_option} == 1 ]; then
  441. while :; do
  442. echo 'Please select a opcode cache of the PHP:'
  443. echo -e "\t${CMSG}1${CEND}. Install Zend OPcache"
  444. echo -e "\t${CMSG}2${CEND}. Install XCache"
  445. echo -e "\t${CMSG}3${CEND}. Install APCU"
  446. echo -e "\t${CMSG}4${CEND}. Install eAccelerator-0.9"
  447. read -e -p "Please input a number:(Default 1 press Enter) " phpcache_option
  448. [ -z "${phpcache_option}" ] && phpcache_option=1
  449. if [[ ! ${phpcache_option} =~ ^[1-4]$ ]]; then
  450. echo "${CWARNING}input error! Please only input number 1~4${CEND}"
  451. else
  452. break
  453. fi
  454. done
  455. fi
  456. if [ ${php_option} == 2 ]; then
  457. while :; do
  458. echo 'Please select a opcode cache of the PHP:'
  459. echo -e "\t${CMSG}1${CEND}. Install Zend OPcache"
  460. echo -e "\t${CMSG}2${CEND}. Install XCache"
  461. echo -e "\t${CMSG}3${CEND}. Install APCU"
  462. echo -e "\t${CMSG}4${CEND}. Install eAccelerator-1.0-dev"
  463. read -e -p "Please input a number:(Default 1 press Enter) " phpcache_option
  464. [ -z "${phpcache_option}" ] && phpcache_option=1
  465. if [[ ! ${phpcache_option} =~ ^[1-4]$ ]]; then
  466. echo "${CWARNING}input error! Please only input number 1~4${CEND}"
  467. else
  468. break
  469. fi
  470. done
  471. fi
  472. if [ ${php_option} == 3 ]; then
  473. while :; do
  474. echo 'Please select a opcode cache of the PHP:'
  475. echo -e "\t${CMSG}1${CEND}. Install Zend OPcache"
  476. echo -e "\t${CMSG}2${CEND}. Install XCache"
  477. echo -e "\t${CMSG}3${CEND}. Install APCU"
  478. read -e -p "Please input a number:(Default 1 press Enter) " phpcache_option
  479. [ -z "${phpcache_option}" ] && phpcache_option=1
  480. if [[ ! ${phpcache_option} =~ ^[1-3]$ ]]; then
  481. echo "${CWARNING}input error! Please only input number 1~3${CEND}"
  482. else
  483. break
  484. fi
  485. done
  486. fi
  487. if [ ${php_option} == 4 ]; then
  488. while :; do
  489. echo 'Please select a opcode cache of the PHP:'
  490. echo -e "\t${CMSG}1${CEND}. Install Zend OPcache"
  491. echo -e "\t${CMSG}2${CEND}. Install XCache"
  492. echo -e "\t${CMSG}3${CEND}. Install APCU"
  493. read -e -p "Please input a number:(Default 1 press Enter) " phpcache_option
  494. [ -z "${phpcache_option}" ] && phpcache_option=1
  495. if [[ ! ${phpcache_option} =~ ^[1-3]$ ]]; then
  496. echo "${CWARNING}input error! Please only input number 1~3${CEND}"
  497. else
  498. break
  499. fi
  500. done
  501. fi
  502. if [[ ${php_option} =~ ^[5-6]$ ]]; then
  503. while :; do
  504. echo 'Please select a opcode cache of the PHP:'
  505. echo -e "\t${CMSG}1${CEND}. Install Zend OPcache"
  506. echo -e "\t${CMSG}3${CEND}. Install APCU"
  507. read -e -p "Please input a number:(Default 1 press Enter) " phpcache_option
  508. [ -z "${phpcache_option}" ] && phpcache_option=1
  509. if [[ ! ${phpcache_option} =~ ^[1,3]$ ]]; then
  510. echo "${CWARNING}input error! Please only input number 1,3${CEND}"
  511. else
  512. break
  513. fi
  514. done
  515. fi
  516. [ ${php_option} == 7 ] && phpcache_option=1
  517. fi
  518. break
  519. fi
  520. done
  521. if [ "${phpcache_option}" == '2' ]; then
  522. while :; do
  523. read -e -p "Please input xcache admin password: " xcachepwd
  524. (( ${#xcachepwd} >= 5 )) && { xcachepwd_md5=$(echo -n "${xcachepwd}" | md5sum | awk '{print $1}') ; break ; } || echo "${CFAILURE}xcache admin password least 5 characters! ${CEND}"
  525. done
  526. fi
  527. if [[ ${php_option} =~ ^[1-4]$ ]] && [ "${phpcache_option}" != '1' -a "${armplatform}" != "y" ]; then
  528. while :; do echo
  529. read -e -p "Do you want to install ZendGuardLoader? [y/n]: " zendguardloader_yn
  530. if [[ ! ${zendguardloader_yn} =~ ^[y,n]$ ]]; then
  531. echo "${CWARNING}input error! Please only input 'y' or 'n'${CEND}"
  532. else
  533. break
  534. fi
  535. done
  536. fi
  537. # ionCube
  538. if [ "${TARGET_ARCH}" != "arm64" ]; then
  539. while :; do echo
  540. read -e -p "Do you want to install ionCube? [y/n]: " ioncube_yn
  541. if [[ ! ${ioncube_yn} =~ ^[y,n]$ ]]; then
  542. echo "${CWARNING}input error! Please only input 'y' or 'n'${CEND}"
  543. else
  544. break
  545. fi
  546. done
  547. fi
  548. # ImageMagick or GraphicsMagick
  549. while :; do echo
  550. read -e -p "Do you want to install ImageMagick or GraphicsMagick? [y/n]: " magick_yn
  551. if [[ ! ${magick_yn} =~ ^[y,n]$ ]]; then
  552. echo "${CWARNING}input error! Please only input 'y' or 'n'${CEND}"
  553. else
  554. break
  555. fi
  556. done
  557. if [ "${magick_yn}" == 'y' ]; then
  558. while :; do
  559. echo 'Please select ImageMagick or GraphicsMagick:'
  560. echo -e "\t${CMSG}1${CEND}. Install ImageMagick"
  561. echo -e "\t${CMSG}2${CEND}. Install GraphicsMagick"
  562. read -e -p "Please input a number:(Default 1 press Enter) " magick_option
  563. [ -z "${magick_option}" ] && magick_option=1
  564. if [[ ! ${magick_option} =~ ^[1-2]$ ]]; then
  565. echo "${CWARNING}input error! Please only input number 1~2${CEND}"
  566. else
  567. break
  568. fi
  569. done
  570. fi
  571. break
  572. fi
  573. done
  574. fi
  575. break
  576. fi
  577. done
  578. # check Pureftpd
  579. while :; do echo
  580. read -e -p "Do you want to install Pure-FTPd? [y/n]: " ftp_yn
  581. if [[ ! ${ftp_yn} =~ ^[y,n]$ ]]; then
  582. echo "${CWARNING}input error! Please only input 'y' or 'n'${CEND}"
  583. else
  584. [ "${ftp_yn}" == 'y' -a -e "${pureftpd_install_dir}/sbin/pure-ftpwho" ] && { echo "${CWARNING}Pure-FTPd already installed! ${CEND}"; ftp_yn=Other; }
  585. break
  586. fi
  587. done
  588. # check phpMyAdmin
  589. if [[ ${php_option} =~ ^[1-7]$ ]] || [ -e "${php_install_dir}/bin/phpize" ]; then
  590. while :; do echo
  591. read -e -p "Do you want to install phpMyAdmin? [y/n]: " phpmyadmin_yn
  592. if [[ ! ${phpmyadmin_yn} =~ ^[y,n]$ ]]; then
  593. echo "${CWARNING}input error! Please only input 'y' or 'n'${CEND}"
  594. else
  595. [ "${phpmyadmin_yn}" == 'y' -a -d "${wwwroot_dir}/default/phpMyAdmin" ] && { echo "${CWARNING}phpMyAdmin already installed! ${CEND}"; phpmyadmin_yn=Other; }
  596. break
  597. fi
  598. done
  599. fi
  600. # check redis
  601. while :; do echo
  602. read -e -p "Do you want to install redis? [y/n]: " redis_yn
  603. if [[ ! ${redis_yn} =~ ^[y,n]$ ]]; then
  604. echo "${CWARNING}input error! Please only input 'y' or 'n'${CEND}"
  605. else
  606. break
  607. fi
  608. done
  609. # check memcached
  610. while :; do echo
  611. read -e -p "Do you want to install memcached? [y/n]: " memcached_yn
  612. if [[ ! ${memcached_yn} =~ ^[y,n]$ ]]; then
  613. echo "${CWARNING}input error! Please only input 'y' or 'n'${CEND}"
  614. else
  615. break
  616. fi
  617. done
  618. while :; do echo
  619. read -e -p "Do you want to install HHVM? [y/n]: " hhvm_yn
  620. if [[ ! ${hhvm_yn} =~ ^[y,n]$ ]]; then
  621. echo "${CWARNING}input error! Please only input 'y' or 'n'${CEND}"
  622. else
  623. if [ "${hhvm_yn}" == 'y' ]; then
  624. [ -e "/usr/bin/hhvm" ] && { echo "${CWARNING}HHVM already installed! ${CEND}"; hhvm_yn=Other; break; }
  625. if [ "${PM}" == 'yum' -a "${OS_BIT}" == '64' ] && [ -n "`grep -E ' 7\.| 6\.[5-9]' /etc/redhat-release`" ]; then
  626. break
  627. else
  628. echo
  629. echo "${CWARNING}HHVM only support CentOS6.5+ 64bit, CentOS7 64bit! ${CEND}"
  630. echo "Press Ctrl+c to cancel or Press any key to continue..."
  631. char=`get_char`
  632. hhvm_yn=Other
  633. fi
  634. fi
  635. break
  636. fi
  637. done
  638. fi
  639. # get the IP information
  640. IPADDR=$(./include/get_ipaddr.py)
  641. PUBLIC_IPADDR=$(./include/get_public_ipaddr.py)
  642. IPADDR_COUNTRY=$(./include/get_ipaddr_state.py $PUBLIC_IPADDR)
  643. # Check download source packages
  644. . ./include/check_download.sh
  645. downloadDepsSrc=1
  646. [ "${PM}" == 'yum' ] && yum -y -q install wget
  647. [ "${PM}" == 'apt' ] && apt-get -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-11.0.sh
  862. Install-JDK110 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. if [ "${redis_pecl}" == '1' ]; then
  912. . include/redis.sh
  913. [ -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
  914. fi
  915. # memcached
  916. if [ "${memcached_yn}" == 'y' ]; then
  917. . include/memcached.sh
  918. [ ! -d "${memcached_install_dir}/include/memcached" ] && Install_memcached 2>&1 | tee -a ${oneinstack_dir}/install.log
  919. [ -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
  920. [ -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
  921. fi
  922. if [ "${memcached_pecl}" == '1' ]; then
  923. . include/memcached.sh
  924. [ -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
  925. fi
  926. if [ "${memcache_pecl}" == '1' ]; then
  927. . include/memcached.sh
  928. [ -e "${php_install_dir}/bin/phpize" ] && [ ! -e "$(${php_install_dir}/bin/php-config --extension-dir)/memcache.so" ] && Install_php-memcache 2>&1 | tee -a ${oneinstack_dir}/install.log
  929. fi
  930. # index example
  931. if [ ! -e "${wwwroot_dir}/default/index.html" -a "${web_yn}" == 'y' ]; then
  932. . include/demo.sh
  933. DEMO 2>&1 | tee -a ${oneinstack_dir}/install.log
  934. fi
  935. # get web_install_dir and db_install_dir
  936. . include/check_dir.sh
  937. # HHVM
  938. if [ "${hhvm_yn}" == 'y' ] && [ "${PM}" == 'yum' -a "${OS_BIT}" == '64' ] && [ -n "`grep -E ' 7\.| 6\.[5-9]' /etc/redhat-release`" ]; then
  939. . include/hhvm_CentOS.sh
  940. Install_hhvm_CentOS 2>&1 | tee -a ${oneinstack_dir}/install.log
  941. fi
  942. # Starting DB
  943. [ -d "/etc/mysql" ] && /bin/mv /etc/mysql{,_bk}
  944. [ -d "${db_install_dir}/support-files" ] && service mysqld start
  945. endTime=`date +%s`
  946. ((installTime=($endTime-$startTime)/60))
  947. echo "####################Congratulations########################"
  948. echo "Total OneinStack Install Time: ${CQUESTION}${installTime}${CEND} minutes"
  949. [ "${web_yn}" == 'y' ] && [[ "${nginx_option}" =~ ^[1-3]$ ]] && echo -e "\n$(printf "%-32s" "Nginx install dir":)${CMSG}${web_install_dir}${CEND}"
  950. [ "${web_yn}" == 'y' ] && [[ "${apache_option}" =~ ^[1,2]$ ]] && echo -e "\n$(printf "%-32s" "Apache install dir":)${CMSG}${apache_install_dir}${CEND}"
  951. [[ "${tomcat_option}" =~ ^[1,2]$ ]] && echo -e "\n$(printf "%-32s" "Tomcat install dir":)${CMSG}${tomcat_install_dir}${CEND}"
  952. [[ "${db_option}" =~ ^[1-9]$|^1[0-3]$ ]] && echo -e "\n$(printf "%-32s" "Database install dir:")${CMSG}${db_install_dir}${CEND}"
  953. [[ "${db_option}" =~ ^[1-9]$|^1[0-3]$ ]] && echo "$(printf "%-32s" "Database data dir:")${CMSG}${db_data_dir}${CEND}"
  954. [[ "${db_option}" =~ ^[1-9]$|^1[0-3]$ ]] && echo "$(printf "%-32s" "Database user:")${CMSG}root${CEND}"
  955. [[ "${db_option}" =~ ^[1-9]$|^1[0-3]$ ]] && echo "$(printf "%-32s" "Database password:")${CMSG}${dbrootpwd}${CEND}"
  956. [ "${db_option}" == '14' ] && echo -e "\n$(printf "%-32s" "PostgreSQL install dir:")${CMSG}${pgsql_install_dir}${CEND}"
  957. [ "${db_option}" == '14' ] && echo "$(printf "%-32s" "PostgreSQL data dir:")${CMSG}${pgsql_data_dir}${CEND}"
  958. [ "${db_option}" == '14' ] && echo "$(printf "%-32s" "PostgreSQL user:")${CMSG}postgres${CEND}"
  959. [ "${db_option}" == '14' ] && echo "$(printf "%-32s" "postgres password:")${CMSG}${dbpostgrespwd}${CEND}"
  960. [ "${db_option}" == '15' ] && echo -e "\n$(printf "%-32s" "MongoDB install dir:")${CMSG}${mongo_install_dir}${CEND}"
  961. [ "${db_option}" == '15' ] && echo "$(printf "%-32s" "MongoDB data dir:")${CMSG}${mongo_data_dir}${CEND}"
  962. [ "${db_option}" == '15' ] && echo "$(printf "%-32s" "MongoDB user:")${CMSG}root${CEND}"
  963. [ "${db_option}" == '15' ] && echo "$(printf "%-32s" "MongoDB password:")${CMSG}${dbmongopwd}${CEND}"
  964. [ "${php_yn}" == 'y' ] && echo -e "\n$(printf "%-32s" "PHP install dir:")${CMSG}${php_install_dir}${CEND}"
  965. [ "${php_yn}" == 'y' -a "${phpcache_option}" == '1' ] && echo "$(printf "%-32s" "Opcache Control Panel URL:")${CMSG}http://${IPADDR}/ocp.php${CEND}"
  966. [ "${phpcache_option}" == '2' ] && echo "$(printf "%-32s" "xcache Control Panel URL:")${CMSG}http://${IPADDR}/xcache${CEND}"
  967. [ "${phpcache_option}" == '2' ] && echo "$(printf "%-32s" "xcache user:")${CMSG}admin${CEND}"
  968. [ "${phpcache_option}" == '2' ] && echo "$(printf "%-32s" "xcache password:")${CMSG}${xcachepwd}${CEND}"
  969. [ "${phpcache_option}" == '3' ] && echo "$(printf "%-32s" "APC Control Panel URL:")${CMSG}http://${IPADDR}/apc.php${CEND}"
  970. [ "${phpcache_option}" == '4' ] && echo "$(printf "%-32s" "eAccelerator Control Panel URL:")${CMSG}http://${IPADDR}/control.php${CEND}"
  971. [ "${phpcache_option}" == '4' ] && echo "$(printf "%-32s" "eAccelerator user:")${CMSG}admin${CEND}"
  972. [ "${phpcache_option}" == '4' ] && echo "$(printf "%-32s" "eAccelerator password:")${CMSG}eAccelerator${CEND}"
  973. [ "${ftp_yn}" == 'y' ] && echo -e "\n$(printf "%-32s" "Pure-FTPd install dir:")${CMSG}${pureftpd_install_dir}${CEND}"
  974. [ "${ftp_yn}" == 'y' ] && echo "$(printf "%-32s" "Create FTP virtual script:")${CMSG}./pureftpd_vhost.sh${CEND}"
  975. [ "${phpmyadmin_yn}" == 'y' ] && echo -e "\n$(printf "%-32s" "phpMyAdmin dir:")${CMSG}${wwwroot_dir}/default/phpMyAdmin${CEND}"
  976. [ "${phpmyadmin_yn}" == 'y' ] && echo "$(printf "%-32s" "phpMyAdmin Control Panel URL:")${CMSG}http://${IPADDR}/phpMyAdmin${CEND}"
  977. [ "${redis_yn}" == 'y' ] && echo -e "\n$(printf "%-32s" "redis install dir:")${CMSG}${redis_install_dir}${CEND}"
  978. [ "${memcached_yn}" == 'y' ] && echo -e "\n$(printf "%-32s" "memcached install dir:")${CMSG}${memcached_install_dir}${CEND}"
  979. [ "${web_yn}" == 'y' ] && echo -e "\n$(printf "%-32s" "Index URL:")${CMSG}http://${IPADDR}/${CEND}"
  980. if [ ${ARG_NUM} == 0 ]; then
  981. while :; do echo
  982. echo "${CMSG}Please restart the server and see if the services start up fine.${CEND}"
  983. read -e -p "Do you want to restart OS ? [y/n]: " reboot_yn
  984. if [[ ! "${reboot_yn}" =~ ^[y,n]$ ]]; then
  985. echo "${CWARNING}input error! Please only input 'y' or 'n'${CEND}"
  986. else
  987. break
  988. fi
  989. done
  990. fi
  991. [ "${reboot_yn}" == 'y' ] && reboot