install.sh 32 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825
  1. #!/bin/bash
  2. # Author: yeho <lj2007331 AT gmail.com>
  3. # BLOG: https://blog.linuxeye.com
  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=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/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. # get pwd
  19. sed -i "s@^oneinstack_dir.*@oneinstack_dir=`pwd`@" ./options.conf
  20. . ./versions.txt
  21. . ./options.conf
  22. . ./include/color.sh
  23. . ./include/check_os.sh
  24. . ./include/check_dir.sh
  25. . ./include/download.sh
  26. . ./include/get_char.sh
  27. # Check if user is root
  28. [ $(id -u) != "0" ] && { echo "${CFAILURE}Error: You must be root to run this script${CEND}"; exit 1; }
  29. mkdir -p $wwwroot_dir/default $wwwlogs_dir
  30. [ -d /data ] && chmod 755 /data
  31. # Use default SSH port 22. If you use another SSH port on your server
  32. if [ -e "/etc/ssh/sshd_config" ]; then
  33. [ -z "`grep ^Port /etc/ssh/sshd_config`" ] && ssh_port=22 || ssh_port=`grep ^Port /etc/ssh/sshd_config | awk '{print $2}'`
  34. while :; do echo
  35. read -p "Please input SSH port(Default: $ssh_port): " SSH_PORT
  36. [ -z "$SSH_PORT" ] && SSH_PORT=$ssh_port
  37. 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
  38. break
  39. else
  40. echo "${CWARNING}input error! Input range: 22,1025~65534${CEND}"
  41. fi
  42. done
  43. if [ -z "`grep ^Port /etc/ssh/sshd_config`" -a "$SSH_PORT" != '22' ]; then
  44. sed -i "s@^#Port.*@&\nPort $SSH_PORT@" /etc/ssh/sshd_config
  45. elif [ -n "`grep ^Port /etc/ssh/sshd_config`" ]; then
  46. sed -i "s@^Port.*@Port $SSH_PORT@" /etc/ssh/sshd_config
  47. fi
  48. fi
  49. # check iptables
  50. while :; do echo
  51. read -p "Do you want to enable iptables? [y/n]: " iptables_yn
  52. if [[ ! $iptables_yn =~ ^[y,n]$ ]]; then
  53. echo "${CWARNING}input error! Please only input 'y' or 'n'${CEND}"
  54. else
  55. break
  56. fi
  57. done
  58. # check Web server
  59. while :; do echo
  60. read -p "Do you want to install Web server? [y/n]: " Web_yn
  61. if [[ ! $Web_yn =~ ^[y,n]$ ]]; then
  62. echo "${CWARNING}input error! Please only input 'y' or 'n'${CEND}"
  63. else
  64. if [ "$Web_yn" == 'y' ]; then
  65. # Nginx/Tegine/OpenResty
  66. while :; do echo
  67. echo 'Please select Nginx server:'
  68. echo -e "\t${CMSG}1${CEND}. Install Nginx"
  69. echo -e "\t${CMSG}2${CEND}. Install Tengine"
  70. echo -e "\t${CMSG}3${CEND}. Install OpenResty"
  71. echo -e "\t${CMSG}4${CEND}. Do not install"
  72. read -p "Please input a number:(Default 1 press Enter) " Nginx_version
  73. [ -z "$Nginx_version" ] && Nginx_version=1
  74. if [[ ! $Nginx_version =~ ^[1-4]$ ]]; then
  75. echo "${CWARNING}input error! Please only input number 1~4${CEND}"
  76. else
  77. [ "$Nginx_version" != '4' -a -e "$nginx_install_dir/sbin/nginx" ] && { echo "${CWARNING}Nginx already installed! ${CEND}"; Nginx_version=Other; }
  78. [ "$Nginx_version" != '4' -a -e "$tengine_install_dir/sbin/nginx" ] && { echo "${CWARNING}Tengine already installed! ${CEND}"; Nginx_version=Other; }
  79. [ "$Nginx_version" != '4' -a -e "$openresty_install_dir/nginx/sbin/nginx" ] && { echo "${CWARNING}OpenResty already installed! ${CEND}"; Nginx_version=Other; }
  80. break
  81. fi
  82. done
  83. # Apache
  84. while :; do echo
  85. echo 'Please select Apache server:'
  86. echo -e "\t${CMSG}1${CEND}. Install Apache-2.4"
  87. echo -e "\t${CMSG}2${CEND}. Install Apache-2.2"
  88. echo -e "\t${CMSG}3${CEND}. Do not install"
  89. read -p "Please input a number:(Default 3 press Enter) " Apache_version
  90. [ -z "$Apache_version" ] && Apache_version=3
  91. if [[ ! $Apache_version =~ ^[1-3]$ ]]; then
  92. echo "${CWARNING}input error! Please only input number 1~3${CEND}"
  93. else
  94. [ "$Apache_version" != '3' -a -e "$apache_install_dir/conf/httpd.conf" ] && { echo "${CWARNING}Aapche already installed! ${CEND}"; Apache_version=Other; }
  95. break
  96. fi
  97. done
  98. # Tomcat
  99. while :; do echo
  100. echo 'Please select tomcat server:'
  101. echo -e "\t${CMSG}1${CEND}. Install Tomcat-8"
  102. echo -e "\t${CMSG}2${CEND}. Install Tomcat-7"
  103. echo -e "\t${CMSG}3${CEND}. Install Tomcat-6"
  104. echo -e "\t${CMSG}4${CEND}. Do not install"
  105. read -p "Please input a number:(Default 4 press Enter) " Tomcat_version
  106. [ -z "$Tomcat_version" ] && Tomcat_version=4
  107. if [[ ! $Tomcat_version =~ ^[1-4]$ ]]; then
  108. echo "${CWARNING}input error! Please only input number 1~4${CEND}"
  109. else
  110. [ "$Tomcat_version" != '4' -a -e "$tomcat_install_dir/conf/server.xml" ] && { echo "${CWARNING}Tomcat already installed! ${CEND}" ; Tomcat_version=Other; }
  111. if [ "$Tomcat_version" == '1' ]; then
  112. while :; do echo
  113. echo 'Please select JDK version:'
  114. echo -e "\t${CMSG}1${CEND}. Install JDK-1.8"
  115. echo -e "\t${CMSG}2${CEND}. Install JDK-1.7"
  116. read -p "Please input a number:(Default 2 press Enter) " JDK_version
  117. [ -z "$JDK_version" ] && JDK_version=2
  118. if [[ ! $JDK_version =~ ^[1-2]$ ]]; then
  119. echo "${CWARNING}input error! Please only input number 1~2${CEND}"
  120. else
  121. break
  122. fi
  123. done
  124. elif [ "$Tomcat_version" == '2' ]; then
  125. while :; do echo
  126. echo 'Please select JDK version:'
  127. echo -e "\t${CMSG}1${CEND}. Install JDK-1.8"
  128. echo -e "\t${CMSG}2${CEND}. Install JDK-1.7"
  129. echo -e "\t${CMSG}3${CEND}. Install JDK-1.6"
  130. read -p "Please input a number:(Default 2 press Enter) " JDK_version
  131. [ -z "$JDK_version" ] && JDK_version=2
  132. if [[ ! $JDK_version =~ ^[1-3]$ ]]; then
  133. echo "${CWARNING}input error! Please only input number 1~3${CEND}"
  134. else
  135. break
  136. fi
  137. done
  138. elif [ "$Tomcat_version" == '3' ]; then
  139. while :; do echo
  140. echo 'Please select JDK version:'
  141. echo -e "\t${CMSG}2${CEND}. Install JDK-1.7"
  142. echo -e "\t${CMSG}3${CEND}. Install JDK-1.6"
  143. read -p "Please input a number:(Default 2 press Enter) " JDK_version
  144. [ -z "$JDK_version" ] && JDK_version=2
  145. if [[ ! $JDK_version =~ ^[2-3]$ ]]; then
  146. echo "${CWARNING}input error! Please only input number 2~3${CEND}"
  147. else
  148. break
  149. fi
  150. done
  151. fi
  152. break
  153. fi
  154. done
  155. fi
  156. break
  157. fi
  158. done
  159. # choice database
  160. while :; do echo
  161. read -p "Do you want to install Database? [y/n]: " DB_yn
  162. if [[ ! $DB_yn =~ ^[y,n]$ ]]; then
  163. echo "${CWARNING}input error! Please only input 'y' or 'n'${CEND}"
  164. else
  165. if [ "$DB_yn" == 'y' ]; then
  166. [ -d "$db_install_dir/support-files" -a -e "${pgsql_install_dir}/bin/psql" ] && { echo "${CWARNING}Database already installed! ${CEND}"; DB_yn=Other; break; }
  167. while :; do echo
  168. echo 'Please select a version of the Database:'
  169. echo -e "\t${CMSG} 1${CEND}. Install MySQL-5.7"
  170. echo -e "\t${CMSG} 2${CEND}. Install MySQL-5.6"
  171. echo -e "\t${CMSG} 3${CEND}. Install MySQL-5.5"
  172. echo -e "\t${CMSG} 4${CEND}. Install MariaDB-10.2"
  173. echo -e "\t${CMSG} 5${CEND}. Install MariaDB-10.1"
  174. echo -e "\t${CMSG} 6${CEND}. Install MariaDB-10.0"
  175. echo -e "\t${CMSG} 7${CEND}. Install MariaDB-5.5"
  176. echo -e "\t${CMSG} 8${CEND}. Install Percona-5.7"
  177. echo -e "\t${CMSG} 9${CEND}. Install Percona-5.6"
  178. echo -e "\t${CMSG}10${CEND}. Install Percona-5.5"
  179. echo -e "\t${CMSG}11${CEND}. Install AliSQL-5.6"
  180. echo -e "\t${CMSG}12${CEND}. Install PostgreSQL"
  181. read -p "Please input a number:(Default 2 press Enter) " DB_version
  182. [ -z "$DB_version" ] && DB_version=2
  183. if [[ "${DB_version}" =~ ^[1-9]$|^1[0-2]$ ]]; then
  184. while :; do
  185. if [ "$DB_version" == '12' ]; then
  186. read -p "Please input the postgres password of database: " dbrootpwd
  187. else
  188. read -p "Please input the root password of database: " dbrootpwd
  189. fi
  190. [ -n "`echo $dbrootpwd | grep '[+|&]'`" ] && { echo "${CWARNING}input error,not contain a plus sign (+) and & ${CEND}"; continue; }
  191. if (( ${#dbrootpwd} >= 5 )); then
  192. [ "$DB_version" == '12' ] && { sed -i "s+^dbpostgrespwd.*+dbpostgrespwd='$dbrootpwd'+" ./options.conf; dbpostgrespwd="$dbrootpwd"; } || sed -i "s+^dbrootpwd.*+dbrootpwd='$dbrootpwd'+" ./options.conf
  193. break
  194. else
  195. echo "${CWARNING}password least 5 characters! ${CEND}"
  196. fi
  197. done
  198. # choose install methods
  199. if [[ "${DB_version}" =~ ^[1-9]$|^10$ ]]; then
  200. while :; do echo
  201. echo "Please choose installation of the database:"
  202. echo -e "\t${CMSG}1${CEND}. Install database from binary package."
  203. echo -e "\t${CMSG}2${CEND}. Install database from source package."
  204. read -p "Please input a number:(Default 1 press Enter) " dbInstallMethods
  205. [ -z "$dbInstallMethods" ] && dbInstallMethods=1
  206. if [[ ! $dbInstallMethods =~ ^[1-2]$ ]]; then
  207. echo "${CWARNING}input error! Please only input number 1~2${CEND}"
  208. else
  209. break
  210. fi
  211. done
  212. fi
  213. break
  214. else
  215. echo "${CWARNING}input error! Please only input number 1~12${CEND}"
  216. fi
  217. done
  218. fi
  219. break
  220. fi
  221. done
  222. # check PHP
  223. while :; do echo
  224. read -p "Do you want to install PHP? [y/n]: " PHP_yn
  225. if [[ ! $PHP_yn =~ ^[y,n]$ ]]; then
  226. echo "${CWARNING}input error! Please only input 'y' or 'n'${CEND}"
  227. else
  228. if [ "$PHP_yn" == 'y' ]; then
  229. [ -e "$php_install_dir/bin/phpize" ] && { echo "${CWARNING}PHP already installed! ${CEND}"; PHP_yn=Other; break; }
  230. while :; do echo
  231. echo 'Please select a version of the PHP:'
  232. echo -e "\t${CMSG}1${CEND}. Install php-5.3"
  233. echo -e "\t${CMSG}2${CEND}. Install php-5.4"
  234. echo -e "\t${CMSG}3${CEND}. Install php-5.5"
  235. echo -e "\t${CMSG}4${CEND}. Install php-5.6"
  236. echo -e "\t${CMSG}5${CEND}. Install php-7.0"
  237. echo -e "\t${CMSG}6${CEND}. Install php-7.1"
  238. echo -e "\t${CMSG}7${CEND}. Install php-7.2"
  239. read -p "Please input a number:(Default 5 press Enter) " PHP_version
  240. [ -z "$PHP_version" ] && PHP_version=5
  241. if [[ ! $PHP_version =~ ^[1-7]$ ]]; then
  242. echo "${CWARNING}input error! Please only input number 1~7${CEND}"
  243. else
  244. while :; do echo
  245. read -p "Do you want to install opcode cache of the PHP? [y/n]: " PHP_cache_yn
  246. if [[ ! $PHP_cache_yn =~ ^[y,n]$ ]]; then
  247. echo "${CWARNING}input error! Please only input 'y' or 'n'${CEND}"
  248. else
  249. if [ "$PHP_cache_yn" == 'y' ]; then
  250. if [ $PHP_version == 1 ]; then
  251. while :; do
  252. echo 'Please select a opcode cache of the PHP:'
  253. echo -e "\t${CMSG}1${CEND}. Install Zend OPcache"
  254. echo -e "\t${CMSG}2${CEND}. Install XCache"
  255. echo -e "\t${CMSG}3${CEND}. Install APCU"
  256. echo -e "\t${CMSG}4${CEND}. Install eAccelerator-0.9"
  257. read -p "Please input a number:(Default 1 press Enter) " PHP_cache
  258. [ -z "$PHP_cache" ] && PHP_cache=1
  259. if [[ ! $PHP_cache =~ ^[1-4]$ ]]; then
  260. echo "${CWARNING}input error! Please only input number 1~4${CEND}"
  261. else
  262. break
  263. fi
  264. done
  265. fi
  266. if [ $PHP_version == 2 ]; then
  267. while :; do
  268. echo 'Please select a opcode cache of the PHP:'
  269. echo -e "\t${CMSG}1${CEND}. Install Zend OPcache"
  270. echo -e "\t${CMSG}2${CEND}. Install XCache"
  271. echo -e "\t${CMSG}3${CEND}. Install APCU"
  272. echo -e "\t${CMSG}4${CEND}. Install eAccelerator-1.0-dev"
  273. read -p "Please input a number:(Default 1 press Enter) " PHP_cache
  274. [ -z "$PHP_cache" ] && PHP_cache=1
  275. if [[ ! $PHP_cache =~ ^[1-4]$ ]]; then
  276. echo "${CWARNING}input error! Please only input number 1~4${CEND}"
  277. else
  278. break
  279. fi
  280. done
  281. fi
  282. if [ $PHP_version == 3 ]; then
  283. while :; do
  284. echo 'Please select a opcode cache of the PHP:'
  285. echo -e "\t${CMSG}1${CEND}. Install Zend OPcache"
  286. echo -e "\t${CMSG}2${CEND}. Install XCache"
  287. echo -e "\t${CMSG}3${CEND}. Install APCU"
  288. read -p "Please input a number:(Default 1 press Enter) " PHP_cache
  289. [ -z "$PHP_cache" ] && PHP_cache=1
  290. if [[ ! $PHP_cache =~ ^[1-3]$ ]]; then
  291. echo "${CWARNING}input error! Please only input number 1~3${CEND}"
  292. else
  293. break
  294. fi
  295. done
  296. fi
  297. if [ $PHP_version == 4 ]; then
  298. while :; do
  299. echo 'Please select a opcode cache of the PHP:'
  300. echo -e "\t${CMSG}1${CEND}. Install Zend OPcache"
  301. echo -e "\t${CMSG}2${CEND}. Install XCache"
  302. echo -e "\t${CMSG}3${CEND}. Install APCU"
  303. read -p "Please input a number:(Default 1 press Enter) " PHP_cache
  304. [ -z "$PHP_cache" ] && PHP_cache=1
  305. if [[ ! $PHP_cache =~ ^[1-3]$ ]]; then
  306. echo "${CWARNING}input error! Please only input number 1~3${CEND}"
  307. else
  308. break
  309. fi
  310. done
  311. fi
  312. if [[ $PHP_version =~ ^[5-6]$ ]]; then
  313. while :; do
  314. echo 'Please select a opcode cache of the PHP:'
  315. echo -e "\t${CMSG}1${CEND}. Install Zend OPcache"
  316. echo -e "\t${CMSG}3${CEND}. Install APCU"
  317. read -p "Please input a number:(Default 1 press Enter) " PHP_cache
  318. [ -z "$PHP_cache" ] && PHP_cache=1
  319. if [[ ! $PHP_cache =~ ^[1,3]$ ]]; then
  320. echo "${CWARNING}input error! Please only input number 1,3${CEND}"
  321. else
  322. break
  323. fi
  324. done
  325. fi
  326. [ $PHP_version == 7 ] && PHP_cache=1
  327. fi
  328. break
  329. fi
  330. done
  331. if [ "$PHP_cache" == '2' ]; then
  332. while :; do
  333. read -p "Please input xcache admin password: " xcache_admin_pass
  334. (( ${#xcache_admin_pass} >= 5 )) && { xcache_admin_md5_pass=`echo -n "$xcache_admin_pass" | md5sum | awk '{print $1}'` ; break ; } || echo "${CFAILURE}xcache admin password least 5 characters! ${CEND}"
  335. done
  336. fi
  337. if [[ $PHP_version =~ ^[1-4]$ ]] && [ "$PHP_cache" != '1' -a "${armPlatform}" != "y" ]; then
  338. while :; do echo
  339. read -p "Do you want to install ZendGuardLoader? [y/n]: " ZendGuardLoader_yn
  340. if [[ ! $ZendGuardLoader_yn =~ ^[y,n]$ ]]; then
  341. echo "${CWARNING}input error! Please only input 'y' or 'n'${CEND}"
  342. else
  343. break
  344. fi
  345. done
  346. fi
  347. # ionCube
  348. if [ "${TARGET_ARCH}" != "arm64" ] && [[ $PHP_version =~ ^[1-6]$ ]]; then
  349. while :; do echo
  350. read -p "Do you want to install ionCube? [y/n]: " ionCube_yn
  351. if [[ ! $ionCube_yn =~ ^[y,n]$ ]]; then
  352. echo "${CWARNING}input error! Please only input 'y' or 'n'${CEND}"
  353. else
  354. break
  355. fi
  356. done
  357. fi
  358. # ImageMagick or GraphicsMagick
  359. while :; do echo
  360. read -p "Do you want to install ImageMagick or GraphicsMagick? [y/n]: " Magick_yn
  361. if [[ ! $Magick_yn =~ ^[y,n]$ ]]; then
  362. echo "${CWARNING}input error! Please only input 'y' or 'n'${CEND}"
  363. else
  364. break
  365. fi
  366. done
  367. if [ "$Magick_yn" == 'y' ]; then
  368. while :; do
  369. echo 'Please select ImageMagick or GraphicsMagick:'
  370. echo -e "\t${CMSG}1${CEND}. Install ImageMagick"
  371. echo -e "\t${CMSG}2${CEND}. Install GraphicsMagick"
  372. read -p "Please input a number:(Default 1 press Enter) " Magick
  373. [ -z "$Magick" ] && Magick=1
  374. if [[ ! $Magick =~ ^[1-2]$ ]]; then
  375. echo "${CWARNING}input error! Please only input number 1~2${CEND}"
  376. else
  377. break
  378. fi
  379. done
  380. fi
  381. break
  382. fi
  383. done
  384. fi
  385. break
  386. fi
  387. done
  388. # check Pureftpd
  389. while :; do echo
  390. read -p "Do you want to install Pure-FTPd? [y/n]: " FTP_yn
  391. if [[ ! $FTP_yn =~ ^[y,n]$ ]]; then
  392. echo "${CWARNING}input error! Please only input 'y' or 'n'${CEND}"
  393. else
  394. [ "$FTP_yn" == 'y' -a -e "$pureftpd_install_dir/sbin/pure-ftpwho" ] && { echo "${CWARNING}Pure-FTPd already installed! ${CEND}"; FTP_yn=Other; }
  395. break
  396. fi
  397. done
  398. # check phpMyAdmin
  399. if [[ $PHP_version =~ ^[1-7]$ ]] || [ -e "$php_install_dir/bin/phpize" ]; then
  400. while :; do echo
  401. read -p "Do you want to install phpMyAdmin? [y/n]: " phpMyAdmin_yn
  402. if [[ ! $phpMyAdmin_yn =~ ^[y,n]$ ]]; then
  403. echo "${CWARNING}input error! Please only input 'y' or 'n'${CEND}"
  404. else
  405. [ "$phpMyAdmin_yn" == 'y' -a -d "$wwwroot_dir/default/phpMyAdmin" ] && { echo "${CWARNING}phpMyAdmin already installed! ${CEND}"; phpMyAdmin_yn=Other; }
  406. break
  407. fi
  408. done
  409. fi
  410. # check redis
  411. while :; do echo
  412. read -p "Do you want to install redis? [y/n]: " redis_yn
  413. if [[ ! $redis_yn =~ ^[y,n]$ ]]; then
  414. echo "${CWARNING}input error! Please only input 'y' or 'n'${CEND}"
  415. else
  416. break
  417. fi
  418. done
  419. # check memcached
  420. while :; do echo
  421. read -p "Do you want to install memcached? [y/n]: " memcached_yn
  422. if [[ ! $memcached_yn =~ ^[y,n]$ ]]; then
  423. echo "${CWARNING}input error! Please only input 'y' or 'n'${CEND}"
  424. else
  425. break
  426. fi
  427. done
  428. while :; do echo
  429. read -p "Do you want to install HHVM? [y/n]: " HHVM_yn
  430. if [[ ! $HHVM_yn =~ ^[y,n]$ ]]; then
  431. echo "${CWARNING}input error! Please only input 'y' or 'n'${CEND}"
  432. else
  433. if [ "$HHVM_yn" == 'y' ]; then
  434. [ -e "/usr/bin/hhvm" ] && { echo "${CWARNING}HHVM already installed! ${CEND}"; HHVM_yn=Other; break; }
  435. if [ "$OS" == 'CentOS' -a "$OS_BIT" == '64' ] && [ -n "`grep -E ' 7\.| 6\.[5-9]' /etc/redhat-release`" ]; then
  436. break
  437. else
  438. echo
  439. echo "${CWARNING}HHVM only support CentOS6.5+ 64bit, CentOS7 64bit! ${CEND}"
  440. echo "Press Ctrl+c to cancel or Press any key to continue..."
  441. char=`get_char`
  442. HHVM_yn=Other
  443. fi
  444. fi
  445. break
  446. fi
  447. done
  448. # get the IP information
  449. IPADDR=`./include/get_ipaddr.py`
  450. PUBLIC_IPADDR=`./include/get_public_ipaddr.py`
  451. IPADDR_COUNTRY_ISP=`./include/get_ipaddr_state.py $PUBLIC_IPADDR`
  452. IPADDR_COUNTRY=`echo $IPADDR_COUNTRY_ISP | awk '{print $1}'`
  453. [ "`echo $IPADDR_COUNTRY_ISP | awk '{print $2}'`"x == '1000323'x ] && IPADDR_ISP=aliyun
  454. # del openssl for jcloud
  455. [ -e "/usr/local/bin/openssl" ] && rm -rf /usr/local/bin/openssl
  456. [ -e "/usr/local/include/openssl" ] && rm -rf /usr/local/include/openssl
  457. # Check binary dependencies packages
  458. . ./include/check_sw.sh
  459. case "${OS}" in
  460. "CentOS")
  461. installDepsCentOS 2>&1 | tee ${oneinstack_dir}/install.log
  462. ;;
  463. "Debian")
  464. installDepsDebian 2>&1 | tee ${oneinstack_dir}/install.log
  465. ;;
  466. "Ubuntu")
  467. installDepsUbuntu 2>&1 | tee ${oneinstack_dir}/install.log
  468. ;;
  469. esac
  470. # init
  471. startTime=`date +%s`
  472. . ./include/memory.sh
  473. case "${OS}" in
  474. "CentOS")
  475. . include/init_CentOS.sh 2>&1 | tee -a ${oneinstack_dir}/install.log
  476. [ -n "$(gcc --version | head -n1 | grep '4\.1\.')" ] && export CC="gcc44" CXX="g++44"
  477. ;;
  478. "Debian")
  479. . include/init_Debian.sh 2>&1 | tee -a ${oneinstack_dir}/install.log
  480. ;;
  481. "Ubuntu")
  482. . include/init_Ubuntu.sh 2>&1 | tee -a ${oneinstack_dir}/install.log
  483. ;;
  484. esac
  485. # Check download source packages
  486. . ./include/check_download.sh
  487. downloadDepsSrc=1
  488. checkDownload 2>&1 | tee -a ${oneinstack_dir}/install.log
  489. # Install dependencies from source package
  490. installDepsBySrc 2>&1 | tee -a ${oneinstack_dir}/install.log
  491. # Jemalloc
  492. if [[ $Nginx_version =~ ^[1-3]$ ]] || [ "$DB_yn" == 'y' ]; then
  493. . include/jemalloc.sh
  494. Install_Jemalloc | tee -a $oneinstack_dir/install.log
  495. fi
  496. # openSSL
  497. . ./include/openssl.sh
  498. if [[ $Tomcat_version =~ ^[1-3]$ ]] || [[ $Apache_version =~ ^[1-2]$ ]] || [[ $PHP_version =~ ^[1-7]$ ]]; then
  499. Install_openSSL102 | tee -a $oneinstack_dir/install.log
  500. fi
  501. # Database
  502. case "${DB_version}" in
  503. 1)
  504. if [ "${dbInstallMethods}" == "2" ]; then
  505. . include/boost.sh
  506. installBoost 2>&1 | tee -a ${oneinstack_dir}/install.log
  507. fi
  508. . include/mysql-5.7.sh
  509. Install_MySQL57 2>&1 | tee -a ${oneinstack_dir}/install.log
  510. ;;
  511. 2)
  512. . include/mysql-5.6.sh
  513. Install_MySQL56 2>&1 | tee -a ${oneinstack_dir}/install.log
  514. ;;
  515. 3)
  516. . include/mysql-5.5.sh
  517. Install_MySQL55 2>&1 | tee -a ${oneinstack_dir}/install.log
  518. ;;
  519. 4)
  520. if [ "${dbInstallMethods}" == "2" ]; then
  521. . include/boost.sh
  522. installBoost 2>&1 | tee -a ${oneinstack_dir}/install.log
  523. fi
  524. . include/mariadb-10.2.sh
  525. Install_MariaDB102 2>&1 | tee -a ${oneinstack_dir}/install.log
  526. ;;
  527. 5)
  528. if [ "${dbInstallMethods}" == "2" ]; then
  529. . include/boost.sh
  530. installBoost 2>&1 | tee -a ${oneinstack_dir}/install.log
  531. fi
  532. . include/mariadb-10.1.sh
  533. Install_MariaDB101 2>&1 | tee -a ${oneinstack_dir}/install.log
  534. ;;
  535. 6)
  536. . include/mariadb-10.0.sh
  537. Install_MariaDB100 2>&1 | tee -a ${oneinstack_dir}/install.log
  538. ;;
  539. 7)
  540. . include/mariadb-5.5.sh
  541. Install_MariaDB55 2>&1 | tee -a ${oneinstack_dir}/install.log
  542. ;;
  543. 8)
  544. if [ "${dbInstallMethods}" == "2" ]; then
  545. . include/boost.sh
  546. installBoost 2>&1 | tee -a ${oneinstack_dir}/install.log
  547. fi
  548. . include/percona-5.7.sh
  549. Install_Percona57 2>&1 | tee -a ${oneinstack_dir}/install.log
  550. ;;
  551. 9)
  552. . include/percona-5.6.sh
  553. Install_Percona56 2>&1 | tee -a ${oneinstack_dir}/install.log
  554. ;;
  555. 10)
  556. . include/percona-5.5.sh
  557. Install_Percona55 2>&1 | tee -a ${oneinstack_dir}/install.log
  558. ;;
  559. 11)
  560. . include/alisql-5.6.sh
  561. Install_AliSQL56 2>&1 | tee -a $oneinstack_dir/install.log
  562. ;;
  563. 12)
  564. . include/postgresql.sh
  565. Install_PostgreSQL 2>&1 | tee -a $oneinstack_dir/install.log
  566. ;;
  567. esac
  568. # Apache
  569. if [ "$Apache_version" == '1' ]; then
  570. . include/apache-2.4.sh
  571. Install_Apache24 2>&1 | tee -a $oneinstack_dir/install.log
  572. elif [ "$Apache_version" == '2' ]; then
  573. . include/apache-2.2.sh
  574. Install_Apache22 2>&1 | tee -a $oneinstack_dir/install.log
  575. fi
  576. # PHP
  577. case "${PHP_version}" in
  578. 1)
  579. . include/php-5.3.sh
  580. Install_PHP53 2>&1 | tee -a ${oneinstack_dir}/install.log
  581. ;;
  582. 2)
  583. . include/php-5.4.sh
  584. Install_PHP54 2>&1 | tee -a ${oneinstack_dir}/install.log
  585. ;;
  586. 3)
  587. . include/php-5.5.sh
  588. Install_PHP55 2>&1 | tee -a ${oneinstack_dir}/install.log
  589. ;;
  590. 4)
  591. . include/php-5.6.sh
  592. Install_PHP56 2>&1 | tee -a ${oneinstack_dir}/install.log
  593. ;;
  594. 5)
  595. . include/php-7.0.sh
  596. Install_PHP70 2>&1 | tee -a ${oneinstack_dir}/install.log
  597. ;;
  598. 6)
  599. . include/php-7.1.sh
  600. Install_PHP71 2>&1 | tee -a ${oneinstack_dir}/install.log
  601. ;;
  602. 7)
  603. . include/php-7.2.sh
  604. Install_PHP72 2>&1 | tee -a ${oneinstack_dir}/install.log
  605. ;;
  606. esac
  607. # ImageMagick or GraphicsMagick
  608. if [ "$Magick" == '1' ]; then
  609. . include/ImageMagick.sh
  610. [ ! -d "/usr/local/imagemagick" ] && Install_ImageMagick 2>&1 | tee -a $oneinstack_dir/install.log
  611. [ ! -e "`$php_install_dir/bin/php-config --extension-dir`/imagick.so" ] && Install_php-imagick 2>&1 | tee -a $oneinstack_dir/install.log
  612. elif [ "$Magick" == '2' ]; then
  613. . include/GraphicsMagick.sh
  614. [ ! -d "/usr/local/graphicsmagick" ] && Install_GraphicsMagick 2>&1 | tee -a $oneinstack_dir/install.log
  615. [ ! -e "`$php_install_dir/bin/php-config --extension-dir`/gmagick.so" ] && Install_php-gmagick 2>&1 | tee -a $oneinstack_dir/install.log
  616. fi
  617. # ionCube
  618. if [ "$ionCube_yn" == 'y' ]; then
  619. . include/ioncube.sh
  620. Install_ionCube 2>&1 | tee -a $oneinstack_dir/install.log
  621. fi
  622. # PHP opcode cache
  623. case "${PHP_cache}" in
  624. 1)
  625. if [[ "${PHP_version}" =~ ^[1,2]$ ]]; then
  626. . include/zendopcache.sh
  627. Install_ZendOPcache 2>&1 | tee -a ${oneinstack_dir}/install.log
  628. fi
  629. ;;
  630. 2)
  631. . include/xcache.sh
  632. Install_XCache 2>&1 | tee -a ${oneinstack_dir}/install.log
  633. ;;
  634. 3)
  635. . include/apcu.sh
  636. Install_APCU 2>&1 | tee -a ${oneinstack_dir}/install.log
  637. ;;
  638. 4)
  639. if [[ "${PHP_version}" =~ ^[1,2]$ ]]; then
  640. . include/eaccelerator.sh
  641. Install_eAccelerator 2>&1 | tee -a ${oneinstack_dir}/install.log
  642. fi
  643. ;;
  644. esac
  645. # ZendGuardLoader (php <= 5.6)
  646. if [ "$ZendGuardLoader_yn" == 'y' ]; then
  647. . include/ZendGuardLoader.sh
  648. Install_ZendGuardLoader 2>&1 | tee -a $oneinstack_dir/install.log
  649. fi
  650. # pecl_pgsql
  651. if [ "$DB_version" == '12' ] && [ -e "${php_install_dir}/bin/phpize" ]; then
  652. . include/pecl_pgsql.sh
  653. Install_pecl-pgsql 2>&1 | tee -a $oneinstack_dir/install.log
  654. fi
  655. # Web server
  656. case "${Nginx_version}" in
  657. 1)
  658. . include/nginx.sh
  659. Install_Nginx 2>&1 | tee -a ${oneinstack_dir}/install.log
  660. ;;
  661. 2)
  662. . include/tengine.sh
  663. Install_Tengine 2>&1 | tee -a ${oneinstack_dir}/install.log
  664. ;;
  665. 3)
  666. . include/openresty.sh
  667. Install_OpenResty 2>&1 | tee -a ${oneinstack_dir}/install.log
  668. ;;
  669. esac
  670. # JDK
  671. case "${JDK_version}" in
  672. 1)
  673. . include/jdk-1.8.sh
  674. Install-JDK18 2>&1 | tee -a ${oneinstack_dir}/install.log
  675. ;;
  676. 2)
  677. . include/jdk-1.7.sh
  678. Install-JDK17 2>&1 | tee -a ${oneinstack_dir}/install.log
  679. ;;
  680. 3)
  681. . include/jdk-1.6.sh
  682. Install-JDK16 2>&1 | tee -a ${oneinstack_dir}/install.log
  683. ;;
  684. esac
  685. case "${Tomcat_version}" in
  686. 1)
  687. . include/tomcat-8.sh
  688. Install_Tomcat8 2>&1 | tee -a ${oneinstack_dir}/install.log
  689. ;;
  690. 2)
  691. . include/tomcat-7.sh
  692. Install_Tomcat7 2>&1 | tee -a ${oneinstack_dir}/install.log
  693. ;;
  694. 3)
  695. . include/tomcat-6.sh
  696. Install_Tomcat6 2>&1 | tee -a ${oneinstack_dir}/install.log
  697. ;;
  698. esac
  699. # Pure-FTPd
  700. if [ "${FTP_yn}" == 'y' ]; then
  701. . include/pureftpd.sh
  702. Install_PureFTPd 2>&1 | tee -a ${oneinstack_dir}/install.log
  703. fi
  704. # phpMyAdmin
  705. if [ "${phpMyAdmin_yn}" == 'y' ]; then
  706. . include/phpmyadmin.sh
  707. Install_phpMyAdmin 2>&1 | tee -a ${oneinstack_dir}/install.log
  708. fi
  709. # redis
  710. if [ "${redis_yn}" == 'y' ]; then
  711. . include/redis.sh
  712. [ ! -d "${redis_install_dir}" ] && Install_redis-server 2>&1 | tee -a ${oneinstack_dir}/install.log
  713. [ -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
  714. fi
  715. # memcached
  716. if [ "${memcached_yn}" == 'y' ]; then
  717. . include/memcached.sh
  718. [ ! -d "${memcached_install_dir}/include/memcached" ] && Install_memcached 2>&1 | tee -a ${oneinstack_dir}/install.log
  719. [ -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
  720. [ -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
  721. fi
  722. # index example
  723. if [ ! -e "${wwwroot_dir}/default/index.html" -a "${Web_yn}" == 'y' ]; then
  724. . include/demo.sh
  725. DEMO 2>&1 | tee -a ${oneinstack_dir}/install.log
  726. fi
  727. # get web_install_dir and db_install_dir
  728. . include/check_dir.sh
  729. # HHVM
  730. if [ "${HHVM_yn}" == 'y' ]; then
  731. . include/hhvm_CentOS.sh
  732. Install_hhvm_CentOS 2>&1 | tee -a ${oneinstack_dir}/install.log
  733. fi
  734. # Starting DB
  735. [ -d "/etc/mysql" ] && /bin/mv /etc/mysql{,_bk}
  736. [ -d "${db_install_dir}/support-files" -a -z "$(ps -ef | grep -v grep | grep mysql)" ] && /etc/init.d/mysqld start
  737. endTime=`date +%s`
  738. ((installTime=($endTime-$startTime)/60))
  739. echo "####################Congratulations########################"
  740. echo "Total OneinStack Install Time: ${CQUESTION}${installTime}${CEND} minutes"
  741. [ "${Web_yn}" == 'y' -a "${Nginx_version}" != '4' -a "${Apache_version}" == '3' ] && echo -e "\n$(printf "%-32s" "Nginx install dir":)${CMSG}${web_install_dir}${CEND}"
  742. [ "${Web_yn}" == 'y' -a "${Nginx_version}" != '4' -a "${Apache_version}" != '3' ] && echo -e "\n$(printf "%-32s" "Nginx install dir":)${CMSG}${web_install_dir}${CEND}\n$(printf "%-32s" "Apache install dir":)${CMSG}${apache_install_dir}${CEND}"
  743. [ "${Web_yn}" == 'y' -a "${Nginx_version}" == '4' -a "${Apache_version}" != '3' ] && echo -e "\n$(printf "%-32s" "Apache install dir":)${CMSG}${apache_install_dir}${CEND}"
  744. [[ "${Tomcat_version}" =~ ^[1,2]$ ]] && echo -e "\n$(printf "%-32s" "Tomcat install dir":)${CMSG}${tomcat_install_dir}${CEND}"
  745. [[ "${DB_version}" =~ ^[1-9]$|^1[0-1]$ ]] && echo -e "\n$(printf "%-32s" "Database install dir:")${CMSG}${db_install_dir}${CEND}"
  746. [[ "${DB_version}" =~ ^[1-9]$|^1[0-1]$ ]] && echo "$(printf "%-32s" "Database data dir:")${CMSG}${db_data_dir}${CEND}"
  747. [[ "${DB_version}" =~ ^[1-9]$|^1[0-1]$ ]] && echo "$(printf "%-32s" "Database user:")${CMSG}root${CEND}"
  748. [[ "${DB_version}" =~ ^[1-9]$|^1[0-1]$ ]] && echo "$(printf "%-32s" "Database password:")${CMSG}${dbrootpwd}${CEND}"
  749. [ "${DB_version}" == '12' ] && echo -e "\n$(printf "%-32s" "PostgreSQL install dir:")${CMSG}${pgsql_install_dir}${CEND}"
  750. [ "${DB_version}" == '12' ] && echo "$(printf "%-32s" "PostgreSQL data dir:")${CMSG}${pgsql_data_dir}${CEND}"
  751. [ "${DB_version}" == '12' ] && echo "$(printf "%-32s" "PostgreSQL user:")${CMSG}postgres${CEND}"
  752. [ "${DB_version}" == '12' ] && echo "$(printf "%-32s" "postgres password:")${CMSG}${dbpostgrespwd}${CEND}"
  753. [ "${PHP_yn}" == 'y' ] && echo -e "\n$(printf "%-32s" "PHP install dir:")${CMSG}${php_install_dir}${CEND}"
  754. [ "${PHP_cache}" == '1' ] && echo "$(printf "%-32s" "Opcache Control Panel URL:")${CMSG}http://${IPADDR}/ocp.php${CEND}"
  755. [ "${PHP_cache}" == '2' ] && echo "$(printf "%-32s" "xcache Control Panel URL:")${CMSG}http://${IPADDR}/xcache${CEND}"
  756. [ "${PHP_cache}" == '2' ] && echo "$(printf "%-32s" "xcache user:")${CMSG}admin${CEND}"
  757. [ "${PHP_cache}" == '2' ] && echo "$(printf "%-32s" "xcache password:")${CMSG}${xcache_admin_pass}${CEND}"
  758. [ "${PHP_cache}" == '3' ] && echo "$(printf "%-32s" "APC Control Panel URL:")${CMSG}http://${IPADDR}/apc.php${CEND}"
  759. [ "${PHP_cache}" == '4' ] && echo "$(printf "%-32s" "eAccelerator Control Panel URL:")${CMSG}http://${IPADDR}/control.php${CEND}"
  760. [ "${PHP_cache}" == '4' ] && echo "$(printf "%-32s" "eAccelerator user:")${CMSG}admin${CEND}"
  761. [ "${PHP_cache}" == '4' ] && echo "$(printf "%-32s" "eAccelerator password:")${CMSG}eAccelerator${CEND}"
  762. [ "${FTP_yn}" == 'y' ] && echo -e "\n$(printf "%-32s" "Pure-FTPd install dir:")${CMSG}${pureftpd_install_dir}${CEND}"
  763. [ "${FTP_yn}" == 'y' ] && echo "$(printf "%-32s" "Create FTP virtual script:")${CMSG}./pureftpd_vhost.sh${CEND}"
  764. [ "${phpMyAdmin_yn}" == 'y' ] && echo -e "\n$(printf "%-32s" "phpMyAdmin dir:")${CMSG}${wwwroot_dir}/default/phpMyAdmin${CEND}"
  765. [ "${phpMyAdmin_yn}" == 'y' ] && echo "$(printf "%-32s" "phpMyAdmin Control Panel URL:")${CMSG}http://${IPADDR}/phpMyAdmin${CEND}"
  766. [ "${redis_yn}" == 'y' ] && echo -e "\n$(printf "%-32s" "redis install dir:")${CMSG}${redis_install_dir}${CEND}"
  767. [ "${memcached_yn}" == 'y' ] && echo -e "\n$(printf "%-32s" "memcached install dir:")${CMSG}${memcached_install_dir}${CEND}"
  768. [ "${Web_yn}" == 'y' ] && echo -e "\n$(printf "%-32s" "Index URL:")${CMSG}http://${IPADDR}/${CEND}"
  769. while :; do echo
  770. echo "${CMSG}Please restart the server and see if the services start up fine.${CEND}"
  771. read -p "Do you want to restart OS ? [y/n]: " restart_yn
  772. if [[ ! "${restart_yn}" =~ ^[y,n]$ ]]; then
  773. echo "${CWARNING}input error! Please only input 'y' or 'n'${CEND}"
  774. else
  775. break
  776. fi
  777. done
  778. [ "${restart_yn}" == 'y' ] && reboot