1
0

install.sh 42 KB

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