1
0

install.sh 51 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388
  1. #!/bin/bash
  2. # Author: yeho <lj2007331 AT gmail.com>
  3. # BLOG: https://linuxeye.com
  4. #
  5. # Notes: OneinStack for CentOS/RedHat 7+ Debian 9+ and Ubuntu 16+
  6. #
  7. # Project home page:
  8. # https://oneinstack.com
  9. # https://github.com/oneinstack/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 7+ Debian 9+ and Ubuntu 16+ #
  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. dbrootpwd=`< /dev/urandom tr -dc A-Za-z0-9 | head -c8`
  30. dbpostgrespwd=`< /dev/urandom tr -dc A-Za-z0-9 | head -c8`
  31. dbmongopwd=`< /dev/urandom tr -dc A-Za-z0-9 | head -c8`
  32. xcachepwd=`< /dev/urandom tr -dc A-Za-z0-9 | head -c8`
  33. dbinstallmethod=1
  34. version() {
  35. echo "version: 2.6"
  36. echo "updated date: 2023-02-04"
  37. }
  38. Show_Help() {
  39. version
  40. echo "Usage: $0 command ...[parameters]....
  41. --help, -h Show this help message, More: https://oneinstack.com/auto
  42. --version, -v Show version info
  43. --nginx_option [1-4] Install Nginx server version
  44. --apache Install Apache
  45. --apache_mode_option [1-2] Apache2.4 mode, 1(default): php-fpm, 2: mod_php
  46. --apache_mpm_option [1-3] Apache2.4 MPM, 1(default): event, 2: prefork, 3: worker
  47. --php_option [1-13] Install PHP version
  48. --mphp_ver [53~83] Install another PHP version (PATH: ${php_install_dir}\${mphp_ver})
  49. --mphp_addons Only install another PHP addons
  50. --phpcache_option [1-4] Install PHP opcode cache, default: 1 opcache
  51. --php_extensions [ext name] Install PHP extensions, include zendguardloader,ioncube,
  52. sourceguardian,imagick,gmagick,fileinfo,imap,ldap,calendar,phalcon,
  53. yaf,yar,redis,memcached,memcache,mongodb,swoole,xdebug
  54. --nodejs Install Nodejs
  55. --tomcat_option [1-6] Install Tomcat version
  56. --jdk_option [1-3] Install JDK version
  57. --db_option [1-14] Install DB version
  58. --dbinstallmethod [1-2] DB install method, default: 1 binary install
  59. --dbrootpwd [password] DB super password
  60. --pureftpd Install Pure-Ftpd
  61. --redis Install Redis
  62. --memcached Install Memcached
  63. --phpmyadmin Install phpMyAdmin
  64. --ssh_port [No.] SSH port
  65. --firewall Enable firewall
  66. --md5sum Check md5sum
  67. --reboot Restart the server after installation
  68. "
  69. }
  70. ARG_NUM=$#
  71. TEMP=`getopt -o hvV --long help,version,nginx_option:,apache,apache_mode_option:,apache_mpm_option:,php_option:,mphp_ver:,mphp_addons,phpcache_option:,php_extensions:,nodejs,tomcat_option:,jdk_option:,db_option:,dbrootpwd:,dbinstallmethod:,pureftpd,redis,memcached,phpmyadmin,ssh_port:,firewall,md5sum,reboot -- "$@" 2>/dev/null`
  72. [ $? != 0 ] && echo "${CWARNING}ERROR: unknown argument! ${CEND}" && Show_Help && exit 1
  73. eval set -- "${TEMP}"
  74. while :; do
  75. [ -z "$1" ] && break;
  76. case "$1" in
  77. -h | --help)
  78. Show_Help
  79. exit 0
  80. ;;
  81. -v | -V | --version)
  82. version
  83. exit 0
  84. ;;
  85. --nginx_option)
  86. nginx_option=$2
  87. shift 2
  88. [[ ! ${nginx_option} =~ ^[1-4]$ ]] && {
  89. echo "${CWARNING}nginx_option input error! Please only input number 1~5${CEND}"
  90. exit 1
  91. }
  92. [ -e "${nginx_install_dir}/sbin/nginx" ] && {
  93. echo "${CWARNING}Nginx already installed! ${CEND}"
  94. unset nginx_option
  95. }
  96. [ -e "${tengine_install_dir}/sbin/nginx" ] && {
  97. echo "${CWARNING}Tengine already installed! ${CEND}"
  98. unset nginx_option
  99. }
  100. [ -e "${openresty_install_dir}/nginx/sbin/nginx" ] && {
  101. echo "${CWARNING}OpenResty already installed! ${CEND}"
  102. unset nginx_option
  103. }
  104. [ -e "${caddy_install_dir}/bin/caddy" ] && {
  105. echo "${CWARNING}Caddy already installed! ${CEND}"
  106. unset nginx_option
  107. }
  108. ;;
  109. --apache)
  110. apache_flag=y
  111. shift 1
  112. [ -e "${apache_install_dir}/bin/httpd" ] && {
  113. echo "${CWARNING}Aapche already installed! ${CEND}"
  114. unset apache_flag
  115. }
  116. ;;
  117. --apache_mode_option)
  118. apache_mode_option=$2
  119. shift 2
  120. [[ ! ${apache_mode_option} =~ ^[1-2]$ ]] && {
  121. echo "${CWARNING}apache_mode_option input error! Please only input number 1~2${CEND}"
  122. exit 1
  123. }
  124. ;;
  125. --apache_mpm_option)
  126. apache_mpm_option=$2
  127. shift 2
  128. [[ ! ${apache_mpm_option} =~ ^[1-3]$ ]] && {
  129. echo "${CWARNING}apache_mpm_option input error! Please only input number 1~3${CEND}"
  130. exit 1
  131. }
  132. ;;
  133. --php_option)
  134. php_option=$2
  135. shift 2
  136. [[ ! ${php_option} =~ ^[1-9]$|^1[0-4]$ ]] && {
  137. echo "${CWARNING}php_option input error! Please only input number 1~14${CEND}"
  138. exit 1
  139. }
  140. [ -e "${php_install_dir}/bin/phpize" ] && {
  141. echo "${CWARNING}PHP already installed! ${CEND}"
  142. unset php_option
  143. }
  144. ;;
  145. --mphp_ver)
  146. mphp_ver=$2
  147. mphp_flag=y
  148. shift 2
  149. [[ ! "${mphp_ver}" =~ ^5[3-6]$|^7[0-4]$|^8[0-3]$ ]] && {
  150. echo "${CWARNING}mphp_ver input error! Please only input number 53~82${CEND}"
  151. exit 1
  152. }
  153. ;;
  154. --mphp_addons)
  155. mphp_addons_flag=y
  156. shift 1
  157. ;;
  158. --phpcache_option)
  159. phpcache_option=$2
  160. shift 2
  161. ;;
  162. --php_extensions)
  163. php_extensions=$2
  164. shift 2
  165. [ -n "$(echo ${php_extensions} | grep -w zendguardloader)" ] && pecl_zendguardloader=1
  166. [ -n "$(echo ${php_extensions} | grep -w ioncube)" ] && pecl_ioncube=1
  167. [ -n "$(echo ${php_extensions} | grep -w sourceguardian)" ] && pecl_sourceguardian=1
  168. [ -n "$(echo ${php_extensions} | grep -w imagick)" ] && pecl_imagick=1
  169. [ -n "$(echo ${php_extensions} | grep -w gmagick)" ] && pecl_gmagick=1
  170. [ -n "$(echo ${php_extensions} | grep -w fileinfo)" ] && pecl_fileinfo=1
  171. [ -n "$(echo ${php_extensions} | grep -w imap)" ] && pecl_imap=1
  172. [ -n "$(echo ${php_extensions} | grep -w ldap)" ] && pecl_ldap=1
  173. [ -n "$(echo ${php_extensions} | grep -w calendar)" ] && pecl_calendar=1
  174. [ -n "$(echo ${php_extensions} | grep -w phalcon)" ] && pecl_phalcon=1
  175. [ -n "$(echo ${php_extensions} | grep -w yaf)" ] && pecl_yaf=1
  176. [ -n "$(echo ${php_extensions} | grep -w yar)" ] && pecl_yar=1
  177. [ -n "$(echo ${php_extensions} | grep -w redis)" ] && pecl_redis=1
  178. [ -n "$(echo ${php_extensions} | grep -w memcached)" ] && pecl_memcached=1
  179. [ -n "$(echo ${php_extensions} | grep -w memcache)" ] && pecl_memcache=1
  180. [ -n "$(echo ${php_extensions} | grep -w mongodb)" ] && pecl_mongodb=1
  181. [ -n "$(echo ${php_extensions} | grep -w swoole)" ] && pecl_swoole=1
  182. [ -n "$(echo ${php_extensions} | grep -w xdebug)" ] && pecl_xdebug=1
  183. ;;
  184. --nodejs)
  185. nodejs_flag=y
  186. shift 1
  187. [ -e "${nodejs_install_dir}/bin/node" ] && {
  188. echo "${CWARNING}Nodejs already installed! ${CEND}"
  189. unset nodejs_flag
  190. }
  191. ;;
  192. --tomcat_option)
  193. tomcat_option=$2
  194. shift 2
  195. [[ ! ${tomcat_option} =~ ^[1-6]$ ]] && {
  196. echo "${CWARNING}tomcat_option input error! Please only input number 1~6${CEND}"
  197. exit 1
  198. }
  199. [ -e "$tomcat_install_dir/conf/server.xml" ] && {
  200. echo "${CWARNING}Tomcat already installed! ${CEND}"
  201. unset tomcat_option
  202. }
  203. ;;
  204. --jdk_option)
  205. jdk_option=$2
  206. shift 2
  207. [[ ! ${jdk_option} =~ ^[1-4]$ ]] && {
  208. echo "${CWARNING}jdk_option input error! Please only input number 1~4${CEND}"
  209. exit 1
  210. }
  211. ;;
  212. --db_option)
  213. db_option=$2
  214. shift 2
  215. if [[ "${db_option}" =~ ^[1-9]$|^1[0-2]$ ]]; then
  216. [ -d "${db_install_dir}/support-files" ] && {
  217. echo "${CWARNING}MySQL already installed! ${CEND}"
  218. unset db_option
  219. }
  220. elif [ "${db_option}" == '13' ]; then
  221. [ -e "${pgsql_install_dir}/bin/psql" ] && {
  222. echo "${CWARNING}PostgreSQL already installed! ${CEND}"
  223. unset db_option
  224. }
  225. elif [ "${db_option}" == '14' ]; then
  226. [ -e "${mongo_install_dir}/bin/mongo" ] && {
  227. echo "${CWARNING}MongoDB already installed! ${CEND}"
  228. unset db_option
  229. }
  230. else
  231. echo "${CWARNING}db_option input error! Please only input number 1~14${CEND}"
  232. exit 1
  233. fi
  234. ;;
  235. --dbrootpwd)
  236. dbrootpwd=$2
  237. shift 2
  238. dbpostgrespwd="${dbrootpwd}"
  239. dbmongopwd="${dbrootpwd}"
  240. ;;
  241. --dbinstallmethod)
  242. dbinstallmethod=$2
  243. shift 2
  244. [[ ! ${dbinstallmethod} =~ ^[1-2]$ ]] && {
  245. echo "${CWARNING}dbinstallmethod input error! Please only input number 1~2${CEND}"
  246. exit 1
  247. }
  248. ;;
  249. --pureftpd)
  250. pureftpd_flag=y
  251. shift 1
  252. [ -e "${pureftpd_install_dir}/sbin/pure-ftpwho" ] && {
  253. echo "${CWARNING}Pure-FTPd already installed! ${CEND}"
  254. unset pureftpd_flag
  255. }
  256. ;;
  257. --redis)
  258. redis_flag=y
  259. shift 1
  260. [ -e "${redis_install_dir}/bin/redis-server" ] && {
  261. echo "${CWARNING}redis-server already installed! ${CEND}"
  262. unset redis_flag
  263. }
  264. ;;
  265. --memcached)
  266. memcached_flag=y
  267. shift 1
  268. [ -e "${memcached_install_dir}/bin/memcached" ] && {
  269. echo "${CWARNING}memcached-server already installed! ${CEND}"
  270. unset memcached_flag
  271. }
  272. ;;
  273. --phpmyadmin)
  274. phpmyadmin_flag=y
  275. shift 1
  276. [ -d "${wwwroot_dir}/default/phpMyAdmin" ] && {
  277. echo "${CWARNING}phpMyAdmin already installed! ${CEND}"
  278. unset phpmyadmin_flag
  279. }
  280. ;;
  281. --ssh_port)
  282. ssh_port=$2
  283. shift 2
  284. ;;
  285. --firewall)
  286. firewall_flag=y
  287. shift 1
  288. ;;
  289. --md5sum)
  290. md5sum_flag=y; shift 1
  291. ;;
  292. --reboot)
  293. reboot_flag=y
  294. shift 1
  295. ;;
  296. --)
  297. shift
  298. ;;
  299. *)
  300. echo "${CWARNING}ERROR: unknown argument! ${CEND}" && Show_Help && exit 1
  301. ;;
  302. esac
  303. done
  304. # Check md5sum
  305. if [ ${ARG_NUM} == 0 ] && [ ! -e ~/.oneinstack ]; then
  306. # Check md5sum
  307. while :; do echo
  308. read -e -p "Do you want to check md5sum? [y/n]: " md5sum_flag
  309. if [[ ! ${md5sum_flag} =~ ^[y,n]$ ]]; then
  310. echo "${CWARNING}input error! Please only input 'y' or 'n'${CEND}"
  311. else
  312. break
  313. fi
  314. done
  315. fi
  316. if [ "${md5sum_flag}" == 'y' ]; then
  317. [ -e "${oneinstack_dir}.tar.gz" ] && oneinstack_file=${oneinstack_dir}.tar.gz
  318. [ -e "${oneinstack_dir}-full.tar.gz" ] && oneinstack_file=${oneinstack_dir}-full.tar.gz
  319. oneinstack_tgz=${oneinstack_file##*/}
  320. if [ -e "${oneinstack_file}" ]; then
  321. now_oneinstack_md5=$(md5sum ${oneinstack_file} | awk '{print $1}')
  322. latest_oneinStack_md5=$(curl --connect-timeout 3 -m 5 -s ${mirror_link}/md5sum.txt | grep ${oneinstack_tgz} | awk '{print $1}')
  323. if [ "${now_oneinstack_md5}" != "${latest_oneinStack_md5}" ]; then
  324. echo "${CFAILURE}Error: The md5 value of the installation package does not match the official website, please download again, url: ${mirror_link}/${oneinstack_tgz}${CEND}"
  325. exit 1
  326. fi
  327. else
  328. echo "${CFAILURE}Error: ${oneinstack_file} does not exist${CEND}"
  329. exit 1
  330. fi
  331. fi
  332. # Use default SSH port 22. If you use another SSH port on your server
  333. if [ -e "/etc/ssh/sshd_config" ]; then
  334. [ -z "`grep ^Port /etc/ssh/sshd_config`" ] && now_ssh_port=22 || now_ssh_port=`grep ^Port /etc/ssh/sshd_config | awk '{print $2}' | head -1`
  335. while :; do echo
  336. [ ${ARG_NUM} == 0 ] && read -e -p "Please input SSH port(Default: ${now_ssh_port}): " ssh_port
  337. ssh_port=${ssh_port:-${now_ssh_port}}
  338. 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
  339. break
  340. else
  341. echo "${CWARNING}input error! Input range: 22,1025~65534${CEND}"
  342. exit 1
  343. fi
  344. done
  345. if [ -z "`grep ^Port /etc/ssh/sshd_config`" -a "${ssh_port}" != '22' ]; then
  346. sed -i "s@^#Port.*@&\nPort ${ssh_port}@" /etc/ssh/sshd_config
  347. elif [ -n "`grep ^Port /etc/ssh/sshd_config`" ]; then
  348. sed -i "s@^Port.*@Port ${ssh_port}@" /etc/ssh/sshd_config
  349. fi
  350. fi
  351. if [ ${ARG_NUM} == 0 ]; then
  352. if [ ! -e ~/.oneinstack ]; then
  353. # check firewall
  354. while :; do echo
  355. read -e -p "Do you want to enable firewall? [y/n]: " firewall_flag
  356. if [[ ! ${firewall_flag} =~ ^[y,n]$ ]]; then
  357. echo "${CWARNING}input error! Please only input 'y' or 'n'${CEND}"
  358. else
  359. break
  360. fi
  361. done
  362. fi
  363. # check Web server
  364. while :; do echo
  365. read -e -p "Do you want to install Web server? [y/n]: " web_flag
  366. if [[ ! ${web_flag} =~ ^[y,n]$ ]]; then
  367. echo "${CWARNING}input error! Please only input 'y' or 'n'${CEND}"
  368. else
  369. if [ "${web_flag}" == 'y' ]; then
  370. # Nginx/Tegine/OpenResty
  371. while :; do
  372. echo
  373. echo 'Please select Web server type:'
  374. echo -e "\t${CMSG}1${CEND}. Install Nginx"
  375. echo -e "\t${CMSG}2${CEND}. Install Tengine"
  376. echo -e "\t${CMSG}3${CEND}. Install OpenResty"
  377. echo -e "\t${CMSG}4${CEND}. Install Caddy"
  378. echo -e "\t${CMSG}5${CEND}. Do not install"
  379. read -e -p "Please input a number:(Default 1 press Enter) " nginx_option
  380. nginx_option=${nginx_option:-1}
  381. if [[ ! ${nginx_option} =~ ^[1-5]$ ]]; then
  382. echo "${CWARNING}input error! Please only input number 1~5${CEND}"
  383. else
  384. [ "${nginx_option}" != '5' -a -e "${nginx_install_dir}/sbin/nginx" ] && {
  385. echo "${CWARNING}Nginx already installed! ${CEND}"
  386. unset nginx_option
  387. }
  388. [ "${nginx_option}" != '5' -a -e "${tengine_install_dir}/sbin/nginx" ] && {
  389. echo "${CWARNING}Tengine already installed! ${CEND}"
  390. unset nginx_option
  391. }
  392. [ "${nginx_option}" != '5' -a -e "${openresty_install_dir}/nginx/sbin/nginx" ] && {
  393. echo "${CWARNING}OpenResty already installed! ${CEND}"
  394. unset nginx_option
  395. }
  396. [ "${nginx_option}" != '5' -a -e "${caddy_install_dir}/bin/caddy" ] && {
  397. echo "${CWARNING}Caddy already installed! ${CEND}"
  398. unset nginx_option
  399. }
  400. break
  401. fi
  402. done
  403. if [[ ${nginx_option} =~ ^[1-3]$ ]]; then
  404. # Apache
  405. while :; do
  406. echo
  407. read -e -p "Do you want to install Apache? [y/n]: " apache_flag
  408. if [[ ! ${apache_flag} =~ ^[y,n]$ ]]; then
  409. echo "${CWARNING}input error! Please only input 'y' or 'n'${CEND}"
  410. else
  411. [ "${apache_flag}" == 'y' -a -e "${apache_install_dir}/bin/httpd" ] && {
  412. echo "${CWARNING}Aapche already installed! ${CEND}"
  413. unset apache_flag
  414. }
  415. break
  416. fi
  417. done
  418. # Apache2.4 mode and Apache2.4 MPM
  419. if [ "${apache_flag}" == 'y' -o -e "${apache_install_dir}/bin/httpd" ]; then
  420. while :; do
  421. echo
  422. echo 'Please select Apache mode:'
  423. echo -e "\t${CMSG}1${CEND}. php-fpm"
  424. echo -e "\t${CMSG}2${CEND}. mod_php"
  425. read -e -p "Please input a number:(Default 1 press Enter) " apache_mode_option
  426. apache_mode_option=${apache_mode_option:-1}
  427. if [[ ! ${apache_mode_option} =~ ^[1-2]$ ]]; then
  428. echo "${CWARNING}input error! Please only input number 1~2${CEND}"
  429. else
  430. break
  431. fi
  432. done
  433. while :; do
  434. echo
  435. echo 'Please select Apache MPM:'
  436. echo -e "\t${CMSG}1${CEND}. event"
  437. echo -e "\t${CMSG}2${CEND}. prefork"
  438. echo -e "\t${CMSG}3${CEND}. worker"
  439. read -e -p "Please input a number:(Default 1 press Enter) " apache_mpm_option
  440. apache_mpm_option=${apache_mpm_option:-1}
  441. if [[ ! ${apache_mpm_option} =~ ^[1-3]$ ]]; then
  442. echo "${CWARNING}input error! Please only input number 1~3${CEND}"
  443. else
  444. break
  445. fi
  446. done
  447. fi
  448. # Tomcat
  449. while :; do
  450. echo
  451. echo 'Please select tomcat server:'
  452. echo -e "\t${CMSG}1${CEND}. Install Tomcat-11"
  453. echo -e "\t${CMSG}2${CEND}. Install Tomcat-10"
  454. echo -e "\t${CMSG}3${CEND}. Install Tomcat-9"
  455. echo -e "\t${CMSG}4${CEND}. Install Tomcat-8"
  456. echo -e "\t${CMSG}5${CEND}. Install Tomcat-7"
  457. echo -e "\t${CMSG}6${CEND}. Install Tomcat-6"
  458. echo -e "\t${CMSG}7${CEND}. Do not install"
  459. read -e -p "Please input a number:(Default 7 press Enter) " tomcat_option
  460. tomcat_option=${tomcat_option:-7}
  461. if [[ ! ${tomcat_option} =~ ^[1-7]$ ]]; then
  462. echo "${CWARNING}input error! Please only input number 1~7${CEND}"
  463. else
  464. [ "${tomcat_option}" != '7' -a -e "$tomcat_install_dir/conf/server.xml" ] && {
  465. echo "${CWARNING}Tomcat already installed! ${CEND}"
  466. unset tomcat_option
  467. }
  468. if [[ "${tomcat_option}" =~ ^1$ ]]; then
  469. while :; do
  470. echo
  471. echo 'Please select JDK version:'
  472. echo -e "\t${CMSG}1${CEND}. Install openjdk-8-jdk"
  473. echo -e "\t${CMSG}2${CEND}. Install openjdk-11-jdk"
  474. echo -e "\t${CMSG}3${CEND}. Install openjdk-17-jdk"
  475. echo -e "\t${CMSG}4${CEND}. Install openjdk-18-jdk"
  476. read -e -p "Please input a number:(Default 1 press Enter) " jdk_option
  477. jdk_option=${jdk_option:-1}
  478. if [[ ! ${jdk_option} =~ ^[1-4]$ ]]; then
  479. echo "${CWARNING}input error! Please only input number 1~4${CEND}"
  480. else
  481. break
  482. fi
  483. done
  484. elif [[ "${tomcat_option}" =~ ^[2-3]$ ]]; then
  485. while :; do
  486. echo
  487. echo 'Please select JDK version:'
  488. echo -e "\t${CMSG}1${CEND}. Install openjdk-8-jdk"
  489. echo -e "\t${CMSG}2${CEND}. Install openjdk-11-jdk"
  490. echo -e "\t${CMSG}3${CEND}. Install openjdk-17-jdk"
  491. read -e -p "Please input a number:(Default 1 press Enter) " jdk_option
  492. jdk_option=${jdk_option:-1}
  493. if [[ ! ${jdk_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. elif [ "${tomcat_option}" == '4' ]; then
  500. while :; do
  501. echo
  502. echo 'Please select JDK version:'
  503. echo -e "\t${CMSG}1${CEND}. Install openjdk-8-jdk"
  504. read -e -p "Please input a number:(Default 1 press Enter) " jdk_option
  505. jdk_option=${jdk_option:-1}
  506. if [[ ! ${jdk_option} =~ ^1$ ]]; then
  507. echo "${CWARNING}input error! Please only input number 1${CEND}"
  508. else
  509. break
  510. fi
  511. done
  512. fi
  513. break
  514. fi
  515. done
  516. elif [ "${nginx_option}" == '4' ]; then
  517. # Caddy
  518. while :; do
  519. echo
  520. read -e -p "Do you want to install Caddy? [y/n]: " caddy_flag
  521. if [[ ! ${caddy_flag} =~ ^[y,n]$ ]]; then
  522. echo "${CWARNING}input error! Please only input 'y' or 'n'${CEND}"
  523. else
  524. [ "${caddy_flag}" == 'y' -a -e "${caddy_install_dir}/bin/caddy" ] && {
  525. echo "${CWARNING}Caddy already installed! ${CEND}"
  526. unset caddy_flag
  527. }
  528. break
  529. fi
  530. done
  531. fi
  532. fi
  533. break
  534. fi
  535. done
  536. # choice database
  537. while :; do
  538. echo
  539. read -e -p "Do you want to install Database? [y/n]: " db_flag
  540. if [[ ! ${db_flag} =~ ^[y,n]$ ]]; then
  541. echo "${CWARNING}input error! Please only input 'y' or 'n'${CEND}"
  542. else
  543. if [ "${db_flag}" == 'y' ]; then
  544. while :; do
  545. echo
  546. echo 'Please select a version of the Database:'
  547. echo -e "\t${CMSG} 1${CEND}. Install MySQL-8.0"
  548. echo -e "\t${CMSG} 2${CEND}. Install MySQL-5.7"
  549. echo -e "\t${CMSG} 3${CEND}. Install MySQL-5.6"
  550. echo -e "\t${CMSG} 4${CEND}. Install MySQL-5.5"
  551. echo -e "\t${CMSG} 5${CEND}. Install MariaDB-10.11"
  552. echo -e "\t${CMSG} 6${CEND}. Install MariaDB-10.5"
  553. echo -e "\t${CMSG} 7${CEND}. Install MariaDB-10.4"
  554. echo -e "\t${CMSG} 8${CEND}. Install MariaDB-5.5"
  555. echo -e "\t${CMSG} 9${CEND}. Install Percona-8.0"
  556. echo -e "\t${CMSG}10${CEND}. Install Percona-5.7"
  557. echo -e "\t${CMSG}11${CEND}. Install Percona-5.6"
  558. echo -e "\t${CMSG}12${CEND}. Install Percona-5.5"
  559. echo -e "\t${CMSG}13${CEND}. Install PostgreSQL"
  560. echo -e "\t${CMSG}14${CEND}. Install MongoDB"
  561. read -e -p "Please input a number:(Default 2 press Enter) " db_option
  562. db_option=${db_option:-2}
  563. if [[ "${db_option}" =~ ^[1-9]$|^1[0-4]$ ]]; then
  564. if [ "${db_option}" == '13' ]; then
  565. [ -e "${pgsql_install_dir}/bin/psql" ] && { echo "${CWARNING}PostgreSQL already installed! ${CEND}"; unset db_option; break; }
  566. elif [ "${db_option}" == '14' ]; then
  567. [ -e "${mongo_install_dir}/bin/mongo" ] && { echo "${CWARNING}MongoDB already installed! ${CEND}"; unset db_option; break; }
  568. else
  569. [ -d "${db_install_dir}/support-files" ] && { echo "${CWARNING}MySQL already installed! ${CEND}"; unset db_option; break; }
  570. fi
  571. while :; do
  572. if [ "${db_option}" == '13' ]; then
  573. read -e -p "Please input the postgres password of PostgreSQL(default: ${dbpostgrespwd}): " dbpwd
  574. dbpwd=${dbpwd:-${dbpostgrespwd}}
  575. elif [ "${db_option}" == '14' ]; then
  576. read -e -p "Please input the root password of MongoDB(default: ${dbmongopwd}): " dbpwd
  577. dbpwd=${dbpwd:-${dbmongopwd}}
  578. else
  579. read -e -p "Please input the root password of MySQL(default: ${dbrootpwd}): " dbpwd
  580. dbpwd=${dbpwd:-${dbrootpwd}}
  581. fi
  582. [ -n "`echo ${dbpwd} | grep '[+|&]'`" ] && { echo "${CWARNING}input error,not contain a plus sign (+) and & ${CEND}"; continue; }
  583. if (( ${#dbpwd} >= 5 )); then
  584. if [ "${db_option}" == '13' ]; then
  585. dbpostgrespwd=${dbpwd}
  586. elif [ "${db_option}" == '14' ]; then
  587. dbmongopwd=${dbpwd}
  588. else
  589. dbrootpwd=${dbpwd}
  590. fi
  591. break
  592. else
  593. echo "${CWARNING}password least 5 characters! ${CEND}"
  594. fi
  595. done
  596. # choose install methods
  597. if [[ "${db_option}" =~ ^[1-9]$|^1[0-2]$ ]]; then
  598. while :; do echo
  599. echo "Please choose installation of the database:"
  600. echo -e "\t${CMSG}1${CEND}. Install database from binary package."
  601. echo -e "\t${CMSG}2${CEND}. Install database from source package."
  602. read -e -p "Please input a number:(Default 1 press Enter) " dbinstallmethod
  603. dbinstallmethod=${dbinstallmethod:-1}
  604. if [[ ! ${dbinstallmethod} =~ ^[1-2]$ ]]; then
  605. echo "${CWARNING}input error! Please only input number 1~2${CEND}"
  606. else
  607. break
  608. fi
  609. done
  610. fi
  611. break
  612. else
  613. echo "${CWARNING}input error! Please only input number 1~14${CEND}"
  614. fi
  615. done
  616. fi
  617. break
  618. fi
  619. done
  620. # choice php
  621. while :; do echo
  622. read -e -p "Do you want to install PHP? [y/n]: " php_flag
  623. if [[ ! ${php_flag} =~ ^[y,n]$ ]]; then
  624. echo "${CWARNING}input error! Please only input 'y' or 'n'${CEND}"
  625. else
  626. if [ "${php_flag}" == 'y' ]; then
  627. [ -e "${php_install_dir}/bin/phpize" ] && { echo "${CWARNING}PHP already installed! ${CEND}"; unset php_option; break; }
  628. while :; do echo
  629. echo 'Please select a version of the PHP:'
  630. echo -e "\t${CMSG} 1${CEND}. Install php-5.3"
  631. echo -e "\t${CMSG} 2${CEND}. Install php-5.4"
  632. echo -e "\t${CMSG} 3${CEND}. Install php-5.5"
  633. echo -e "\t${CMSG} 4${CEND}. Install php-5.6"
  634. echo -e "\t${CMSG} 5${CEND}. Install php-7.0"
  635. echo -e "\t${CMSG} 6${CEND}. Install php-7.1"
  636. echo -e "\t${CMSG} 7${CEND}. Install php-7.2"
  637. echo -e "\t${CMSG} 8${CEND}. Install php-7.3"
  638. echo -e "\t${CMSG} 9${CEND}. Install php-7.4"
  639. echo -e "\t${CMSG}10${CEND}. Install php-8.0"
  640. echo -e "\t${CMSG}11${CEND}. Install php-8.1"
  641. echo -e "\t${CMSG}12${CEND}. Install php-8.2"
  642. echo -e "\t${CMSG}13${CEND}. Install php-8.3"
  643. echo -e "\t${CMSG}14${CEND}. Install php-8.4"
  644. read -e -p "Please input a number:(Default 7 press Enter) " php_option
  645. php_option=${php_option:-7}
  646. if [[ ! ${php_option} =~ ^[1-9]$|^1[0-4]$ ]]; then
  647. echo "${CWARNING}input error! Please only input number 1~14${CEND}"
  648. else
  649. break
  650. fi
  651. done
  652. fi
  653. break
  654. fi
  655. done
  656. # check php ver
  657. if [ -e "${php_install_dir}/bin/phpize" ]; then
  658. PHP_detail_ver=$(${php_install_dir}/bin/php-config --version)
  659. PHP_main_ver=${PHP_detail_ver%.*}
  660. fi
  661. # PHP opcode cache and extensions
  662. if [[ ${php_option} =~ ^[1-9]$|^1[0-3]$ ]] || [ -e "${php_install_dir}/bin/phpize" ]; then
  663. while :; do echo
  664. read -e -p "Do you want to install opcode cache of the PHP? [y/n]: " phpcache_flag
  665. if [[ ! ${phpcache_flag} =~ ^[y,n]$ ]]; then
  666. echo "${CWARNING}input error! Please only input 'y' or 'n'${CEND}"
  667. else
  668. if [ "${phpcache_flag}" == 'y' ]; then
  669. if [ "${php_option}" == '1' -o "${PHP_main_ver}" == '5.3' ]; then
  670. while :; do
  671. echo 'Please select a opcode cache of the PHP:'
  672. echo -e "\t${CMSG}1${CEND}. Install Zend OPcache"
  673. echo -e "\t${CMSG}2${CEND}. Install APCU"
  674. echo -e "\t${CMSG}3${CEND}. Install XCache"
  675. echo -e "\t${CMSG}4${CEND}. Install eAccelerator-0.9"
  676. read -e -p "Please input a number:(Default 1 press Enter) " phpcache_option
  677. phpcache_option=${phpcache_option:-1}
  678. if [[ ! ${phpcache_option} =~ ^[1-4]$ ]]; then
  679. echo "${CWARNING}input error! Please only input number 1~4${CEND}"
  680. else
  681. break
  682. fi
  683. done
  684. fi
  685. if [ "${php_option}" == '2' -o "${PHP_main_ver}" == '5.4' ]; then
  686. while :; do
  687. echo 'Please select a opcode cache of the PHP:'
  688. echo -e "\t${CMSG}1${CEND}. Install Zend OPcache"
  689. echo -e "\t${CMSG}2${CEND}. Install APCU"
  690. echo -e "\t${CMSG}3${CEND}. Install XCache"
  691. echo -e "\t${CMSG}4${CEND}. Install eAccelerator-1.0-dev"
  692. read -e -p "Please input a number:(Default 1 press Enter) " phpcache_option
  693. phpcache_option=${phpcache_option:-1}
  694. if [[ ! ${phpcache_option} =~ ^[1-4]$ ]]; then
  695. echo "${CWARNING}input error! Please only input number 1~4${CEND}"
  696. else
  697. break
  698. fi
  699. done
  700. fi
  701. if [ "${php_option}" == '3' -o "${PHP_main_ver}" == '5.5' ]; then
  702. while :; do
  703. echo 'Please select a opcode cache of the PHP:'
  704. echo -e "\t${CMSG}1${CEND}. Install Zend OPcache"
  705. echo -e "\t${CMSG}2${CEND}. Install APCU"
  706. echo -e "\t${CMSG}3${CEND}. Install XCache"
  707. read -e -p "Please input a number:(Default 1 press Enter) " phpcache_option
  708. phpcache_option=${phpcache_option:-1}
  709. if [[ ! ${phpcache_option} =~ ^[1-3]$ ]]; then
  710. echo "${CWARNING}input error! Please only input number 1~3${CEND}"
  711. else
  712. break
  713. fi
  714. done
  715. fi
  716. if [ "${php_option}" == '4' -o "${PHP_main_ver}" == '5.6' ]; then
  717. while :; do
  718. echo 'Please select a opcode cache of the PHP:'
  719. echo -e "\t${CMSG}1${CEND}. Install Zend OPcache"
  720. echo -e "\t${CMSG}2${CEND}. Install APCU"
  721. echo -e "\t${CMSG}3${CEND}. Install XCache"
  722. read -e -p "Please input a number:(Default 1 press Enter) " phpcache_option
  723. phpcache_option=${phpcache_option:-1}
  724. if [[ ! ${phpcache_option} =~ ^[1-3]$ ]]; then
  725. echo "${CWARNING}input error! Please only input number 1~3${CEND}"
  726. else
  727. break
  728. fi
  729. done
  730. fi
  731. if [[ ${php_option} =~ ^[5-9]$|^1[0-3]$ ]] || [[ "${PHP_main_ver}" =~ ^7.[0-4]$|^8.[0-3]$ ]]; then
  732. while :; do
  733. echo 'Please select a opcode cache of the PHP:'
  734. echo -e "\t${CMSG}1${CEND}. Install Zend OPcache"
  735. echo -e "\t${CMSG}2${CEND}. Install APCU"
  736. read -e -p "Please input a number:(Default 1 press Enter) " phpcache_option
  737. phpcache_option=${phpcache_option:-1}
  738. if [[ ! ${phpcache_option} =~ ^[1-2]$ ]]; then
  739. echo "${CWARNING}input error! Please only input number 1~2${CEND}"
  740. else
  741. break
  742. fi
  743. done
  744. fi
  745. fi
  746. break
  747. fi
  748. done
  749. # set xcache passwd
  750. if [ "${phpcache_option}" == '3' ]; then
  751. while :; do
  752. read -e -p "Please input xcache admin password: " xcachepwd
  753. (( ${#xcachepwd} >= 5 )) && { xcachepwd_md5=$(echo -n "${xcachepwd}" | md5sum | awk '{print $1}') ; break ; } || echo "${CFAILURE}xcache admin password least 5 characters! ${CEND}"
  754. done
  755. fi
  756. # PHP extension
  757. while :; do
  758. echo
  759. echo 'Please select PHP extensions:'
  760. echo -e "\t${CMSG} 0${CEND}. Do not install"
  761. echo -e "\t${CMSG} 1${CEND}. Install zendguardloader(PHP<=5.6)"
  762. echo -e "\t${CMSG} 2${CEND}. Install ioncube"
  763. echo -e "\t${CMSG} 3${CEND}. Install sourceguardian(PHP<=7.2)"
  764. echo -e "\t${CMSG} 4${CEND}. Install imagick"
  765. echo -e "\t${CMSG} 5${CEND}. Install gmagick"
  766. echo -e "\t${CMSG} 6${CEND}. Install fileinfo"
  767. echo -e "\t${CMSG} 7${CEND}. Install imap"
  768. echo -e "\t${CMSG} 8${CEND}. Install ldap"
  769. echo -e "\t${CMSG} 9${CEND}. Install phalcon(PHP>=5.5)"
  770. echo -e "\t${CMSG}10${CEND}. Install yaf(PHP>=7.0)"
  771. echo -e "\t${CMSG}11${CEND}. Install redis"
  772. echo -e "\t${CMSG}12${CEND}. Install memcached"
  773. echo -e "\t${CMSG}13${CEND}. Install memcache"
  774. echo -e "\t${CMSG}14${CEND}. Install mongodb"
  775. echo -e "\t${CMSG}15${CEND}. Install swoole"
  776. echo -e "\t${CMSG}16${CEND}. Install xdebug(PHP>=5.5)"
  777. read -e -p "Please input numbers:(Default '4 11 12' press Enter) " phpext_option
  778. phpext_option=${phpext_option:-'4 11 12'}
  779. [ "${phpext_option}" == '0' ] && break
  780. array_phpext=(${phpext_option})
  781. array_all=(1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16)
  782. for v in ${array_phpext[@]}
  783. do
  784. [ -z "`echo ${array_all[@]} | grep -w ${v}`" ] && phpext_flag=1
  785. done
  786. if [ "${phpext_flag}" == '1' ]; then
  787. unset phpext_flag
  788. echo; echo "${CWARNING}input error! Please only input number 4 11 12 and so on${CEND}"; echo
  789. continue
  790. else
  791. [ -n "`echo ${array_phpext[@]} | grep -w 1`" ] && pecl_zendguardloader=1
  792. [ -n "`echo ${array_phpext[@]} | grep -w 2`" ] && pecl_ioncube=1
  793. [ -n "`echo ${array_phpext[@]} | grep -w 3`" ] && pecl_sourceguardian=1
  794. [ -n "`echo ${array_phpext[@]} | grep -w 4`" ] && pecl_imagick=1
  795. [ -n "`echo ${array_phpext[@]} | grep -w 5`" ] && pecl_gmagick=1
  796. [ -n "`echo ${array_phpext[@]} | grep -w 6`" ] && pecl_fileinfo=1
  797. [ -n "`echo ${array_phpext[@]} | grep -w 7`" ] && pecl_imap=1
  798. [ -n "`echo ${array_phpext[@]} | grep -w 8`" ] && pecl_ldap=1
  799. [ -n "`echo ${array_phpext[@]} | grep -w 9`" ] && pecl_phalcon=1
  800. [ -n "`echo ${array_phpext[@]} | grep -w 10`" ] && pecl_yaf=1
  801. [ -n "`echo ${array_phpext[@]} | grep -w 11`" ] && pecl_redis=1
  802. [ -n "`echo ${array_phpext[@]} | grep -w 12`" ] && pecl_memcached=1
  803. [ -n "`echo ${array_phpext[@]} | grep -w 13`" ] && pecl_memcache=1
  804. [ -n "`echo ${array_phpext[@]} | grep -w 14`" ] && pecl_mongodb=1
  805. [ -n "`echo ${array_phpext[@]} | grep -w 15`" ] && pecl_swoole=1
  806. [ -n "`echo ${array_phpext[@]} | grep -w 16`" ] && pecl_xdebug=1
  807. break
  808. fi
  809. done
  810. fi
  811. # check Nodejs
  812. while :; do echo
  813. read -e -p "Do you want to install Nodejs? [y/n]: " nodejs_flag
  814. if [[ ! ${nodejs_flag} =~ ^[y,n]$ ]]; then
  815. echo "${CWARNING}input error! Please only input 'y' or 'n'${CEND}"
  816. else
  817. [ "${nodejs_flag}" == 'y' -a -e "${nodejs_install_dir}/bin/node" ] && { echo "${CWARNING}Nodejs already installed! ${CEND}"; unset nodejs_flag; }
  818. break
  819. fi
  820. done
  821. # check Pureftpd
  822. while :; do echo
  823. read -e -p "Do you want to install Pure-FTPd? [y/n]: " pureftpd_flag
  824. if [[ ! ${pureftpd_flag} =~ ^[y,n]$ ]]; then
  825. echo "${CWARNING}input error! Please only input 'y' or 'n'${CEND}"
  826. else
  827. [ "${pureftpd_flag}" == 'y' -a -e "${pureftpd_install_dir}/sbin/pure-ftpwho" ] && { echo "${CWARNING}Pure-FTPd already installed! ${CEND}"; unset pureftpd_flag; }
  828. break
  829. fi
  830. done
  831. # check phpMyAdmin
  832. if [[ ${php_option} =~ ^[1-9]$|^1[0-3]$ ]] || [ -e "${php_install_dir}/bin/phpize" ]; then
  833. while :; do echo
  834. read -e -p "Do you want to install phpMyAdmin? [y/n]: " phpmyadmin_flag
  835. if [[ ! ${phpmyadmin_flag} =~ ^[y,n]$ ]]; then
  836. echo "${CWARNING}input error! Please only input 'y' or 'n'${CEND}"
  837. else
  838. [ "${phpmyadmin_flag}" == 'y' -a -d "${wwwroot_dir}/default/phpMyAdmin" ] && { echo "${CWARNING}phpMyAdmin already installed! ${CEND}"; unset phpmyadmin_flag; }
  839. break
  840. fi
  841. done
  842. fi
  843. # check redis
  844. while :; do echo
  845. read -e -p "Do you want to install redis-server? [y/n]: " redis_flag
  846. if [[ ! ${redis_flag} =~ ^[y,n]$ ]]; then
  847. echo "${CWARNING}input error! Please only input 'y' or 'n'${CEND}"
  848. else
  849. [ "${redis_flag}" == 'y' -a -e "${redis_install_dir}/bin/redis-server" ] && { echo "${CWARNING}redis-server already installed! ${CEND}"; unset redis_flag; }
  850. break
  851. fi
  852. done
  853. # check memcached
  854. while :; do echo
  855. read -e -p "Do you want to install memcached-server? [y/n]: " memcached_flag
  856. if [[ ! ${memcached_flag} =~ ^[y,n]$ ]]; then
  857. echo "${CWARNING}input error! Please only input 'y' or 'n'${CEND}"
  858. else
  859. [ "${memcached_flag}" == 'y' -a -e "${memcached_install_dir}/bin/memcached" ] && { echo "${CWARNING}memcached-server already installed! ${CEND}"; unset memcached_flag; }
  860. break
  861. fi
  862. done
  863. fi
  864. if [[ ${nginx_option} =~ ^[1-4]$ ]] || [ "${apache_flag}" == 'y' ] || [ "${caddy_flag}" == 'y' ] || [[ ${tomcat_option} =~ ^[1-6]$ ]]; then
  865. [ ! -d ${wwwroot_dir}/default ] && mkdir -p ${wwwroot_dir}/default
  866. [ ! -d ${wwwlogs_dir} ] && mkdir -p ${wwwlogs_dir}
  867. fi
  868. [ -d /data ] && chmod 755 /data
  869. # install wget gcc curl
  870. if [ ! -e ~/.oneinstack ]; then
  871. downloadDepsSrc=1
  872. [ "${PM}" == 'apt-get' ] && apt-get -y update > /dev/null
  873. [ "${PM}" == 'yum' ] && yum clean all > /dev/null
  874. ${PM} -y install wget gcc curl > /dev/null
  875. fi
  876. # get the IP information
  877. IPADDR=$(./include/ois.${ARCH} ip_local)
  878. OUTIP_STATE=$(./include/ois.${ARCH} ip_state)
  879. # openSSL
  880. . ./include/openssl.sh
  881. # Check download source packages
  882. . ./include/check_download.sh
  883. [ "${armplatform}" == "y" ] && dbinstallmethod=2
  884. checkDownload 2>&1 | tee -a ${oneinstack_dir}/install.log
  885. # get OS Memory
  886. . ./include/memory.sh
  887. if [ ! -e ~/.oneinstack ]; then
  888. # Check binary dependencies packages
  889. . ./include/check_sw.sh
  890. case "${Family}" in
  891. "rhel")
  892. installDepsRHEL 2>&1 | tee ${oneinstack_dir}/install.log
  893. . include/init_RHEL.sh 2>&1 | tee -a ${oneinstack_dir}/install.log
  894. ;;
  895. "debian")
  896. installDepsDebian 2>&1 | tee ${oneinstack_dir}/install.log
  897. . include/init_Debian.sh 2>&1 | tee -a ${oneinstack_dir}/install.log
  898. ;;
  899. "ubuntu")
  900. installDepsUbuntu 2>&1 | tee ${oneinstack_dir}/install.log
  901. . include/init_Ubuntu.sh 2>&1 | tee -a ${oneinstack_dir}/install.log
  902. ;;
  903. esac
  904. # Install dependencies from source package
  905. installDepsBySrc 2>&1 | tee -a ${oneinstack_dir}/install.log
  906. fi
  907. # start Time
  908. startTime=`date +%s`
  909. # openSSL
  910. Install_openSSL | tee -a ${oneinstack_dir}/install.log
  911. # Jemalloc
  912. if [[ ${nginx_option} =~ ^[1-3]$ ]] || [[ "${db_option}" =~ ^[1-9]$|^1[0-2]$ ]]; then
  913. . include/jemalloc.sh
  914. Install_Jemalloc | tee -a ${oneinstack_dir}/install.log
  915. fi
  916. # Database
  917. case "${db_option}" in
  918. 1)
  919. . include/mysql-8.0.sh
  920. Install_MySQL80 2>&1 | tee -a ${oneinstack_dir}/install.log
  921. ;;
  922. 2)
  923. . include/mysql-5.7.sh
  924. Install_MySQL57 2>&1 | tee -a ${oneinstack_dir}/install.log
  925. ;;
  926. 3)
  927. . include/mysql-5.6.sh
  928. Install_MySQL56 2>&1 | tee -a ${oneinstack_dir}/install.log
  929. ;;
  930. 4)
  931. . include/mysql-5.5.sh
  932. Install_MySQL55 2>&1 | tee -a ${oneinstack_dir}/install.log
  933. ;;
  934. 5)
  935. . include/mariadb-10.11.sh
  936. Install_MariaDB1011 2>&1 | tee -a ${oneinstack_dir}/install.log
  937. ;;
  938. 6)
  939. . include/mariadb-10.5.sh
  940. Install_MariaDB105 2>&1 | tee -a ${oneinstack_dir}/install.log
  941. ;;
  942. 7)
  943. . include/mariadb-10.4.sh
  944. Install_MariaDB104 2>&1 | tee -a ${oneinstack_dir}/install.log
  945. ;;
  946. 8)
  947. . include/mariadb-5.5.sh
  948. Install_MariaDB55 2>&1 | tee -a ${oneinstack_dir}/install.log
  949. ;;
  950. 9)
  951. [ "${Family}" == 'rhel' ] && [ "${RHEL_ver}" == '8' ] && dbinstallmethod=2 && checkDownload
  952. . include/percona-8.0.sh
  953. Install_Percona80 2>&1 | tee -a ${oneinstack_dir}/install.log
  954. ;;
  955. 10)
  956. . include/percona-5.7.sh
  957. Install_Percona57 2>&1 | tee -a ${oneinstack_dir}/install.log
  958. ;;
  959. 11)
  960. . include/percona-5.6.sh
  961. Install_Percona56 2>&1 | tee -a ${oneinstack_dir}/install.log
  962. ;;
  963. 12)
  964. . include/percona-5.5.sh
  965. Install_Percona55 2>&1 | tee -a ${oneinstack_dir}/install.log
  966. ;;
  967. 13)
  968. . include/postgresql.sh
  969. Install_PostgreSQL 2>&1 | tee -a ${oneinstack_dir}/install.log
  970. ;;
  971. 14)
  972. . include/mongodb.sh
  973. Install_MongoDB 2>&1 | tee -a ${oneinstack_dir}/install.log
  974. ;;
  975. esac
  976. # Nginx server
  977. case "${nginx_option}" in
  978. 1)
  979. . include/nginx.sh
  980. Install_Nginx 2>&1 | tee -a ${oneinstack_dir}/install.log
  981. ;;
  982. 2)
  983. . include/tengine.sh
  984. Install_Tengine 2>&1 | tee -a ${oneinstack_dir}/install.log
  985. ;;
  986. 3)
  987. . include/openresty.sh
  988. Install_OpenResty 2>&1 | tee -a ${oneinstack_dir}/install.log
  989. ;;
  990. 4)
  991. . include/caddy.sh
  992. Install_Caddy 2>&1 | tee -a ${oneinstack_dir}/install.log
  993. caddy_flag='y'
  994. ;;
  995. esac
  996. # Apache
  997. if [ "${apache_flag}" == 'y' ]; then
  998. apache_mode_option=${apache_mode_option:-1}
  999. apache_mpm_option=${apache_mpm_option:-1}
  1000. . include/apache.sh
  1001. Install_Apache 2>&1 | tee -a ${oneinstack_dir}/install.log
  1002. fi
  1003. # PHP
  1004. case "${php_option}" in
  1005. 1)
  1006. . include/php-5.3.sh
  1007. Install_PHP53 2>&1 | tee -a ${oneinstack_dir}/install.log
  1008. ;;
  1009. 2)
  1010. . include/php-5.4.sh
  1011. Install_PHP54 2>&1 | tee -a ${oneinstack_dir}/install.log
  1012. ;;
  1013. 3)
  1014. . include/php-5.5.sh
  1015. Install_PHP55 2>&1 | tee -a ${oneinstack_dir}/install.log
  1016. ;;
  1017. 4)
  1018. . include/php-5.6.sh
  1019. Install_PHP56 2>&1 | tee -a ${oneinstack_dir}/install.log
  1020. ;;
  1021. 5)
  1022. . include/php-7.0.sh
  1023. Install_PHP70 2>&1 | tee -a ${oneinstack_dir}/install.log
  1024. ;;
  1025. 6)
  1026. . include/php-7.1.sh
  1027. Install_PHP71 2>&1 | tee -a ${oneinstack_dir}/install.log
  1028. ;;
  1029. 7)
  1030. . include/php-7.2.sh
  1031. Install_PHP72 2>&1 | tee -a ${oneinstack_dir}/install.log
  1032. ;;
  1033. 8)
  1034. . include/php-7.3.sh
  1035. Install_PHP73 2>&1 | tee -a ${oneinstack_dir}/install.log
  1036. ;;
  1037. 9)
  1038. . include/php-7.4.sh
  1039. Install_PHP74 2>&1 | tee -a ${oneinstack_dir}/install.log
  1040. ;;
  1041. 10)
  1042. . include/php-8.0.sh
  1043. Install_PHP80 2>&1 | tee -a ${oneinstack_dir}/install.log
  1044. ;;
  1045. 11)
  1046. . include/php-8.1.sh
  1047. Install_PHP81 2>&1 | tee -a ${oneinstack_dir}/install.log
  1048. ;;
  1049. 12)
  1050. . include/php-8.2.sh
  1051. Install_PHP82 2>&1 | tee -a ${oneinstack_dir}/install.log
  1052. ;;
  1053. 13)
  1054. . include/php-8.3.sh
  1055. Install_PHP83 2>&1 | tee -a ${oneinstack_dir}/install.log
  1056. ;;
  1057. 14)
  1058. . include/php-8.4.sh
  1059. Install_PHP84 2>&1 | tee -a ${oneinstack_dir}/install.log
  1060. ;;
  1061. esac
  1062. PHP_addons() {
  1063. # PHP opcode cache
  1064. case "${phpcache_option}" in
  1065. 1)
  1066. . include/zendopcache.sh
  1067. Install_ZendOPcache 2>&1 | tee -a ${oneinstack_dir}/install.log
  1068. ;;
  1069. 2)
  1070. . include/apcu.sh
  1071. Install_APCU 2>&1 | tee -a ${oneinstack_dir}/install.log
  1072. ;;
  1073. 3)
  1074. . include/xcache.sh
  1075. Install_XCache 2>&1 | tee -a ${oneinstack_dir}/install.log
  1076. ;;
  1077. 4)
  1078. . include/eaccelerator.sh
  1079. Install_eAccelerator 2>&1 | tee -a ${oneinstack_dir}/install.log
  1080. ;;
  1081. esac
  1082. # ZendGuardLoader
  1083. if [ "${pecl_zendguardloader}" == '1' ]; then
  1084. . include/ZendGuardLoader.sh
  1085. Install_ZendGuardLoader 2>&1 | tee -a ${oneinstack_dir}/install.log
  1086. fi
  1087. # ioncube
  1088. if [ "${pecl_ioncube}" == '1' ]; then
  1089. . include/ioncube.sh
  1090. Install_ionCube 2>&1 | tee -a ${oneinstack_dir}/install.log
  1091. fi
  1092. # SourceGuardian
  1093. if [ "${pecl_sourceguardian}" == '1' ]; then
  1094. . include/sourceguardian.sh
  1095. Install_SourceGuardian 2>&1 | tee -a ${oneinstack_dir}/install.log
  1096. fi
  1097. # imagick
  1098. if [ "${pecl_imagick}" == '1' ]; then
  1099. . include/ImageMagick.sh
  1100. Install_ImageMagick 2>&1 | tee -a ${oneinstack_dir}/install.log
  1101. Install_pecl_imagick 2>&1 | tee -a ${oneinstack_dir}/install.log
  1102. fi
  1103. # gmagick
  1104. if [ "${pecl_gmagick}" == '1' ]; then
  1105. . include/GraphicsMagick.sh
  1106. Install_GraphicsMagick 2>&1 | tee -a ${oneinstack_dir}/install.log
  1107. Install_pecl_gmagick 2>&1 | tee -a ${oneinstack_dir}/install.log
  1108. fi
  1109. # fileinfo
  1110. if [ "${pecl_fileinfo}" == '1' ]; then
  1111. . include/pecl_fileinfo.sh
  1112. Install_pecl_fileinfo 2>&1 | tee -a ${oneinstack_dir}/install.log
  1113. fi
  1114. # imap
  1115. if [ "${pecl_imap}" == '1' ]; then
  1116. . include/pecl_imap.sh
  1117. Install_pecl_imap 2>&1 | tee -a ${oneinstack_dir}/install.log
  1118. fi
  1119. # ldap
  1120. if [ "${pecl_ldap}" == '1' ]; then
  1121. . include/pecl_ldap.sh
  1122. Install_pecl_ldap 2>&1 | tee -a ${oneinstack_dir}/install.log
  1123. fi
  1124. # calendar
  1125. if [ "${pecl_calendar}" == '1' ]; then
  1126. . include/pecl_calendar.sh
  1127. Install_pecl_calendar 2>&1 | tee -a ${oneinstack_dir}/install.log
  1128. fi
  1129. # phalcon
  1130. if [ "${pecl_phalcon}" == '1' ]; then
  1131. . include/pecl_phalcon.sh
  1132. Install_pecl_phalcon 2>&1 | tee -a ${oneinstack_dir}/install.log
  1133. fi
  1134. # yaf
  1135. if [ "${pecl_yaf}" == '1' ]; then
  1136. . include/pecl_yaf.sh
  1137. Install_pecl_yaf 2>&1 | tee -a ${oneinstack_dir}/install.log
  1138. fi
  1139. # yar
  1140. if [ "${pecl_yar}" == '1' ]; then
  1141. . include/pecl_yar.sh
  1142. Install_pecl_yar 2>&1 | tee -a ${oneinstack_dir}/install.log
  1143. fi
  1144. # pecl_memcached
  1145. if [ "${pecl_memcached}" == '1' ]; then
  1146. . include/memcached.sh
  1147. Install_pecl_memcached 2>&1 | tee -a ${oneinstack_dir}/install.log
  1148. fi
  1149. # pecl_memcache
  1150. if [ "${pecl_memcache}" == '1' ]; then
  1151. . include/memcached.sh
  1152. Install_pecl_memcache 2>&1 | tee -a ${oneinstack_dir}/install.log
  1153. fi
  1154. # pecl_redis
  1155. if [ "${pecl_redis}" == '1' ]; then
  1156. . include/redis.sh
  1157. Install_pecl_redis 2>&1 | tee -a ${oneinstack_dir}/install.log
  1158. fi
  1159. # pecl_mongodb
  1160. if [ "${pecl_mongodb}" == '1' ]; then
  1161. . include/pecl_mongodb.sh
  1162. Install_pecl_mongodb 2>&1 | tee -a ${oneinstack_dir}/install.log
  1163. fi
  1164. # swoole
  1165. if [ "${pecl_swoole}" == '1' ]; then
  1166. . include/pecl_swoole.sh
  1167. Install_pecl_swoole 2>&1 | tee -a ${oneinstack_dir}/install.log
  1168. fi
  1169. # xdebug
  1170. if [ "${pecl_xdebug}" == '1' ]; then
  1171. . include/pecl_xdebug.sh
  1172. Install_pecl_xdebug 2>&1 | tee -a ${oneinstack_dir}/install.log
  1173. fi
  1174. # pecl_pgsql
  1175. if [ -e "${pgsql_install_dir}/bin/psql" ]; then
  1176. . include/pecl_pgsql.sh
  1177. Install_pecl_pgsql 2>&1 | tee -a ${oneinstack_dir}/install.log
  1178. fi
  1179. }
  1180. [ "${mphp_addons_flag}" != 'y' ] && PHP_addons
  1181. if [ "${mphp_flag}" == 'y' ]; then
  1182. . include/mphp.sh
  1183. Install_MPHP 2>&1 | tee -a ${oneinstack_dir}/install.log
  1184. php_install_dir=${php_install_dir}${mphp_ver}
  1185. PHP_addons
  1186. fi
  1187. # JDK
  1188. case "${jdk_option}" in
  1189. 1)
  1190. . include/openjdk-8.sh
  1191. Install_OpenJDK8 2>&1 | tee -a ${oneinstack_dir}/install.log
  1192. ;;
  1193. 2)
  1194. . include/openjdk-11.sh
  1195. Install_OpenJDK11 2>&1 | tee -a ${oneinstack_dir}/install.log
  1196. ;;
  1197. 3)
  1198. . include/openjdk-17.sh
  1199. Install_OpenJDK17 2>&1 | tee -a ${oneinstack_dir}/install.log
  1200. ;;
  1201. 4)
  1202. . include/openjdk-18.sh
  1203. Install_OpenJDK18 2>&1 | tee -a ${oneinstack_dir}/install.log
  1204. ;;
  1205. esac
  1206. case "${tomcat_option}" in
  1207. 1)
  1208. . include/tomcat-11.sh
  1209. Install_Tomcat11 2>&1 | tee -a ${oneinstack_dir}/install.log
  1210. ;;
  1211. 2)
  1212. . include/tomcat-10.sh
  1213. Install_Tomcat10 2>&1 | tee -a ${oneinstack_dir}/install.log
  1214. ;;
  1215. 3)
  1216. . include/tomcat-9.sh
  1217. Install_Tomcat9 2>&1 | tee -a ${oneinstack_dir}/install.log
  1218. ;;
  1219. 4)
  1220. . include/tomcat-8.sh
  1221. Install_Tomcat8 2>&1 | tee -a ${oneinstack_dir}/install.log
  1222. ;;
  1223. 5)
  1224. . include/tomcat-7.sh
  1225. Install_Tomcat7 2>&1 | tee -a ${oneinstack_dir}/install.log
  1226. ;;
  1227. 6)
  1228. . include/tomcat-6.sh
  1229. Install_Tomcat6 2>&1 | tee -a ${oneinstack_dir}/install.log
  1230. ;;
  1231. esac
  1232. # Nodejs
  1233. if [ "${nodejs_flag}" == 'y' ]; then
  1234. . include/nodejs.sh
  1235. Install_Nodejs 2>&1 | tee -a ${oneinstack_dir}/install.log
  1236. fi
  1237. # Pure-FTPd
  1238. if [ "${pureftpd_flag}" == 'y' ]; then
  1239. . include/pureftpd.sh
  1240. Install_PureFTPd 2>&1 | tee -a ${oneinstack_dir}/install.log
  1241. fi
  1242. # phpMyAdmin
  1243. if [ "${phpmyadmin_flag}" == 'y' ]; then
  1244. . include/phpmyadmin.sh
  1245. Install_phpMyAdmin 2>&1 | tee -a ${oneinstack_dir}/install.log
  1246. fi
  1247. # redis
  1248. if [ "${redis_flag}" == 'y' ]; then
  1249. . include/redis.sh
  1250. Install_redis_server 2>&1 | tee -a ${oneinstack_dir}/install.log
  1251. fi
  1252. # memcached
  1253. if [ "${memcached_flag}" == 'y' ]; then
  1254. . include/memcached.sh
  1255. Install_memcached_server 2>&1 | tee -a ${oneinstack_dir}/install.log
  1256. fi
  1257. # index example
  1258. if [ -d "${wwwroot_dir}/default" ]; then
  1259. . include/demo.sh
  1260. DEMO 2>&1 | tee -a ${oneinstack_dir}/install.log
  1261. fi
  1262. # get web_install_dir and db_install_dir
  1263. . include/check_dir.sh
  1264. # Starting DB
  1265. [ -d "/etc/mysql" ] && /bin/mv /etc/mysql{,_bk}
  1266. [ -d "${db_install_dir}/support-files" ] && [ -z "`ps -ef | grep mysqld_safe | grep -v grep`" ] && service mysqld start
  1267. # reload php
  1268. [ -e "${php_install_dir}/sbin/php-fpm" ] && { [ -e "/bin/systemctl" ] && systemctl reload php-fpm || service php-fpm reload; }
  1269. [ -n "${mphp_ver}" -a -e "${php_install_dir}${mphp_ver}/sbin/php-fpm" ] && { [ -e "/bin/systemctl" ] && systemctl reload php${mphp_ver}-fpm || service php${mphp_ver}-fpm reload; }
  1270. [ -e "${apache_install_dir}/bin/apachectl" ] && ${apache_install_dir}/bin/apachectl -k graceful
  1271. endTime=`date +%s`
  1272. ((installTime=($endTime-$startTime)/60))
  1273. echo "####################Congratulations########################"
  1274. echo "Total OneinStack Install Time: ${CQUESTION}${installTime}${CEND} minutes"
  1275. [[ "${nginx_option}" =~ ^[1-3]$ ]] && echo -e "\n$(printf "%-32s" "Nginx install dir":)${CMSG}${web_install_dir}${CEND}"
  1276. [ "${apache_flag}" == 'y' ] && echo -e "\n$(printf "%-32s" "Apache install dir":)${CMSG}${apache_install_dir}${CEND}"
  1277. [ "${caddy_flag}" == 'y' ] && echo -e "\n$(printf "%-32s" "Caddy install dir":)${CMSG}${caddy_install_dir}${CEND}"
  1278. [[ "${tomcat_option}" =~ ^[1-6]$ ]] && echo -e "\n$(printf "%-32s" "Tomcat install dir":)${CMSG}${tomcat_install_dir}${CEND}"
  1279. [[ "${db_option}" =~ ^[1-9]$|^1[0-2]$ ]] && echo -e "\n$(printf "%-32s" "Database install dir:")${CMSG}${db_install_dir}${CEND}"
  1280. [[ "${db_option}" =~ ^[1-9]$|^1[0-2]$ ]] && echo "$(printf "%-32s" "Database data dir:")${CMSG}${db_data_dir}${CEND}"
  1281. [[ "${db_option}" =~ ^[1-9]$|^1[0-2]$ ]] && echo "$(printf "%-32s" "Database user:")${CMSG}root${CEND}"
  1282. [[ "${db_option}" =~ ^[1-9]$|^1[0-2]$ ]] && echo "$(printf "%-32s" "Database password:")${CMSG}${dbrootpwd}${CEND}"
  1283. [ "${db_option}" == '13' ] && echo -e "\n$(printf "%-32s" "PostgreSQL install dir:")${CMSG}${pgsql_install_dir}${CEND}"
  1284. [ "${db_option}" == '13' ] && echo "$(printf "%-32s" "PostgreSQL data dir:")${CMSG}${pgsql_data_dir}${CEND}"
  1285. [ "${db_option}" == '13' ] && echo "$(printf "%-32s" "PostgreSQL user:")${CMSG}postgres${CEND}"
  1286. [ "${db_option}" == '13' ] && echo "$(printf "%-32s" "postgres password:")${CMSG}${dbpostgrespwd}${CEND}"
  1287. [ "${db_option}" == '14' ] && echo -e "\n$(printf "%-32s" "MongoDB install dir:")${CMSG}${mongo_install_dir}${CEND}"
  1288. [ "${db_option}" == '14' ] && echo "$(printf "%-32s" "MongoDB data dir:")${CMSG}${mongo_data_dir}${CEND}"
  1289. [ "${db_option}" == '14' ] && echo "$(printf "%-32s" "MongoDB user:")${CMSG}root${CEND}"
  1290. [ "${db_option}" == '14' ] && echo "$(printf "%-32s" "MongoDB password:")${CMSG}${dbmongopwd}${CEND}"
  1291. [[ "${php_option}" =~ ^[1-9]$|^1[0-2]$ ]] && echo -e "\n$(printf "%-32s" "PHP install dir:")${CMSG}${php_install_dir}${CEND}"
  1292. [ "${phpcache_option}" == '1' ] && echo "$(printf "%-32s" "Opcache Control Panel URL:")${CMSG}http://${IPADDR}/ocp.php${CEND}"
  1293. [ "${phpcache_option}" == '2' ] && echo "$(printf "%-32s" "APC Control Panel URL:")${CMSG}http://${IPADDR}/apc.php${CEND}"
  1294. [ "${phpcache_option}" == '3' -a -e "${php_install_dir}/etc/php.d/04-xcache.ini" ] && echo "$(printf "%-32s" "xcache Control Panel URL:")${CMSG}http://${IPADDR}/xcache${CEND}"
  1295. [ "${phpcache_option}" == '3' -a -e "${php_install_dir}/etc/php.d/04-xcache.ini" ] && echo "$(printf "%-32s" "xcache user:")${CMSG}admin${CEND}"
  1296. [ "${phpcache_option}" == '3' -a -e "${php_install_dir}/etc/php.d/04-xcache.ini" ] && echo "$(printf "%-32s" "xcache password:")${CMSG}${xcachepwd}${CEND}"
  1297. [ "${phpcache_option}" == '4' -a -e "${php_install_dir}/etc/php.d/02-eaccelerator.ini" ] && echo "$(printf "%-32s" "eAccelerator Control Panel URL:")${CMSG}http://${IPADDR}/control.php${CEND}"
  1298. [ "${phpcache_option}" == '4' -a -e "${php_install_dir}/etc/php.d/02-eaccelerator.ini" ] && echo "$(printf "%-32s" "eAccelerator user:")${CMSG}admin${CEND}"
  1299. [ "${phpcache_option}" == '4' -a -e "${php_install_dir}/etc/php.d/02-eaccelerator.ini" ] && echo "$(printf "%-32s" "eAccelerator password:")${CMSG}eAccelerator${CEND}"
  1300. [ "${pureftpd_flag}" == 'y' ] && echo -e "\n$(printf "%-32s" "Pure-FTPd install dir:")${CMSG}${pureftpd_install_dir}${CEND}"
  1301. [ "${pureftpd_flag}" == 'y' ] && echo "$(printf "%-32s" "Create FTP virtual script:")${CMSG}./pureftpd_vhost.sh${CEND}"
  1302. [ "${phpmyadmin_flag}" == 'y' ] && echo -e "\n$(printf "%-32s" "phpMyAdmin dir:")${CMSG}${wwwroot_dir}/default/phpMyAdmin${CEND}"
  1303. [ "${phpmyadmin_flag}" == 'y' ] && echo "$(printf "%-32s" "phpMyAdmin Control Panel URL:")${CMSG}http://${IPADDR}/phpMyAdmin${CEND}"
  1304. [ "${redis_flag}" == 'y' ] && echo -e "\n$(printf "%-32s" "redis install dir:")${CMSG}${redis_install_dir}${CEND}"
  1305. [ "${memcached_flag}" == 'y' ] && echo -e "\n$(printf "%-32s" "memcached install dir:")${CMSG}${memcached_install_dir}${CEND}"
  1306. if [[ ${nginx_option} =~ ^[1-4]$ ]] || [ "${apache_flag}" == 'y' ] || [[ ${tomcat_option} =~ ^[1-6]$ ]]; then
  1307. echo -e "\n$(printf "%-32s" "Index URL:")${CMSG}http://${IPADDR}/${CEND}"
  1308. fi
  1309. if [ ${ARG_NUM} == 0 ]; then
  1310. while :; do echo
  1311. echo "${CMSG}Please restart the server and see if the services start up fine.${CEND}"
  1312. read -e -p "Do you want to restart OS ? [y/n]: " reboot_flag
  1313. if [[ ! "${reboot_flag}" =~ ^[y,n]$ ]]; then
  1314. echo "${CWARNING}input error! Please only input 'y' or 'n'${CEND}"
  1315. else
  1316. break
  1317. fi
  1318. done
  1319. fi
  1320. [ "${reboot_flag}" == 'y' ] && reboot