1
0

install.sh 49 KB

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