1
0

install.sh 42 KB

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