1
0

install.sh 42 KB

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