install.sh 43 KB

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