install.sh 37 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736
  1. #!/bin/bash
  2. # Author: yeho <lj2007331 AT gmail.com>
  3. # BLOG: https://blog.linuxeye.com
  4. #
  5. # Version: 1.0-Alpha Jun 15,2015 lj2007331 AT gmail.com
  6. # Notes: OneinStack for CentOS/RadHat 5+ Debian 6+ and Ubuntu 12+
  7. #
  8. # Project home page:
  9. # http://oneinstack.com
  10. # Check if user is root
  11. [ $(id -u) != "0" ] && { echo -e "\033[31mError: You must be root to run this script\033[0m"; exit 1; }
  12. export PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
  13. clear
  14. printf "
  15. #######################################################################
  16. # OneinStack for CentOS/RadHat 5+ Debian 6+ and Ubuntu 12+ #
  17. # For more information please visit http://oneinstack.com #
  18. #######################################################################
  19. "
  20. get_char()
  21. {
  22. SAVEDSTTY=`stty -g`
  23. stty -echo
  24. stty cbreak
  25. dd if=/dev/tty bs=1 count=1 2> /dev/null
  26. stty -raw
  27. stty echo
  28. stty $SAVEDSTTY
  29. }
  30. #get pwd
  31. sed -i "s@^oneinstack_dir.*@oneinstack_dir=`pwd`@" ./options.conf
  32. # get local ip address
  33. local_IP=`./functions/get_local_ip.py`
  34. # import apps version
  35. . ./apps.conf
  36. # Definition Directory
  37. . ./options.conf
  38. . functions/check_os.sh
  39. mkdir -p $wwwroot_dir/default $wwwlogs_dir $oneinstack_dir/{src,conf}
  40. # choice upgrade OS
  41. while :
  42. do
  43. echo
  44. read -p "Do you want to upgrade operating system? [y/n]: " upgrade_yn
  45. if [ "$upgrade_yn" != 'y' -a "$upgrade_yn" != 'n' ];then
  46. echo -e "\033[31minput error! Please only input 'y' or 'n'\033[0m"
  47. else
  48. [ -e init/init_*.ed -a "$upgrade_yn" == 'y' ] && { echo -e "\033[31mYour system is already upgraded! \033[0m" ; upgrade_yn=n ; }
  49. # check sendmail
  50. #if [ "$OS" != 'Debian' ];then
  51. # while :
  52. # do
  53. # echo
  54. # read -p "Do you want to install sendmail? [y/n]: " sendmail_yn
  55. # if [ "$sendmail_yn" != 'y' -a "$sendmail_yn" != 'n' ];then
  56. # echo -e "\033[31minput error! Please only input 'y' or 'n'\033[0m"
  57. # else
  58. # break
  59. # fi
  60. # done
  61. #fi
  62. break
  63. fi
  64. done
  65. # Use default SSH port 22. If you use another SSH port on your server
  66. [ -z "`grep ^Port /etc/ssh/sshd_config`" ] && ssh_port=22 || ssh_port=`grep ^Port /etc/ssh/sshd_config | awk '{print $2}'`
  67. while :
  68. do
  69. echo
  70. read -p "Please input SSH port(Default: $ssh_port): " SSH_PORT
  71. [ -z "$SSH_PORT" ] && SSH_PORT=$ssh_port
  72. 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
  73. break
  74. else
  75. echo -e "\033[31minput error! Input range: 22,1024~65535\033[0m"
  76. fi
  77. done
  78. if [ -z "`grep ^Port /etc/ssh/sshd_config`" -a "$SSH_PORT" != '22' ];then
  79. sed -i "s@^#Port.*@&\nPort $SSH_PORT@" /etc/ssh/sshd_config
  80. elif [ -n "`grep ^Port /etc/ssh/sshd_config`" ];then
  81. sed -i "s@^Port.*@Port $SSH_PORT@" /etc/ssh/sshd_config
  82. fi
  83. # check Web server
  84. while :
  85. do
  86. echo
  87. read -p "Do you want to install Web server? [y/n]: " Web_yn
  88. if [ "$Web_yn" != 'y' -a "$Web_yn" != 'n' ];then
  89. echo -e "\033[31minput error! Please only input 'y' or 'n'\033[0m"
  90. else
  91. if [ "$Web_yn" == 'y' ];then
  92. [ -d "$web_install_dir/conf" ] && { echo -e "\033[31mThe web service already installed! \033[0m" ; Web_yn=Other ; break ; }
  93. while :
  94. do
  95. echo
  96. echo 'Please select Nginx server:'
  97. echo -e "\t\033[32m1\033[0m. Install Nginx"
  98. echo -e "\t\033[32m2\033[0m. Install Tengine"
  99. echo -e "\t\033[32m3\033[0m. Do not install"
  100. read -p "Please input a number:(Default 1 press Enter) " Nginx_version
  101. [ -z "$Nginx_version" ] && Nginx_version=1
  102. if [ $Nginx_version != 1 -a $Nginx_version != 2 -a $Nginx_version != 3 ];then
  103. echo -e "\033[31minput error! Please only input number 1,2,3\033[0m"
  104. else
  105. while :
  106. do
  107. echo
  108. echo 'Please select Apache server:'
  109. echo -e "\t\033[32m1\033[0m. Install Apache-2.4"
  110. echo -e "\t\033[32m2\033[0m. Install Apache-2.2"
  111. echo -e "\t\033[32m3\033[0m. Do not install"
  112. read -p "Please input a number:(Default 3 press Enter) " Apache_version
  113. [ -z "$Apache_version" ] && Apache_version=3
  114. if [ $Apache_version != 1 -a $Apache_version != 2 -a $Apache_version != 3 ];then
  115. echo -e "\033[31minput error! Please only input number 1,2,3\033[0m"
  116. else
  117. break
  118. fi
  119. done
  120. while :
  121. do
  122. echo
  123. echo 'Please select tomcat server:'
  124. echo -e "\t\033[32m1\033[0m. Install Tomcat-8"
  125. echo -e "\t\033[32m2\033[0m. Install Tomcat-7"
  126. echo -e "\t\033[32m3\033[0m. Do not install"
  127. read -p "Please input a number:(Default 3 press Enter) " Tomcat_version
  128. [ -z "$Tomcat_version" ] && Tomcat_version=3
  129. if [ $Tomcat_version != 1 -a $Tomcat_version != 2 -a $Tomcat_version != 3 ];then
  130. echo -e "\033[31minput error! Please only input number 1,2,3\033[0m"
  131. else
  132. if [ "$Tomcat_version" == '1' ];then
  133. while :
  134. do
  135. echo
  136. echo 'Please select JDK version:'
  137. echo -e "\t\033[32m1\033[0m. Install JDK-1.8"
  138. echo -e "\t\033[32m2\033[0m. Install JDK-1.7"
  139. read -p "Please input a number:(Default 2 press Enter) " JDK_version
  140. [ -z "$JDK_version" ] && JDK_version=2
  141. if [ $JDK_version != 1 -a $JDK_version != 2 ];then
  142. echo -e "\033[31minput error! Please only input number 1,2\033[0m"
  143. else
  144. break
  145. fi
  146. done
  147. fi
  148. if [ "$Tomcat_version" == '2' ];then
  149. while :
  150. do
  151. echo
  152. echo 'Please select JDK version:'
  153. echo -e "\t\033[32m1\033[0m. Install JDK-1.8"
  154. echo -e "\t\033[32m2\033[0m. Install JDK-1.7"
  155. echo -e "\t\033[32m3\033[0m. Install JDK-1.6"
  156. read -p "Please input a number:(Default 2 press Enter) " JDK_version
  157. [ -z "$JDK_version" ] && JDK_version=2
  158. if [ $JDK_version != 1 -a $JDK_version != 2 -a $JDK_version != 3 ];then
  159. echo -e "\033[31minput error! Please only input number 1,2,3\033[0m"
  160. else
  161. break
  162. fi
  163. done
  164. fi
  165. break
  166. fi
  167. done
  168. break
  169. fi
  170. done
  171. fi
  172. break
  173. fi
  174. done
  175. # choice database
  176. while :
  177. do
  178. echo
  179. read -p "Do you want to install Database? [y/n]: " DB_yn
  180. if [ "$DB_yn" != 'y' -a "$DB_yn" != 'n' ];then
  181. echo -e "\033[31minput error! Please only input 'y' or 'n'\033[0m"
  182. else
  183. if [ "$DB_yn" == 'y' ];then
  184. [ -d "$db_install_dir/support-files" ] && { echo -e "\033[31mThe database already installed! \033[0m" ; DB_yn=Other ; break ; }
  185. while :
  186. do
  187. echo
  188. echo 'Please select a version of the Database:'
  189. echo -e "\t\033[32m1\033[0m. Install MySQL-5.6"
  190. echo -e "\t\033[32m2\033[0m. Install MySQL-5.5"
  191. echo -e "\t\033[32m3\033[0m. Install MariaDB-10.0"
  192. echo -e "\t\033[32m4\033[0m. Install MariaDB-5.5"
  193. echo -e "\t\033[32m5\033[0m. Install Percona-5.6"
  194. echo -e "\t\033[32m6\033[0m. Install Percona-5.5"
  195. read -p "Please input a number:(Default 1 press Enter) " DB_version
  196. [ -z "$DB_version" ] && DB_version=1
  197. if [ $DB_version != 1 -a $DB_version != 2 -a $DB_version != 3 -a $DB_version != 4 -a $DB_version != 5 -a $DB_version != 6 ];then
  198. echo -e "\033[31minput error! Please only input number 1,2,3,4,5,6 \033[0m"
  199. else
  200. while :
  201. do
  202. read -p "Please input the root password of database: " dbrootpwd
  203. [ -n "`echo $dbrootpwd | grep '[+|&]'`" ] && { echo -e "\033[31minput error,not contain a plus sign (+) and & \033[0m"; continue; }
  204. (( ${#dbrootpwd} >= 5 )) && sed -i "s+^dbrootpwd.*+dbrootpwd='$dbrootpwd'+" ./options.conf && break || echo -e "\033[31mdatabase root password least 5 characters! \033[0m"
  205. done
  206. break
  207. fi
  208. done
  209. fi
  210. break
  211. fi
  212. done
  213. # check PHP
  214. while :
  215. do
  216. echo
  217. read -p "Do you want to install PHP? [y/n]: " PHP_yn
  218. if [ "$PHP_yn" != 'y' -a "$PHP_yn" != 'n' ];then
  219. echo -e "\033[31minput error! Please only input 'y' or 'n'\033[0m"
  220. else
  221. if [ "$PHP_yn" == 'y' ];then
  222. [ -d "$php_install_dir/bin" ] && { echo -e "\033[31mThe php already installed! \033[0m" ; PHP_yn=Other ; break ; }
  223. while :
  224. do
  225. echo
  226. echo 'Please select a version of the PHP:'
  227. echo -e "\t\033[32m1\033[0m. Install php-5.3"
  228. echo -e "\t\033[32m2\033[0m. Install php-5.4"
  229. echo -e "\t\033[32m3\033[0m. Install php-5.5"
  230. echo -e "\t\033[32m4\033[0m. Install php-5.6"
  231. echo -e "\t\033[32m5\033[0m. Install php-7/phpng(beta)"
  232. read -p "Please input a number:(Default 1 press Enter) " PHP_version
  233. [ -z "$PHP_version" ] && PHP_version=1
  234. if [ $PHP_version != 1 -a $PHP_version != 2 -a $PHP_version != 3 -a $PHP_version != 4 -a $PHP_version != 5 ];then
  235. echo -e "\033[31minput error! Please only input number 1,2,3,4,5 \033[0m"
  236. else
  237. while :
  238. do
  239. echo
  240. read -p "Do you want to install opcode cache of the PHP? [y/n]: " PHP_cache_yn
  241. if [ "$PHP_cache_yn" != 'y' -a "$PHP_cache_yn" != 'n' ];then
  242. echo -e "\033[31minput error! Please only input 'y' or 'n'\033[0m"
  243. else
  244. if [ "$PHP_cache_yn" == 'y' ];then
  245. if [ $PHP_version == 1 ];then
  246. while :
  247. do
  248. echo 'Please select a opcode cache of the PHP:'
  249. echo -e "\t\033[32m1\033[0m. Install Zend OPcache"
  250. echo -e "\t\033[32m2\033[0m. Install XCache"
  251. echo -e "\t\033[32m3\033[0m. Install APCU"
  252. echo -e "\t\033[32m4\033[0m. Install eAccelerator-0.9"
  253. read -p "Please input a number:(Default 1 press Enter) " PHP_cache
  254. [ -z "$PHP_cache" ] && PHP_cache=1
  255. if [ $PHP_cache != 1 -a $PHP_cache != 2 -a $PHP_cache != 3 -a $PHP_cache != 4 ];then
  256. echo -e "\033[31minput error! Please only input number 1,2,3,4\033[0m"
  257. else
  258. break
  259. fi
  260. done
  261. fi
  262. if [ $PHP_version == 2 ];then
  263. while :
  264. do
  265. echo 'Please select a opcode cache of the PHP:'
  266. echo -e "\t\033[32m1\033[0m. Install Zend OPcache"
  267. echo -e "\t\033[32m2\033[0m. Install XCache"
  268. echo -e "\t\033[32m3\033[0m. Install APCU"
  269. echo -e "\t\033[32m4\033[0m. Install eAccelerator-1.0-dev"
  270. read -p "Please input a number:(Default 1 press Enter) " PHP_cache
  271. [ -z "$PHP_cache" ] && PHP_cache=1
  272. if [ $PHP_cache != 1 -a $PHP_cache != 2 -a $PHP_cache != 3 -a $PHP_cache != 4 ];then
  273. echo -e "\033[31minput error! Please only input number 1,2,3,4\033[0m"
  274. else
  275. break
  276. fi
  277. done
  278. fi
  279. if [ $PHP_version == 3 ];then
  280. while :
  281. do
  282. echo 'Please select a opcode cache of the PHP:'
  283. echo -e "\t\033[32m1\033[0m. Install Zend OPcache"
  284. echo -e "\t\033[32m2\033[0m. Install XCache"
  285. echo -e "\t\033[32m3\033[0m. Install APCU"
  286. read -p "Please input a number:(Default 1 press Enter) " PHP_cache
  287. [ -z "$PHP_cache" ] && PHP_cache=1
  288. if [ $PHP_cache != 1 -a $PHP_cache != 2 -a $PHP_cache != 3 ];then
  289. echo -e "\033[31minput error! Please only input number 1,2,3\033[0m"
  290. else
  291. break
  292. fi
  293. done
  294. fi
  295. if [ $PHP_version == 4 ];then
  296. while :
  297. do
  298. echo 'Please select a opcode cache of the PHP:'
  299. echo -e "\t\033[32m1\033[0m. Install Zend OPcache"
  300. echo -e "\t\033[32m2\033[0m. Install XCache"
  301. read -p "Please input a number:(Default 1 press Enter) " PHP_cache
  302. [ -z "$PHP_cache" ] && PHP_cache=1
  303. if [ $PHP_cache != 1 -a $PHP_cache != 2 ];then
  304. echo -e "\033[31minput error! Please only input number 1,2\033[0m"
  305. else
  306. break
  307. fi
  308. done
  309. fi
  310. if [ $PHP_version == 5 ];then
  311. while :
  312. do
  313. echo 'Please select a opcode cache of the PHP:'
  314. echo -e "\t\033[32m1\033[0m. Install Zend OPcache"
  315. read -p "Please input a number:(Default 1 press Enter) " PHP_cache
  316. [ -z "$PHP_cache" ] && PHP_cache=1
  317. if [ $PHP_cache != 1 ];then
  318. echo -e "\033[31minput error! Please only input number 1\033[0m"
  319. else
  320. break
  321. fi
  322. done
  323. fi
  324. fi
  325. break
  326. fi
  327. done
  328. if [ "$PHP_cache" == '2' ];then
  329. while :
  330. do
  331. read -p "Please input xcache admin password: " xcache_admin_pass
  332. (( ${#xcache_admin_pass} >= 5 )) && { xcache_admin_md5_pass=`echo -n "$xcache_admin_pass" | md5sum | awk '{print $1}'` ; break ; } || echo -e "\033[31mxcache admin password least 5 characters! \033[0m"
  333. done
  334. fi
  335. if [ "$PHP_version" != '5' ];then
  336. while :
  337. do
  338. echo
  339. read -p "Do you want to install ZendGuardLoader? [y/n]: " ZendGuardLoader_yn
  340. if [ "$ZendGuardLoader_yn" != 'y' -a "$ZendGuardLoader_yn" != 'n' ];then
  341. echo -e "\033[31minput error! Please only input 'y' or 'n'\033[0m"
  342. else
  343. break
  344. fi
  345. done
  346. fi
  347. if [ "$PHP_version" != '5' ];then
  348. while :
  349. do
  350. echo
  351. read -p "Do you want to install ionCube? [y/n]: " ionCube_yn
  352. if [ "$ionCube_yn" != 'y' -a "$ionCube_yn" != 'n' ];then
  353. echo -e "\033[31minput error! Please only input 'y' or 'n'\033[0m"
  354. else
  355. break
  356. fi
  357. done
  358. fi
  359. if [ "$PHP_version" != '5' ];then
  360. while :
  361. do
  362. echo
  363. read -p "Do you want to install ImageMagick or GraphicsMagick? [y/n]: " Magick_yn
  364. if [ "$Magick_yn" != 'y' -a "$Magick_yn" != 'n' ];then
  365. echo -e "\033[31minput error! Please only input 'y' or 'n'\033[0m"
  366. else
  367. break
  368. fi
  369. done
  370. fi
  371. if [ "$Magick_yn" == 'y' ];then
  372. while :
  373. do
  374. echo 'Please select ImageMagick or GraphicsMagick:'
  375. echo -e "\t\033[32m1\033[0m. Install ImageMagick"
  376. echo -e "\t\033[32m2\033[0m. Install GraphicsMagick"
  377. read -p "Please input a number:(Default 1 press Enter) " Magick
  378. [ -z "$Magick" ] && Magick=1
  379. if [ $Magick != 1 -a $Magick != 2 ];then
  380. echo -e "\033[31minput error! Please only input number 1,2 \033[0m"
  381. else
  382. break
  383. fi
  384. done
  385. fi
  386. break
  387. fi
  388. done
  389. fi
  390. break
  391. fi
  392. done
  393. # check Pureftpd
  394. while :
  395. do
  396. echo
  397. read -p "Do you want to install Pure-FTPd? [y/n]: " FTP_yn
  398. if [ "$FTP_yn" != 'y' -a "$FTP_yn" != 'n' ];then
  399. echo -e "\033[31minput error! Please only input 'y' or 'n'\033[0m"
  400. else
  401. [ "$FTP_yn" == 'y' -a -d "$pureftpd_install_dir/bin" ] && { echo -e "\033[31mThe FTP service already installed! \033[0m" ; FTP_yn=Other ; break ; }
  402. break
  403. fi
  404. done
  405. # check phpMyAdmin
  406. while :
  407. do
  408. echo
  409. read -p "Do you want to install phpMyAdmin? [y/n]: " phpMyAdmin_yn
  410. if [ "$phpMyAdmin_yn" != 'y' -a "$phpMyAdmin_yn" != 'n' ];then
  411. echo -e "\033[31minput error! Please only input 'y' or 'n'\033[0m"
  412. else
  413. if [ "$phpMyAdmin_yn" == 'y' ];then
  414. [ -d "$wwwroot_dir/default/phpMyAdmin" ] && echo -e "\033[31mThe phpMyAdmin already installed! \033[0m" && phpMyAdmin_yn=Other && break
  415. fi
  416. break
  417. fi
  418. done
  419. # check redis
  420. if [ "$PHP_version" != '5' ];then
  421. while :
  422. do
  423. echo
  424. read -p "Do you want to install redis? [y/n]: " redis_yn
  425. if [ "$redis_yn" != 'y' -a "$redis_yn" != 'n' ];then
  426. echo -e "\033[31minput error! Please only input 'y' or 'n'\033[0m"
  427. else
  428. if [ "$redis_yn" == 'y' ];then
  429. [ -d "$redis_install_dir" ] && { echo -e "\033[31mThe redis already installed! \033[0m" ; redis_yn=Other ; break ; }
  430. fi
  431. break
  432. fi
  433. done
  434. # check memcached
  435. while :
  436. do
  437. echo
  438. read -p "Do you want to install memcached? [y/n]: " memcached_yn
  439. if [ "$memcached_yn" != 'y' -a "$memcached_yn" != 'n' ];then
  440. echo -e "\033[31minput error! Please only input 'y' or 'n'\033[0m"
  441. else
  442. if [ "$memcached_yn" == 'y' ];then
  443. [ -d "$memcached_install_dir/bin" ] && { echo -e "\033[31mThe memcached already installed! \033[0m" ; memcached_yn=Other ; break ; }
  444. fi
  445. break
  446. fi
  447. done
  448. fi
  449. # check jemalloc or tcmalloc
  450. if [ "$Web_yn" == 'y' -o "$DB_yn" == 'y' ];then
  451. while :
  452. do
  453. echo
  454. read -p "Do you want to use jemalloc or tcmalloc optimize Database and Web server? [y/n]: " je_tc_malloc_yn
  455. if [ "$je_tc_malloc_yn" != 'y' -a "$je_tc_malloc_yn" != 'n' ];then
  456. echo -e "\033[31minput error! Please only input 'y' or 'n'\033[0m"
  457. else
  458. if [ "$je_tc_malloc_yn" == 'y' ];then
  459. echo 'Please select jemalloc or tcmalloc:'
  460. echo -e "\t\033[32m1\033[0m. jemalloc"
  461. echo -e "\t\033[32m2\033[0m. tcmalloc"
  462. while :
  463. do
  464. read -p "Please input a number:(Default 1 press Enter) " je_tc_malloc
  465. [ -z "$je_tc_malloc" ] && je_tc_malloc=1
  466. if [ $je_tc_malloc != 1 -a $je_tc_malloc != 2 ];then
  467. echo -e "\033[31minput error! Please only input number 1,2\033[0m"
  468. else
  469. break
  470. fi
  471. done
  472. fi
  473. break
  474. fi
  475. done
  476. fi
  477. while :
  478. do
  479. echo
  480. read -p "Do you want to install HHVM? [y/n]: " HHVM_yn
  481. if [ "$HHVM_yn" != 'y' -a "$HHVM_yn" != 'n' ];then
  482. echo -e "\033[31minput error! Please only input 'y' or 'n'\033[0m"
  483. else
  484. if [ "$HHVM_yn" == 'y' ];then
  485. if [ -e '/etc/redhat-release' ] && [ -n "`grep -E ' 7\.| 6\.5| 6\.6| 6\.7' /etc/redhat-release`" -a -d "/lib64" ];then
  486. break
  487. else
  488. echo -e "\033[31mHHVM only support CentOS6.5+ 64bit, CentOS7 64bit! \033[0m"
  489. echo "Press Ctrl+c to cancel or Press any key to continue..."
  490. echo
  491. char=`get_char`
  492. HHVM_yn=
  493. break
  494. fi
  495. elif [ "$HHVM_yn" == 'n' ];then
  496. break
  497. fi
  498. fi
  499. done
  500. chmod +x functions/*.sh init/* *.sh
  501. # init
  502. if [ "$OS" == 'CentOS' ];then
  503. . init/init_CentOS.sh 2>&1 | tee $oneinstack_dir/install.log
  504. [ -n "`gcc --version | head -n1 | grep '4\.1\.'`" ] && export CC="gcc44" CXX="g++44"
  505. elif [ "$OS" == 'Debian' ];then
  506. . init/init_Debian.sh 2>&1 | tee $oneinstack_dir/install.log
  507. elif [ "$OS" == 'Ubuntu' ];then
  508. . init/init_Ubuntu.sh 2>&1 | tee $oneinstack_dir/install.log
  509. fi
  510. # jemalloc or tcmalloc
  511. if [ "$je_tc_malloc_yn" == 'y' -a "$je_tc_malloc" == '1' -a ! -e "/usr/local/lib/libjemalloc.so" ];then
  512. . functions/jemalloc.sh
  513. Install_jemalloc | tee -a $oneinstack_dir/install.log
  514. elif [ "$je_tc_malloc_yn" == 'y' -a "$je_tc_malloc" == '2' -a ! -e "/usr/local/lib/libtcmalloc.so" ];then
  515. . functions/tcmalloc.sh
  516. Install_tcmalloc | tee -a $oneinstack_dir/install.log
  517. fi
  518. # Database
  519. if [ "$DB_version" == '1' ];then
  520. . functions/mysql-5.6.sh
  521. Install_MySQL-5-6 2>&1 | tee -a $oneinstack_dir/install.log
  522. elif [ "$DB_version" == '2' ];then
  523. . functions/mysql-5.5.sh
  524. Install_MySQL-5-5 2>&1 | tee -a $oneinstack_dir/install.log
  525. elif [ "$DB_version" == '3' ];then
  526. . functions/mariadb-10.0.sh
  527. Install_MariaDB-10-0 2>&1 | tee -a $oneinstack_dir/install.log
  528. elif [ "$DB_version" == '4' ];then
  529. . functions/mariadb-5.5.sh
  530. Install_MariaDB-5-5 2>&1 | tee -a $oneinstack_dir/install.log
  531. elif [ "$DB_version" == '5' ];then
  532. . functions/percona-5.6.sh
  533. Install_Percona-5-6 2>&1 | tee -a $oneinstack_dir/install.log
  534. elif [ "$DB_version" == '6' ];then
  535. . functions/percona-5.5.sh
  536. Install_Percona-5-5 2>&1 | tee -a $oneinstack_dir/install.log
  537. fi
  538. # Apache
  539. if [ "$Apache_version" == '1' ];then
  540. . functions/apache-2.4.sh
  541. Install_Apache-2-4 2>&1 | tee -a $oneinstack_dir/install.log
  542. elif [ "$Apache_version" == '2' ];then
  543. . functions/apache-2.2.sh
  544. Install_Apache-2-2 2>&1 | tee -a $oneinstack_dir/install.log
  545. fi
  546. # PHP
  547. if [ "$PHP_version" == '1' ];then
  548. . functions/php-5.3.sh
  549. Install_PHP-5-3 2>&1 | tee -a $oneinstack_dir/install.log
  550. elif [ "$PHP_version" == '2' ];then
  551. . functions/php-5.4.sh
  552. Install_PHP-5-4 2>&1 | tee -a $oneinstack_dir/install.log
  553. elif [ "$PHP_version" == '3' ];then
  554. . functions/php-5.5.sh
  555. Install_PHP-5-5 2>&1 | tee -a $oneinstack_dir/install.log
  556. elif [ "$PHP_version" == '4' ];then
  557. . functions/php-5.6.sh
  558. Install_PHP-5-6 2>&1 | tee -a $oneinstack_dir/install.log
  559. elif [ "$PHP_version" == '5' ];then
  560. . functions/php-7.sh
  561. Install_PHP-7 2>&1 | tee -a $oneinstack_dir/install.log
  562. fi
  563. # ImageMagick or GraphicsMagick
  564. if [ "$Magick" == '1' ];then
  565. . functions/ImageMagick.sh
  566. Install_ImageMagick 2>&1 | tee -a $oneinstack_dir/install.log
  567. elif [ "$Magick" == '2' ];then
  568. . functions/GraphicsMagick.sh
  569. Install_GraphicsMagick 2>&1 | tee -a $oneinstack_dir/install.log
  570. fi
  571. # ionCube
  572. if [ "$ionCube_yn" == 'y' ];then
  573. . functions/ioncube.sh
  574. Install_ionCube 2>&1 | tee -a $oneinstack_dir/install.log
  575. fi
  576. # PHP opcode cache
  577. if [ "$PHP_cache" == '1' ] && [ "$PHP_version" == '1' -o "$PHP_version" == '2' ];then
  578. . functions/zendopcache.sh
  579. Install_ZendOPcache 2>&1 | tee -a $oneinstack_dir/install.log
  580. elif [ "$PHP_cache" == '2' ];then
  581. . functions/xcache.sh
  582. Install_XCache 2>&1 | tee -a $oneinstack_dir/install.log
  583. elif [ "$PHP_cache" == '3' ];then
  584. . functions/apcu.sh
  585. Install_APCU 2>&1 | tee -a $oneinstack_dir/install.log
  586. elif [ "$PHP_cache" == '4' -a "$PHP_version" == '2' ];then
  587. . functions/eaccelerator-1.0-dev.sh
  588. Install_eAccelerator-1-0-dev 2>&1 | tee -a $oneinstack_dir/install.log
  589. elif [ "$PHP_cache" == '4' -a "$PHP_version" == '1' ];then
  590. . functions/eaccelerator-0.9.sh
  591. Install_eAccelerator-0-9 2>&1 | tee -a $oneinstack_dir/install.log
  592. fi
  593. # ZendGuardLoader (php <= 5.6)
  594. if [ "$ZendGuardLoader_yn" == 'y' ];then
  595. . functions/ZendGuardLoader.sh
  596. Install_ZendGuardLoader 2>&1 | tee -a $oneinstack_dir/install.log
  597. fi
  598. # Web server
  599. if [ "$Nginx_version" == '1' ];then
  600. . functions/nginx.sh
  601. Install_Nginx 2>&1 | tee -a $oneinstack_dir/install.log
  602. elif [ "$Nginx_version" == '2' ];then
  603. . functions/tengine.sh
  604. Install_Tengine 2>&1 | tee -a $oneinstack_dir/install.log
  605. fi
  606. # JDK
  607. if [ "$JDK_version" == '1' ];then
  608. . functions/jdk-1.8.sh
  609. Install-JDK-1-8 2>&1 | tee -a $oneinstack_dir/install.log
  610. elif [ "$JDK_version" == '2' ];then
  611. . functions/jdk-1.7.sh
  612. Install-JDK-1-7 2>&1 | tee -a $oneinstack_dir/install.log
  613. elif [ "$JDK_version" == '3' ];then
  614. . functions/jdk-1.6.sh
  615. Install-JDK-1-6 2>&1 | tee -a $oneinstack_dir/install.log
  616. fi
  617. if [ "$Tomcat_version" == '1' ];then
  618. . functions/tomcat-8.sh
  619. Install_tomcat-8 2>&1 | tee -a $oneinstack_dir/install.log
  620. elif [ "$Tomcat_version" == '2' ];then
  621. . functions/tomcat-7.sh
  622. Install_tomcat-7 2>&1 | tee -a $oneinstack_dir/install.log
  623. fi
  624. # Pure-FTPd
  625. if [ "$FTP_yn" == 'y' ];then
  626. . functions/pureftpd.sh
  627. Install_PureFTPd 2>&1 | tee -a $oneinstack_dir/install.log
  628. fi
  629. # phpMyAdmin
  630. if [ "$phpMyAdmin_yn" == 'y' ];then
  631. . functions/phpmyadmin.sh
  632. Install_phpMyAdmin 2>&1 | tee -a $oneinstack_dir/install.log
  633. fi
  634. # redis
  635. if [ "$redis_yn" == 'y' ];then
  636. . functions/redis.sh
  637. Install_redis 2>&1 | tee -a $oneinstack_dir/install.log
  638. fi
  639. # memcached
  640. if [ "$memcached_yn" == 'y' ];then
  641. . functions/memcached.sh
  642. Install_memcached 2>&1 | tee -a $oneinstack_dir/install.log
  643. fi
  644. # get db_install_dir and web_install_dir
  645. . ./options.conf
  646. # index example
  647. if [ ! -e "$wwwroot_dir/default/index.html" -a "$Web_yn" == 'y' ];then
  648. . functions/test.sh
  649. TEST 2>&1 | tee -a $oneinstack_dir/install.log
  650. fi
  651. if [ "$HHVM_yn" == 'y' ];then
  652. . functions/hhvm_CentOS.sh
  653. Install_hhvm_CentOS 2>&1 | tee -a $oneinstack_dir/install.log
  654. fi
  655. # Starting DB
  656. [ -e "$db_install_dir" -a -z "`ps -ef | grep -v grep | grep mysql`" ] && /etc/init.d/mysqld start
  657. echo "####################Congratulations########################"
  658. [ "$Web_yn" == 'y' -a "$Nginx_version" != '3' -a "$Apache_version" == '3' ] && echo -e "\n`printf "%-32s" "Nginx/Tengine install dir":`\033[32m$web_install_dir\033[0m"
  659. [ "$Web_yn" == 'y' -a "$Nginx_version" != '3' -a "$Apache_version" != '3' ] && echo -e "\n`printf "%-32s" "Nginx/Tengine install dir":`\033[32m$web_install_dir\033[0m\n`printf "%-32s" "Apache install dir":`\033[32m$apache_install_dir\033[0m"
  660. [ "$Web_yn" == 'y' -a "$Nginx_version" == '3' -a "$Apache_version" != '3' ] && echo -e "\n`printf "%-32s" "Apache install dir":`\033[32m$apache_install_dir\033[0m"
  661. [ "$Tomcat_version" == '1' -o "$Tomcat_version" == '2' ] && echo -e "\n`printf "%-32s" "Tomcat install dir":`\033[32m$tomcat_install_dir\033[0m"
  662. [ "$DB_yn" == 'y' ] && echo -e "\n`printf "%-32s" "Database install dir:"`\033[32m$db_install_dir\033[0m"
  663. [ "$DB_yn" == 'y' ] && echo -e "`printf "%-32s" "Database data dir:"`\033[32m$db_data_dir\033[0m"
  664. [ "$DB_yn" == 'y' ] && echo -e "`printf "%-32s" "Database user:"`\033[32mroot\033[0m"
  665. [ "$DB_yn" == 'y' ] && echo -e "`printf "%-32s" "Database password:"`\033[32m${dbrootpwd}\033[0m"
  666. [ "$PHP_yn" == 'y' ] && echo -e "\n`printf "%-32s" "PHP install dir:"`\033[32m$php_install_dir\033[0m"
  667. [ "$PHP_cache" == '1' ] && echo -e "`printf "%-32s" "Opcache Control Panel url:"`\033[32mhttp://$local_IP/ocp.php\033[0m"
  668. [ "$PHP_cache" == '2' ] && echo -e "`printf "%-32s" "xcache Control Panel url:"`\033[32mhttp://$local_IP/xcache\033[0m"
  669. [ "$PHP_cache" == '2' ] && echo -e "`printf "%-32s" "xcache user:"`\033[32madmin\033[0m"
  670. [ "$PHP_cache" == '2' ] && echo -e "`printf "%-32s" "xcache password:"`\033[32m$xcache_admin_pass\033[0m"
  671. [ "$PHP_cache" == '3' ] && echo -e "`printf "%-32s" "APC Control Panel url:"`\033[32mhttp://$local_IP/apc.php\033[0m"
  672. [ "$PHP_cache" == '4' ] && echo -e "`printf "%-32s" "eAccelerator Control Panel url:"`\033[32mhttp://$local_IP/control.php\033[0m"
  673. [ "$PHP_cache" == '4' ] && echo -e "`printf "%-32s" "eAccelerator user:"`\033[32madmin\033[0m"
  674. [ "$PHP_cache" == '4' ] && echo -e "`printf "%-32s" "eAccelerator password:"`\033[32meAccelerator\033[0m"
  675. [ "$FTP_yn" == 'y' ] && echo -e "\n`printf "%-32s" "Pure-FTPd install dir:"`\033[32m$pureftpd_install_dir\033[0m"
  676. [ "$FTP_yn" == 'y' ] && echo -e "`printf "%-32s" "Create FTP virtual script:"`\033[32m./pureftpd_vhost.sh\033[0m"
  677. [ "$phpMyAdmin_yn" == 'y' ] && echo -e "\n`printf "%-32s" "phpMyAdmin dir:"`\033[32m$wwwroot_dir/default/phpMyAdmin\033[0m"
  678. [ "$phpMyAdmin_yn" == 'y' ] && echo -e "`printf "%-32s" "phpMyAdmin Control Panel url:"`\033[32mhttp://$local_IP/phpMyAdmin\033[0m"
  679. [ "$redis_yn" == 'y' ] && echo -e "\n`printf "%-32s" "redis install dir:"`\033[32m$redis_install_dir\033[0m"
  680. [ "$memcached_yn" == 'y' ] && echo -e "\n`printf "%-32s" "memcached install dir:"`\033[32m$memcached_install_dir\033[0m"
  681. [ "$Web_yn" == 'y' ] && echo -e "\n`printf "%-32s" "index url:"`\033[32mhttp://$local_IP/\033[0m"
  682. while :
  683. do
  684. echo
  685. echo -e "\033[31mPlease restart the server and see if the services start up fine.\033[0m"
  686. read -p "Do you want to restart OS ? [y/n]: " restart_yn
  687. if [ "$restart_yn" != 'y' -a "$restart_yn" != 'n' ];then
  688. echo -e "\033[31minput error! Please only input 'y' or 'n'\033[0m"
  689. else
  690. break
  691. fi
  692. done
  693. [ "$restart_yn" == 'y' ] && reboot