install.sh 43 KB

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