install.sh 31 KB

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