install.sh 42 KB

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