addons.sh 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530
  1. #!/bin/bash
  2. # Author: yeho <lj2007331 AT gmail.com>
  3. # BLOG: https://blog.linuxeye.cn
  4. #
  5. # Notes: OneinStack for CentOS/RadHat 6+ Debian 7+ and Ubuntu 12+
  6. #
  7. # Project home page:
  8. # https://oneinstack.com
  9. # https://github.com/lj2007331/oneinstack
  10. export PATH=/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. # Install/Uninstall Extensions #
  16. # For more information please visit https://oneinstack.com #
  17. #######################################################################
  18. "
  19. # Check if user is root
  20. [ $(id -u) != '0' ] && { echo "${CFAILURE}Error: You must be root to run this script${CEND}"; exit 1; }
  21. oneinstack_dir=$(dirname "`readlink -f $0`")
  22. pushd ${oneinstack_dir} > /dev/null
  23. # get the IP information
  24. PUBLIC_IPADDR=`./include/get_public_ipaddr.py`
  25. IPADDR_COUNTRY=`./include/get_ipaddr_state.py $PUBLIC_IPADDR | awk '{print $1}'`
  26. . ./versions.txt
  27. . ./options.conf
  28. . ./include/color.sh
  29. . ./include/memory.sh
  30. . ./include/check_os.sh
  31. . ./include/check_download.sh
  32. . ./include/download.sh
  33. . ./include/get_char.sh
  34. . ./include/zendopcache.sh
  35. . ./include/xcache.sh
  36. . ./include/apcu.sh
  37. . ./include/eaccelerator.sh
  38. . ./include/ZendGuardLoader.sh
  39. . ./include/ioncube.sh
  40. . ./include/ImageMagick.sh
  41. . ./include/GraphicsMagick.sh
  42. . ./include/memcached.sh
  43. . ./include/redis.sh
  44. . ./include/python.sh
  45. # Check PHP
  46. if [ -e "${php_install_dir}/bin/phpize" ]; then
  47. phpExtensionDir=$(${php_install_dir}/bin/php-config --extension-dir)
  48. PHP_detail_ver=$(${php_install_dir}/bin/php -r 'echo PHP_VERSION;')
  49. PHP_main_ver=${PHP_detail_ver%.*}
  50. fi
  51. # Check PHP Extensions
  52. Check_PHP_Extension() {
  53. [ ! -e "${php_install_dir}/bin/phpize" ] && { echo "${CWARNING}PHP was not exist! ${CEND}"; exit 1; }
  54. [ -e "`ls ${php_install_dir}/etc/php.d/0?-${PHP_extension}.ini 2> /dev/null`" ] && { echo "${CWARNING}PHP ${PHP_extension} module already installed! ${CEND}"; exit 1; }
  55. }
  56. # restart PHP
  57. Restart_PHP() {
  58. [ -e "${apache_install_dir}/conf/httpd.conf" ] && /etc/init.d/httpd restart || /etc/init.d/php-fpm restart
  59. }
  60. # Check succ
  61. Check_succ() {
  62. [ -f "${phpExtensionDir}/${PHP_extension}.so" ] && { Restart_PHP; echo;echo "${CSUCCESS}PHP ${PHP_extension} module installed successfully! ${CEND}"; }
  63. }
  64. # Uninstall succ
  65. Uninstall_succ() {
  66. [ -e "`ls ${php_install_dir}/etc/php.d/0?-${PHP_extension}.ini 2> /dev/null`" ] && { rm -rf ${php_install_dir}/etc/php.d/0?-${PHP_extension}.ini; Restart_PHP; echo; echo "${CMSG}PHP ${PHP_extension} module uninstall completed${CEND}"; } || { echo; echo "${CWARNING}${PHP_extension} module does not exist! ${CEND}"; }
  67. }
  68. Install_fail2ban() {
  69. [ ! -e "${python_install_dir}/bin/python" ] && Install_Python
  70. pushd ${oneinstack_dir}/src > /dev/null
  71. src_url=http://mirrors.linuxeye.com/oneinstack/src/fail2ban-${fail2ban_ver}.tar.gz && Download_src
  72. tar xzf fail2ban-${fail2ban_ver}.tar.gz
  73. pushd fail2ban-${fail2ban_ver}
  74. ${python_install_dir}/bin/python setup.py install
  75. if [ "${OS}" == "CentOS" ]; then
  76. LOGPATH=/var/log/secure
  77. /bin/cp files/redhat-initd /etc/init.d/fail2ban
  78. sed -i "s@^FAIL2BAN=.*@FAIL2BAN=${python_install_dir}/bin/fail2ban-client@" /etc/init.d/fail2ban
  79. sed -i 's@Starting fail2ban.*@&\n [ ! -e "/var/run/fail2ban" ] \&\& mkdir /var/run/fail2ban@' /etc/init.d/fail2ban
  80. chmod +x /etc/init.d/fail2ban
  81. chkconfig --add fail2ban
  82. chkconfig fail2ban on
  83. fi
  84. if [[ "${OS}" =~ ^Ubuntu$|^Debian$ ]]; then
  85. LOGPATH=/var/log/auth.log
  86. /bin/cp files/debian-initd /etc/init.d/fail2ban
  87. sed -i 's@2 3 4 5@3 4 5@' /etc/init.d/fail2ban
  88. sed -i "s@^DAEMON=.*@DAEMON=${python_install_dir}/bin/\$NAME-client@" /etc/init.d/fail2ban
  89. chmod +x /etc/init.d/fail2ban
  90. update-rc.d fail2ban defaults
  91. fi
  92. [ -z "`grep ^Port /etc/ssh/sshd_config`" ] && now_ssh_port=22 || now_ssh_port=`grep ^Port /etc/ssh/sshd_config | awk '{print $2}'`
  93. cat > /etc/fail2ban/jail.local << EOF
  94. [DEFAULT]
  95. ignoreip = 127.0.0.1/8
  96. bantime = 86400
  97. findtime = 600
  98. maxretry = 5
  99. [ssh-iptables]
  100. enabled = true
  101. filter = sshd
  102. action = iptables[name=SSH, port=$now_ssh_port, protocol=tcp]
  103. logpath = $LOGPATH
  104. EOF
  105. cat > /etc/logrotate.d/fail2ban << EOF
  106. /var/log/fail2ban.log {
  107. missingok
  108. notifempty
  109. postrotate
  110. ${python_install_dir}/bin/fail2ban-client flushlogs >/dev/null || true
  111. endscript
  112. }
  113. EOF
  114. sed -i 's@^iptables = iptables.*@iptables = iptables@' /etc/fail2ban/action.d/iptables-common.conf
  115. kill -9 `ps -ef | grep fail2ban | grep -v grep | awk '{print $2}'` > /dev/null 2>&1
  116. /etc/init.d/fail2ban start
  117. popd
  118. if [ -e "${python_install_dir}/bin/fail2ban-python" ]; then
  119. echo; echo "${CSUCCESS}fail2ban installed successfully! ${CEND}"
  120. else
  121. echo; echo "${CFAILURE}fail2ban install failed, Please try again! ${CEND}"
  122. fi
  123. popd
  124. }
  125. Uninstall_fail2ban() {
  126. /etc/init.d/fail2ban stop
  127. ${python_install_dir}/bin/pip uninstall -y fail2ban > /dev/null 2>&1
  128. rm -rf /etc/init.d/fail2ban /etc/fail2ban /etc/logrotate.d/fail2ban /var/log/fail2ban.* /var/run/fail2ban
  129. echo; echo "${CMSG}fail2ban uninstall completed${CEND}";
  130. }
  131. ACTION_FUN() {
  132. while :; do
  133. echo
  134. echo "Please select an action:"
  135. echo -e "\t${CMSG}1${CEND}. install"
  136. echo -e "\t${CMSG}2${CEND}. uninstall"
  137. read -p "Please input a number:(Default 1 press Enter) " ACTION
  138. [ -z "${ACTION}" ] && ACTION=1
  139. if [[ ! "${ACTION}" =~ ^[1,2]$ ]]; then
  140. echo "${CWARNING}input error! Please only input number 1~2${CEND}"
  141. else
  142. break
  143. fi
  144. done
  145. }
  146. while :;do
  147. printf "
  148. What Are You Doing?
  149. \t${CMSG} 1${CEND}. Install/Uninstall PHP opcode cache
  150. \t${CMSG} 2${CEND}. Install/Uninstall ZendGuardLoader/ionCube PHP Extension
  151. \t${CMSG} 3${CEND}. Install/Uninstall ImageMagick/GraphicsMagick PHP Extension
  152. \t${CMSG} 4${CEND}. Install/Uninstall fileinfo PHP Extension
  153. \t${CMSG} 5${CEND}. Install/Uninstall memcached/memcache
  154. \t${CMSG} 6${CEND}. Install/Uninstall Redis
  155. \t${CMSG} 7${CEND}. Install/Uninstall swoole PHP Extension
  156. \t${CMSG} 8${CEND}. Install/Uninstall xdebug PHP Extension
  157. \t${CMSG} 9${CEND}. Install/Uninstall PHP Composer
  158. \t${CMSG}10${CEND}. Install/Uninstall fail2ban
  159. \t${CMSG} q${CEND}. Exit
  160. "
  161. read -p "Please input the correct option: " Number
  162. if [[ ! "${Number}" =~ ^[1-9,q]$|^10$ ]]; then
  163. echo "${CFAILURE}input error! Please only input 1~10 and q${CEND}"
  164. else
  165. case "${Number}" in
  166. 1)
  167. ACTION_FUN
  168. while :; do echo
  169. echo "Please select a opcode cache of the PHP:"
  170. echo -e "\t${CMSG}1${CEND}. Zend OPcache"
  171. echo -e "\t${CMSG}2${CEND}. XCache"
  172. echo -e "\t${CMSG}3${CEND}. APCU"
  173. echo -e "\t${CMSG}4${CEND}. eAccelerator"
  174. read -p "Please input a number:(Default 1 press Enter) " phpcache_option
  175. [ -z "${phpcache_option}" ] && phpcache_option=1
  176. if [[ ! "${phpcache_option}" =~ ^[1-4]$ ]]; then
  177. echo "${CWARNING}input error! Please only input number 1~4${CEND}"
  178. else
  179. case "${phpcache_option}" in
  180. 1)
  181. PHP_extension=opcache
  182. ;;
  183. 2)
  184. PHP_extension=xcache
  185. ;;
  186. 3)
  187. PHP_extension=apcu
  188. ;;
  189. 4)
  190. PHP_extension=eaccelerator
  191. ;;
  192. esac
  193. break
  194. fi
  195. done
  196. if [ "${ACTION}" = '1' ]; then
  197. Check_PHP_Extension
  198. case "${phpcache_option}" in
  199. 1)
  200. pushd ${oneinstack_dir}/src > /dev/null
  201. if [[ "${PHP_main_ver}" =~ ^5.[3-4]$ ]]; then
  202. src_url=https://pecl.php.net/get/zendopcache-${zendopcache_ver}.tgz && Download_src
  203. Install_ZendOPcache
  204. else
  205. src_url=http://www.php.net/distributions/php-${PHP_detail_ver}.tar.gz && Download_src
  206. Install_ZendOPcache
  207. fi
  208. popd
  209. Check_succ
  210. ;;
  211. 2)
  212. if [[ "${PHP_main_ver}" =~ ^5.[3-6]$ ]]; then
  213. while :; do
  214. read -p "Please input xcache admin password: " xcachepwd
  215. (( ${#xcachepwd} >= 5 )) && { xcachepwd_md5=$(echo -n "${xcachepwd}" | md5sum | awk '{print $1}') ; break ; } || echo "${CFAILURE}xcache admin password least 5 characters! ${CEND}"
  216. done
  217. checkDownload
  218. Install_XCache
  219. Check_succ
  220. else
  221. echo "${CWARNING}Your php does not support XCache! ${CEND}"; exit 1
  222. fi
  223. ;;
  224. 3)
  225. if [[ "${PHP_main_ver}" =~ ^5.[3-6]$|^7.[0-2]$ ]]; then
  226. checkDownload
  227. Install_APCU
  228. Check_succ
  229. else
  230. echo "${CWARNING}Your php does not support APCU! ${CEND}"; exit 1
  231. fi
  232. ;;
  233. 4)
  234. if [[ "${PHP_main_ver}" =~ ^5.[3-4]$ ]]; then
  235. checkDownload
  236. Install_eAccelerator
  237. Check_succ
  238. else
  239. echo "${CWARNING}Your php does not support eAccelerator! ${CEND}"; exit 1
  240. fi
  241. ;;
  242. esac
  243. else
  244. Uninstall_succ
  245. fi
  246. ;;
  247. 2)
  248. ACTION_FUN
  249. while :; do echo
  250. echo "Please select ZendGuardLoader/ionCube:"
  251. echo -e "\t${CMSG}1${CEND}. ZendGuardLoader"
  252. echo -e "\t${CMSG}2${CEND}. ionCube Loader"
  253. read -p "Please input a number:(Default 1 press Enter) " Loader
  254. [ -z "${Loader}" ] && Loader=1
  255. if [[ ! "${Loader}" =~ ^[1,2]$ ]]; then
  256. echo "${CWARNING}input error! Please only input number 1~2${CEND}"
  257. else
  258. [ "${Loader}" = '1' ] && PHP_extension=ZendGuardLoader
  259. [ "${Loader}" = '2' ] && PHP_extension=ioncube
  260. break
  261. fi
  262. done
  263. if [ "${ACTION}" = '1' ]; then
  264. Check_PHP_Extension
  265. if [ "${Loader}" = '1' ]; then
  266. if [[ "${PHP_main_ver}" =~ ^5.[3-6]$ ]] && [ "${armplatform}" != 'y' ]; then
  267. zendguardloader_yn='y' && checkDownload
  268. Install_ZendGuardLoader
  269. Check_succ
  270. else
  271. echo; echo "${CWARNING}Your php ${PHP_detail_ver} or platform ${TARGET_ARCH} does not support ${PHP_extension}! ${CEND}";
  272. fi
  273. elif [ "${Loader}" = '2' ]; then
  274. if [[ "${PHP_main_ver}" =~ ^5.[3-6]$|^7.[0-2]$ ]] || [ "${TARGET_ARCH}" != "arm64" ]; then
  275. ioncube_yn='y' && checkDownload
  276. Install_ionCube
  277. Restart_PHP; echo "${CSUCCESS}PHP ioncube module installed successfully! ${CEND}";
  278. else
  279. echo; echo "${CWARNING}Your php ${PHP_detail_ver} or platform ${TARGET_ARCH} does not support ${PHP_extension}! ${CEND}";
  280. fi
  281. fi
  282. else
  283. Uninstall_succ
  284. fi
  285. ;;
  286. 3)
  287. ACTION_FUN
  288. while :; do echo
  289. echo "Please select ImageMagick/GraphicsMagick:"
  290. echo -e "\t${CMSG}1${CEND}. ImageMagick"
  291. echo -e "\t${CMSG}2${CEND}. GraphicsMagick"
  292. read -p "Please input a number:(Default 1 press Enter) " magick_option
  293. [ -z "${magick_option}" ] && magick_option=1
  294. if [[ ! "${magick_option}" =~ ^[1,2]$ ]]; then
  295. echo "${CWARNING}input error! Please only input number 1~2${CEND}"
  296. else
  297. [ "${magick_option}" = '1' ] && PHP_extension=imagick
  298. [ "${magick_option}" = '2' ] && PHP_extension=gmagick
  299. break
  300. fi
  301. done
  302. if [ "${ACTION}" = '1' ]; then
  303. Check_PHP_Extension
  304. magick_yn=y && checkDownload
  305. if [ "${magick_option}" = '1' ]; then
  306. [ ! -d "/usr/local/imagemagick" ] && Install_ImageMagick
  307. Install_php-imagick
  308. Check_succ
  309. elif [ "${magick_option}" = '2' ]; then
  310. [ ! -d "/usr/local/graphicsmagick" ] && Install_GraphicsMagick
  311. Install_php-gmagick
  312. Check_succ
  313. fi
  314. else
  315. Uninstall_succ
  316. [ -d "/usr/local/imagemagick" ] && rm -rf /usr/local/imagemagick
  317. [ -d "/usr/local/graphicsmagick" ] && rm -rf /usr/local/graphicsmagick
  318. fi
  319. ;;
  320. 4)
  321. ACTION_FUN
  322. PHP_extension=fileinfo
  323. if [ "${ACTION}" = '1' ]; then
  324. Check_PHP_Extension
  325. pushd ${oneinstack_dir}/src > /dev/null
  326. src_url=http://www.php.net/distributions/php-${PHP_detail_ver}.tar.gz && Download_src
  327. tar xzf php-${PHP_detail_ver}.tar.gz
  328. pushd php-${PHP_detail_ver}/ext/fileinfo
  329. ${php_install_dir}/bin/phpize
  330. ./configure --with-php-config=${php_install_dir}/bin/php-config
  331. make -j ${THREAD} && make install
  332. popd;popd
  333. rm -rf php-${PHP_detail_ver}
  334. echo "extension=fileinfo.so" > ${php_install_dir}/etc/php.d/04-fileinfo.ini
  335. Check_succ
  336. else
  337. Uninstall_succ
  338. fi
  339. ;;
  340. 5)
  341. ACTION_FUN
  342. while :; do echo
  343. echo "Please select memcache/memcached PHP Extension:"
  344. echo -e "\t${CMSG}1${CEND}. memcache PHP Extension"
  345. echo -e "\t${CMSG}2${CEND}. memcached PHP Extension"
  346. echo -e "\t${CMSG}3${CEND}. memcache/memcached PHP Extension"
  347. read -p "Please input a number:(Default 1 press Enter) " Memcache
  348. [ -z "${Memcache}" ] && Memcache=1
  349. if [[ ! "${Memcache}" =~ ^[1-3]$ ]]; then
  350. echo "${CWARNING}input error! Please only input number 1~3${CEND}"
  351. else
  352. [ "${Memcache}" = '1' ] && PHP_extension=memcache
  353. [ "${Memcache}" = '2' ] && PHP_extension=memcached
  354. break
  355. fi
  356. done
  357. if [ "${ACTION}" = '1' ]; then
  358. memcached_yn=y && checkDownload
  359. case "${Memcache}" in
  360. 1)
  361. [ ! -d "${memcached_install_dir}/include/memcached" ] && Install_memcached
  362. Check_PHP_Extension
  363. Install_php-memcache
  364. Check_succ
  365. ;;
  366. 2)
  367. [ ! -d "${memcached_install_dir}/include/memcached" ] && Install_memcached
  368. Check_PHP_Extension
  369. Install_php-memcached
  370. Check_succ
  371. ;;
  372. 3)
  373. [ ! -d "${memcached_install_dir}/include/memcached" ] && Install_memcached
  374. PHP_extension=memcache && Check_PHP_Extension
  375. Install_php-memcache
  376. PHP_extension=memcached && Check_PHP_Extension
  377. Install_php-memcached
  378. [ -f "${phpExtensionDir}/memcache.so" -a "${phpExtensionDir}/memcached.so" ] && { Restart_PHP; echo;echo "${CSUCCESS}PHP memcache/memcached module installed successfully! ${CEND}"; }
  379. ;;
  380. esac
  381. else
  382. PHP_extension=memcache && Uninstall_succ
  383. PHP_extension=memcached && Uninstall_succ
  384. [ -e "${memcached_install_dir}" ] && { service memcached stop > /dev/null 2>&1; rm -rf ${memcached_install_dir} /etc/init.d/memcached /usr/bin/memcached; }
  385. fi
  386. ;;
  387. 6)
  388. ACTION_FUN
  389. PHP_extension=redis
  390. redis_yn=y && checkDownload
  391. if [ "${ACTION}" = '1' ]; then
  392. [ ! -d "${redis_install_dir}" ] && Install_redis-server
  393. Check_PHP_Extension
  394. Install_php-redis
  395. else
  396. Uninstall_succ
  397. [ -e "${redis_install_dir}" ] && { service redis-server stop > /dev/null 2>&1; rm -rf ${redis_install_dir} /etc/init.d/redis-server /usr/local/bin/redis-*; }
  398. fi
  399. ;;
  400. 7)
  401. ACTION_FUN
  402. PHP_extension=swoole
  403. if [ "${ACTION}" = '1' ]; then
  404. Check_PHP_Extension
  405. pushd ${oneinstack_dir}/src > /dev/null
  406. if [[ "${PHP_main_ver}" =~ ^7\.[0-2]$ ]]; then
  407. src_url=https://pecl.php.net/get/swoole-${swoole_ver}.tgz && Download_src
  408. tar xzf swoole-${swoole_ver}.tgz
  409. pushd swoole-${swoole_ver}
  410. else
  411. src_url=https://pecl.php.net/get/swoole-1.10.1.tgz && Download_src
  412. tar xzf swoole-1.10.1.tgz
  413. pushd swoole-1.10.1
  414. fi
  415. ${php_install_dir}/bin/phpize
  416. ./configure --with-php-config=${php_install_dir}/bin/php-config
  417. make -j ${THREAD} && make install
  418. popd
  419. rm -rf swoole-${swoole_ver}
  420. popd
  421. echo 'extension=swoole.so' > ${php_install_dir}/etc/php.d/06-swoole.ini
  422. Check_succ
  423. else
  424. Uninstall_succ
  425. fi
  426. ;;
  427. 8)
  428. ACTION_FUN
  429. PHP_extension=xdebug
  430. if [ "${ACTION}" = '1' ]; then
  431. Check_PHP_Extension
  432. pushd ${oneinstack_dir}/src > /dev/null
  433. if [[ "${PHP_main_ver}" =~ ^7\.[0-2]$ ]]; then
  434. src_url=https://pecl.php.net/get/xdebug-${xdebug_ver}.tgz && Download_src
  435. src_url=http://mirrors.linuxeye.com/oneinstack/src/webgrind-master.zip && Download_src
  436. tar xzf xdebug-${xdebug_ver}.tgz
  437. unzip -q webgrind-master.zip
  438. /bin/mv webgrind-master ${wwwroot_dir}/default/webgrind
  439. pushd xdebug-${xdebug_ver}
  440. elif [[ "${PHP_main_ver}" =~ ^5\.[5-6]$ ]]; then
  441. src_url=https://pecl.php.net/get/xdebug-2.5.5.tgz && Download_src
  442. src_url=http://mirrors.linuxeye.com/oneinstack/src/webgrind-master.zip && Download_src
  443. tar xzf xdebug-2.5.5.tgz
  444. unzip -q webgrind-master.zip
  445. /bin/mv webgrind-master ${wwwroot_dir}/default/webgrind
  446. pushd xdebug-2.5.5
  447. else
  448. echo "${CWARNING}Need a PHP version >= 5.5.0 and <= 7.2.0${CEND}"
  449. exit 1
  450. fi
  451. ${php_install_dir}/bin/phpize
  452. ./configure --with-php-config=${php_install_dir}/bin/php-config
  453. make -j ${THREAD} && make install
  454. popd
  455. rm -rf xdebug-${xdebug_ver}
  456. popd
  457. [ ! -e /tmp/xdebug ] && { mkdir /tmp/xdebug; chown ${run_user}.${run_user} /tmp/xdebug; }
  458. [ ! -e /tmp/webgrind ] && { mkdir /tmp/webgrind; chown ${run_user}.${run_user} /tmp/webgrind; }
  459. chown -R ${run_user}.${run_user} ${wwwroot_dir}/default/webgrind
  460. sed -i 's@static $storageDir.*@static $storageDir = "/tmp/webgrind";@' ${wwwroot_dir}/default/webgrind/config.php
  461. sed -i 's@static $profilerDir.*@static $profilerDir = "/tmp/xdebug";@' ${wwwroot_dir}/default/webgrind/config.php
  462. cat > ${php_install_dir}/etc/php.d/08-xdebug.ini << EOF
  463. [xdebug]
  464. zend_extension=xdebug.so
  465. xdebug.trace_output_dir=/tmp/xdebug
  466. xdebug.profiler_output_dir = /tmp/xdebug
  467. xdebug.profiler_enable = On
  468. xdebug.profiler_enable_trigger = 1
  469. EOF
  470. Check_succ
  471. echo; echo "Webgrind URL: ${CMSG}http://{Public IP}/webgrind ${CEND}"
  472. else
  473. rm -rf /tmp/{xdebug,webgrind} ${wwwroot_dir}/default/webgrind
  474. Uninstall_succ
  475. fi
  476. ;;
  477. 9)
  478. ACTION_FUN
  479. if [ "${ACTION}" = '1' ]; then
  480. [ -e "/usr/local/bin/composer" ] && { echo "${CWARNING}PHP Composer already installed! ${CEND}"; exit 1; }
  481. if [ "$IPADDR_COUNTRY"x == "CN"x ]; then
  482. wget -c https://dl.laravel-china.org/composer.phar -O /usr/local/bin/composer > /dev/null 2>&1
  483. ${php_install_dir}/bin/php /usr/local/bin/composer config -g repo.packagist composer https://packagist.phpcomposer.com
  484. else
  485. wget -c https://getcomposer.org/composer.phar -O /usr/local/bin/composer > /dev/null 2>&1
  486. fi
  487. chmod +x /usr/local/bin/composer
  488. if [ -e "/usr/local/bin/composer" ]; then
  489. echo; echo "${CSUCCESS}Composer installed successfully! ${CEND}"
  490. else
  491. echo; echo "${CFAILURE}Composer install failed, Please try again! ${CEND}"
  492. fi
  493. else
  494. rm -rf /usr/local/bin/composer
  495. echo; echo "${CMSG}composer uninstall completed${CEND}";
  496. fi
  497. ;;
  498. 10)
  499. ACTION_FUN
  500. if [ "${ACTION}" = '1' ]; then
  501. Install_fail2ban
  502. else
  503. Uninstall_fail2ban
  504. fi
  505. ;;
  506. q)
  507. exit
  508. ;;
  509. esac
  510. fi
  511. done