diff --git a/.gitignore b/.gitignore deleted file mode 100644 index 882ecd60..00000000 --- a/.gitignore +++ /dev/null @@ -1 +0,0 @@ -install.log diff --git a/README.md b/README.md index 7b65cddd..e50aa758 100644 --- a/README.md +++ b/README.md @@ -1,156 +1,133 @@ -## Recommend +[![PayPal donate button](https://img.shields.io/badge/paypal-donate-green.svg)](https://paypal.me/yeho)[![支付宝捐助按钮](https://img.shields.io/badge/%E6%94%AF%E4%BB%98%E5%AE%9D-%E5%90%91TA%E6%8D%90%E5%8A%A9-green.svg)](https://static.oneinstack.com/images/alipay.png)[![微信捐助按钮](https://img.shields.io/badge/%E5%BE%AE%E4%BF%A1-%E5%90%91TA%E6%8D%90%E5%8A%A9-green.svg)](https://static.oneinstack.com/images/weixin.png) -This project no longer adds new features and is only for daily maintenance. It is recommended to use the docker-compose version. Project link: https://github.com/linuxeye/bypanel - -[Aliyun ECS recommend](https://www.aliyun.com/daily-act/ecs/activity_selection?userCode=ird24dsz) - -## lnmp -This script is written using the shell, in order to quickly deploy `LEMP`/`LAMP`/`LNMP`/`LNMPA`/`LTMP`(Linux, Nginx/Tengine/OpenResty, MySQL in a production environment/MariaDB/Percona, PHP, JAVA), applicable to RHEL 7, 8, 9(including CentOS,RedHat,AlmaLinux,Rocky), Debian 9, 10, 11, 12, Ubuntu 16, 18, 20, 22, 24 and Fedora 27+ of 64. +This script is written using the shell, in order to quickly deploy `LEMP`/`LAMP`/`LNMP`/`LNMPA`(Linux, Nginx/Tengine/OpenResty, MySQL in a production environment/MariaDB/Percona, PHP), applicable to CentOS 5~7(including redhat), Debian 6~8, Ubuntu 12~16 of 32 and 64. Script properties: -- Continually updated, Provide Shell Interaction and Autoinstall +- Continually updated - Source compiler installation, most stable source is the latest version, and download from the official site - Some security optimization -- Providing a plurality of database versions (MySQL-8.4, MySQL-8.0, MySQL-5.7, MySQL-5.5, MariaDB-11.8, MariaDB-11.4, MariaDB-10.11, MariaDB-5.5, Percona-8.4, Percona-8.0, Percona-5.7, Percona-5.5, PostgreSQL, MongoDB) -- Providing multiple PHP versions (PHP-8.5, PHP-8.4, PHP-8.3, PHP-8.2, PHP-8.1, PHP-8.0, PHP-7.4, PHP-7.3, PHP-7.2, PHP-7.1, PHP-7.0, PHP-5.6, PHP-5.5, PHP-5.4, PHP-5.3) -- Provide Nginx, Tengine, OpenResty, Apache and ngx_lua_waf -- Providing a plurality of Tomcat version (Tomcat-10, Tomcat-9, Tomcat-8, Tomcat-7) -- Providing a plurality of JDK version (OpenJDK-8, OpenJDK-11, OpenJDK-17) -- According to their needs to install PHP Cache Accelerator provides ZendOPcache, apcu, eAccelerator. And php extensions,include ZendGuardLoader,ionCube,SourceGuardian,imagick,gmagick,fileinfo,imap,ldap,calendar,phalcon,yaf,yar,redis,memcached,memcache,mongodb,swoole,xdebug -- Installation Nodejs, Pureftpd, phpMyAdmin according to their needs +- Providing a plurality of database versions (MySQL-5.7, MySQL-5.6, MySQL-5.5, MariaDB-10.1, MariaDB-10.0, MariaDB-5.5, Percona-5.7, Percona-5.6, Percona-5.5, AliSQL-5.6) +- Providing multiple PHP versions (PHP-7.1, PHP-7.0, PHP-5.6, PHP-5.5, PHP-5.4, PHP-5.3) +- Provide Nginx, Tengine, OpenResty +- Providing a plurality of Apache version (Apache-2.4, Apache-2.2) +- According to their needs to install PHP Cache Accelerator provides ZendOPcache, xcache, apcu, eAccelerator. And php encryption and decryption tool ionCube, ZendGuardLoader +- Installation Pureftpd, phpMyAdmin according to their needs - Install memcached, redis according to their needs - Jemalloc optimize MySQL, Nginx - Providing add a virtual host script, include Let's Encrypt SSL certificate -- Provide Nginx/Tengine/OpenResty/Apache/Tomcat, MySQL/MariaDB/Percona, PHP, Redis, Memcached, phpMyAdmin upgrade script -- Provide local,remote(rsync between servers),Aliyun OSS,Qcloud COS,UPYUN,QINIU,Amazon S3,Google Drive and Dropbox backup script - -## Installation - -Install the dependencies for your distro, download the source and run the installation script. - -#### CentOS/Redhat - -```bash -yum -y install wget screen -``` +- Provide Nginx/Tengine/OpenResty, MySQL/MariaDB/Percona, PHP, Redis, Memcached, phpMyAdmin upgrade script +- Provide local backup and remote backup (rsync between servers) script +- Provided under HHVM install CentOS 6,7 -#### Debian/Ubuntu +## How to use +If your server system: CentOS/Redhat (Do not enter "//" and "// subsequent sentence) ```bash -apt-get -y install wget screen -``` - -#### Download Source and Install - -```bash -wget http://mirrors.linuxeye.com/lnmp-full.tar.gz -# wget https://downloads.sourceforge.net/project/linuxeye/lnmp-full.tar.gz +yum -y install wget screen python // For CentOS / Redhat +wget http://mirrors.linuxeye.com/lnmp-full.tar.gz // Contains the source code tar xzf lnmp-full.tar.gz -cd lnmp -``` - -If you disconnect during installation, you can execute the command `screen -r lnmp` to reconnect to the install window -```bash -screen -S lnmp -``` - -If you need to modify the directory (installation, data storage, Nginx logs), modify `options.conf` file before running install.sh -```bash -./install.sh +cd lnmp // If you need to modify the directory (installation, data storage, Nginx logs), modify options.conf file +screen -S lnmp // if network interruption, you can execute the command `screen -r lnmp` reconnect install window +./install.sh // Do not sh install.sh or bash install.sh such execution ``` - -## How to install another PHP version - +If your server system: Debian/Ubuntu (Do not enter "//" and "// subsequent sentence) ```bash -~/lnmp/install.sh --mphp_ver 54 - +apt-get -y install wget screen python // For Debian / Ubuntu +wget http://mirrors.linuxeye.com/lnmp-full.tar.gz // Contains the source code +tar xzf lnmp-full.tar.gz +cd lnmp // If you need to modify the directory (installation, data storage, Nginx logs), modify options.conf file +screen -S lnmp // if network interruption, you can execute the command `screen -r lnmp` reconnect install window +./install.sh // Do not sh install.sh or bash install.sh such execution ``` ## How to add Extensions ```bash -~/lnmp/addons.sh - +cd ~/lnmp // Must enter the directory execution under lnmp +./addons.sh // Do not sh addons.sh or bash addons.sh such execution ``` ## How to add a virtual host ```bash -~/lnmp/vhost.sh +cd ~/lnmp // Must enter the directory execution under lnmp +./vhost.sh // Do not sh vhost.sh or bash vhost.sh such execution ``` ## How to delete a virtual host ```bash -~/lnmp/vhost.sh --del +cd ~/lnmp +./vhost.sh del ``` -## How to add FTP virtual user +## How to add FTP virtual user ```bash -~/lnmp/pureftpd_vhost.sh +cd ~/lnmp +./pureftpd_vhost.sh ``` ## How to backup ```bash -~/lnmp/backup_setup.sh // Backup parameters -~/lnmp/backup.sh // Perform the backup immediately -crontab -l // Can be added to scheduled tasks, such as automatic backups every day 1:00 - 0 1 * * * cd ~/lnmp/backup.sh > /dev/null 2>&1 & +cd ~/lnmp +./backup_setup.sh // Backup parameters +./backup.sh // Perform the backup immediately +crontab -l // Can be added to scheduled tasks, such as automatic backups every day 1:00 + 0 1 * * * cd ~/lnmp;./backup.sh > /dev/null 2>&1 & ``` ## How to manage service Nginx/Tengine/OpenResty: ```bash -systemctl {start|stop|status|restart|reload} nginx +service nginx {start|stop|status|restart|reload|configtest} ``` MySQL/MariaDB/Percona: ```bash -systemctl {start|stop|restart|reload|status} mysqld -``` -PostgreSQL: -```bash -systemctl {start|stop|restart|status} postgresql -``` -MongoDB: -```bash -systemctl {start|stop|status|restart|reload} mongod +service mysqld {start|stop|restart|reload|status} ``` PHP: ```bash -systemctl {start|stop|restart|reload|status} php-fpm +service php-fpm {start|stop|restart|reload|status} ``` -Apache: +HHVM: ```bash -systemctl {start|restart|stop} httpd +service supervisord {start|stop|status|restart|reload} ``` -Tomcat: +Apache: ```bash -systemctl {start|stop|status|restart} tomcat +service httpd {start|restart|stop} ``` -Pure-FTPd: +Pure-Ftpd: ```bash -systemctl {start|stop|restart|status} pureftpd +service pureftpd {start|stop|restart|status} ``` Redis: ```bash -systemctl {start|stop|status|restart|reload} redis-server +service redis-server {start|stop|status|restart|reload} ``` Memcached: ```bash -systemctl {start|stop|status|restart|reload} memcached +service memcached {start|stop|status|restart|reload} ``` -## How to upgrade +## How to upgrade ```bash -~/lnmp/upgrade.sh +./upgrade.sh ``` -## How to uninstall +## How to uninstall ```bash -~/lnmp/uninstall.sh +./uninstall.sh ``` + +## Installation + +Follow the instructions in [Wiki Installation page](https://github.com/lj2007331/lnmp/wiki/Installation)
+ +For feedback, questions, and to follow the progress of the project (Chinese):
+[lnmp最新源码一键安装脚本](https://blog.linuxeye.com/31.html)
diff --git a/addons.sh b/addons.sh index 1c505213..d1ece37a 100755 --- a/addons.sh +++ b/addons.sh @@ -1,86 +1,186 @@ #!/bin/bash # Author: yeho -# BLOG: https://linuxeye.com +# BLOG: https://blog.linuxeye.com # +# Notes: OneinStack for CentOS/RadHat 5+ Debian 6+ and Ubuntu 12+ # +# Project home page: +# https://oneinstack.com +# https://github.com/lj2007331/oneinstack export PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin clear printf " ####################################################################### +# OneinStack for CentOS/RadHat 5+ Debian 6+ and Ubuntu 12+ # # Install/Uninstall Extensions # +# For more information please visit https://oneinstack.com # ####################################################################### " + # Check if user is root -# shellcheck disable=SC2046 [ $(id -u) != '0' ] && { echo "${CFAILURE}Error: You must be root to run this script${CEND}"; exit 1; } -current_dir=$(dirname "`readlink -f $0`") -# shellcheck disable=SC2164 -pushd ${current_dir} > /dev/null +# get pwd +sed -i "s@^oneinstack_dir.*@oneinstack_dir=$(pwd)@" ./options.conf . ./versions.txt . ./options.conf . ./include/color.sh +. ./include/memory.sh . ./include/check_os.sh +. ./include/check_download.sh . ./include/download.sh . ./include/get_char.sh -. ./include/composer.sh +. ./include/zendopcache.sh +. ./include/xcache.sh +. ./include/apcu.sh +. ./include/eaccelerator.sh -. ./include/fail2ban.sh +. ./include/ZendGuardLoader.sh +. ./include/ioncube.sh -. ./include/ngx_lua_waf.sh +. ./include/ImageMagick.sh +. ./include/GraphicsMagick.sh -# get the out ip country -OUTIP_STATE=$(./include/ois.${ARCH} ip_state) +. ./include/memcached.sh -# shellcheck disable=SC2154 -Show_Help() { - echo - echo "Usage: $0 command ... - --help, -h Show this help message - --install, -i Install - --uninstall, -u Uninstall - --composer Composer - --fail2ban Fail2ban - --ngx_lua_waf Ngx_lua_waf - " -} +. ./include/redis.sh -ARG_NUM=$# -TEMP=`getopt -o hiu --long help,install,uninstall,composer,fail2ban,ngx_lua_waf -- "$@" 2>/dev/null` -[ $? != 0 ] && echo "${CWARNING}ERROR: unknown argument! ${CEND}" && Show_Help && exit 1 -eval set -- "${TEMP}" -while :; do - [ -z "$1" ] && break; - case "$1" in - -h|--help) - Show_Help; exit 0 - ;; - -i|--install) - install_flag=y; shift 1 - ;; - -u|--uninstall) - uninstall_flag=y; shift 1 +. ./include/python.sh + +# Check PHP +if [ -e "${php_install_dir}/bin/phpize" ]; then + phpExtensionDir=$(${php_install_dir}/bin/php-config --extension-dir) + PHP_detail_version=$(${php_install_dir}/bin/php -r 'echo PHP_VERSION;') + PHP_main_version=${PHP_detail_version%.*} + + case "${PHP_main_version}" in + "5.3") + PHP_version=1 ;; - --composer) - composer_flag=y; shift 1 + "5.4") + PHP_version=2 ;; - --fail2ban) - fail2ban_flag=y; shift 1 + "5.5") + PHP_version=3 ;; - --ngx_lua_waf) - ngx_lua_waf_flag=y; shift 1 + "5.6") + PHP_version=4 ;; - --) - shift + "7.0" | "7.1") + PHP_version=5 ;; *) - echo "${CWARNING}ERROR: unknown argument! ${CEND}" && Show_Help && exit 1 + echo "${CFAILURE}Your PHP version ${PHP_main_version} is not supported! ${CEND}" + kill -9 $$ ;; esac -done +fi + +# Check PHP Extensions +Check_PHP_Extension() { + [ -e "${php_install_dir}/etc/php.d/ext-${PHP_extension}.ini" ] && { echo "${CWARNING}PHP ${PHP_extension} module already installed! ${CEND}"; exit 1; } +} + +# restart PHP +Restart_PHP() { + [ -e "${apache_install_dir}/conf/httpd.conf" ] && /etc/init.d/httpd restart || /etc/init.d/php-fpm restart +} + +# Check succ +Check_succ() { + [ -f "${phpExtensionDir}/${PHP_extension}.so" ] && { Restart_PHP; echo;echo "${CSUCCESS}PHP ${PHP_extension} module installed successfully! ${CEND}"; } +} + +# Uninstall succ +Uninstall_succ() { + [ -e "${php_install_dir}/etc/php.d/ext-${PHP_extension}.ini" ] && { rm -rf ${php_install_dir}/etc/php.d/ext-${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}"; } +} + +Install_letsencrypt() { + [ ! -e "${python_install_dir}/bin/python" ] && Install_Python + ${python_install_dir}/bin/pip install certbot + if [ -e "${python_install_dir}/bin/certbot" ]; then + echo; echo "${CSUCCESS}Let's Encrypt client installed successfully! ${CEND}" + else + echo; echo "${CFAILURE}Let's Encrypt client install failed, Please try again! ${CEND}" + fi +} + +Uninstall_letsencrypt() { + ${python_install_dir}/bin/pip uninstall -y certbot > /dev/null 2>&1 + rm -rf /etc/letsencrypt /var/log/letsencrypt /var/lib/letsencrypt ${python_install_dir} + [ "${OS}" == "CentOS" ] && Cron_file=/var/spool/cron/root || Cron_file=/var/spool/cron/crontabs/root + [ -e "$Cron_file" ] && sed -i '/certbot/d' ${Cron_file} + echo; echo "${CMSG}Let's Encrypt client uninstall completed${CEND}"; +} + +Install_fail2ban() { + [ ! -e "${python_install_dir}/bin/python" ] && Install_Python + pushd ${oneinstack_dir}/src + src_url=http://mirrors.linuxeye.com/oneinstack/src/fail2ban-${fail2ban_version}.tar.gz && Download_src + tar xzf fail2ban-${fail2ban_version}.tar.gz + pushd fail2ban-${fail2ban_version} + ${python_install_dir}/bin/python setup.py install + if [ "${OS}" == "CentOS" ]; then + LOGPATH=/var/log/secure + /bin/cp files/redhat-initd /etc/init.d/fail2ban + sed -i "s@^FAIL2BAN=.*@FAIL2BAN=${python_install_dir}/bin/fail2ban-client@" /etc/init.d/fail2ban + sed -i 's@Starting fail2ban.*@&\n [ ! -e "/var/run/fail2ban" ] \&\& mkdir /var/run/fail2ban@' /etc/init.d/fail2ban + chmod +x /etc/init.d/fail2ban + chkconfig --add fail2ban + chkconfig fail2ban on + fi + if [[ "${OS}" =~ ^Ubuntu$|^Debian$ ]]; then + LOGPATH=/var/log/auth.log + /bin/cp files/debian-initd /etc/init.d/fail2ban + sed -i 's@2 3 4 5@3 4 5@' /etc/init.d/fail2ban + sed -i "s@^DAEMON=.*@DAEMON=${python_install_dir}/bin/\$NAME-client@" /etc/init.d/fail2ban + chmod +x /etc/init.d/fail2ban + update-rc.d fail2ban defaults + fi + [ -z "`grep ^Port /etc/ssh/sshd_config`" ] && ssh_port=22 || ssh_port=`grep ^Port /etc/ssh/sshd_config | awk '{print $2}'` + cat > /etc/fail2ban/jail.local << EOF +[DEFAULT] +ignoreip = 127.0.0.1/8 +bantime = 86400 +findtime = 600 +maxretry = 5 +[ssh-iptables] +enabled = true +filter = sshd +action = iptables[name=SSH, port=$ssh_port, protocol=tcp] +logpath = $LOGPATH +EOF + cat > /etc/logrotate.d/fail2ban << EOF +/var/log/fail2ban.log { + missingok + notifempty + postrotate + ${python_install_dir}/bin/fail2ban-client flushlogs >/dev/null || true + endscript +} +EOF + sed -i 's@^iptables = iptables.*@iptables = iptables@' /etc/fail2ban/action.d/iptables-common.conf + kill -9 `ps -ef | grep fail2ban | grep -v grep | awk '{print $2}'` > /dev/null 2>&1 + /etc/init.d/fail2ban start + popd + if [ -e "${python_install_dir}/bin/fail2ban-python" ]; then + echo; echo "${CSUCCESS}fail2ban installed successfully! ${CEND}" + else + echo; echo "${CFAILURE}fail2ban install failed, Please try again! ${CEND}" + fi + popd +} + +Uninstall_fail2ban() { + /etc/init.d/fail2ban stop + ${python_install_dir}/bin/pip uninstall -y fail2ban > /dev/null 2>&1 + rm -rf /etc/init.d/fail2ban /etc/fail2ban /etc/logrotate.d/fail2ban /var/log/fail2ban.* /var/run/fail2ban + echo; echo "${CMSG}fail2ban uninstall completed${CEND}"; +} ACTION_FUN() { while :; do @@ -88,92 +188,295 @@ ACTION_FUN() { echo "Please select an action:" echo -e "\t${CMSG}1${CEND}. install" echo -e "\t${CMSG}2${CEND}. uninstall" - read -e -p "Please input a number:(Default 1 press Enter) " ACTION - ACTION=${ACTION:-1} + read -p "Please input a number:(Default 1 press Enter) " ACTION + [ -z "${ACTION}" ] && ACTION=1 if [[ ! "${ACTION}" =~ ^[1,2]$ ]]; then - echo "${CWARNING}input error! Please only input number 1~2${CEND}" + echo "${CWARNING}input error! Please only input number 1,2${CEND}" else - [ "${ACTION}" == '1' ] && install_flag=y - [ "${ACTION}" == '2' ] && uninstall_flag=y break fi done } -Menu() { - while :;do - printf " +while :;do + printf " What Are You Doing? -\t${CMSG}1${CEND}. Install/Uninstall PHP Composer -\t${CMSG}2${CEND}. Install/Uninstall fail2ban -\t${CMSG}3${CEND}. Install/Uninstall ngx_lua_waf +\t${CMSG}1${CEND}. Install/Uninstall PHP opcode cache +\t${CMSG}2${CEND}. Install/Uninstall ZendGuardLoader/ionCube PHP Extension +\t${CMSG}3${CEND}. Install/Uninstall ImageMagick/GraphicsMagick PHP Extension +\t${CMSG}4${CEND}. Install/Uninstall fileinfo PHP Extension +\t${CMSG}5${CEND}. Install/Uninstall memcached/memcache +\t${CMSG}6${CEND}. Install/Uninstall Redis +\t${CMSG}7${CEND}. Install/Uninstall Let's Encrypt client +\t${CMSG}8${CEND}. Install/Uninstall fail2ban \t${CMSG}q${CEND}. Exit " - read -e -p "Please input the correct option: " Number - if [[ ! "${Number}" =~ ^[1-3,q]$ ]]; then - echo "${CFAILURE}input error! Please only input 1~3 and q${CEND}" - else - case "${Number}" in - 1) - ACTION_FUN - if [ "${install_flag}" = 'y' ]; then - Install_composer - elif [ "${uninstall_flag}" = 'y' ]; then - Uninstall_composer + read -p "Please input the correct option: " Number + if [[ ! "${Number}" =~ ^[1-8,q]$ ]]; then + echo "${CFAILURE}input error! Please only input 1 ~ 8 and q${CEND}" + else + case "${Number}" in + 1) + ACTION_FUN + while :; do echo + echo "Please select a opcode cache of the PHP:" + echo -e "\t${CMSG}1${CEND}. Zend OPcache" + echo -e "\t${CMSG}2${CEND}. XCache" + echo -e "\t${CMSG}3${CEND}. APCU" + echo -e "\t${CMSG}4${CEND}. eAccelerator" + read -p "Please input a number:(Default 1 press Enter) " PHP_cache + [ -z "${PHP_cache}" ] && PHP_cache=1 + if [[ ! "${PHP_cache}" =~ ^[1-4]$ ]]; then + echo "${CWARNING}input error! Please only input number 1,2,3,4${CEND}" + else + case "${PHP_cache}" in + 1) + PHP_extension=opcache + ;; + 2) + PHP_extension=xcache + ;; + 3) + PHP_extension=apcu + ;; + 4) + PHP_extension=eaccelerator + ;; + esac + break fi - ;; - 2) - ACTION_FUN - if [ "${install_flag}" = 'y' ]; then - Install_fail2ban - elif [ "${uninstall_flag}" = 'y' ]; then - Uninstall_fail2ban + done + if [ "${ACTION}" = '1' ]; then + Check_PHP_Extension + if [ -e ${php_install_dir}/etc/php.d/ext-ZendGuardLoader.ini ]; then + echo; echo "${CWARNING}You have to install ZendGuardLoader, You need to uninstall it before install ${PHP_extension}! ${CEND}"; echo; exit 1 + else + case "${PHP_cache}" in + 1) + pushd ${oneinstack_dir}/src + if [[ "${PHP_main_version}" =~ ^5.[3-4]$ ]]; then + src_url=https://pecl.php.net/get/zendopcache-${zendopcache_version}.tgz && Download_src + Install_ZendOPcache + else + src_url=http://www.php.net/distributions/php-${PHP_detail_version}.tar.gz && Download_src + Install_ZendOPcache + fi + popd + Check_succ + ;; + 2) + if [[ ${PHP_main_version} =~ ^5.[3-6]$ ]]; then + while :; do + read -p "Please input xcache admin password: " xcache_admin_pass + (( ${#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}" + done + checkDownload + Install_XCache + Check_succ + else + echo "${CWARNING}Your php does not support XCache! ${CEND}"; exit 1 + fi + ;; + 3) + if [[ "${PHP_main_version}" =~ ^5.[3-6]$|^7.[0-1]$ ]]; then + checkDownload + Install_APCU + Check_succ + else + echo "${CWARNING}Your php does not support APCU! ${CEND}"; exit 1 + fi + ;; + 4) + if [[ "${PHP_main_version}" =~ ^5.[3-4]$ ]]; then + checkDownload + Install_eAccelerator + Check_succ + else + echo "${CWARNING}Your php does not support eAccelerator! ${CEND}"; exit 1 + fi + ;; + esac fi - ;; - 3) - ACTION_FUN - if [ "${install_flag}" = 'y' ]; then - # shellcheck disable=SC2154 - [ -e "${nginx_install_dir}/sbin/nginx" ] && Nginx_lua_waf - # shellcheck disable=SC2154 - [ -e "${tengine_install_dir}/sbin/nginx" ] && Tengine_lua_waf - enable_lua_waf - elif [ "${uninstall_flag}" = 'y' ]; then - disable_lua_waf + else + Uninstall_succ + fi + ;; + 2) + ACTION_FUN + while :; do echo + echo "Please select ZendGuardLoader/ionCube:" + echo -e "\t${CMSG}1${CEND}. ZendGuardLoader" + echo -e "\t${CMSG}2${CEND}. ionCube Loader" + read -p "Please input a number:(Default 1 press Enter) " Loader + [ -z "${Loader}" ] && Loader=1 + if [[ ! "${Loader}" =~ ^[1,2]$ ]]; then + echo "${CWARNING}input error! Please only input number 1,2${CEND}" + else + [ "${Loader}" = '1' ] && PHP_extension=ZendGuardLoader + [ "${Loader}" = '2' ] && PHP_extension=0ioncube + break fi - ;; - q) - exit - ;; - esac - fi - done -} - -if [ ${ARG_NUM} == 0 ]; then - Menu -else - if [ "${composer_flag}" == 'y' ]; then - if [ "${install_flag}" = 'y' ]; then - Install_composer - elif [ "${uninstall_flag}" = 'y' ]; then - Uninstall_composer - fi - fi - if [ "${fail2ban_flag}" == 'y' ]; then - if [ "${install_flag}" = 'y' ]; then - Install_fail2ban - elif [ "${uninstall_flag}" = 'y' ]; then - Uninstall_fail2ban - fi - fi - if [ "${ngx_lua_waf_flag}" == 'y' ]; then - if [ "${install_flag}" = 'y' ]; then - [ -e "${nginx_install_dir}/sbin/nginx" ] && Nginx_lua_waf - [ -e "${tengine_install_dir}/sbin/nginx" ] && Tengine_lua_waf - enable_lua_waf - elif [ "${uninstall_flag}" = 'y' ]; then - disable_lua_waf - fi + done + if [ "${ACTION}" = '1' ]; then + Check_PHP_Extension + if [ "${Loader}" = '1' ]; then + if [[ "${PHP_main_version}" =~ ^5.[3-6]$ ]] || [ "${armPlatform}" != 'y' ]; then + if [ -e ${php_install_dir}/etc/php.d/ext-opcache.ini ]; then + echo; echo "${CWARNING}You have to install OpCache, You need to uninstall it before install ZendGuardLoader! ${CEND}"; echo; exit 1 + else + ZendGuardLoader_yn='y' && checkDownload + Install_ZendGuardLoader + Check_succ + fi + else + echo; echo "${CWARNING}Your php ${PHP_detail_version} or platform ${TARGET_ARCH} does not support ${PHP_extension}! ${CEND}"; + fi + elif [ "${Loader}" = '2' ]; then + if [[ "${PHP_main_version}" =~ ^5.[3-6]$|^7.0$ ]] || [ "${TARGET_ARCH}" != "arm64" ]; then + ionCube_yn='y' && checkDownload + Install_ionCube + Restart_PHP; echo "${CSUCCESS}PHP ioncube module installed successfully! ${CEND}"; + else + echo; echo "${CWARNING}Your php ${PHP_detail_version} or platform ${TARGET_ARCH} does not support ${PHP_extension}! ${CEND}"; + fi + fi + else + Uninstall_succ + fi + ;; + 3) + ACTION_FUN + while :; do echo + echo "Please select ImageMagick/GraphicsMagick:" + echo -e "\t${CMSG}1${CEND}. ImageMagick" + echo -e "\t${CMSG}2${CEND}. GraphicsMagick" + read -p "Please input a number:(Default 1 press Enter) " Magick + [ -z "${Magick}" ] && Magick=1 + if [[ ! "${Magick}" =~ ^[1,2]$ ]]; then + echo "${CWARNING}input error! Please only input number 1,2${CEND}" + else + [ "${Magick}" = '1' ] && PHP_extension=imagick + [ "${Magick}" = '2' ] && PHP_extension=gmagick + break + fi + done + if [ "${ACTION}" = '1' ]; then + Check_PHP_Extension + Magick_yn=y && checkDownload + if [ "${Magick}" = '1' ]; then + [ ! -d "/usr/local/imagemagick" ] && Install_ImageMagick + Install_php-imagick + Check_succ + elif [ "${Magick}" = '2' ]; then + [ ! -d "/usr/local/graphicsmagick" ] && Install_GraphicsMagick + Install_php-gmagick + Check_succ + fi + else + Uninstall_succ + [ -d "/usr/local/imagemagick" ] && rm -rf /usr/local/imagemagick + [ -d "/usr/local/graphicsmagick" ] && rm -rf /usr/local/graphicsmagick + fi + ;; + 4) + ACTION_FUN + PHP_extension=fileinfo + if [ "${ACTION}" = '1' ]; then + Check_PHP_Extension + pushd ${oneinstack_dir}/src + src_url=http://www.php.net/distributions/php-${PHP_detail_version}.tar.gz && Download_src + tar xzf php-${PHP_detail_version}.tar.gz + pushd php-${PHP_detail_version}/ext/fileinfo + ${php_install_dir}/bin/phpize + ./configure --with-php-config=${php_install_dir}/bin/php-config + make -j ${THREAD} && make install + popd;popd + rm -rf php-${PHP_detail_version} + echo "extension=fileinfo.so" > ${php_install_dir}/etc/php.d/ext-fileinfo.ini + Check_succ + else + Uninstall_succ + fi + ;; + 5) + ACTION_FUN + while :; do echo + echo "Please select memcache/memcached PHP Extension:" + echo -e "\t${CMSG}1${CEND}. memcache PHP Extension" + echo -e "\t${CMSG}2${CEND}. memcached PHP Extension" + echo -e "\t${CMSG}3${CEND}. memcache/memcached PHP Extension" + read -p "Please input a number:(Default 1 press Enter) " Memcache + [ -z "${Memcache}" ] && Memcache=1 + if [[ ! "${Memcache}" =~ ^[1-3]$ ]]; then + echo "${CWARNING}input error! Please only input number 1,2,3${CEND}" + else + [ "${Memcache}" = '1' ] && PHP_extension=memcache + [ "${Memcache}" = '2' ] && PHP_extension=memcached + break + fi + done + if [ "${ACTION}" = '1' ]; then + memcached_yn=y && checkDownload + case "${Memcache}" in + 1) + [ ! -d "${memcached_install_dir}/include/memcached" ] && Install_memcached + Check_PHP_Extension + Install_php-memcache + Check_succ + ;; + 2) + [ ! -d "${memcached_install_dir}/include/memcached" ] && Install_memcached + Check_PHP_Extension + Install_php-memcached + Check_succ + ;; + 3) + [ ! -d "${memcached_install_dir}/include/memcached" ] && Install_memcached + PHP_extension=memcache && Check_PHP_Extension + Install_php-memcache + PHP_extension=memcached && Check_PHP_Extension + Install_php-memcached + [ -f "${phpExtensionDir}/memcache.so" -a "${phpExtensionDir}/memcached.so" ] && { Restart_PHP; echo;echo "${CSUCCESS}PHP memcache/memcached module installed successfully! ${CEND}"; } + ;; + esac + else + PHP_extension=memcache && Uninstall_succ + PHP_extension=memcached && Uninstall_succ + [ -e "${memcached_install_dir}" ] && { service memcached stop > /dev/null 2>&1; rm -rf ${memcached_install_dir} /etc/init.d/memcached /usr/bin/memcached; } + fi + ;; + 6) + ACTION_FUN + PHP_extension=redis + redis_yn=y && checkDownload + if [ "${ACTION}" = '1' ]; then + [ ! -d "${redis_install_dir}" ] && Install_redis-server + Check_PHP_Extension + Install_php-redis + else + Uninstall_succ + [ -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-*; } + fi + ;; + 7) + ACTION_FUN + if [ "${ACTION}" = '1' ]; then + Install_letsencrypt + else + Uninstall_letsencrypt + fi + ;; + 8) + ACTION_FUN + if [ "${ACTION}" = '1' ]; then + Install_fail2ban + else + Uninstall_fail2ban + fi + ;; + q) + exit + ;; + esac fi -fi +done diff --git a/backup.sh b/backup.sh index d6531b81..3a89cc15 100755 --- a/backup.sh +++ b/backup.sh @@ -1,293 +1,113 @@ #!/bin/bash # Author: yeho -# BLOG: https://linuxeye.com +# BLOG: https://blog.linuxeye.com # +# Notes: OneinStack for CentOS/RadHat 5+ Debian 6+ and Ubuntu 12+ # - -export PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin +# Project home page: +# https://oneinstack.com +# https://github.com/lj2007331/oneinstack # Check if user is root [ $(id -u) != "0" ] && { echo "${CFAILURE}Error: You must be root to run this script${CEND}"; exit 1; } -current_dir=$(dirname "`readlink -f $0`") -pushd ${current_dir}/tools > /dev/null +pushd tools > /dev/null . ../options.conf -[ ! -e "${backup_dir}" ] && mkdir -p ${backup_dir} DB_Local_BK() { - for D in `echo ${db_name} | tr ',' ' '` + for D in `echo $db_name | tr ',' ' '` do - ./db_bk.sh ${D} + ./db_bk.sh $D done } DB_Remote_BK() { - for D in `echo ${db_name} | tr ',' ' '` + for D in `echo $db_name | tr ',' ' '` do - ./db_bk.sh ${D} - DB_GREP="DB_${D}_`date +%Y%m%d`" - DB_FILE=`ls -lrt ${backup_dir} | grep ${DB_GREP} | tail -1 | awk '{print $NF}'` - echo "file:::${backup_dir}/${DB_FILE} ${backup_dir} push" >> config_backup.txt - echo "com:::[ -e "${backup_dir}/${DB_FILE}" ] && rm -rf ${backup_dir}/DB_${D}_$(date +%Y%m%d --date="${expired_days} days ago")_*.tgz" >> config_backup.txt - done -} - -DB_OSS_BK() { - for D in `echo ${db_name} | tr ',' ' '` - do - ./db_bk.sh ${D} - DB_GREP="DB_${D}_`date +%Y%m%d`" - DB_FILE=`ls -lrt ${backup_dir} | grep ${DB_GREP} | tail -1 | awk '{print $NF}'` - ossutil cp -f ${backup_dir}/${DB_FILE} oss://${oss_bucket}/`date +%F`/${DB_FILE} - if [ $? -eq 0 ]; then - ossutil rm -rf oss://${oss_bucket}/`date +%F --date="${expired_days} days ago"`/ - [ -z "`echo ${backup_destination} | grep -ow 'local'`" ] && rm -f ${backup_dir}/${DB_FILE} - fi + ./db_bk.sh $D + DB_GREP="DB_${D}_`date +%Y`" + DB_FILE=`ls -lrt $backup_dir | grep ${DB_GREP} | tail -1 | awk '{print $NF}'` + echo "file:::$backup_dir/$DB_FILE $backup_dir push" >> config_bakcup.txt + echo "com:::[ -e "$backup_dir/$DB_FILE" ] && rm -rf $backup_dir/DB_${D}_$(date +%Y%m%d --date="$expired_days days ago")_*.tgz" >> config_bakcup.txt done } DB_COS_BK() { - for D in `echo ${db_name} | tr ',' ' '` + for D in `echo $db_name | tr ',' ' '` do - ./db_bk.sh ${D} - DB_GREP="DB_${D}_`date +%Y%m%d`" - DB_FILE=`ls -lrt ${backup_dir} | grep ${DB_GREP} | tail -1 | awk '{print $NF}'` - coscli sync ${backup_dir}/${DB_FILE} cos://${cos_bucket}/`date +%F`/${DB_FILE} - if [ $? -eq 0 ]; then - coscli rm -rf cos://${cos_bucket}/`date +%F --date="${expired_days} days ago"` > /dev/null 2>&1 - [ -z "`echo ${backup_destination} | grep -ow 'local'`" ] && rm -f ${backup_dir}/${DB_FILE} - fi - done -} - -DB_UPYUN_BK() { - for D in `echo ${db_name} | tr ',' ' '` - do - ./db_bk.sh ${D} - DB_GREP="DB_${D}_`date +%Y%m%d`" - DB_FILE=`ls -lrt ${backup_dir} | grep ${DB_GREP} | tail -1 | awk '{print $NF}'` - upx put ${backup_dir}/${DB_FILE} /`date +%F`/${DB_FILE} - if [ $? -eq 0 ]; then - upx rm -a `date +%F --date="${expired_days} days ago"` > /dev/null 2>&1 - [ -z "`echo ${backup_destination} | grep -ow 'local'`" ] && rm -f ${backup_dir}/${DB_FILE} - fi - done -} - -DB_QINIU_BK() { - for D in `echo ${db_name} | tr ',' ' '` - do - ./db_bk.sh ${D} - DB_GREP="DB_${D}_`date +%Y%m%d`" - DB_FILE=`ls -lrt ${backup_dir} | grep ${DB_GREP} | tail -1 | awk '{print $NF}'` - qshell rput ${qiniu_bucket} /`date +%F`/${DB_FILE} ${backup_dir}/${DB_FILE} - if [ $? -eq 0 ]; then - qshell listbucket ${qiniu_bucket} /`date +%F --date="${expired_days} days ago"` /tmp/qiniu.txt > /dev/null 2>&1 - qshell batchdelete -force ${qiniu_bucket} /tmp/qiniu.txt > /dev/null 2>&1 - [ -z "`echo ${backup_destination} | grep -ow 'local'`" ] && rm -f ${backup_dir}/${DB_FILE} - rm -f /tmp/qiniu.txt - fi + ./db_bk.sh $D + DB_GREP="DB_${D}_`date +%Y`" + DB_FILE=`ls -lrt $backup_dir | grep ${DB_GREP} | tail -1 | awk '{print $NF}'` + ${python_install_dir}/bin/python ./coscmd put $backup_dir/$DB_FILE /`date +%F`/$DB_FILE + [ $? -eq 0 ] && ${python_install_dir}/bin/python ./coscmd rm /`date +%F --date="$expired_days days ago"`/ > /dev/null 2>&1 done } -DB_S3_BK() { - for D in `echo ${db_name} | tr ',' ' '` - do - ./db_bk.sh ${D} - DB_GREP="DB_${D}_`date +%Y%m%d`" - DB_FILE=`ls -lrt ${backup_dir} | grep ${DB_GREP} | tail -1 | awk '{print $NF}'` - aws s3 sync ${backup_dir}/${DB_FILE} s3://${s3_bucket}/`date +%F`/${DB_FILE} - if [ $? -eq 0 ]; then - aws s3 rm -r s3://${s3_bucket}/`date +%F --date="${expired_days} days ago"` > /dev/null 2>&1 - [ -z "`echo ${backup_destination} | grep -ow 'local'`" ] && rm -f ${backup_dir}/${DB_FILE} - fi - done -} - -DB_DROPBOX_BK() { - for D in `echo ${db_name} | tr ',' ' '` - do - ./db_bk.sh ${D} - DB_GREP="DB_${D}_`date +%Y%m%d`" - DB_FILE=`ls -lrt ${backup_dir} | grep ${DB_GREP} | tail -1 | awk '{print $NF}'` - dbxcli put ${backup_dir}/${DB_FILE} `date +%F`/${DB_FILE} - if [ $? -eq 0 ]; then - dbxcli rm -f `date +%F --date="${expired_days} days ago"` > /dev/null 2>&1 - [ -z "`echo ${backup_destination} | grep -ow 'local'`" ] && rm -f ${backup_dir}/${DB_FILE} - fi - done -} - -WEB_LOCAL_BK() { - for W in `echo ${website_name} | tr ',' ' '` +WEB_Local_BK() { + for W in `echo $website_name | tr ',' ' '` do ./website_bk.sh $W done } WEB_Remote_BK() { - for W in `echo ${website_name} | tr ',' ' '` + for W in `echo $website_name | tr ',' ' '` do - if [ `du -sm "${wwwroot_dir}/${WebSite}" | awk '{print $1}'` -lt 2048 ]; then + if [ `du -sm "$wwwroot_dir/$WebSite" | awk '{print $1}'` -lt 1024 ];then ./website_bk.sh $W - Web_GREP="Web_${W}_`date +%Y%m%d`" - Web_FILE=`ls -lrt ${backup_dir} | grep ${Web_GREP} | tail -1 | awk '{print $NF}'` - echo "file:::${backup_dir}/${Web_FILE} ${backup_dir} push" >> config_backup.txt - echo "com:::[ -e "${backup_dir}/${Web_FILE}" ] && rm -rf ${backup_dir}/Web_${W}_$(date +%Y%m%d --date="${expired_days} days ago")_*.tgz" >> config_backup.txt + Web_GREP="Web_${W}_`date +%Y`" + Web_FILE=`ls -lrt $backup_dir | grep ${Web_GREP} | tail -1 | awk '{print $NF}'` + echo "file:::$backup_dir/$Web_FILE $backup_dir push" >> config_bakcup.txt + echo "com:::[ -e "$backup_dir/$Web_FILE" ] && rm -rf $backup_dir/Web_${W}_$(date +%Y%m%d --date="$expired_days days ago")_*.tgz" >> config_bakcup.txt else - echo "file:::${wwwroot_dir}/$W ${backup_dir} push" >> config_backup.txt - fi - done -} - -WEB_OSS_BK() { - for W in `echo $website_name | tr ',' ' '` - do - [ ! -e "${wwwroot_dir}/${WebSite}" ] && { echo "[${wwwroot_dir}/${WebSite}] not exist"; break; } - PUSH_FILE="${backup_dir}/Web_${W}_$(date +%Y%m%d_%H).tgz" - if [ ! -e "${PUSH_FILE}" ]; then - pushd ${wwwroot_dir} > /dev/null - tar czf ${PUSH_FILE} ./$W - popd > /dev/null - fi - ossutil cp -f ${PUSH_FILE} oss://${oss_bucket}/`date +%F`/${PUSH_FILE##*/} - if [ $? -eq 0 ]; then - ossutil rm -rf oss://${oss_bucket}/`date +%F --date="${expired_days} days ago"`/ - [ -z "`echo ${backup_destination} | grep -ow 'local'`" ] && rm -f ${PUSH_FILE} + echo "file:::$wwwroot_dir/$W $backup_dir push" >> config_bakcup.txt fi done } WEB_COS_BK() { - for W in `echo ${website_name} | tr ',' ' '` - do - [ ! -e "${wwwroot_dir}/${WebSite}" ] && { echo "[${wwwroot_dir}/${WebSite}] not exist"; break; } - PUSH_FILE="${backup_dir}/Web_${W}_$(date +%Y%m%d_%H).tgz" - if [ ! -e "${PUSH_FILE}" ]; then - pushd ${wwwroot_dir} > /dev/null - tar czf ${PUSH_FILE} ./$W - popd > /dev/null - fi - coscli sync ${PUSH_FILE} cos://${cos_bucket}/`date +%F`/${PUSH_FILE##*/} - if [ $? -eq 0 ]; then - coscli rm -rf cos://${cos_bucket}/`date +%F --date="${expired_days} days ago"` > /dev/null 2>&1 - [ -z "`echo ${backup_destination} | grep -ow 'local'`" ] && rm -f ${PUSH_FILE} - fi - done -} - -WEB_UPYUN_BK() { - for W in `echo ${website_name} | tr ',' ' '` - do - [ ! -e "${wwwroot_dir}/${WebSite}" ] && { echo "[${wwwroot_dir}/${WebSite}] not exist"; break; } - [ ! -e "${backup_dir}" ] && mkdir -p ${backup_dir} - PUSH_FILE="${backup_dir}/Web_${W}_$(date +%Y%m%d_%H).tgz" - if [ ! -e "${PUSH_FILE}" ]; then - pushd ${wwwroot_dir} > /dev/null - tar czf ${PUSH_FILE} ./$W - popd > /dev/null - fi - upx put ${PUSH_FILE} /`date +%F`/${PUSH_FILE##*/} - if [ $? -eq 0 ]; then - upx rm -a `date +%F --date="${expired_days} days ago"` > /dev/null 2>&1 - [ -z "`echo ${backup_destination} | grep -ow 'local'`" ] && rm -f ${PUSH_FILE} - fi - done -} - -WEB_QINIU_BK() { - for W in `echo ${website_name} | tr ',' ' '` - do - [ ! -e "${wwwroot_dir}/${WebSite}" ] && { echo "[${wwwroot_dir}/${WebSite}] not exist"; break; } - [ ! -e "${backup_dir}" ] && mkdir -p ${backup_dir} - PUSH_FILE="${backup_dir}/Web_${W}_$(date +%Y%m%d_%H).tgz" - if [ ! -e "${PUSH_FILE}" ]; then - pushd ${wwwroot_dir} > /dev/null - tar czf ${PUSH_FILE} ./$W - popd > /dev/null - fi - qshell rput ${qiniu_bucket} /`date +%F`/${PUSH_FILE##*/} ${PUSH_FILE} - if [ $? -eq 0 ]; then - qshell listbucket ${qiniu_bucket} /`date +%F --date="${expired_days} days ago"` /tmp/qiniu.txt > /dev/null 2>&1 - qshell batchdelete -force ${qiniu_bucket} /tmp/qiniu.txt > /dev/null 2>&1 - [ -z "`echo ${backup_destination} | grep -ow 'local'`" ] && rm -f ${PUSH_FILE} - rm -f /tmp/qiniu.txt - fi - done -} - -WEB_S3_BK() { - for W in `echo ${website_name} | tr ',' ' '` - do - [ ! -e "${wwwroot_dir}/${WebSite}" ] && { echo "[${wwwroot_dir}/${WebSite}] not exist"; break; } - [ ! -e "${backup_dir}" ] && mkdir -p ${backup_dir} - PUSH_FILE="${backup_dir}/Web_${W}_$(date +%Y%m%d_%H).tgz" - if [ ! -e "${PUSH_FILE}" ]; then - pushd ${wwwroot_dir} > /dev/null - tar czf ${PUSH_FILE} ./$W - popd > /dev/null - fi - aws s3 sync ${PUSH_FILE} s3://${s3_bucket}/`date +%F`/${PUSH_FILE##*/} - if [ $? -eq 0 ]; then - aws s3 rm -r s3://${s3_bucket}/`date +%F --date="${expired_days} days ago"` > /dev/null 2>&1 - [ -z "`echo ${backup_destination} | grep -ow 'local'`" ] && rm -f ${PUSH_FILE} - fi - done -} - -WEB_DROPBOX_BK() { - for W in `echo ${website_name} | tr ',' ' '` + for W in `echo $website_name | tr ',' ' '` do - [ ! -e "${wwwroot_dir}/${WebSite}" ] && { echo "[${wwwroot_dir}/${WebSite}] not exist"; break; } - [ ! -e "${backup_dir}" ] && mkdir -p ${backup_dir} - PUSH_FILE="${backup_dir}/Web_${W}_$(date +%Y%m%d_%H).tgz" - if [ ! -e "${PUSH_FILE}" ]; then - pushd ${wwwroot_dir} > /dev/null - tar czf ${PUSH_FILE} ./$W - popd > /dev/null - fi - dbxcli put ${PUSH_FILE} `date +%F`/${PUSH_FILE##*/} - if [ $? -eq 0 ]; then - dbxcli rm -f `date +%F --date="${expired_days} days ago"` > /dev/null 2>&1 - [ -z "`echo ${backup_destination} | grep -ow 'local'`" ] && rm -f ${PUSH_FILE} - fi - done -} - -for DEST in `echo ${backup_destination} | tr ',' ' '` -do - if [ "${DEST}" == 'local' ]; then - [ -n "`echo ${backup_content} | grep -ow db`" ] && DB_Local_BK - [ -n "`echo ${backup_content} | grep -ow web`" ] && WEB_LOCAL_BK - fi - if [ "${DEST}" == 'remote' ]; then - echo "com:::[ ! -e "${backup_dir}" ] && mkdir -p ${backup_dir}" > config_backup.txt - [ -n "`echo ${backup_content} | grep -ow db`" ] && DB_Remote_BK - [ -n "`echo ${backup_content} | grep -ow web`" ] && WEB_Remote_BK - ./mabs.sh -c config_backup.txt -T -1 | tee -a mabs.log - fi - if [ "${DEST}" == 'oss' ]; then - [ -n "`echo ${backup_content} | grep -ow db`" ] && DB_OSS_BK - [ -n "`echo ${backup_content} | grep -ow web`" ] && WEB_OSS_BK - fi - if [ "${DEST}" == 'cos' ]; then - [ -n "`echo ${backup_content} | grep -ow db`" ] && DB_COS_BK - [ -n "`echo ${backup_content} | grep -ow web`" ] && WEB_COS_BK - fi - if [ "${DEST}" == 'upyun' ]; then - [ -n "`echo ${backup_content} | grep -ow db`" ] && DB_UPYUN_BK - [ -n "`echo ${backup_content} | grep -ow web`" ] && WEB_UPYUN_BK - fi - if [ "${DEST}" == 'qiniu' ]; then - [ -n "`echo ${backup_content} | grep -ow db`" ] && DB_QINIU_BK - [ -n "`echo ${backup_content} | grep -ow web`" ] && WEB_QINIU_BK - fi - if [ "${DEST}" == 's3' ]; then - [ -n "`echo ${backup_content} | grep -ow db`" ] && DB_S3_BK - [ -n "`echo ${backup_content} | grep -ow web`" ] && WEB_S3_BK - fi - if [ "${DEST}" == 'dropbox' ]; then - [ -n "`echo ${backup_content} | grep -ow db`" ] && DB_DROPBOX_BK - [ -n "`echo ${backup_content} | grep -ow web`" ] && WEB_DROPBOX_BK - fi -done + [ ! -e "$wwwroot_dir/$WebSite" ] && { echo "[$wwwroot_dir/$WebSite] not exist"; break; } + PUSH_FILE="$backup_dir/Web_${W}_$(date +%Y%m%d_%H).tgz" + if [ ! -e "$PUSH_FILE" ]; then + pushd $wwwroot_dir + tar czf $PUSH_FILE ./$W + popd + fi + ${python_install_dir}/bin/python ./coscmd put $PUSH_FILE /`date +%F`/Web_${W}_$(date +%Y%m%d_%H).tgz + [ $? -eq 0 ] && { [ -e "$PUSH_FILE" ] && rm -rf $PUSH_FILE; ${python_install_dir}/bin/python ./coscmd rm /`date +%F --date="$expired_days days ago"`/ > /dev/null 2>&1; } + done +} + +if [ "$backup_destination" == 'local' ]; then + [ -n "`echo $backup_content | grep -ow db`" ] && DB_Local_BK + [ -n "`echo $backup_content | grep -ow web`" ] && WEB_Local_BK +elif [ "$backup_destination" == 'remote' ]; then + echo "com:::[ ! -e "$backup_dir" ] && mkdir -p $backup_dir" > config_bakcup.txt + [ -n "`echo $backup_content | grep -ow db`" ] && DB_Remote_BK + [ -n "`echo $backup_content | grep -ow web`" ] && WEB_Remote_BK + ./mabs.sh -c config_bakcup.txt -T -1 | tee mabs.log +elif [ "$backup_destination" == 'cos' ]; then + [ -n "`echo $backup_content | grep -ow db`" ] && DB_COS_BK + [ -n "`echo $backup_content | grep -ow web`" ] && WEB_COS_BK +elif [ "$backup_destination" == 'local,remote' ]; then + echo "com:::[ ! -e "$backup_dir" ] && mkdir -p $backup_dir" > config_bakcup.txt + [ -n "`echo $backup_content | grep -ow db`" ] && DB_Local_BK + [ -n "`echo $backup_content | grep -ow web`" ] && WEB_Local_BK + [ -n "`echo $backup_content | grep -ow db`" ] && DB_Remote_BK + [ -n "`echo $backup_content | grep -ow web`" ] && WEB_Remote_BK + ./mabs.sh -c config_bakcup.txt -T -1 | tee mabs.log +elif [ "$backup_destination" == 'local,cos' ]; then + [ -n "`echo $backup_content | grep -ow db`" ] && DB_Local_BK + [ -n "`echo $backup_content | grep -ow db`" ] && DB_COS_BK + [ -n "`echo $backup_content | grep -ow web`" ] && WEB_Local_BK + [ -n "`echo $backup_content | grep -ow web`" ] && WEB_COS_BK +elif [ "$backup_destination" == 'remote,cos' ]; then + echo "com:::[ ! -e "$backup_dir" ] && mkdir -p $backup_dir" > config_bakcup.txt + [ -n "`echo $backup_content | grep -ow db`" ] && DB_Remote_BK + [ -n "`echo $backup_content | grep -ow db`" ] && DB_COS_BK + [ -n "`echo $backup_content | grep -ow web`" ] && WEB_Remote_BK + [ -n "`echo $backup_content | grep -ow web`" ] && WEB_COS_BK + ./mabs.sh -c config_bakcup.txt -T -1 | tee mabs.log +fi diff --git a/backup_setup.sh b/backup_setup.sh index 1c5aad6c..94fba0bd 100755 --- a/backup_setup.sh +++ b/backup_setup.sh @@ -1,551 +1,210 @@ #!/bin/bash # Author: yeho -# BLOG: https://linuxeye.com +# BLOG: https://blog.linuxeye.com # +# Notes: OneinStack for CentOS/RadHat 5+ Debian 6+ and Ubuntu 12+ # +# Project home page: +# https://oneinstack.com +# https://github.com/lj2007331/oneinstack export PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin clear printf " ####################################################################### +# OneinStack for CentOS/RadHat 5+ Debian 6+ and Ubuntu 12+ # # Setup the backup parameters # +# For more information please visit https://oneinstack.com # ####################################################################### " -# Check if user is root -[ $(id -u) != "0" ] && { echo "${CFAILURE}Error: You must be root to run this script${CEND}"; exit 1; } +# get pwd +sed -i "s@^oneinstack_dir.*@oneinstack_dir=$(pwd)@" ./options.conf -current_dir=$(dirname "`readlink -f $0`") -pushd ${current_dir} > /dev/null . ./options.conf . ./versions.txt . ./include/color.sh -. ./include/check_os.sh . ./include/check_dir.sh . ./include/download.sh +. ./include/python.sh + +# Check if user is root +[ $(id -u) != "0" ] && { echo "${CFAILURE}Error: You must be root to run this script${CEND}"; exit 1; } while :; do echo echo 'Please select your backup destination:' - echo -e "\t${CMSG}1${CEND}. Localhost" - echo -e "\t${CMSG}2${CEND}. Remote host" - echo -e "\t${CMSG}3${CEND}. Aliyun OSS" - echo -e "\t${CMSG}4${CEND}. Qcloud COS" - echo -e "\t${CMSG}5${CEND}. UPYUN" - echo -e "\t${CMSG}6${CEND}. QINIU" - echo -e "\t${CMSG}7${CEND}. Amazon S3" - echo -e "\t${CMSG}8${CEND}. Dropbox" - read -e -p "Please input numbers:(Default 1 press Enter) " desc_bk - desc_bk=${desc_bk:-'1'} - array_desc=(${desc_bk}) - array_all=(1 2 3 4 5 6 7 8) - for v in ${array_desc[@]} - do - [ -z "`echo ${array_all[@]} | grep -w ${v}`" ] && desc_flag=1 - done - if [ "${desc_flag}" == '1' ]; then - unset desc_flag - echo; echo "${CWARNING}input error! Please only input number 1 3 4 and so on${CEND}"; echo - continue + echo -e "\t${CMSG}1${CEND}. Only Localhost" + echo -e "\t${CMSG}2${CEND}. Only Remote host" + echo -e "\t${CMSG}3${CEND}. Only Qcloud COS" + echo -e "\t${CMSG}4${CEND}. Localhost and Remote host" + echo -e "\t${CMSG}5${CEND}. Localhost and Qcloud COS" + echo -e "\t${CMSG}6${CEND}. Remote host and Qcloud COS" + read -p "Please input a number:(Default 1 press Enter) " DESC_BK + [ -z "$DESC_BK" ] && DESC_BK=1 + if [[ ! $DESC_BK =~ ^[1-6]$ ]]; then + echo "${CWARNING}input error! Please only input number 1,2,3,4,5,6${CEND}" else - sed -i 's@^backup_destination=.*@backup_destination=@' ./options.conf break fi done -[ -n "`echo ${desc_bk} | grep -w 1`" ] && sed -i 's@^backup_destination=.*@backup_destination=local@' ./options.conf -[ -n "`echo ${desc_bk} | grep -w 2`" ] && sed -i 's@^backup_destination=.*@&,remote@' ./options.conf -[ -n "`echo ${desc_bk} | grep -w 3`" ] && sed -i 's@^backup_destination=.*@&,oss@' ./options.conf -[ -n "`echo ${desc_bk} | grep -w 4`" ] && sed -i 's@^backup_destination=.*@&,cos@' ./options.conf -[ -n "`echo ${desc_bk} | grep -w 5`" ] && sed -i 's@^backup_destination=.*@&,upyun@' ./options.conf -[ -n "`echo ${desc_bk} | grep -w 6`" ] && sed -i 's@^backup_destination=.*@&,qiniu@' ./options.conf -[ -n "`echo ${desc_bk} | grep -w 7`" ] && sed -i 's@^backup_destination=.*@&,s3@' ./options.conf -[ -n "`echo ${desc_bk} | grep -w 8`" ] && sed -i 's@^backup_destination=.*@&,dropbox@' ./options.conf -sed -i 's@^backup_destination=,@backup_destination=@' ./options.conf +[ "$DESC_BK" == '1' ] && sed -i 's@^backup_destination=.*@backup_destination=local@' ./options.conf +[ "$DESC_BK" == '2' ] && sed -i 's@^backup_destination=.*@backup_destination=remote@' ./options.conf +[ "$DESC_BK" == '3' ] && sed -i 's@^backup_destination=.*@backup_destination=cos@' ./options.conf +[ "$DESC_BK" == '4' ] && sed -i 's@^backup_destination=.*@backup_destination=local,remote@' ./options.conf +[ "$DESC_BK" == '5' ] && sed -i 's@^backup_destination=.*@backup_destination=local,cos@' ./options.conf +[ "$DESC_BK" == '6' ] && sed -i 's@^backup_destination=.*@backup_destination=Remote,cos@' ./options.conf while :; do echo echo 'Please select your backup content:' echo -e "\t${CMSG}1${CEND}. Only Database" echo -e "\t${CMSG}2${CEND}. Only Website" echo -e "\t${CMSG}3${CEND}. Database and Website" - read -e -p "Please input a number:(Default 1 press Enter) " content_bk - content_bk=${content_bk:-1} - if [[ ! ${content_bk} =~ ^[1-3]$ ]]; then - echo "${CWARNING}input error! Please only input number 1~3${CEND}" + read -p "Please input a number:(Default 1 press Enter) " CONTENT_BK + [ -z "$CONTENT_BK" ] && CONTENT_BK=1 + if [[ ! $CONTENT_BK =~ ^[1-3]$ ]]; then + echo "${CWARNING}input error! Please only input number 1,2,3${CEND}" else break fi done -[ "${content_bk}" == '1' ] && sed -i 's@^backup_content=.*@backup_content=db@' ./options.conf -[ "${content_bk}" == '2' ] && sed -i 's@^backup_content=.*@backup_content=web@' ./options.conf -[ "${content_bk}" == '3' ] && sed -i 's@^backup_content=.*@backup_content=db,web@' ./options.conf +[ "$CONTENT_BK" == '1' ] && sed -i 's@^backup_content=.*@backup_content=db@' ./options.conf +[ "$CONTENT_BK" == '2' ] && sed -i 's@^backup_content=.*@backup_content=web@' ./options.conf +[ "$CONTENT_BK" == '3' ] && sed -i 's@^backup_content=.*@backup_content=db,web@' ./options.conf -if [ -n "`echo ${desc_bk} | grep -Ew '1|2'`" ]; then +if [ "$DESC_BK" != '3' ]; then while :; do echo echo "Please enter the directory for save the backup file: " - read -e -p "(Default directory: ${backup_dir}): " new_backup_dir - new_backup_dir=${new_backup_dir:-${backup_dir}} - if [ -z "`echo ${new_backup_dir}| grep '^/'`" ]; then + read -p "(Default directory: $backup_dir): " NEW_backup_dir + [ -z "$NEW_backup_dir" ] && NEW_backup_dir="$backup_dir" + if [ -z "`echo $NEW_backup_dir| grep '^/'`" ]; then echo "${CWARNING}input error! ${CEND}" else break fi done - sed -i "s@^backup_dir=.*@backup_dir=${new_backup_dir}@" ./options.conf + sed -i "s@^backup_dir=.*@backup_dir=$NEW_backup_dir@" ./options.conf fi while :; do echo - echo "Please enter a valid backup number of days: " - read -e -p "(Default days: 5): " expired_days - expired_days=${expired_days:-5} - [ -n "`echo ${expired_days} | sed -n "/^[0-9]\+$/p"`" ] && break || echo "${CWARNING}input error! Please only enter numbers! ${CEND}" + echo "Pleas enter a valid backup number of days: " + read -p "(Default days: 5): " expired_days + [ -z "$expired_days" ] && expired_days=5 + [ -n "`echo $expired_days | sed -n "/^[0-9]\+$/p"`" ] && break || echo "${CWARNING}input error! Please only enter numbers! ${CEND}" done -sed -i "s@^expired_days=.*@expired_days=${expired_days}@" ./options.conf +sed -i "s@^expired_days=.*@expired_days=$expired_days@" ./options.conf -if [ "${content_bk}" != '2' ]; then - databases=`${db_install_dir}/bin/mysql -uroot -p$dbrootpwd -e "show databases\G" | grep Database | awk '{print $2}' | grep -Evw "(performance_schema|information_schema|mysql|sys)"` +if [ "$CONTENT_BK" != '2' ]; then + databases=`$db_install_dir/bin/mysql -uroot -p$dbrootpwd -e "show databases\G" | grep Database | awk '{print $2}' | grep -Evw "(performance_schema|information_schema|mysql|sys)"` while :; do echo echo "Please enter one or more name for database, separate multiple database names with commas: " - read -e -p "(Default database: `echo $databases | tr ' ' ','`) " db_name - db_name=`echo ${db_name} | tr -d ' '` - [ -z "${db_name}" ] && db_name="`echo $databases | tr ' ' ','`" + read -p "(Default database: `echo $databases | tr ' ' ','`) " db_name + db_name=`echo $db_name | tr -d ' '` + [ -z "$db_name" ] && db_name="`echo $databases | tr ' ' ','`" D_tmp=0 - for D in `echo ${db_name} | tr ',' ' '` + for D in `echo $db_name | tr ',' ' '` do [ -z "`echo $databases | grep -w $D`" ] && { echo "${CWARNING}$D was not exist! ${CEND}" ; D_tmp=1; } done [ "$D_tmp" != '1' ] && break done - sed -i "s@^db_name=.*@db_name=${db_name}@" ./options.conf + sed -i "s@^db_name=.*@db_name=$db_name@" ./options.conf fi -if [ "${content_bk}" != '1' ]; then - websites=`ls ${wwwroot_dir}` +if [ "$CONTENT_BK" != '1' ]; then + websites=`ls $wwwroot_dir | grep -vw default` while :; do echo echo "Please enter one or more name for website, separate multiple website names with commas: " - read -e -p "(Default website: `echo $websites | tr ' ' ','`) " website_name - website_name=`echo ${website_name} | tr -d ' '` - [ -z "${website_name}" ] && website_name="`echo $websites | tr ' ' ','`" + read -p "(Default website: `echo $websites | tr ' ' ','`) " website_name + website_name=`echo $website_name | tr -d ' '` + [ -z "$website_name" ] && website_name="`echo $websites | tr ' ' ','`" W_tmp=0 - for W in `echo ${website_name} | tr ',' ' '` + for W in `echo $website_name | tr ',' ' '` do - [ ! -e "${wwwroot_dir}/$W" ] && { echo "${CWARNING}${wwwroot_dir}/$W not exist! ${CEND}" ; W_tmp=1; } + [ ! -e "$wwwroot_dir/$W" ] && { echo "${CWARNING}$wwwroot_dir/$W not exist! ${CEND}" ; W_tmp=1; } done [ "$W_tmp" != '1' ] && break done - sed -i "s@^website_name=.*@website_name=${website_name}@" ./options.conf + sed -i "s@^website_name=.*@website_name=$website_name@" ./options.conf fi echo echo "You have to backup the content:" -[ "${content_bk}" != '2' ] && echo "Database: ${CMSG}${db_name}${CEND}" -[ "${content_bk}" != '1' ] && echo "Website: ${CMSG}${website_name}${CEND}" +[ "$CONTENT_BK" != '2' ] && echo "Database: ${CMSG}$db_name${CEND}" +[ "$CONTENT_BK" != '1' ] && echo "Website: ${CMSG}$website_name${CEND}" -if [ -n "`echo ${desc_bk} | grep -w 2`" ]; then +if [[ "$DESC_BK" =~ ^[2,4,6]$ ]]; then > tools/iplist.txt while :; do echo - read -e -p "Please enter the remote host address: " remote_address - [ -z "${remote_address}" -o "${remote_address}" == '127.0.0.1' ] && continue + read -p "Please enter the remote host ip: " remote_ip + [ -z "$remote_ip" -o "$remote_ip" == '127.0.0.1' ] && continue echo - read -e -p "Please enter the remote host port(Default: 22) : " remote_port - remote_port=${remote_port:-22} + read -p "Please enter the remote host port(Default: 22) : " remote_port + [ -z "$remote_port" ] && remote_port=22 echo - read -e -p "Please enter the remote host user(Default: root) : " remote_user - remote_user=${remote_user:-root} + read -p "Please enter the remote host user(Default: root) : " remote_user + [ -z "$remote_user" ] && remote_user=root echo - read -e -p "Please enter the remote host password: " remote_password - IPcode=$(echo "ibase=16;$(echo "${remote_address}" | xxd -ps -u)"|bc|tr -d '\\'|tr -d '\n') - Portcode=$(echo "ibase=16;$(echo "${remote_port}" | xxd -ps -u)"|bc|tr -d '\\'|tr -d '\n') + read -p "Please enter the remote host password: " remote_password + IPcode=$(echo "ibase=16;$(echo "$remote_ip" | xxd -ps -u)"|bc|tr -d '\\'|tr -d '\n') + Portcode=$(echo "ibase=16;$(echo "$remote_port" | xxd -ps -u)"|bc|tr -d '\\'|tr -d '\n') PWcode=$(echo "ibase=16;$(echo "$remote_password" | xxd -ps -u)"|bc|tr -d '\\'|tr -d '\n') - [ -e "~/.ssh/known_hosts" ] && grep ${remote_address} ~/.ssh/known_hosts | sed -i "/${remote_address}/d" ~/.ssh/known_hosts - ./tools/mssh.exp ${IPcode}P ${remote_user} ${PWcode}P ${Portcode}P true 10 + [ -e "~/.ssh/known_hosts" ] && grep $remote_ip ~/.ssh/known_hosts | sed -i "/$remote_ip/d" ~/.ssh/known_hosts + ./tools/mssh.exp ${IPcode}P $remote_user ${PWcode}P ${Portcode}P true 10 if [ $? -eq 0 ]; then - [ -z "`grep ${remote_address} tools/iplist.txt`" ] && echo "${remote_address} ${remote_port} ${remote_user} $remote_password" >> tools/iplist.txt || echo "${CWARNING}${remote_address} has been added! ${CEND}" + [ -z "`grep $remote_ip tools/iplist.txt`" ] && echo "$remote_ip $remote_port $remote_user $remote_password" >> tools/iplist.txt || echo "${CWARNING}$remote_ip has been added! ${CEND}" while :; do - read -e -p "Do you want to add more host ? [y/n]: " morehost_flag - if [[ ! ${morehost_flag} =~ ^[y,n]$ ]]; then + read -p "Do you want to add more host ? [y/n]: " more_host_yn + if [ "$more_host_yn" != 'y' -a "$more_host_yn" != 'n' ]; then echo "${CWARNING}input error! Please only input 'y' or 'n'${CEND}" else break fi done - [ "${morehost_flag}" == 'n' ] && break + [ "$more_host_yn" == 'n' ] && break fi done fi -if [ -n "`echo ${desc_bk} | grep -w 3`" ]; then - if [ ! -e "/usr/local/bin/ossutil" ]; then - curl -sSL https://gosspublic.alicdn.com/ossutil/install.sh | sudo bash - fi +if [[ "$DESC_BK" =~ ^[3,5,6]$ ]]; then + [ ! -e "${python_install_dir}/bin/python" ] && Install_Python + [ ! -e "${python_install_dir}/lib/python2.7/site-packages/requests" ] && ${python_install_dir}/bin/pip install requests while :; do echo - echo 'Please select your backup aliyun datacenter:' - echo -e "\t ${CMSG}1${CEND}. cn-hangzhou-华东1 (杭州) ${CMSG}2${CEND}. cn-shanghai-华东2 (上海)" - echo -e "\t ${CMSG}3${CEND}. cn-nanjing-华东5 (南京) ${CMSG}4${CEND}. cn-fuzhou-华东6 (福州)" - echo -e "\t ${CMSG}5${CEND}. cn-wuhan-华中1 (武汉) ${CMSG}6${CEND}. cn-qingdao-华北1 (青岛)" - echo -e "\t ${CMSG}7${CEND}. cn-beijing-华北2 (北京) ${CMSG}8${CEND}. cn-zhangjiakou-华北3 (张家口)" - echo -e "\t ${CMSG}9${CEND}. cn-huhehaote-华北5 (呼和浩特) ${CMSG}10${CEND}. cn-wulanchabu-华北6 (乌兰察布)" - echo -e "\t${CMSG}11${CEND}. cn-shenzhen-华南1 (深圳) ${CMSG}12${CEND}. cn-heyuan-华南2 (河源)" - echo -e "\t${CMSG}13${CEND}. cn-guangzhou-华南3 (广州) ${CMSG}14${CEND}. cn-chengdu-西南1 (成都)" - echo -e "\t${CMSG}15${CEND}. cn-hongkong-香港 ${CMSG}16${CEND}. us-west-1-美国 (硅谷)" - echo -e "\t${CMSG}17${CEND}. us-east-1-美国 (弗吉尼亚) ${CMSG}16${CEND}. ap-northeast-1-日本 (东京)" - echo -e "\t${CMSG}19${CEND}. ap-northeast-2-韩国 (首尔) ${CMSG}20${CEND}. ap-southeast-1-新加坡" - echo -e "\t${CMSG}21${CEND}. ap-southeast-3-马来西亚 (吉隆坡) ${CMSG}22${CEND}. ap-southeast-5-印度尼西亚 (雅加达)" - echo -e "\t${CMSG}23${CEND}. ap-southeast-6-菲律宾 (马尼拉) ${CMSG}24${CEND}. ap-southeast-7-泰国 (曼谷)" - echo -e "\t${CMSG}25${CEND}. eu-central-1-德国 (法兰克福) ${CMSG}26${CEND}. eu-west-1-英国 (伦敦)" - echo -e "\t${CMSG}27${CEND}. me-east-1-阿联酋 (迪拜)" - read -e -p "Please input a number:(Default 1 press Enter) " Location - Location=${Location:-1} - if [[ "${Location}" =~ ^[1-9]$|^1[0-9]$|^2[0-7]$ ]]; then + echo 'Please select your backup datacenter:' + echo -e "\t ${CMSG}1${CEND}. 华南(广州) ${CMSG}2${CEND}. 华北(天津)" + echo -e "\t ${CMSG}3${CEND}. 华东(上海) ${CMSG}4${CEND}. 新加坡" + read -p "Please input a number:(Default 1 press Enter) " Location + [ -z "$Location" ] && Location=1 + if [ ${Location} -ge 1 >/dev/null 2>&1 -a ${Location} -le 4 >/dev/null 2>&1 ]; then break else - echo "${CWARNING}input error! Please only input number 1~27${CEND}" + echo "${CWARNING}input error! Please only input number 1,2,3,4${CEND}" fi done - [ "${Location}" == '1' ] && Host=oss-cn-hangzhou-internal.aliyuncs.com - [ "${Location}" == '2' ] && Host=oss-cn-shanghai-internal.aliyuncs.com - [ "${Location}" == '3' ] && Host=oss-cn-nanjing-internal.aliyuncs.com - [ "${Location}" == '4' ] && Host=oss-cn-fuzhou-internal.aliyuncs.com - [ "${Location}" == '5' ] && Host=oss-cn-wuhan-lr-internal.aliyuncs.com - [ "${Location}" == '6' ] && Host=oss-cn-qingdao-internal.aliyuncs.com - [ "${Location}" == '7' ] && Host=oss-cn-beijing-internal.aliyuncs.com - [ "${Location}" == '8' ] && Host=oss-cn-zhangjiakou-internal.aliyuncs.com - [ "${Location}" == '9' ] && Host=oss-cn-huhehaote-internal.aliyuncs.com - [ "${Location}" == '10' ] && Host=oss-cn-wulanchabu-internal.aliyuncs.com - [ "${Location}" == '11' ] && Host=oss-cn-shenzhen-internal.aliyuncs.com - [ "${Location}" == '12' ] && Host=oss-cn-heyuan-internal.aliyuncs.com - [ "${Location}" == '13' ] && Host=oss-cn-guangzhou-internal.aliyuncs.com - [ "${Location}" == '14' ] && Host=oss-cn-chengdu-internal.aliyuncs.com - [ "${Location}" == '15' ] && Host=oss-cn-hongkong-internal.aliyuncs.com - [ "${Location}" == '16' ] && Host=oss-us-west-1-internal.aliyuncs.com - [ "${Location}" == '17' ] && Host=oss-us-east-1-internal.aliyuncs.com - [ "${Location}" == '18' ] && Host=oss-ap-northeast-1-internal.aliyuncs.com - [ "${Location}" == '19' ] && Host=oss-ap-northeast-2-internal.aliyuncs.com - [ "${Location}" == '20' ] && Host=oss-ap-southeast-1-internal.aliyuncs.com - [ "${Location}" == '21' ] && Host=oss-ap-southeast-3-internal.aliyuncs.com - [ "${Location}" == '22' ] && Host=oss-ap-southeast-5-internal.aliyuncs.com - [ "${Location}" == '23' ] && Host=oss-ap-southeast-6-internal.aliyuncs.com - [ "${Location}" == '24' ] && Host=oss-ap-southeast-7-internal.aliyuncs.com - [ "${Location}" == '25' ] && Host=oss-eu-central-1-internal.aliyuncs.com - [ "${Location}" == '26' ] && Host=oss-eu-west-1-internal.aliyuncs.com - [ "${Location}" == '27' ] && Host=oss-me-east-1-internal.aliyuncs.com - [ "$(./include/ois.${ARCH} conn_port --host ${Host} --port 80)" == "false" ] && Host=`echo ${Host} | sed 's@-internal@@g'` - [ -e "/root/.ossutilconfig" ] && rm -f /root/.ossutilconfig + [ "$Location" == '1' ] && region=gz + [ "$Location" == '2' ] && region=tj + [ "$Location" == '3' ] && region=sh + [ "$Location" == '4' ] && region=sgp while :; do echo - read -e -p "Please enter the aliyun oss Access Key ID: " KeyID - [ -z "${KeyID}" ] && continue + read -p "Please enter the Qcloud COS appid: " appid + [ -z "$appid" ] && continue echo - read -e -p "Please enter the aliyun oss Access Key Secret: " KeySecret - [ -z "${KeySecret}" ] && continue - ossutil ls -e ${Host} -i ${KeyID} -k ${KeySecret} > /dev/null 2>&1 - if [ $? -eq 0 ]; then - ossutil config -e ${Host} -i ${KeyID} -k ${KeySecret} > /dev/null 2>&1 - while :; do echo - read -e -p "Please enter the aliyun oss bucket: " OSS_BUCKET - ossutil mb oss://${OSS_BUCKET} > /dev/null 2>&1 - if [ $? -eq 0 ]; then - echo "${CMSG}Bucket oss://${OSS_BUCKET}/ created${CEND}" - sed -i "s@^oss_bucket=.*@oss_bucket=${OSS_BUCKET}@" ./options.conf - break - else - echo "${CWARNING}[${OSS_BUCKET}] already exists, You need to use the OSS Console to create a bucket for storing.${CEND}" - fi - done - break - fi - done -fi - -if [ -n "`echo ${desc_bk} | grep -w 4`" ]; then - if [ ! -e "/usr/local/bin/coscli" ]; then - wget -qc https://cosbrowser.cloud.tencent.com/software/coscli/coscli-linux -O /usr/local/bin/coscli - chmod +x /usr/local/bin/coscli - fi - - while :; do echo - echo 'Please select your backup qcloud datacenter:' - echo -e "\t ${CMSG} 1${CEND}. ap-beijing-北京 ${CMSG}2${CEND}. ap-nanjing-南京" - echo -e "\t ${CMSG} 3${CEND}. ap-shanghai-上海 ${CMSG}4${CEND}. ap-guangzhou-广州" - echo -e "\t ${CMSG} 5${CEND}. ap-chengdu-成都 ${CMSG}6${CEND}. ap-chongqing-重庆" - echo -e "\t ${CMSG} 7${CEND}. ap-shenzhen-fsi-深圳金融 ${CMSG}8${CEND}. ap-shanghai-fsi-上海金融" - echo -e "\t ${CMSG} 9${CEND}. ap-beijing-fsi-北京金融 ${CMSG}10${CEND}. ap-hongkong-香港" - echo -e "\t ${CMSG}11${CEND}. ap-singapore-新加坡 ${CMSG}12${CEND}. ap-mumbai-孟买" - echo -e "\t ${CMSG}13${CEND}. ap-jakarta-雅加达 ${CMSG}14${CEND}. ap-seoul-首尔" - echo -e "\t ${CMSG}15${CEND}. ap-bangkok-曼谷 ${CMSG}16${CEND}. ap-tokyo-东京" - echo -e "\t ${CMSG}17${CEND}. na-siliconvalley-硅谷 ${CMSG}18${CEND}. na-ashburn-弗吉尼亚" - echo -e "\t ${CMSG}19${CEND}. na-toronto-多伦多 ${CMSG}20${CEND}. sa-saopaulo-圣保罗" - echo -e "\t ${CMSG}21${CEND}. eu-frankfurt-法兰克福" - read -e -p "Please input a number:(Default 1 press Enter) " Location - Location=${Location:-1} - if [[ "${Location}" =~ ^[1-9]$|^1[0-9]$|^2[0-1]$ ]]; then - break - else - echo "${CWARNING}input error! Please only input number 1~21${CEND}" - fi - done - [ "${Location}" == '1' ] && REGION='ap-beijing' - [ "${Location}" == '2' ] && REGION='ap-nanjing' - [ "${Location}" == '3' ] && REGION='ap-shanghai' - [ "${Location}" == '4' ] && REGION='ap-guangzhou' - [ "${Location}" == '5' ] && REGION='ap-chengdu' - [ "${Location}" == '6' ] && REGION='ap-chongqing' - [ "${Location}" == '7' ] && REGION='ap-shenzhen-fsi' - [ "${Location}" == '8' ] && REGION='ap-shanghai-fsi' - [ "${Location}" == '9' ] && REGION='ap-beijing-fsi' - [ "${Location}" == '10' ] && REGION='ap-hongkong' - [ "${Location}" == '11' ] && REGION='ap-singapore' - [ "${Location}" == '12' ] && REGION='ap-mumbai' - [ "${Location}" == '13' ] && REGION='ap-jakarta' - [ "${Location}" == '14' ] && REGION='ap-seoul' - [ "${Location}" == '15' ] && REGION='ap-bangkok' - [ "${Location}" == '16' ] && REGION='ap-tokyo' - [ "${Location}" == '17' ] && REGION='na-siliconvalley' - [ "${Location}" == '18' ] && REGION='na-ashburn' - [ "${Location}" == '19' ] && REGION='na-toronto' - [ "${Location}" == '20' ] && REGION='sa-saopaulo' - [ "${Location}" == '21' ] && REGION='eu-frankfurt' - while :; do echo - read -e -p "Please enter the Qcloud COS SECRET_ID: " SECRET_ID - [ -z "${SECRET_ID}" ] && continue - echo - read -e -p "Please enter the Qcloud COS SECRET_KEY: " SECRET_KEY - [ -z "${SECRET_KEY}" ] && continue - echo - read -e -p "Please enter the Qcloud COS BUCKET: " COS_BUCKET - [ -z "${COS_BUCKET}" ] && continue - cat > ~/.cos.yaml << EOF -cos: - base: - secretid: ${SECRET_ID} - secretkey: ${SECRET_KEY} - protocol: https - buckets: - - name: ${COS_BUCKET} - endpoint: cos.${REGION}.myqcloud.com -EOF - coscli ls cos://${COS_BUCKET} > /dev/null 2>&1 - if [ $? -eq 0 ]; then - echo "${CMSG}SECRET_ID/SECRET_KEY/REGION/BUCKET OK${CEND}" - sed -i "s@^cos_bucket=.*@cos_bucket=${COS_BUCKET}@" ./options.conf - echo - break - else - coscli mb cos://${COS_BUCKET} -e cos.${REGION}.myqcloud.com > /dev/null 2>&1 - if [ $? -eq 0 ]; then - echo "${CMSG}Bucket ${COS_BUCKET} created${CEND}" - sed -i "s@^cos_bucket=.*@cos_bucket=${COS_BUCKET}@" ./options.conf - echo - break - else - echo "${CWARNING}input error! SECRET_ID/SECRET_KEY/REGION/BUCKET invalid${CEND}" - continue - fi - fi - done -fi - -if [ -n "`echo ${desc_bk} | grep -w 5`" ]; then - if [ ! -e "/usr/local/bin/upx" ]; then - if [ "${armplatform}" == 'y' ]; then - wget -qc https://collection.b0.upaiyun.com/softwares/upx/upx_0.4.8_linux_arm64.tar.gz -O /tmp/upx_0.4.8_linux_arm64.tar.gz - tar xzf /tmp/upx_0.4.8_linux_arm64.tar.gz -C /tmp/ - else - wget -qc https://collection.b0.upaiyun.com/softwares/upx/upx_0.4.8_linux_amd64.tar.gz -O /tmp/upx_0.4.8_linux_x86_64.tar.gz - tar xzf /tmp/upx_0.4.8_linux_x86_64.tar.gz -C /tmp/ - fi - /bin/mv /tmp/upx /usr/local/bin/upx - chmod +x /usr/local/bin/upx - rm -f /tmp/{upx_*,LICENSE,README.md} - fi - while :; do echo - read -e -p "Please enter the upyun ServiceName: " ServiceName - [ -z "${ServiceName}" ] && continue - echo - read -e -p "Please enter the upyun Operator: " Operator - [ -z "${Operator}" ] && continue - echo - read -e -p "Please enter the upyun Password: " Password - [ -z "${Password}" ] && continue - echo - upx login ${ServiceName} ${Operator} ${Password} > /dev/null 2>&1 - if [ $? = 0 ]; then - echo "${CMSG}ServiceName/Operator/Password OK${CEND}" - echo - break - else - echo "${CWARNING}input error! ServiceName/Operator/Password invalid${CEND}" - fi - done -fi - -if [ -n "`echo ${desc_bk} | grep -w 6`" ]; then - if [ ! -e "/usr/local/bin/qshell" ]; then - if [ "${armplatform}" == 'y' ]; then - wget -qc https://github.com/qiniu/qshell/releases/download/v2.15.0/qshell-v2.15.0-linux-arm64.tar.gz -O /tmp/qshell-v2.15.0-linux-arm64.tar.gz - tar xzf /tmp/qshell-v2.15.0-linux-arm64.tar.gz -C /usr/local/bin/ - else - wget -qc https://github.com/qiniu/qshell/releases/download/v2.15.0/qshell-v2.15.0-linux-amd64.tar.gz -O /tmp/qshell-v2.15.0-linux-amd64.tar.gz - tar xzf qshell-v2.15.0-linux-amd64.tar.gz -C /usr/local/bin/ - fi - chmod +x /usr/local/bin/qshell - rm -f /tmp/qshell* - fi - while :; do echo - echo 'Please select your backup qiniu datacenter:' - echo -e "\t ${CMSG} 1${CEND}. 华东 ${CMSG}2${CEND}. 华北" - echo -e "\t ${CMSG} 3${CEND}. 华南 ${CMSG}4${CEND}. 北美" - echo -e "\t ${CMSG} 5${CEND}. 东南亚 ${CMSG}6${CEND}. 华东-浙江2" - read -e -p "Please input a number:(Default 1 press Enter) " Location - Location=${Location:-1} - if [[ "${Location}" =~ ^[1-6]$ ]]; then - break - else - echo "${CWARNING}input error! Please only input number 1~6${CEND}" - fi - done - [ "${Location}" == '1' ] && zone='z0' - [ "${Location}" == '2' ] && zone='z1' - [ "${Location}" == '3' ] && zone='z2' - [ "${Location}" == '4' ] && zone='na0' - [ "${Location}" == '5' ] && zone='as0' - [ "${Location}" == '6' ] && zone='cn-east-2' - while :; do echo - read -e -p "Please enter the qiniu AccessKey: " AccessKey - [ -z "${AccessKey}" ] && continue + read -p "Please enter the Qcloud COS secret id: " secret_id + [ -z "$secret_id" ] && continue echo - read -e -p "Please enter the qiniu SecretKey: " SecretKey - [ -z "${SecretKey}" ] && continue + read -p "Please enter the Qcloud COS secret key: " secret_key + [ -z "$secret_key" ] && continue echo - read -e -p "Please enter the qiniu bucket: " QINIU_BUCKET - [ -z "${QINIU_BUCKET}" ] && continue + read -p "Please enter the Qcloud COS bucket: " bucket + [ -z "$bucket" ] && continue echo - qshell account ${AccessKey} ${SecretKey} backup - if qshell buckets | grep -w ${QINIU_BUCKET} > /dev/null 2>&1; then - sed -i "s@^qiniu_bucket=.*@qiniu_bucket=${QINIU_BUCKET}@" ./options.conf - echo "${CMSG}AccessKey/SecretKey/Bucket OK${CEND}" + $python_install_dir/bin/python ./tools/coscmd config --appid=$appid --id=$secret_id --key=$secret_key --region=$region --bucket=$bucket >/dev/null 2>&1 + if [ "`$python_install_dir/bin/python ./tools/coscmd ls /`" == 'True' ];then + echo "${CMSG}appid/secret_id/secret_key/region/bucket OK${CEND}" echo break else - echo "${CWARNING}input error! AccessKey/SecretKey/Bucket invalid${CEND}" - fi - done -fi - -if [ -n "`echo ${desc_bk} | grep -w 7`" ]; then - if [ ! -e "/usr/local/bin/aws" ] && [ ! -e "/usr/bin/aws" ]; then - wget -qc https://awscli.amazonaws.com/awscli-exe-linux-$(arch).zip -O /tmp/awscliv2.zip - unzip /tmp/awscliv2.zip -d /tmp/ - /tmp/aws/install - rm -rf /tmp/{awscliv2.zip,aws} - fi - while :; do echo - echo 'Please select your backup amazon datacenter:' - echo -e "\t ${CMSG} 1${CEND}. us-east-2 ${CMSG} 2${CEND}. us-east-1" - echo -e "\t ${CMSG} 3${CEND}. us-west-1 ${CMSG} 4${CEND}. us-west-2" - echo -e "\t ${CMSG} 5${CEND}. af-south-1 ${CMSG} 6${CEND}. ap-east-1" - echo -e "\t ${CMSG} 7${CEND}. ap-south-2 ${CMSG} 8${CEND}. ap-southeast-3" - echo -e "\t ${CMSG} 9${CEND}. ap-southeast-4 ${CMSG}10${CEND}. ap-south-1" - echo -e "\t ${CMSG}11${CEND}. ap-northeast-3 ${CMSG}12${CEND}. ap-northeast-2" - echo -e "\t ${CMSG}13${CEND}. ap-southeast-1 ${CMSG}14${CEND}. ap-southeast-2" - echo -e "\t ${CMSG}15${CEND}. ap-northeast-1 ${CMSG}16${CEND}. ca-central-1" - echo -e "\t ${CMSG}17${CEND}. eu-central-1 ${CMSG}18${CEND}. eu-west-1" - echo -e "\t ${CMSG}19${CEND}. eu-west-2 ${CMSG}20${CEND}. eu-south-1" - echo -e "\t ${CMSG}21${CEND}. eu-west-3 ${CMSG}22${CEND}. eu-south-2" - echo -e "\t ${CMSG}23${CEND}. eu-north-1 ${CMSG}24${CEND}. eu-central-2" - echo -e "\t ${CMSG}25${CEND}. me-south-1 ${CMSG}26${CEND}. me-central-1" - echo -e "\t ${CMSG}27${CEND}. sa-east-1 ${CMSG}28${CEND}. us-gov-east-1" - echo -e "\t ${CMSG}29${CEND}. us-gov-west-1 ${CMSG}30${CEND}. cn-north-1" - echo -e "\t ${CMSG}31${CEND}. cn-northwest-1" - read -e -p "Please input a number:(Default 1 press Enter) " Location - Location=${Location:-1} - if [[ "${Location}" =~ ^[1-9]$|^[1-2][0-9]$|^3[0-1]$ ]]; then - break - else - echo "${CWARNING}input error! Please only input number 1~31${CEND}" - fi - done - [ "${Location}" == '1' ] && REGION='us-east-2' - [ "${Location}" == '2' ] && REGION='us-east-1' - [ "${Location}" == '3' ] && REGION='us-west-1' - [ "${Location}" == '4' ] && REGION='us-west-2' - [ "${Location}" == '5' ] && REGION='af-south-1' - [ "${Location}" == '6' ] && REGION='ap-east-1' - [ "${Location}" == '7' ] && REGION='ap-south-2' - [ "${Location}" == '8' ] && REGION='ap-southeast-3' - [ "${Location}" == '9' ] && REGION='ap-southeast-4' - [ "${Location}" == '10' ] && REGION='ap-south-1' - [ "${Location}" == '11' ] && REGION='ap-northeast-3' - [ "${Location}" == '12' ] && REGION='ap-northeast-2' - [ "${Location}" == '13' ] && REGION='ap-southeast-1' - [ "${Location}" == '14' ] && REGION='ap-southeast-2' - [ "${Location}" == '15' ] && REGION='ap-northeast-1' - [ "${Location}" == '16' ] && REGION='ca-central-1' - [ "${Location}" == '17' ] && REGION='eu-central-1' - [ "${Location}" == '18' ] && REGION='eu-west-1' - [ "${Location}" == '19' ] && REGION='eu-west-2' - [ "${Location}" == '20' ] && REGION='eu-south-1' - [ "${Location}" == '21' ] && REGION='eu-west-3' - [ "${Location}" == '22' ] && REGION='eu-south-2' - [ "${Location}" == '23' ] && REGION='eu-north-1' - [ "${Location}" == '24' ] && REGION='eu-central-2' - [ "${Location}" == '25' ] && REGION='me-south-1' - [ "${Location}" == '26' ] && REGION='me-central-1' - [ "${Location}" == '27' ] && REGION='sa-east-1' - [ "${Location}" == '28' ] && REGION='us-gov-east-1' - [ "${Location}" == '29' ] && REGION='us-gov-west-1' - [ "${Location}" == '30' ] && REGION='cn-north-1' - [ "${Location}" == '31' ] && REGION='cn-northwest-1' - while :; do echo - read -e -p "Please enter the AWS Access Key: " ACCESS_KEY - [ -z "${ACCESS_KEY}" ] && continue - echo - read -e -p "Please enter the AWS Access Key: " SECRET_KEY - [ -z "${SECRET_KEY}" ] && continue - aws configure set aws_access_key_id ${ACCESS_KEY} - aws configure set aws_secret_access_key ${SECRET_KEY} - aws configure set region ${REGION} - aws sts get-caller-identity > /dev/null 2>&1 - if [ $? -eq 0 ]; then - echo "${CMSG}ACCESS_KEY/SECRET_KEY OK${CEND}" - while :; do echo - read -e -p "Please enter the Amazon S3 bucket: " S3_BUCKET - [ -z "${S3_BUCKET}" ] && continue - aws s3 ls s3://${S3_BUCKET} > /dev/null 2>&1 - if [ $? -eq 0 ]; then - echo "${CMSG}Bucket s3://${S3_BUCKET}/ existed${CEND}" - sed -i "s@^s3_bucket=.*@s3_bucket=${S3_BUCKET}@" ./options.conf - break - else - aws s3 mb s3://${S3_BUCKET} > /dev/null 2>&1 - if [ $? -eq 0 ]; then - echo "${CMSG}Bucket s3://${S3_BUCKET}/ created${CEND}" - sed -i "s@^s3_bucket=.*@s3_bucket=${S3_BUCKET}@" ./options.conf - break - else - echo "${CWARNING}The requested bucket name is not available. The bucket namespace is shared by all users of the system. Please select a different name and try again.${CEND}" - continue - fi - fi - done - break - else - echo "${CWARNING}input error! ACCESS_KEY/SECRET_KEY invalid${CEND}" - continue - fi - done -fi - -if [ -n "`echo ${desc_bk} | grep -w 8`" ]; then - if [ ! -e "/usr/local/bin/dbxcli" ]; then - if [ "${armplatform}" == 'y' ]; then - wget -qc ${mirror_link}/src/dbxcli-linux-arm -O /usr/local/bin/dbxcli - else - wget -qc ${mirror_link}/src/dbxcli-linux-amd64 -O /usr/local/bin/dbxcli - fi - chmod +x /usr/local/bin/dbxcli - fi - while :; do echo - if dbxcli account; then - break + echo "${CWARNING}input error! appid/secret_id/secret_key/region/bucket invalid${CEND}" fi done fi diff --git a/config/cloudflare.conf b/config/cloudflare.conf deleted file mode 100644 index ac462ea3..00000000 --- a/config/cloudflare.conf +++ /dev/null @@ -1,25 +0,0 @@ -set_real_ip_from 103.21.244.0/22; -set_real_ip_from 103.22.200.0/22; -set_real_ip_from 103.31.4.0/22; -set_real_ip_from 104.16.0.0/12; -set_real_ip_from 108.162.192.0/18; -set_real_ip_from 131.0.72.0/22; -set_real_ip_from 141.101.64.0/18; -set_real_ip_from 162.158.0.0/15; -set_real_ip_from 172.64.0.0/13; -set_real_ip_from 173.245.48.0/20; -set_real_ip_from 188.114.96.0/20; -set_real_ip_from 190.93.240.0/20; -set_real_ip_from 197.234.240.0/22; -set_real_ip_from 198.41.128.0/17; -set_real_ip_from 2400:cb00::/32; -set_real_ip_from 2606:4700::/32; -set_real_ip_from 2803:f800::/32; -set_real_ip_from 2405:b500::/32; -set_real_ip_from 2405:8100::/32; -set_real_ip_from 2c0f:f248::/32; -set_real_ip_from 2a06:98c0::/29; - -# use any of the following two -real_ip_header CF-Connecting-IP; -#real_ip_header X-Forwarded-For; diff --git a/config/codeigniter.conf b/config/codeigniter.conf deleted file mode 100644 index ac112d41..00000000 --- a/config/codeigniter.conf +++ /dev/null @@ -1,3 +0,0 @@ -location / { - try_files $uri $uri/ /index.php?/$request_uri; -} diff --git a/config/drupal.conf b/config/drupal.conf index a4de4e9c..0bba6612 100644 --- a/config/drupal.conf +++ b/config/drupal.conf @@ -1,4 +1,3 @@ if (!-e $request_filename) { - rewrite ^/update.php(.*)$ /update.php?q=$1 last; rewrite ^/(.*)$ /index.php?q=$1 last; } diff --git a/config/index.html b/config/index.html index 1a88f041..751a24d8 100644 --- a/config/index.html +++ b/config/index.html @@ -1,293 +1,37 @@ - - - + + - - - LNMP - LEMP stack/LAMP stack/LNMP stack installation scripts for CentOS/Redhat Debian and Ubuntu - - + +OneinStack - A PHP/JAVA Deployment Tool + + + - -
-
- -
- -
-
-

LNMP

-

{{ translations[currentLanguage].subtitle }}

-
- -
- {{ translations[currentLanguage].demoWarning }} -
- -
-
-
{{ feature.icon }}
-

{{ feature.title }}

-

{{ feature.description }}

-
-
- - - - -
- -
-
-
- - +
+
+

Congratulations, OneinStack installed successfully!

+

OneinStack Linux+Nginx/Tengine+MySQL/MariaDB/Percona
+PHP+Pureftpd+phpMyAdmin+redis+memcached+jemalloc.

+

Check environment:  Proberv phpinfo Opcache phpMyAdmin

+

Create Web virtual running script:  ./vhost.sh

+

Create FTP virtual running script:  ./pureftpd_vhost.sh

+

For feedback, questions, and to follow the progress of the project:   https://oneinstack.com

+

Author email:  

+

Donate:    

+

          Paypal:  lj2007331@gmail.com   Alipay:  lj2007331@gmail.com

+
+

OneinStack by LinuxEye

+
- diff --git a/config/index_cn.html b/config/index_cn.html new file mode 100644 index 00000000..7dde0d4f --- /dev/null +++ b/config/index_cn.html @@ -0,0 +1,38 @@ + + + + +OneinStack - PHP/JAVA环境一键部署工具 + + + + + +
+
+

恭喜您,OneinStack 安装成功!

+

OneinStack Linux+Nginx/Tengine+MySQL/MariaDB/Percona+PHP
+Pureftpd+phpMyAdmin+redis+memcached+jemalloc脚本中用到的软件包大多最新稳定版本,修复了一些安全性问题。

+

查看本地环境:  探针 phpinfo Opcache phpMyAdmin(为了更安全,建议重命名 phpMyAdmin 目录!)

+

创建 WEB 虚拟主机执行脚本:  ./vhost.sh

+

创建 FTP 虚拟账号执行脚本:  ./pureftpd_vhost.sh

+

Github 项目地址:  https://github.com/lj2007331/oneinstack

+

OneinStack 官网:  https://oneinstack.com

+

QQ 群:  558540514(付费千人群) 262601796(新)

+

赞助我们:    

+

          Paypal:  lj2007331@gmail.com   支付宝:  lj2007331@gmail.com

+
+

OneinStack by Linux 运维笔记

+
+ + diff --git a/config/magento2.conf b/config/magento2.conf index ed3615c7..5b3708bb 100644 --- a/config/magento2.conf +++ b/config/magento2.conf @@ -1,14 +1,14 @@ server { listen 80; - server_name linuxeye.com; - set $MAGE_ROOT /data/wwwroot/default; + server_name oneinstack.com; + set $MAGE_ROOT /data/wwwroot/default; root $MAGE_ROOT/pub; index index.php; autoindex off; charset UTF-8; error_page 404 403 /errors/404.php; #add_header "X-UA-Compatible" "IE=Edge"; - + # PHP entry point for setup application location ~* ^/setup($|/) { root $MAGE_ROOT; @@ -19,16 +19,16 @@ server { fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; include fastcgi_params; } - + location ~ ^/setup/(?!pub/). { deny all; } - + location ~ ^/setup/pub/ { add_header X-Frame-Options "SAMEORIGIN"; } } - + # PHP entry point for update application location ~* ^/update($|/) { root $MAGE_ROOT; @@ -40,21 +40,21 @@ server { fastcgi_param PATH_INFO $fastcgi_path_info; include fastcgi_params; } - + # Deny everything but index.php location ~ ^/update/(?!pub/). { deny all; } - + location ~ ^/update/pub/ { add_header X-Frame-Options "SAMEORIGIN"; } } - + location / { try_files $uri $uri/ /index.php?$args; } - + location /pub/ { location ~ ^/pub/media/(downloadable|customer|import|theme_customization/.*\.xml) { deny all; @@ -62,7 +62,7 @@ server { alias $MAGE_ROOT/pub/; add_header X-Frame-Options "SAMEORIGIN"; } - + location /static/ { # Uncomment the following line in production mode # expires max; @@ -70,7 +70,7 @@ server { location ~ ^/static/version { rewrite ^/static/(version\d*/)?(.*)$ /static/$2 last; } - + location ~* \.(ico|jpg|jpeg|png|gif|svg|js|css|swf|eot|ttf|otf|woff|woff2)$ { add_header Cache-Control "public"; add_header X-Frame-Options "SAMEORIGIN"; @@ -94,13 +94,13 @@ server { } add_header X-Frame-Options "SAMEORIGIN"; } - + location /media/ { try_files $uri $uri/ /get.php?$args; location ~ ^/media/theme_customization/.*\.xml { deny all; } - + location ~* \.(ico|jpg|jpeg|png|gif|svg|js|css|swf|eot|ttf|otf|woff|woff2)$ { add_header Cache-Control "public"; add_header X-Frame-Options "SAMEORIGIN"; @@ -115,35 +115,35 @@ server { } add_header X-Frame-Options "SAMEORIGIN"; } - + location /media/customer/ { deny all; } - + location /media/downloadable/ { deny all; } - + location /media/import/ { deny all; } - + # PHP entry point for main application location ~ (index|get|static|report|404|503)\.php$ { try_files $uri =404; fastcgi_pass unix:/dev/shm/php-cgi.sock; fastcgi_buffers 1024 4k; - + fastcgi_param PHP_FLAG "session.auto_start=off \n suhosin.session.cryptua=off"; fastcgi_param PHP_VALUE "memory_limit=768M \n max_execution_time=600"; fastcgi_read_timeout 600s; fastcgi_connect_timeout 600s; - + fastcgi_index index.php; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; include fastcgi_params; } - + gzip on; gzip_disable "msie6"; gzip_comp_level 6; @@ -163,7 +163,7 @@ server { application/xml+rss image/svg+xml; gzip_vary on; - + # Banned locations (only reached if the earlier PHP entry point regexes don't match) location ~* (\.php$|\.htaccess$|\.git) { deny all; diff --git a/config/nextcloud.conf b/config/nextcloud.conf deleted file mode 100644 index ca6eed84..00000000 --- a/config/nextcloud.conf +++ /dev/null @@ -1,82 +0,0 @@ -#(可选)添加如下header主要为了安全 -add_header X-Content-Type-Options nosniff; -add_header X-XSS-Protection "1; mode=block"; -add_header X-Robots-Tag none; -add_header X-Download-Options noopen; -add_header X-Permitted-Cross-Domain-Policies none; - -#(可选)为了支持user_webfinger app -rewrite ^/.well-known/host-meta /public.php?service=host-meta last; -rewrite ^/.well-known/host-meta.json /public.php?service=host-meta-json last; - -#这儿是为了支持日历和联系人,建议加上 -location = /.well-known/carddav { - return 301 $scheme://$host/remote.php/dav; -} -location = /.well-known/caldav { - return 301 $scheme://$host/remote.php/dav; -} - -#设置上传文件的最大大小(还和php里的那个设置有关) -client_max_body_size 512M; -fastcgi_buffers 64 4K; - -#最主要的,将所有请求转发到index.php上 -location / { - rewrite ^ /index.php$uri; -} - -#安全设置,禁止访问部分敏感内容 -location ~ ^/(?:build|tests|config|lib|3rdparty|templates|data)/ { - deny all; -} -location ~ ^/(?:\.|autotest|occ|issue|indie|db_|console) { - deny all; -} - -#这部分吧,默认就有,不过有所不同,所以我合并了下,替换原来的就行 -location ~ ^/(?:index|remote|public|cron|core/ajax/update|status|ocs/v[12]|updater/.+|ocs-provider/.+)\.php(?:$|/) { - fastcgi_split_path_info ^(.+\.php)(/.*)$; - fastcgi_param PATH_INFO $fastcgi_path_info; - fastcgi_param modHeadersAvailable true; - fastcgi_param front_controller_active true; - fastcgi_pass unix:/dev/shm/php-cgi.sock; - fastcgi_intercept_errors on; - fastcgi_request_buffering off; - include fastcgi.conf; -} - -#安全设置,禁止访问部分敏感内容 -location ~ ^/(?:updater|ocs-provider)(?:$|/) { - try_files $uri/ =404; - index index.php; -} - -location ~ \.(?:css|js|woff|svg|gif)$ { - try_files $uri /index.php$uri$is_args$args; - add_header Cache-Control "public, max-age=15778463"; - add_header X-Content-Type-Options nosniff; - add_header X-XSS-Protection "1; mode=block"; - add_header X-Robots-Tag none; - add_header X-Download-Options noopen; - add_header X-Permitted-Cross-Domain-Policies none; - access_log off; -} - -location ~ \.(?:png|html|ttf|ico|jpg|jpeg)$ { - try_files $uri /index.php$uri$is_args$args; - access_log off; -} - -location = /robots.txt { - allow all; - log_not_found off; - access_log off; -} - -gzip on; -gzip_vary on; -gzip_comp_level 4; -gzip_min_length 256; -gzip_proxied expired no-cache no-store private no_last_modified no_etag auth; -gzip_types application/atom+xml application/javascript application/json application/ld+json application/manifest+json application/rss+xml application/vnd.geo+json application/vnd.ms-fontobject application/x-font-ttf application/x-web-app-manifest+json application/xhtml+xml application/xml font/opentype image/bmp image/svg+xml image/x-icon text/cache-manifest text/css text/plain text/vcard text/vnd.rim.location.xloc text/vtt text/x-component text/x-cross-domain-policy; diff --git a/config/nginx.conf b/config/nginx.conf index 8e722075..c0af2d92 100644 --- a/config/nginx.conf +++ b/config/nginx.conf @@ -51,36 +51,11 @@ http { image/x-icon; gzip_disable "MSIE [1-6]\.(?!.*SV1)"; - ##Brotli Compression - #brotli on; - #brotli_comp_level 6; - #brotli_types text/plain text/css application/json application/x-javascript text/xml application/xml application/xml+rss text/javascript application/javascript image/svg+xml; - - ##If you have a lot of static files to serve through Nginx then caching of the files' metadata (not the actual files' contents) can save some latency. - #open_file_cache max=1000 inactive=20s; - #open_file_cache_valid 30s; - #open_file_cache_min_uses 2; - #open_file_cache_errors on; - - log_format json escape=json '{"@timestamp":"$time_iso8601",' - '"server_addr":"$server_addr",' - '"remote_addr":"$remote_addr",' - '"scheme":"$scheme",' - '"request_method":"$request_method",' - '"request_uri": "$request_uri",' - '"request_length": "$request_length",' - '"uri": "$uri", ' - '"request_time":$request_time,' - '"body_bytes_sent":$body_bytes_sent,' - '"bytes_sent":$bytes_sent,' - '"status":"$status",' - '"upstream_time":"$upstream_response_time",' - '"upstream_host":"$upstream_addr",' - '"upstream_status":"$upstream_status",' - '"host":"$host",' - '"http_referer":"$http_referer",' - '"http_user_agent":"$http_user_agent"' - '}'; + #If you have a lot of static files to serve through Nginx then caching of the files' metadata (not the actual files' contents) can save some latency. + open_file_cache max=1000 inactive=20s; + open_file_cache_valid 30s; + open_file_cache_min_uses 2; + open_file_cache_errors on; ######################## default ############################ server { @@ -111,12 +86,9 @@ http { expires 7d; access_log off; } - location ~ ^/(\.user.ini|\.ht|\.git|\.svn|\.project|LICENSE|README.md) { + location ~ /\.ht { deny all; } - location /.well-known { - allow all; - } } ########################## vhost ############################# include vhost/*.conf; diff --git a/config/nginx_apache.conf b/config/nginx_apache.conf index ee6399b4..8ae472f0 100644 --- a/config/nginx_apache.conf +++ b/config/nginx_apache.conf @@ -51,36 +51,11 @@ http { image/x-icon; gzip_disable "MSIE [1-6]\.(?!.*SV1)"; - ##Brotli Compression - #brotli on; - #brotli_comp_level 6; - #brotli_types text/plain text/css application/json application/x-javascript text/xml application/xml application/xml+rss text/javascript application/javascript image/svg+xml; - - ##If you have a lot of static files to serve through Nginx then caching of the files' metadata (not the actual files' contents) can save some latency. - #open_file_cache max=1000 inactive=20s; - #open_file_cache_valid 30s; - #open_file_cache_min_uses 2; - #open_file_cache_errors on; - - log_format json escape=json '{"@timestamp":"$time_iso8601",' - '"server_addr":"$server_addr",' - '"remote_addr":"$remote_addr",' - '"scheme":"$scheme",' - '"request_method":"$request_method",' - '"request_uri": "$request_uri",' - '"request_length": "$request_length",' - '"uri": "$uri", ' - '"request_time":$request_time,' - '"body_bytes_sent":$body_bytes_sent,' - '"bytes_sent":$bytes_sent,' - '"status":"$status",' - '"upstream_time":"$upstream_response_time",' - '"upstream_host":"$upstream_addr",' - '"upstream_status":"$upstream_status",' - '"host":"$host",' - '"http_referer":"$http_referer",' - '"http_user_agent":"$http_user_agent"' - '}'; + #If you have a lot of static files to serve through Nginx then caching of the files' metadata (not the actual files' contents) can save some latency. + open_file_cache max=1000 inactive=20s; + open_file_cache_valid 30s; + open_file_cache_min_uses 2; + open_file_cache_errors on; ######################## default ############################ server { @@ -116,12 +91,9 @@ http { expires 7d; access_log off; } - location ~ ^/(\.user.ini|\.ht|\.git|\.svn|\.project|LICENSE|README.md) { + location ~ /\.ht { deny all; } - location /.well-known { - allow all; - } } ########################## vhost ############################# include vhost/*.conf; diff --git a/config/nginx_tomcat.conf b/config/nginx_tomcat.conf index 710c68ee..090acaa9 100644 --- a/config/nginx_tomcat.conf +++ b/config/nginx_tomcat.conf @@ -51,36 +51,11 @@ http { image/x-icon; gzip_disable "MSIE [1-6]\.(?!.*SV1)"; - ##Brotli Compression - #brotli on; - #brotli_comp_level 6; - #brotli_types text/plain text/css application/json application/x-javascript text/xml application/xml application/xml+rss text/javascript application/javascript image/svg+xml; - - ##If you have a lot of static files to serve through Nginx then caching of the files' metadata (not the actual files' contents) can save some latency. - #open_file_cache max=1000 inactive=20s; - #open_file_cache_valid 30s; - #open_file_cache_min_uses 2; - #open_file_cache_errors on; - - log_format json escape=json '{"@timestamp":"$time_iso8601",' - '"server_addr":"$server_addr",' - '"remote_addr":"$remote_addr",' - '"scheme":"$scheme",' - '"request_method":"$request_method",' - '"request_uri": "$request_uri",' - '"request_length": "$request_length",' - '"uri": "$uri", ' - '"request_time":$request_time,' - '"body_bytes_sent":$body_bytes_sent,' - '"bytes_sent":$bytes_sent,' - '"status":"$status",' - '"upstream_time":"$upstream_response_time",' - '"upstream_host":"$upstream_addr",' - '"upstream_status":"$upstream_status",' - '"host":"$host",' - '"http_referer":"$http_referer",' - '"http_user_agent":"$http_user_agent"' - '}'; + #If you have a lot of static files to serve through Nginx then caching of the files' metadata (not the actual files' contents) can save some latency. + open_file_cache max=1000 inactive=20s; + open_file_cache_valid 30s; + open_file_cache_min_uses 2; + open_file_cache_errors on; ######################## default ############################ server { @@ -109,12 +84,9 @@ http { proxy_pass http://127.0.0.1:8080; include proxy.conf; } - location ~ ^/(\.user.ini|\.ht|\.git|\.svn|\.project|LICENSE|README.md) { + location ~ /\.ht { deny all; } - location /.well-known { - allow all; - } } ########################## vhost ############################# include vhost/*.conf; diff --git a/config/server.xml b/config/server.xml index f328f932..1ba0a989 100644 --- a/config/server.xml +++ b/config/server.xml @@ -20,6 +20,7 @@ -# BLOG: https://linuxeye.com +# BLOG: https://blog.linuxeye.com +# +# Notes: OneinStack for CentOS/RadHat 5+ Debian 6+ and Ubuntu 12+ +# +# Project home page: +# https://oneinstack.com +# https://github.com/lj2007331/oneinstack Install_GraphicsMagick() { - if [ -d "${gmagick_install_dir}" ]; then - echo "${CWARNING}GraphicsMagick already installed! ${CEND}" - else - pushd ${current_dir}/src > /dev/null - tar xJf GraphicsMagick-${graphicsmagick_ver}.tar.xz - pushd GraphicsMagick-${graphicsmagick_ver} > /dev/null - ./configure --prefix=${gmagick_install_dir} --enable-shared --enable-static --enable-symbol-prefix - make -j ${THREAD} && make install - popd > /dev/null - rm -rf GraphicsMagick-${graphicsmagick_ver} - popd > /dev/null - fi -} - -Uninstall_GraphicsMagick() { - if [ -d "${gmagick_install_dir}" ]; then - rm -rf ${gmagick_install_dir} - echo; echo "${CMSG}GraphicsMagick uninstall completed${CEND}" - fi + pushd ${oneinstack_dir}/src + tar xzf GraphicsMagick-${GraphicsMagick_version}.tar.gz + pushd GraphicsMagick-${GraphicsMagick_version} + ./configure --prefix=/usr/local/graphicsmagick --enable-shared --enable-static + make -j ${THREAD} && make install + popd + rm -rf GraphicsMagick-${GraphicsMagick_version} + popd } -Install_pecl_gmagick() { +Install_php-gmagick() { + pushd ${oneinstack_dir}/src if [ -e "${php_install_dir}/bin/phpize" ]; then - pushd ${current_dir}/src > /dev/null phpExtensionDir=`${php_install_dir}/bin/php-config --extension-dir` - if [ "`${php_install_dir}/bin/php-config --version | awk -F. '{print $1}'`" == '5' ]; then - tar xzf gmagick-1.1.7RC3.tgz - pushd gmagick-1.1.7RC3 > /dev/null + if [ "`${php_install_dir}/bin/php -r 'echo PHP_VERSION;' | awk -F. '{print $1}'`" == '7' ]; then + tar xzf gmagick-${gmagick_for_php7_version}.tgz + pushd gmagick-${gmagick_for_php7_version} else - tar xzf gmagick-${gmagick_ver}.tgz - pushd gmagick-${gmagick_ver} > /dev/null + tar xzf gmagick-${gmagick_version}.tgz + pushd gmagick-${gmagick_version} fi export PKG_CONFIG_PATH=/usr/local/lib/pkgconfig ${php_install_dir}/bin/phpize - ./configure --with-php-config=${php_install_dir}/bin/php-config --with-gmagick=${gmagick_install_dir} + ./configure --with-php-config=${php_install_dir}/bin/php-config --with-gmagick=/usr/local/graphicsmagick make -j ${THREAD} && make install - popd > /dev/null + popd if [ -f "${phpExtensionDir}/gmagick.so" ]; then - echo 'extension=gmagick.so' > ${php_install_dir}/etc/php.d/03-gmagick.ini + echo 'extension=gmagick.so' > ${php_install_dir}/etc/php.d/ext-gmagick.ini echo "${CSUCCESS}PHP gmagick module installed successfully! ${CEND}" - rm -rf gmagick-${gmagick_ver} gmagick-1.1.7RC3 + rm -rf gmagick-${gmagick_for_php7_version} gmagick-${gmagick_version} else - echo "${CFAILURE}PHP gmagick module install failed, Please contact the author! ${CEND}" && grep -Ew 'NAME|ID|ID_LIKE|VERSION_ID|PRETTY_NAME' /etc/os-release + echo "${CFAILURE}PHP gmagick module install failed, Please contact the author! ${CEND}" fi - popd > /dev/null - fi -} - -Uninstall_pecl_gmagick() { - if [ -e "${php_install_dir}/etc/php.d/03-gmagick.ini" ]; then - rm -f ${php_install_dir}/etc/php.d/03-gmagick.ini - echo; echo "${CMSG}PHP gmagick module uninstall completed${CEND}" - else - echo; echo "${CWARNING}PHP gmagick module does not exist! ${CEND}" fi + popd } diff --git a/include/ImageMagick.sh b/include/ImageMagick.sh index 5c84edde..fc7acbdf 100644 --- a/include/ImageMagick.sh +++ b/include/ImageMagick.sh @@ -1,74 +1,47 @@ #!/bin/bash # Author: yeho -# BLOG: https://linuxeye.com +# BLOG: https://blog.linuxeye.com +# +# Notes: OneinStack for CentOS/RadHat 5+ Debian 6+ and Ubuntu 12+ +# +# Project home page: +# https://oneinstack.com +# https://github.com/lj2007331/oneinstack Install_ImageMagick() { - if [ -d "${imagick_install_dir}" ]; then - echo "${CWARNING}ImageMagick already installed! ${CEND}" - else - pushd ${current_dir}/src > /dev/null - tar xzf ImageMagick-${imagemagick_ver}.tar.gz - #if [ "${PM}" == 'yum' ]; then - # yum -y install libwebp-devel - #elif [ "${PM}" == 'apt-get' ]; then - # yum -y install libwebp-dev - #fi - pushd ImageMagick-${imagemagick_ver} > /dev/null - ./configure --prefix=${imagick_install_dir} --enable-shared --enable-static - make -j ${THREAD} && make install - popd > /dev/null - rm -rf ImageMagick-${imagemagick_ver} - popd > /dev/null - fi -} - -Uninstall_ImageMagick() { - if [ -d "${imagick_install_dir}" ]; then - rm -rf ${imagick_install_dir} - echo; echo "${CMSG}ImageMagick uninstall completed${CEND}" - fi + pushd ${oneinstack_dir}/src + tar xzf ImageMagick-${ImageMagick_version}.tar.gz + pushd ImageMagick-${ImageMagick_version} + ./configure --prefix=/usr/local/imagemagick --enable-shared --enable-static + make -j ${THREAD} && make install + popd + rm -rf ImageMagick-${ImageMagick_version} + popd } -Install_pecl_imagick() { +Install_php-imagick() { + pushd ${oneinstack_dir}/src if [ -e "${php_install_dir}/bin/phpize" ]; then - pushd ${current_dir}/src > /dev/null - PHP_detail_ver=$(${php_install_dir}/bin/php-config --version) - PHP_main_ver=${PHP_detail_ver%.*} phpExtensionDir=`${php_install_dir}/bin/php-config --extension-dir` - if [[ "${PHP_main_ver}" =~ ^5.3$ ]]; then - src_url=https://pecl.php.net/get/imagick-3.4.4.tgz && Download_src - tar xzf imagick-3.4.4.tgz - pushd imagick-3.4.4 > /dev/null - elif [[ "${PHP_main_ver}" =~ ^5.[4-5]$ ]]; then - src_url=https://pecl.php.net/get/imagick-3.7.0.tgz && Download_src - tar xzf imagick-3.7.0.tgz - pushd imagick-3.7.0 > /dev/null + if [ "`${php_install_dir}/bin/php -r 'echo PHP_VERSION;' | awk -F. '{print $1"."$2}'`" == '5.3' ]; then + tar xzf imagick-${imagick_for_php53_version}.tgz + pushd imagick-${imagick_for_php53_version} else - src_url=https://pecl.php.net/get/imagick-${imagick_ver}.tgz && Download_src - tar xzf imagick-${imagick_ver}.tgz - pushd imagick-${imagick_ver} > /dev/null + tar xzf imagick-${imagick_version}.tgz + pushd imagick-${imagick_version} fi export PKG_CONFIG_PATH=/usr/local/lib/pkgconfig ${php_install_dir}/bin/phpize - ./configure --with-php-config=${php_install_dir}/bin/php-config --with-imagick=${imagick_install_dir} + ./configure --with-php-config=${php_install_dir}/bin/php-config --with-imagick=/usr/local/imagemagick make -j ${THREAD} && make install - popd > /dev/null + popd if [ -f "${phpExtensionDir}/imagick.so" ]; then - echo 'extension=imagick.so' > ${php_install_dir}/etc/php.d/03-imagick.ini + echo 'extension=imagick.so' > ${php_install_dir}/etc/php.d/ext-imagick.ini echo "${CSUCCESS}PHP imagick module installed successfully! ${CEND}" - rm -rf imagick-${imagick_ver} imagick-3.7.0 imagick-3.4.4 + rm -rf imagick-${imagick_for_php53_version} imagick-${imagick_version} else - echo "${CFAILURE}PHP imagick module install failed, Please contact the author! ${CEND}" && grep -Ew 'NAME|ID|ID_LIKE|VERSION_ID|PRETTY_NAME' /etc/os-release + echo "${CFAILURE}PHP imagick module install failed, Please contact the author! ${CEND}" fi - popd > /dev/null - fi -} - -Uninstall_pecl_imagick() { - if [ -e "${php_install_dir}/etc/php.d/03-imagick.ini" ]; then - rm -f ${php_install_dir}/etc/php.d/03-imagick.ini - echo; echo "${CMSG}PHP imagick module uninstall completed${CEND}" - else - echo; echo "${CWARNING}PHP imagick module does not exist! ${CEND}" fi + popd } diff --git a/include/ZendGuardLoader.sh b/include/ZendGuardLoader.sh index e9ae363e..03fd5ca7 100644 --- a/include/ZendGuardLoader.sh +++ b/include/ZendGuardLoader.sh @@ -1,64 +1,80 @@ #!/bin/bash # Author: yeho -# BLOG: https://linuxeye.com +# BLOG: https://blog.linuxeye.com +# +# Notes: OneinStack for CentOS/RadHat 5+ Debian 6+ and Ubuntu 12+ +# +# Project home page: +# https://oneinstack.com +# https://github.com/lj2007331/oneinstack Install_ZendGuardLoader() { - if [ -e "${php_install_dir}/bin/phpize" ]; then - pushd ${current_dir}/src > /dev/null - PHP_detail_ver=$(${php_install_dir}/bin/php-config --version) - PHP_main_ver=${PHP_detail_ver%.*} - phpExtensionDir=`${php_install_dir}/bin/php-config --extension-dir` - [ ! -d "${phpExtensionDir}" ] && mkdir -p ${phpExtensionDir} - if [ -n "`echo $phpExtensionDir | grep 'non-zts'`" ] && [ "${armplatform}" != 'y' ]; then - case "${PHP_main_ver}" in - 5.6) - tar xzf zend-loader-php5.6-linux-x86_64.tar.gz - /bin/mv zend-loader-php5.6-linux-x86_64/ZendGuardLoader.so ${phpExtensionDir} - rm -rf zend-loader-php5.6-linux-x86_64 - ;; - 5.5) - tar xzf zend-loader-php5.5-linux-x86_64.tar.gz - /bin/mv zend-loader-php5.5-linux-x86_64/ZendGuardLoader.so ${phpExtensionDir} - rm -rf zend-loader-php5.5-linux-x86_64 - ;; - 5.4) - tar xzf ZendGuardLoader-70429-PHP-5.4-linux-glibc23-x86_64.tar.gz - /bin/mv ZendGuardLoader-70429-PHP-5.4-linux-glibc23-x86_64/php-5.4.x/ZendGuardLoader.so ${phpExtensionDir} - rm -rf ZendGuardLoader-70429-PHP-5.4-linux-glibc23-x86_64 - ;; - 5.3) - tar xzf ZendGuardLoader-php-5.3-linux-glibc23-x86_64.tar.gz - /bin/mv ZendGuardLoader-php-5.3-linux-glibc23-x86_64/php-5.3.x/ZendGuardLoader.so ${phpExtensionDir} - rm -rf ZendGuardLoader-php-5.3-linux-glibc23-x86_64 - ;; - *) - echo "${CWARNING}Your php ${PHP_detail_ver} does not support ZendGuardLoader! ${CEND}"; - ;; - esac + pushd ${oneinstack_dir}/src + PHP_detail_version=$(${php_install_dir}/bin/php -r 'echo PHP_VERSION;') + PHP_main_version=${PHP_detail_version%.*} + phpExtensionDir=`${php_install_dir}/bin/php-config --extension-dir` + [ ! -d "${phpExtensionDir}" ] && mkdir -p ${phpExtensionDir} + if [ "$OS_BIT" == '64' ]; then + if [ "$PHP_main_version" == '5.6' ]; then + tar xzf zend-loader-php5.6-linux-x86_64.tar.gz + /bin/cp zend-loader-php5.6-linux-x86_64/ZendGuardLoader.so ${phpExtensionDir} + rm -rf zend-loader-php5.6-linux-x86_64 + fi + + if [ "$PHP_main_version" == '5.5' ]; then + tar xzf zend-loader-php5.5-linux-x86_64.tar.gz + /bin/cp zend-loader-php5.5-linux-x86_64/ZendGuardLoader.so ${phpExtensionDir} + rm -rf zend-loader-php5.5-linux-x86_64 + fi + + if [ "$PHP_main_version" == '5.4' ]; then + tar xzf ZendGuardLoader-70429-PHP-5.4-linux-glibc23-x86_64.tar.gz + /bin/cp ZendGuardLoader-70429-PHP-5.4-linux-glibc23-x86_64/php-5.4.x/ZendGuardLoader.so ${phpExtensionDir} + rm -rf ZendGuardLoader-70429-PHP-5.4-linux-glibc23-x86_64 + fi + + if [ "$PHP_main_version" == '5.3' ]; then + tar xzf ZendGuardLoader-php-5.3-linux-glibc23-x86_64.tar.gz + /bin/cp ZendGuardLoader-php-5.3-linux-glibc23-x86_64/php-5.3.x/ZendGuardLoader.so ${phpExtensionDir} + rm -rf ZendGuardLoader-php-5.3-linux-glibc23-x86_64 + fi + else + if [ "$PHP_main_version" == '5.6' ]; then + tar xzf zend-loader-php5.6-linux-i386.tar.gz + /bin/cp zend-loader-php5.6-linux-i386/ZendGuardLoader.so ${phpExtensionDir} + rm -rf zend-loader-php5.6-linux-i386 + fi + + if [ "$PHP_main_version" == '5.5' ]; then + tar xzf zend-loader-php5.5-linux-i386.tar.gz + /bin/cp zend-loader-php5.5-linux-i386/ZendGuardLoader.so ${phpExtensionDir} + rm -rf zend-loader-php5.5-linux-x386 + fi + + if [ "$PHP_main_version" == '5.4' ]; then + tar xzf ZendGuardLoader-70429-PHP-5.4-linux-glibc23-i386.tar.gz + /bin/cp ZendGuardLoader-70429-PHP-5.4-linux-glibc23-i386/php-5.4.x/ZendGuardLoader.so ${phpExtensionDir} + rm -rf ZendGuardLoader-70429-PHP-5.4-linux-glibc23-i386 + fi + + if [ "$PHP_main_version" == '5.3' ]; then + tar xzf ZendGuardLoader-php-5.3-linux-glibc23-i386.tar.gz + /bin/cp ZendGuardLoader-php-5.3-linux-glibc23-i386/php-5.3.x/ZendGuardLoader.so ${phpExtensionDir} + rm -rf ZendGuardLoader-php-5.3-linux-glibc23-i386 + fi + fi - if [ -f "${phpExtensionDir}/ZendGuardLoader.so" ]; then - chmod 644 ${phpExtensionDir}/ZendGuardLoader.so - cat > ${php_install_dir}/etc/php.d/01-ZendGuardLoader.ini<< EOF + if [ -f "${phpExtensionDir}/ZendGuardLoader.so" ]; then + cat > $php_install_dir/etc/php.d/ext-ZendGuardLoader.ini << EOF [Zend Guard Loader] zend_extension=${phpExtensionDir}/ZendGuardLoader.so zend_loader.enable=1 zend_loader.disable_licensing=0 zend_loader.obfuscation_level_support=3 EOF - echo "${CSUCCESS}PHP ZendGuardLoader module installed successfully! ${CEND}" - fi - else - echo "Error! Your Apache's prefork or PHP already enable thread safety or platform ${TARGET_ARCH} does not support ZendGuardLoader! " - fi - popd > /dev/null - fi -} - -Uninstall_ZendGuardLoader() { - if [ -e "${php_install_dir}/etc/php.d/01-ZendGuardLoader.ini" ]; then - rm -f ${php_install_dir}/etc/php.d/01-ZendGuardLoader.ini - echo; echo "${CMSG}PHP ZendGuardLoader module uninstall completed${CEND}" + echo "${CSUCCESS}PHP ZendGuardLoader module installed successfully! ${CEND}" else - echo; echo "${CWARNING}PHP ZendGuardLoader module does not exist! ${CEND}" + echo "${CFAILURE}PHP ZendGuardLoader module install failed, Please contact the author! ${CEND}" fi + popd } diff --git a/include/alisql-5.6.sh b/include/alisql-5.6.sh new file mode 100644 index 00000000..17ba3c67 --- /dev/null +++ b/include/alisql-5.6.sh @@ -0,0 +1,209 @@ +#!/bin/bash +# Author: yeho +# BLOG: https://blog.linuxeye.com +# +# Notes: OneinStack for CentOS/RadHat 5+ Debian 6+ and Ubuntu 12+ +# +# Project home page: +# https://oneinstack.com +# https://github.com/lj2007331/oneinstack + +Install_AliSQL56() { + pushd ${oneinstack_dir}/src + + id -u mysql >/dev/null 2>&1 + [ $? -ne 0 ] && useradd -M -s /sbin/nologin mysql + + [ ! -d "${alisql_install_dir}" ] && mkdir -p ${alisql_install_dir} + mkdir -p ${alisql_data_dir};chown mysql.mysql -R ${alisql_data_dir} + + tar xvf alisql-${alisql56_version}.tar.gz + pushd alisql-${alisql56_version} + cmake . -DCMAKE_INSTALL_PREFIX=${alisql_install_dir} \ + -DCMAKE_BUILD_TYPE="Release" \ + -DWITH_EMBEDDED_SERVER=0 \ + -DWITH_EXTRA_CHARSETS=all \ + -DWITH_MYISAM_STORAGE_ENGINE=1 \ + -DWITH_INNOBASE_STORAGE_ENGINE=1 \ + -DWITH_PARTITION_STORAGE_ENGINE=1 \ + -DWITH_CSV_STORAGE_ENGINE=1 \ + -DWITH_ARCHIVE_STORAGE_ENGINE=1 \ + -DWITH_BLACKHOLE_STORAGE_ENGINE=1 \ + -DWITH_FEDERATED_STORAGE_ENGINE=1 \ + -DWITH_PERFSCHEMA_STORAGE_ENGINE=1 \ + -DWITH_TOKUDB_STORAGE_ENGINE=0 + make -j ${THREAD} + make install + popd + + if [ -d "${alisql_install_dir}/support-files" ]; then + echo never > /sys/kernel/mm/transparent_hugepage/enabled + echo "${CSUCCESS}AliSQL installed successfully! ${CEND}" + rm -rf alisql-${alisql56_version} + else + rm -rf ${alisql_install_dir} + rm -rf alisql-${alisql56_version} + echo "${CFAILURE}AliSQL install failed, Please contact the author! ${CEND}" + kill -9 $$ + fi + /bin/cp ${alisql_install_dir}/support-files/mysql.server /etc/init.d/mysqld + [ -z "`grep transparent_hugepage /etc/init.d/mysqld`" ] && sed -i "s@^basedir=.*@echo never > /sys/kernel/mm/transparent_hugepage/enabled\n&@" /etc/init.d/mysqld + sed -i "s@^basedir=.*@basedir=${alisql_install_dir}@" /etc/init.d/mysqld + sed -i "s@^datadir=.*@datadir=${alisql_data_dir}@" /etc/init.d/mysqld + chmod +x /etc/init.d/mysqld + [ "${OS}" == "CentOS" ] && { chkconfig --add mysqld; chkconfig mysqld on; } + [[ "${OS}" =~ ^Ubuntu$|^Debian$ ]] && update-rc.d mysqld defaults + popd + + # my.cnf + [ -d "/etc/mysql" ] && /bin/mv /etc/mysql{,_bk} + cat > /etc/my.cnf << EOF +[client] +port = 3306 +socket = /tmp/mysql.sock +default-character-set = utf8mb4 + +[mysql] +prompt="AliSQL [\\d]> " +no-auto-rehash + +[mysqld] +port = 3306 +socket = /tmp/mysql.sock + +basedir = ${alisql_install_dir} +datadir = ${alisql_data_dir} +pid-file = ${alisql_data_dir}/mysql.pid +user = mysql +bind-address = 0.0.0.0 +server-id = 1 + +init-connect = 'SET NAMES utf8mb4' +character-set-server = utf8mb4 + +skip-name-resolve +#skip-networking +back_log = 300 + +max_connections = 1000 +max_connect_errors = 6000 +open_files_limit = 65535 +table_open_cache = 128 +max_allowed_packet = 500M +binlog_cache_size = 1M +max_heap_table_size = 8M +tmp_table_size = 16M + +read_buffer_size = 2M +read_rnd_buffer_size = 8M +sort_buffer_size = 8M +join_buffer_size = 8M +key_buffer_size = 4M + +thread_cache_size = 8 + +query_cache_type = 1 +query_cache_size = 8M +query_cache_limit = 2M + +ft_min_word_len = 4 + +log_bin = mysql-bin +binlog_format = mixed +expire_logs_days = 7 + +log_error = ${alisql_data_dir}/mysql-error.log +slow_query_log = 1 +long_query_time = 1 +slow_query_log_file = ${alisql_data_dir}/mysql-slow.log + +performance_schema = 0 +explicit_defaults_for_timestamp + +#lower_case_table_names = 1 + +skip-external-locking + +default_storage_engine = InnoDB +innodb_file_per_table = 1 +innodb_open_files = 500 +innodb_buffer_pool_size = 64M +innodb_write_io_threads = 4 +innodb_read_io_threads = 4 +innodb_thread_concurrency = 0 +innodb_purge_threads = 1 +innodb_flush_log_at_trx_commit = 2 +innodb_log_buffer_size = 2M +innodb_log_file_size = 32M +innodb_log_files_in_group = 3 +innodb_max_dirty_pages_pct = 90 +innodb_lock_wait_timeout = 120 + +bulk_insert_buffer_size = 8M +myisam_sort_buffer_size = 8M +myisam_max_sort_file_size = 10G +myisam_repair_threads = 1 + +interactive_timeout = 28800 +wait_timeout = 28800 + +[mysqldump] +quick +max_allowed_packet = 500M + +[myisamchk] +key_buffer_size = 8M +sort_buffer_size = 8M +read_buffer = 4M +write_buffer = 4M +EOF + + sed -i "s@max_connections.*@max_connections = $((${Mem}/3))@" /etc/my.cnf + if [ ${Mem} -gt 1500 -a ${Mem} -le 2500 ]; then + sed -i 's@^thread_cache_size.*@thread_cache_size = 16@' /etc/my.cnf + sed -i 's@^query_cache_size.*@query_cache_size = 16M@' /etc/my.cnf + sed -i 's@^myisam_sort_buffer_size.*@myisam_sort_buffer_size = 16M@' /etc/my.cnf + sed -i 's@^key_buffer_size.*@key_buffer_size = 16M@' /etc/my.cnf + sed -i 's@^innodb_buffer_pool_size.*@innodb_buffer_pool_size = 128M@' /etc/my.cnf + sed -i 's@^tmp_table_size.*@tmp_table_size = 32M@' /etc/my.cnf + sed -i 's@^table_open_cache.*@table_open_cache = 256@' /etc/my.cnf + elif [ ${Mem} -gt 2500 -a ${Mem} -le 3500 ]; then + sed -i 's@^thread_cache_size.*@thread_cache_size = 32@' /etc/my.cnf + sed -i 's@^query_cache_size.*@query_cache_size = 32M@' /etc/my.cnf + sed -i 's@^myisam_sort_buffer_size.*@myisam_sort_buffer_size = 32M@' /etc/my.cnf + sed -i 's@^key_buffer_size.*@key_buffer_size = 64M@' /etc/my.cnf + sed -i 's@^innodb_buffer_pool_size.*@innodb_buffer_pool_size = 512M@' /etc/my.cnf + sed -i 's@^tmp_table_size.*@tmp_table_size = 64M@' /etc/my.cnf + sed -i 's@^table_open_cache.*@table_open_cache = 512@' /etc/my.cnf + elif [ ${Mem} -gt 3500 ]; then + sed -i 's@^thread_cache_size.*@thread_cache_size = 64@' /etc/my.cnf + sed -i 's@^query_cache_size.*@query_cache_size = 64M@' /etc/my.cnf + sed -i 's@^myisam_sort_buffer_size.*@myisam_sort_buffer_size = 64M@' /etc/my.cnf + sed -i 's@^key_buffer_size.*@key_buffer_size = 256M@' /etc/my.cnf + sed -i 's@^innodb_buffer_pool_size.*@innodb_buffer_pool_size = 1024M@' /etc/my.cnf + sed -i 's@^tmp_table_size.*@tmp_table_size = 128M@' /etc/my.cnf + sed -i 's@^table_open_cache.*@table_open_cache = 1024@' /etc/my.cnf + fi + + ${alisql_install_dir}/scripts/mysql_install_db --user=mysql --basedir=${alisql_install_dir} --datadir=${alisql_data_dir} + + chown mysql.mysql -R ${alisql_data_dir} + [ -d "/etc/mysql" ] && mv /etc/mysql{,_bk} + service mysqld start + [ -z "$(grep ^'export PATH=' /etc/profile)" ] && echo "export PATH=${alisql_install_dir}/bin:\$PATH" >> /etc/profile + [ -n "$(grep ^'export PATH=' /etc/profile)" -a -z "$(grep ${alisql_install_dir} /etc/profile)" ] && sed -i "s@^export PATH=\(.*\)@export PATH=${alisql_install_dir}/bin:\1@" /etc/profile + . /etc/profile + + ${alisql_install_dir}/bin/mysql -e "grant all privileges on *.* to root@'127.0.0.1' identified by \"${dbrootpwd}\" with grant option;" + ${alisql_install_dir}/bin/mysql -e "grant all privileges on *.* to root@'localhost' identified by \"${dbrootpwd}\" with grant option;" + ${alisql_install_dir}/bin/mysql -uroot -p${dbrootpwd} -e "delete from mysql.user where Password='';" + ${alisql_install_dir}/bin/mysql -uroot -p${dbrootpwd} -e "delete from mysql.db where User='';" + ${alisql_install_dir}/bin/mysql -uroot -p${dbrootpwd} -e "delete from mysql.proxies_priv where Host!='localhost';" + ${alisql_install_dir}/bin/mysql -uroot -p${dbrootpwd} -e "drop database test;" + ${alisql_install_dir}/bin/mysql -uroot -p${dbrootpwd} -e "reset master;" + rm -rf /etc/ld.so.conf.d/{mysql,mariadb,percona,alisql}*.conf + [ -e "${alisql_install_dir}/my.cnf" ] && rm -rf ${alisql_install_dir}/my.cnf + echo "${alisql_install_dir}/lib" > /etc/ld.so.conf.d/alisql.conf + ldconfig + service mysqld stop +} diff --git a/include/apache-2.2.sh b/include/apache-2.2.sh new file mode 100644 index 00000000..c045489d --- /dev/null +++ b/include/apache-2.2.sh @@ -0,0 +1,131 @@ +#!/bin/bash +# Author: yeho +# BLOG: https://blog.linuxeye.com +# +# Notes: OneinStack for CentOS/RadHat 5+ Debian 6+ and Ubuntu 12+ +# +# Project home page: +# https://oneinstack.com +# https://github.com/lj2007331/oneinstack + +Install_Apache22() { + pushd ${oneinstack_dir}/src + id -u ${run_user} >/dev/null 2>&1 + [ $? -ne 0 ] && useradd -M -s /sbin/nologin ${run_user} + tar xzf httpd-${apache22_version}.tar.gz + pushd httpd-${apache22_version} + [ ! -d "${apache_install_dir}" ] && mkdir -p ${apache_install_dir} + [ "${Ubuntu_version}" == "12" ] && sed -i '@SSL_PROTOCOL_SSLV2@d' modules/ssl/ssl_engine_io.c + LDFLAGS=-ldl ./configure --prefix=${apache_install_dir} --with-mpm=prefork --with-included-apr --enable-headers --enable-deflate --enable-so --enable-rewrite --enable-ssl --with-ssl --enable-expires --enable-static-support --enable-suexec --enable-modules=all --enable-mods-shared=all + make -j ${THREAD} && make install + unset LDFLAGS + if [ -e "${apache_install_dir}/conf/httpd.conf" ]; then + echo "${CSUCCESS}Apache installed successfully! ${CEND}" + popd + rm -rf httpd-${apache22_version} + else + rm -rf ${apache_install_dir} + echo "${CFAILURE}Apache install failed, Please contact the author! ${CEND}" + kill -9 $$ + fi + + [ -z "`grep ^'export PATH=' /etc/profile`" ] && echo "export PATH=${apache_install_dir}/bin:\$PATH" >> /etc/profile + [ -n "`grep ^'export PATH=' /etc/profile`" -a -z "`grep ${apache_install_dir} /etc/profile`" ] && sed -i "s@^export PATH=\(.*\)@export PATH=${apache_install_dir}/bin:\1@" /etc/profile + . /etc/profile + + /bin/cp ${apache_install_dir}/bin/apachectl /etc/init.d/httpd + sed -i '2a # chkconfig: - 85 15' /etc/init.d/httpd + sed -i '3a # description: Apache is a World Wide Web server. It is used to serve' /etc/init.d/httpd + chmod +x /etc/init.d/httpd + [ "$OS" == 'CentOS' ] && { chkconfig --add httpd; chkconfig httpd on; } + [[ $OS =~ ^Ubuntu$|^Debian$ ]] && update-rc.d httpd defaults + + sed -i "s@^User daemon@User ${run_user}@" ${apache_install_dir}/conf/httpd.conf + sed -i "s@^Group daemon@Group ${run_user}@" ${apache_install_dir}/conf/httpd.conf + if [ "${Nginx_version}" == '4' -a ! -e "${web_install_dir}/sbin/nginx" ]; then + sed -i 's/^#ServerName www.example.com:80/ServerName 0.0.0.0:80/' ${apache_install_dir}/conf/httpd.conf + TMP_PORT=80 + elif [[ ${Nginx_version} =~ ^[1-3]$ ]] || [ -e "${web_install_dir}/sbin/nginx" ]; then + sed -i 's/^#ServerName www.example.com:80/ServerName 127.0.0.1:88/' ${apache_install_dir}/conf/httpd.conf + sed -i 's@^Listen.*@Listen 127.0.0.1:88@' ${apache_install_dir}/conf/httpd.conf + TMP_PORT=88 + fi + sed -i "s@AddType\(.*\)Z@AddType\1Z\n AddType application/x-httpd-php .php .phtml\n AddType application/x-httpd-php-source .phps@" ${apache_install_dir}/conf/httpd.conf + sed -i "s@#AddHandler cgi-script .cgi@AddHandler cgi-script .cgi .pl@" ${apache_install_dir}/conf/httpd.conf + sed -i 's@DirectoryIndex index.html@DirectoryIndex index.html index.php@' ${apache_install_dir}/conf/httpd.conf + sed -i "s@^DocumentRoot.*@DocumentRoot \"$wwwroot_dir/default\"@" ${apache_install_dir}/conf/httpd.conf + sed -i "s@^@@" ${apache_install_dir}/conf/httpd.conf + sed -i "s@^#Include conf/extra/httpd-mpm.conf@Include conf/extra/httpd-mpm.conf@" ${apache_install_dir}/conf/httpd.conf + + #logrotate apache log + cat > /etc/logrotate.d/apache << EOF +$wwwlogs_dir/*apache.log { + daily + rotate 5 + missingok + dateext + compress + notifempty + sharedscripts + postrotate + [ -e /var/run/httpd.pid ] && kill -USR1 \`cat /var/run/httpd.pid\` + endscript +} +EOF + + mkdir ${apache_install_dir}/conf/vhost + cat > ${apache_install_dir}/conf/vhost/0.conf << EOF +NameVirtualHost *:$TMP_PORT + + ServerAdmin admin@linuxeye.com + DocumentRoot "$wwwroot_dir/default" + ServerName 127.0.0.1 + ErrorLog "$wwwlogs_dir/error_apache.log" + CustomLog "$wwwlogs_dir/access_apache.log" common + + SetOutputFilter DEFLATE + Options FollowSymLinks ExecCGI + AllowOverride All + Order allow,deny + Allow from all + DirectoryIndex index.html index.php + + + SetHandler server-status + Order Deny,Allow + Deny from all + Allow from 127.0.0.1 + + +EOF + + cat >> ${apache_install_dir}/conf/httpd.conf < + AddOutputFilterByType DEFLATE text/html text/plain text/css text/xml text/javascript + + RequestHeader edit "If-None-Match" "^(.*)-gzip(.*)\$" "\$1\$2" + Header edit "ETag" "^(.*)-gzip(.*)\$" "\$1\$2" + + DeflateCompressionLevel 6 + SetOutputFilter DEFLATE + + +PidFile /var/run/httpd.pid +ServerTokens ProductOnly +ServerSignature Off +Include conf/vhost/*.conf +EOF + + if [ "${Nginx_version}" != '4' -o -e "${web_install_dir}/sbin/nginx" ]; then + ${apache_install_dir}/bin/apxs -i -c -n mod_remoteip.so mod_remoteip.c + cat > ${apache_install_dir}/conf/extra/httpd-remoteip.conf << EOF +LoadModule remoteip_module modules/mod_remoteip.so +RemoteIPHeader X-Forwarded-For +RemoteIPInternalProxy 127.0.0.1 +EOF + sed -i "s@Include conf/extra/httpd-mpm.conf@Include conf/extra/httpd-mpm.conf\nInclude conf/extra/httpd-remoteip.conf@" ${apache_install_dir}/conf/httpd.conf + fi + ldconfig + service httpd start + popd +} diff --git a/include/apache-2.4.sh b/include/apache-2.4.sh new file mode 100644 index 00000000..d6926d21 --- /dev/null +++ b/include/apache-2.4.sh @@ -0,0 +1,161 @@ +#!/bin/bash +# Author: yeho +# BLOG: https://blog.linuxeye.com +# +# Notes: OneinStack for CentOS/RadHat 5+ Debian 6+ and Ubuntu 12+ +# +# Project home page: +# https://oneinstack.com +# https://github.com/lj2007331/oneinstack + +Install_Apache24() { + pushd ${oneinstack_dir}/src + tar xzf pcre-${pcre_version}.tar.gz + pushd pcre-${pcre_version} + ./configure + make -j ${THREAD} && make install + popd + id -u ${run_user} >/dev/null 2>&1 + [ $? -ne 0 ] && useradd -M -s /sbin/nologin $run_user + tar xzf httpd-${apache24_version}.tar.gz + tar xzf nghttp2-${nghttp2_version}.tar.gz + tar xzf apr-${apr_version}.tar.gz + tar xzf apr-util-${apr_util_version}.tar.gz + + # install nghttp2 + if [ ! -e "/usr/local/lib/libnghttp2.so" ]; then + pushd nghttp2-${nghttp2_version} + ./configure + make -j ${THREAD} && make install + popd + echo '/usr/local/lib' > /etc/ld.so.conf.d/local.conf; ldconfig + rm -rf nghttp2-${nghttp2_version} + fi + + pushd httpd-${apache24_version} + [ ! -d "${apache_install_dir}" ] && mkdir -p ${apache_install_dir} + /bin/cp -R ../apr-${apr_version} ./srclib/apr + /bin/cp -R ../apr-util-${apr_util_version} ./srclib/apr-util + LDFLAGS=-ldl LD_LIBRARY_PATH=${openssl_install_dir}/lib ./configure --prefix=${apache_install_dir} --with-mpm=prefork --with-included-apr --enable-headers --enable-deflate --enable-so --enable-dav --enable-rewrite --enable-ssl --with-ssl=${openssl_install_dir} --enable-http2 --with-nghttp2=/usr/local --enable-expires --enable-static-support --enable-suexec --enable-modules=all --enable-mods-shared=all + make -j ${THREAD} && make install + unset LDFLAGS + if [ -e "${apache_install_dir}/conf/httpd.conf" ]; then + echo "${CSUCCESS}Apache installed successfully! ${CEND}" + popd + rm -rf httpd-${apache24_version} + else + rm -rf ${apache_install_dir} + echo "${CFAILURE}Apache install failed, Please contact the author! ${CEND}" + kill -9 $$ + fi + + [ -z "`grep ^'export PATH=' /etc/profile`" ] && echo "export PATH=${apache_install_dir}/bin:\$PATH" >> /etc/profile + [ -n "`grep ^'export PATH=' /etc/profile`" -a -z "`grep ${apache_install_dir} /etc/profile`" ] && sed -i "s@^export PATH=\(.*\)@export PATH=${apache_install_dir}/bin:\1@" /etc/profile + . /etc/profile + + sed -i "s@^export LD_LIBRARY_PATH.*@export LD_LIBRARY_PATH=\$LD_LIBRARY_PATH:${openssl_install_dir}/lib@" ${apache_install_dir}/bin/envvars + + /bin/cp ${apache_install_dir}/bin/apachectl /etc/init.d/httpd + sed -i '2a # chkconfig: - 85 15' /etc/init.d/httpd + sed -i '3a # description: Apache is a World Wide Web server. It is used to serve' /etc/init.d/httpd + chmod +x /etc/init.d/httpd + [ "$OS" == 'CentOS' ] && { chkconfig --add httpd; chkconfig httpd on; } + [[ $OS =~ ^Ubuntu$|^Debian$ ]] && update-rc.d httpd defaults + + sed -i "s@^User daemon@User $run_user@" ${apache_install_dir}/conf/httpd.conf + sed -i "s@^Group daemon@Group $run_user@" ${apache_install_dir}/conf/httpd.conf + if [ "${Nginx_version}" == '4' -a ! -e "${web_install_dir}/sbin/nginx" ]; then + sed -i 's/^#ServerName www.example.com:80/ServerName 0.0.0.0:80/' ${apache_install_dir}/conf/httpd.conf + TMP_PORT=80 + elif [[ ${Nginx_version} =~ ^[1-3]$ ]] || [ -e "${web_install_dir}/sbin/nginx" ]; then + sed -i 's/^#ServerName www.example.com:80/ServerName 127.0.0.1:88/' ${apache_install_dir}/conf/httpd.conf + sed -i 's@^Listen.*@Listen 127.0.0.1:88@' ${apache_install_dir}/conf/httpd.conf + TMP_PORT=88 + fi + sed -i "s@AddType\(.*\)Z@AddType\1Z\n AddType application/x-httpd-php .php .phtml\n AddType application/x-httpd-php-source .phps@" ${apache_install_dir}/conf/httpd.conf + sed -i "s@#AddHandler cgi-script .cgi@AddHandler cgi-script .cgi .pl@" ${apache_install_dir}/conf/httpd.conf + sed -ri 's@^#(.*mod_suexec.so)@\1@' ${apache_install_dir}/conf/httpd.conf + sed -ri 's@^#(.*mod_vhost_alias.so)@\1@' ${apache_install_dir}/conf/httpd.conf + sed -ri 's@^#(.*mod_rewrite.so)@\1@' ${apache_install_dir}/conf/httpd.conf + sed -ri 's@^#(.*mod_deflate.so)@\1@' ${apache_install_dir}/conf/httpd.conf + sed -ri 's@^#(.*mod_expires.so)@\1@' ${apache_install_dir}/conf/httpd.conf + sed -ri 's@^#(.*mod_ssl.so)@\1@' ${apache_install_dir}/conf/httpd.conf + sed -ri 's@^#(.*mod_http2.so)@\1@' ${apache_install_dir}/conf/httpd.conf + sed -i 's@DirectoryIndex index.html@DirectoryIndex index.html index.php@' ${apache_install_dir}/conf/httpd.conf + sed -i "s@^DocumentRoot.*@DocumentRoot \"$wwwroot_dir/default\"@" ${apache_install_dir}/conf/httpd.conf + sed -i "s@^@@" ${apache_install_dir}/conf/httpd.conf + sed -i "s@^#Include conf/extra/httpd-mpm.conf@Include conf/extra/httpd-mpm.conf@" ${apache_install_dir}/conf/httpd.conf + + #logrotate apache log + cat > /etc/logrotate.d/apache << EOF +$wwwlogs_dir/*apache.log { + daily + rotate 5 + missingok + dateext + compress + notifempty + sharedscripts + postrotate + [ -e /var/run/httpd.pid ] && kill -USR1 \`cat /var/run/httpd.pid\` + endscript +} +EOF + + mkdir ${apache_install_dir}/conf/vhost + cat > ${apache_install_dir}/conf/vhost/0.conf << EOF + + ServerAdmin admin@linuxeye.com + DocumentRoot "$wwwroot_dir/default" + ServerName 127.0.0.1 + ErrorLog "$wwwlogs_dir/error_apache.log" + CustomLog "$wwwlogs_dir/access_apache.log" common + + SetOutputFilter DEFLATE + Options FollowSymLinks ExecCGI + Require all granted + AllowOverride All + Order allow,deny + Allow from all + DirectoryIndex index.html index.php + + + SetHandler server-status + Order Deny,Allow + Deny from all + Allow from 127.0.0.1 + + +EOF + + cat >> ${apache_install_dir}/conf/httpd.conf < + AddOutputFilterByType DEFLATE text/html text/plain text/css text/xml text/javascript + + RequestHeader edit "If-None-Match" "^(.*)-gzip(.*)\$" "\$1\$2" + Header edit "ETag" "^(.*)-gzip(.*)\$" "\$1\$2" + + DeflateCompressionLevel 6 + SetOutputFilter DEFLATE + + +ProtocolsHonorOrder On +PidFile /var/run/httpd.pid +ServerTokens ProductOnly +ServerSignature Off +Include conf/vhost/*.conf +EOF + [ "${Nginx_version}" == '4' -a ! -e "${web_install_dir}/sbin/nginx" ] && echo 'Protocols h2 http/1.1' >> ${apache_install_dir}/conf/httpd.conf + if [ "${Nginx_version}" != '4' -o -e "${web_install_dir}/sbin/nginx" ]; then + cat > ${apache_install_dir}/conf/extra/httpd-remoteip.conf << EOF +LoadModule remoteip_module modules/mod_remoteip.so +RemoteIPHeader X-Forwarded-For +RemoteIPInternalProxy 127.0.0.1 +EOF + sed -i "s@Include conf/extra/httpd-mpm.conf@Include conf/extra/httpd-mpm.conf\nInclude conf/extra/httpd-remoteip.conf@" ${apache_install_dir}/conf/httpd.conf + sed -i "s@LogFormat \"%h %l@LogFormat \"%h %a %l@g" ${apache_install_dir}/conf/httpd.conf + fi + ldconfig + service httpd start + popd +} diff --git a/include/apache.sh b/include/apache.sh deleted file mode 100644 index 3ac98a57..00000000 --- a/include/apache.sh +++ /dev/null @@ -1,184 +0,0 @@ -#!/bin/bash -# Author: yeho -# BLOG: https://linuxeye.com - -Install_Apache() { - pushd ${current_dir}/src > /dev/null - tar xzf pcre-${pcre_ver}.tar.gz - pushd pcre-${pcre_ver} > /dev/null - ./configure - make -j ${THREAD} && make install - popd > /dev/null - id -g ${run_group} >/dev/null 2>&1 - [ $? -ne 0 ] && groupadd ${run_group} - id -u ${run_user} >/dev/null 2>&1 - [ $? -ne 0 ] && useradd -g ${run_group} -M -s /sbin/nologin ${run_user} - tar xzf httpd-${apache_ver}.tar.gz - - # install apr - if [ ! -e "${apr_install_dir}/bin/apr-1-config" ]; then - tar xzf apr-${apr_ver}.tar.gz - pushd apr-${apr_ver} > /dev/null - ./configure --prefix=${apr_install_dir} - make -j ${THREAD} && make install - popd > /dev/null - rm -rf apr-${apr_ver} - fi - - # install apr-util - if [ ! -e "${apr_install_dir}/bin/apu-1-config" ]; then - tar xzf apr-util-${apr_util_ver}.tar.gz - pushd apr-util-${apr_util_ver} > /dev/null - ./configure --prefix=${apr_install_dir} --with-apr=${apr_install_dir} - make -j ${THREAD} && make install - popd > /dev/null - rm -rf apr-util-${apr_util_ver} - fi - - # install nghttp2 - if [ ! -e "/usr/local/lib/libnghttp2.so" ]; then - tar xzf nghttp2-${nghttp2_ver}.tar.gz - pushd nghttp2-${nghttp2_ver} > /dev/null - ./configure - make -j ${THREAD} && make install - popd > /dev/null - [ -z "`grep /usr/local/lib /etc/ld.so.conf.d/*.conf`" ] && echo '/usr/local/lib' > /etc/ld.so.conf.d/local.conf - ldconfig - rm -rf nghttp2-${nghttp2_ver} - fi - - pushd httpd-${apache_ver} > /dev/null - LDFLAGS=-ldl ./configure --prefix=${apache_install_dir} --enable-mpms-shared=all --with-pcre --with-apr=${apr_install_dir} --with-apr-util=${apr_install_dir} --enable-headers --enable-mime-magic --enable-deflate --enable-proxy --enable-so --enable-dav --enable-rewrite --enable-remoteip --enable-expires --enable-static-support --enable-suexec --enable-mods-shared=most --enable-nonportable-atomics=yes --enable-ssl --with-ssl --enable-http2 --with-nghttp2=/usr/local - make -j ${THREAD} && make install - popd > /dev/null - unset LDFLAGS - if [ -e "${apache_install_dir}/bin/httpd" ]; then - echo "${CSUCCESS}Apache installed successfully! ${CEND}" - rm -rf httpd-${apache_ver} pcre-${pcre_ver} - else - rm -rf ${apache_install_dir} - echo "${CFAILURE}Apache install failed, Please contact the author! ${CEND}" && grep -Ew 'NAME|ID|ID_LIKE|VERSION_ID|PRETTY_NAME' /etc/os-release - kill -9 $$; exit 1; - fi - - [ -z "`grep ^'export PATH=' /etc/profile`" ] && echo "export PATH=${apache_install_dir}/bin:\$PATH" >> /etc/profile - [ -n "`grep ^'export PATH=' /etc/profile`" -a -z "`grep ${apache_install_dir} /etc/profile`" ] && sed -i "s@^export PATH=\(.*\)@export PATH=${apache_install_dir}/bin:\1@" /etc/profile - . /etc/profile - - /bin/cp ../init.d/httpd.service /lib/systemd/system/ - sed -i "s@/usr/local/apache@${apache_install_dir}@g" /lib/systemd/system/httpd.service - systemctl enable httpd - - sed -i "s@^User daemon@User ${run_user}@" ${apache_install_dir}/conf/httpd.conf - sed -i "s@^Group daemon@Group ${run_group}@" ${apache_install_dir}/conf/httpd.conf - if [[ ! ${nginx_option} =~ ^[1-3]$ ]] && [ ! -e "${web_install_dir}/sbin/nginx" ]; then - sed -i 's/^#ServerName www.example.com:80/ServerName 0.0.0.0:80/' ${apache_install_dir}/conf/httpd.conf - TMP_PORT=80 - elif [[ ${nginx_option} =~ ^[1-3]$ ]] || [ -e "${web_install_dir}/sbin/nginx" ]; then - sed -i 's/^#ServerName www.example.com:80/ServerName 127.0.0.1:88/' ${apache_install_dir}/conf/httpd.conf - sed -i 's@^Listen.*@Listen 127.0.0.1:88@' ${apache_install_dir}/conf/httpd.conf - TMP_PORT=88 - fi - sed -i "s@AddType\(.*\)Z@AddType\1Z\n AddType application/x-httpd-php .php .phtml\n AddType application/x-httpd-php-source .phps@" ${apache_install_dir}/conf/httpd.conf - sed -i "s@#AddHandler cgi-script .cgi@AddHandler cgi-script .cgi .pl@" ${apache_install_dir}/conf/httpd.conf - sed -ri 's@^#(LoadModule.*mod_proxy.so)@\1@' ${apache_install_dir}/conf/httpd.conf - sed -ri 's@^#(LoadModule.*mod_proxy_fcgi.so)@\1@' ${apache_install_dir}/conf/httpd.conf - sed -ri 's@^#(LoadModule.*mod_suexec.so)@\1@' ${apache_install_dir}/conf/httpd.conf - sed -ri 's@^#(LoadModule.*mod_vhost_alias.so)@\1@' ${apache_install_dir}/conf/httpd.conf - sed -ri 's@^#(LoadModule.*mod_rewrite.so)@\1@' ${apache_install_dir}/conf/httpd.conf - sed -ri 's@^#(LoadModule.*mod_deflate.so)@\1@' ${apache_install_dir}/conf/httpd.conf - sed -ri 's@^#(LoadModule.*mod_expires.so)@\1@' ${apache_install_dir}/conf/httpd.conf - sed -ri 's@^#(LoadModule.*mod_ssl.so)@\1@' ${apache_install_dir}/conf/httpd.conf - sed -ri 's@^#(LoadModule.*mod_http2.so)@\1@' ${apache_install_dir}/conf/httpd.conf - sed -i 's@DirectoryIndex index.html@DirectoryIndex index.html index.php@' ${apache_install_dir}/conf/httpd.conf - sed -i "s@^DocumentRoot.*@DocumentRoot \"${wwwroot_dir}/default\"@" ${apache_install_dir}/conf/httpd.conf - sed -i "s@^@@" ${apache_install_dir}/conf/httpd.conf - sed -i "s@^#Include conf/extra/httpd-mpm.conf@Include conf/extra/httpd-mpm.conf@" ${apache_install_dir}/conf/httpd.conf - if [ "${apache_mpm_option}" == '2' ]; then - sed -ri 's@^(LoadModule.*mod_mpm_event.so)@#\1@' ${apache_install_dir}/conf/httpd.conf - sed -i 's@^#LoadModule mpm_prefork_module@LoadModule mpm_prefork_module@' ${apache_install_dir}/conf/httpd.conf - elif [ "${apache_mpm_option}" == '3' ]; then - sed -ri 's@^(LoadModule.*mod_mpm_event.so)@#\1@' ${apache_install_dir}/conf/httpd.conf - sed -i 's@^#LoadModule mpm_worker_module@LoadModule mpm_worker_module@' ${apache_install_dir}/conf/httpd.conf - fi - - #logrotate apache log - cat > /etc/logrotate.d/apache << EOF -${wwwlogs_dir}/*apache.log { - daily - rotate 5 - missingok - dateext - compress - notifempty - sharedscripts - postrotate - [ -e /var/run/httpd.pid ] && kill -USR1 \`cat /var/run/httpd.pid\` - endscript -} -EOF - - mkdir ${apache_install_dir}/conf/vhost - [ "${apache_mode_option}" != '2' ] && Apache_fcgi=$(echo -e "\n Order allow,deny\n Deny from all\n \n \n SetHandler \"proxy:unix:/dev/shm/php-cgi.sock|fcgi://localhost\"\n ") - cat > ${apache_install_dir}/conf/vhost/0.conf << EOF - - ServerAdmin admin@example.com - DocumentRoot "${wwwroot_dir}/default" - ServerName 127.0.0.1 - ErrorLog "${wwwlogs_dir}/error_apache.log" - CustomLog "${wwwlogs_dir}/access_apache.log" common - - Order allow,deny - Deny from all - - ${Apache_fcgi} - - SetOutputFilter DEFLATE - Options FollowSymLinks ExecCGI - Require all granted - AllowOverride All - Order allow,deny - Allow from all - DirectoryIndex index.html index.php - - - SetHandler server-status - Order Deny,Allow - Deny from all - Allow from 127.0.0.1 - - -EOF - - cat >> ${apache_install_dir}/conf/httpd.conf < - AddOutputFilterByType DEFLATE text/html text/plain text/css text/xml text/javascript - - RequestHeader edit "If-None-Match" "^(.*)-gzip(.*)\$" "\$1\$2" - Header edit "ETag" "^(.*)-gzip(.*)\$" "\$1\$2" - - DeflateCompressionLevel 6 - SetOutputFilter DEFLATE - - -ProtocolsHonorOrder On -PidFile /var/run/httpd.pid -ServerTokens ProductOnly -ServerSignature Off -Include conf/vhost/*.conf -EOF - [ "${nginx_option}" == '4' -a ! -e "${web_install_dir}/sbin/nginx" ] && echo 'Protocols h2 http/1.1' >> ${apache_install_dir}/conf/httpd.conf - if [ "${nginx_option}" != '4' -o -e "${web_install_dir}/sbin/nginx" ]; then - cat > ${apache_install_dir}/conf/extra/httpd-remoteip.conf << EOF -LoadModule remoteip_module modules/mod_remoteip.so -RemoteIPHeader X-Forwarded-For -RemoteIPInternalProxy 127.0.0.1 -EOF - sed -i "s@Include conf/extra/httpd-mpm.conf@Include conf/extra/httpd-mpm.conf\nInclude conf/extra/httpd-remoteip.conf@" ${apache_install_dir}/conf/httpd.conf - sed -i "s@LogFormat \"%h %l@LogFormat \"%h %a %l@g" ${apache_install_dir}/conf/httpd.conf - fi - ldconfig - sed -i "s@^export LD_LIBRARY_PATH.*@export LD_LIBRARY_PATH=/usr/local/lib:\$LD_LIBRARY_PATH@" ${apache_install_dir}/bin/envvars - systemctl start httpd - popd > /dev/null -} diff --git a/include/apcu.sh b/include/apcu.sh index 8fc99088..b97db664 100644 --- a/include/apcu.sh +++ b/include/apcu.sh @@ -1,23 +1,29 @@ #!/bin/bash # Author: yeho -# BLOG: https://linuxeye.com +# BLOG: https://blog.linuxeye.com +# +# Notes: OneinStack for CentOS/RadHat 5+ Debian 6+ and Ubuntu 12+ +# +# Project home page: +# https://oneinstack.com +# https://github.com/lj2007331/oneinstack Install_APCU() { - if [ -e "${php_install_dir}/bin/phpize" ]; then - pushd ${current_dir}/src > /dev/null - phpExtensionDir=`${php_install_dir}/bin/php-config --extension-dir` - if [ "`${php_install_dir}/bin/php-config --version | awk -F. '{print $1}'`" == '5' ]; then - tar xzf apcu-4.0.11.tgz - pushd apcu-4.0.11 > /dev/null - else - tar xzf apcu-${apcu_ver}.tgz - pushd apcu-${apcu_ver} > /dev/null - fi - ${php_install_dir}/bin/phpize - ./configure --with-php-config=${php_install_dir}/bin/php-config - make -j ${THREAD} && make install - if [ -f "${phpExtensionDir}/apcu.so" ]; then - cat > ${php_install_dir}/etc/php.d/02-apcu.ini << EOF + pushd ${oneinstack_dir}/src + phpExtensionDir=`${php_install_dir}/bin/php-config --extension-dir` + if [ "`${php_install_dir}/bin/php -r 'echo PHP_VERSION;' | awk -F. '{print $1}'`" == '7' ]; then + tar xzf apcu-${apcu_for_php7_version}.tgz + pushd apcu-${apcu_for_php7_version} + else + tar xzf apcu-${apcu_version}.tgz + pushd apcu-${apcu_version} + fi + + ${php_install_dir}/bin/phpize + ./configure --with-php-config=${php_install_dir}/bin/php-config + make -j ${THREAD} && make install + if [ -f "${phpExtensionDir}/apcu.so" ]; then + cat > ${php_install_dir}/etc/php.d/ext-apcu.ini << EOF [apcu] extension=apcu.so apc.enabled=1 @@ -25,22 +31,12 @@ apc.shm_size=32M apc.ttl=7200 apc.enable_cli=1 EOF - /bin/cp apc.php ${wwwroot_dir}/default - popd > /dev/null - echo "${CSUCCESS}PHP apcu module installed successfully! ${CEND}" - rm -rf apcu-${apcu_ver} apcu-4.0.11 package.xml - else - echo "${CFAILURE}PHP apcu module install failed, Please contact the author! ${CEND}" && grep -Ew 'NAME|ID|ID_LIKE|VERSION_ID|PRETTY_NAME' /etc/os-release - fi - popd > /dev/null - fi -} - -Uninstall_APCU() { - if [ -e "${php_install_dir}/etc/php.d/02-apcu.ini" ]; then - rm -rf ${php_install_dir}/etc/php.d/02-apcu.ini ${wwwroot_dir}/default/apc.php - echo; echo "${CMSG}PHP apcu module uninstall completed${CEND}" + /bin/cp apc.php ${wwwroot_dir}/default + echo "${CSUCCESS}APCU module installed successfully! ${CEND}" + popd + rm -rf apcu-${apcu_for_php7_version} apcu-${apcu_version} package.xml else - echo; echo "${CWARNING}PHP apcu module does not exist! ${CEND}" + echo "${CFAILURE}APCU module install failed, Please contact the author! ${CEND}" fi + popd } diff --git a/include/boost.sh b/include/boost.sh new file mode 100644 index 00000000..1cb15e2e --- /dev/null +++ b/include/boost.sh @@ -0,0 +1,30 @@ +#!/bin/bash +# Author: Alpha Eva +# +# Notes: OneinStack for CentOS/RadHat 5+ Debian 6+ and Ubuntu 12+ +# +# Project home page: +# https://oneinstack.com +# https://github.com/lj2007331/oneinstack + +installBoost() { + pushd ${oneinstack_dir}/src + if [ ! -e "/usr/local/lib/libboost_system.so" ]; then + boostVersion2=$(echo ${boost_version} | awk -F. '{print $1}')_$(echo ${boost_version} | awk -F. '{print $2}')_$(echo ${boost_version} | awk -F. '{print $3}') + tar xvf boost_${boostVersion2}.tar.gz + pushd boost_${boostVersion2} + ./bootstrap.sh + ./bjam --prefix=/usr/local + ./b2 install + popd + fi + if [ -e "/usr/local/lib/libboost_system.so" ]; then + echo '/usr/local/lib' > /etc/ld.so.conf.d/local.conf + ldconfig + echo "${CSUCCESS}Boost installed successfully! ${CEND}" + rm -rf boost_${boostVersion2} + else + echo "${CFAILURE}Boost installed failed, Please contact the author! ${CEND}" + fi + popd +} diff --git a/include/check_db.sh b/include/check_db.sh new file mode 100644 index 00000000..6cfd0cb5 --- /dev/null +++ b/include/check_db.sh @@ -0,0 +1,13 @@ +#!/bin/bash +# Author: yeho +# BLOG: https://blog.linuxeye.com +# +# Notes: OneinStack for CentOS/RadHat 5+ Debian 6+ and Ubuntu 12+ +# +# Project home page: +# http://oneinstack.com +# https://github.com/lj2007331/oneinstack + +[ -d "$mysql_install_dir/support-files" ] && { db_install_dir=$mysql_install_dir; db_data_dir=$mysql_data_dir; } +[ -d "$mariadb_install_dir/support-files" ] && { db_install_dir=$mariadb_install_dir; db_data_dir=$mariadb_data_dir; } +[ -d "$percona_install_dir/support-files" ] && { db_install_dir=$percona_install_dir; db_data_dir=$percona_data_dir; } diff --git a/include/check_dir.sh b/include/check_dir.sh index 19655a02..171143b8 100644 --- a/include/check_dir.sh +++ b/include/check_dir.sh @@ -1,13 +1,20 @@ #!/bin/bash # Author: yeho -# BLOG: https://linuxeye.com +# BLOG: https://blog.linuxeye.com +# +# Notes: OneinStack for CentOS/RadHat 5+ Debian 6+ and Ubuntu 12+ +# +# Project home page: +# https://oneinstack.com +# https://github.com/lj2007331/oneinstack # check MySQL dir -[ -d "${mysql_install_dir}/support-files" ] && { db_install_dir=${mysql_install_dir}; db_data_dir=${mysql_data_dir}; } -[ -d "${mariadb_install_dir}/support-files" ] && { db_install_dir=${mariadb_install_dir}; db_data_dir=${mariadb_data_dir}; } -[ -d "${percona_install_dir}/support-files" ] && { db_install_dir=${percona_install_dir}; db_data_dir=${percona_data_dir}; } +[ -d "$mysql_install_dir/support-files" ] && { db_install_dir=$mysql_install_dir; db_data_dir=$mysql_data_dir; } +[ -d "$mariadb_install_dir/support-files" ] && { db_install_dir=$mariadb_install_dir; db_data_dir=$mariadb_data_dir; } +[ -d "$percona_install_dir/support-files" ] && { db_install_dir=$percona_install_dir; db_data_dir=$percona_data_dir; } +[ -d "$alisql_install_dir/support-files" ] && { db_install_dir=$alisql_install_dir; db_data_dir=$alisql_data_dir; } # check Nginx dir -[ -e "${nginx_install_dir}/sbin/nginx" ] && web_install_dir=${nginx_install_dir} -[ -e "${tengine_install_dir}/sbin/nginx" ] && web_install_dir=${tengine_install_dir} -[ -e "${openresty_install_dir}/nginx/sbin/nginx" ] && web_install_dir=${openresty_install_dir}/nginx +[ -e "$nginx_install_dir/sbin/nginx" ] && web_install_dir=$nginx_install_dir +[ -e "$tengine_install_dir/sbin/nginx" ] && web_install_dir=$tengine_install_dir +[ -e "$openresty_install_dir/nginx/sbin/nginx" ] && web_install_dir=$openresty_install_dir/nginx diff --git a/include/check_download.sh b/include/check_download.sh index c8bf481b..0d08056c 100644 --- a/include/check_download.sh +++ b/include/check_download.sh @@ -1,319 +1,389 @@ #!/bin/bash # Author: Alpha Eva +# +# Notes: OneinStack for CentOS/RadHat 5+ Debian 6+ and Ubuntu 12+ +# +# Project home page: +# https://oneinstack.com +# https://github.com/lj2007331/oneinstack checkDownload() { - pushd ${current_dir}/src > /dev/null - # icu - if ! command -v icu-config >/dev/null 2>&1 || icu-config --version | grep '^3.' || [ "${Ubuntu_ver}" == "20" ]; then - echo "Download icu..." - src_url=${mirror_link}/src/icu4c-${icu4c_ver}-src.tgz && Download_src - fi + mirrorLink=http://mirrors.linuxeye.com/oneinstack/src + pushd ${oneinstack_dir}/src - # General system utils - if [ "${with_old_openssl_flag}" == 'y' ]; then + # Web + if [ "${Web_yn}" == 'y' ]; then echo "Download openSSL..." - src_url=https://www.openssl.org/source/old/1.0.2/openssl-1.0.2u.tar.gz && Download_src - echo "Download cacert.pem..." - src_url=https://curl.se/ca/cacert.pem && Download_src - fi - - # openssl - if [[ ${nginx_option} =~ ^[1-3]$ ]]; then - echo "Download openSSL..." - src_url=${mirror_link}/src/openssl-${openssl_ver}.tar.gz && Download_src - fi - - # jemalloc - if [[ ${nginx_option} =~ ^[1-3]$ ]] || [[ "${db_option}" =~ ^[1-9]$|^1[0-2]$ ]]; then - echo "Download jemalloc..." - src_url=${mirror_link}/src/jemalloc-${jemalloc_ver}.tar.bz2 && Download_src - fi + src_url=https://www.openssl.org/source/openssl-${openssl_version}.tar.gz && Download_src + case "${Nginx_version}" in + 1) + echo "Download nginx..." + src_url=http://nginx.org/download/nginx-${nginx_version}.tar.gz && Download_src + ;; + 2) + echo "Download tengine..." + src_url=http://tengine.taobao.org/download/tengine-${tengine_version}.tar.gz && Download_src + ;; + 3) + echo "Download openresty..." + src_url=https://openresty.org/download/openresty-${openresty_version}.tar.gz && Download_src + ;; + esac - # nginx/tengine/openresty - case "${nginx_option}" in - 1) - echo "Download nginx..." - src_url=http://nginx.org/download/nginx-${nginx_ver}.tar.gz && Download_src - ;; - 2) - echo "Download tengine..." - #src_url=http://tengine.taobao.org/download/tengine-${tengine_ver}.tar.gz && Download_src - src_url=${mirror_link}/src/tengine-${tengine_ver}.tar.gz && Download_src - ;; - 3) - echo "Download openresty..." - src_url=https://openresty.org/download/openresty-${openresty_ver}.tar.gz && Download_src - ;; - esac + if [[ "${Nginx_version}" =~ ^[1-3]$ || ${Apache_version} == '1' ]]; then + echo "Download pcre..." + src_url=${mirrorLink}/pcre-${pcre_version}.tar.gz && Download_src + fi - # pcre - if [[ "${nginx_option}" =~ ^[1-3]$ ]] || [ "${apache_flag}" == 'y' ]; then - echo "Download pcre..." - src_url=https://downloads.sourceforge.net/project/pcre/pcre/${pcre_ver}/pcre-${pcre_ver}.tar.gz && Download_src - fi + # apache + if [ "${Apache_version}" == '1' ]; then + echo "Download apache 2.4..." + src_url=http://archive.apache.org/dist/apr/apr-${apr_version}.tar.gz && Download_src + src_url=http://archive.apache.org/dist/apr/apr-util-${apr_util_version}.tar.gz && Download_src + src_url=http://mirrors.linuxeye.com/apache/httpd/nghttp2-${nghttp2_version}.tar.gz && Download_src + src_url=http://mirrors.linuxeye.com/apache/httpd/httpd-${apache24_version}.tar.gz && Download_src + fi + if [ "${Apache_version}" == '2' ]; then + echo "Download apache 2.2..." + src_url=http://mirrors.linuxeye.com/apache/httpd/httpd-${apache22_version}.tar.gz && Download_src - # apache - if [ "${apache_flag}" == 'y' ]; then - echo "Download apache 2.4..." - src_url=http://archive.apache.org/dist/httpd/httpd-${apache_ver}.tar.gz && Download_src - src_url=http://archive.apache.org/dist/apr/apr-${apr_ver}.tar.gz && Download_src - src_url=http://archive.apache.org/dist/apr/apr-util-${apr_util_ver}.tar.gz && Download_src - src_url=${mirror_link}/apache/httpd/nghttp2-${nghttp2_ver}.tar.gz && Download_src - fi + echo "Download mod_remoteip.c for apache 2.2..." + src_url=${mirrorLink}/mod_remoteip.c && Download_src + fi - # tomcat - case "${tomcat_option}" in - 1) - echo "Download tomcat 10..." - src_url=${mirror_link}/apache/tomcat/v${tomcat10_ver}/apache-tomcat-${tomcat10_ver}.tar.gz && Download_src - ;; - 2) - echo "Download tomcat 9..." - src_url=${mirror_link}/apache/tomcat/v${tomcat9_ver}/apache-tomcat-${tomcat9_ver}.tar.gz && Download_src - ;; - 3) - echo "Download tomcat 8..." - src_url=${mirror_link}/apache/tomcat/v${tomcat8_ver}/apache-tomcat-${tomcat8_ver}.tar.gz && Download_src - ;; - 4) - echo "Download tomcat 7..." - src_url=${mirror_link}/apache/tomcat/v${tomcat7_ver}/apache-tomcat-${tomcat7_ver}.tar.gz && Download_src - src_url=${mirror_link}/apache/tomcat/v${tomcat7_ver}/catalina-jmx-remote.jar && Download_src - ;; - esac + # tomcat + case "${Tomcat_version}" in + 1) + echo "Download tomcat 8..." + src_url=http://mirrors.linuxeye.com/apache/tomcat/v${tomcat8_version}/apache-tomcat-${tomcat8_version}.tar.gz && Download_src + src_url=http://mirrors.linuxeye.com/apache/tomcat/v${tomcat8_version}/catalina-jmx-remote.jar && Download_src + ;; + 2) + echo "Download tomcat 7..." + src_url=http://mirrors.linuxeye.com/apache/tomcat/v${tomcat7_version}/apache-tomcat-${tomcat7_version}.tar.gz && Download_src + src_url=http://mirrors.linuxeye.com/apache/tomcat/v${tomcat7_version}/catalina-jmx-remote.jar && Download_src + ;; + 3) + echo "Download tomcat 6..." + src_url=http://mirrors.linuxeye.com/apache/tomcat/v${tomcat6_version}/apache-tomcat-${tomcat6_version}.tar.gz && Download_src + src_url=http://mirrors.linuxeye.com/apache/tomcat/v${tomcat6_version}/catalina-jmx-remote.jar && Download_src + ;; + esac - # jdk apr - if [[ "${jdk_option}" =~ ^[1-3]$ ]]; then - echo "Download apr..." - src_url=http://archive.apache.org/dist/apr/apr-${apr_ver}.tar.gz && Download_src + if [[ "${JDK_version}" =~ ^[1-3]$ ]]; then + case "${JDK_version}" in + 1) + echo "Download JDK 1.8..." + JDK_FILE="jdk-$(echo ${jdk18_version} | awk -F. '{print $2}')u$(echo ${jdk18_version} | awk -F_ '{print $NF}')-linux-${SYS_BIG_FLAG}.tar.gz" + ;; + 2) + echo "Download JDK 1.7..." + JDK_FILE="jdk-$(echo ${jdk17_version} | awk -F. '{print $2}')u$(echo ${jdk17_version} | awk -F_ '{print $NF}')-linux-${SYS_BIG_FLAG}.tar.gz" + ;; + 3) + echo "Download JDK 1.6..." + JDK_FILE="jdk-$(echo ${jdk16_version} | awk -F. '{print $2}')u$(echo ${jdk16_version} | awk -F_ '{print $NF}')-linux-${SYS_BIG_FLAG}.bin" + ;; + esac + echo "Download apr..." + src_url=http://archive.apache.org/dist/apr/apr-${apr_version}.tar.gz && Download_src + # start download... + src_url=http://mirrors.linuxeye.com/jdk/${JDK_FILE} && Download_src + fi fi - if [[ "${db_option}" =~ ^[1-9]$|^1[0-4]$ ]]; then - if [[ "${db_option}" =~ ^[1,2,5,6,7,9]$|^10$ ]] && [ "${dbinstallmethod}" == "2" ]; then - [[ "${db_option}" =~ ^[2,5,6,7]$|^10$ ]] && boost_ver=${boost_oldver} - [[ "${db_option}" =~ ^9$ ]] && boost_ver=${boost_percona_ver} + if [ "${DB_yn}" == 'y' ]; then + if [[ "${DB_version}" =~ ^[1,4,7]$ ]] && [ "${dbInstallMethods}" == "2" ]; then echo "Download boost..." - [ "${OUTIP_STATE}"x == "China"x ] && DOWN_ADDR_BOOST=${mirror_link}/src || DOWN_ADDR_BOOST=https://downloads.sourceforge.net/project/boost/boost/${boost_ver} - boostVersion2=$(echo ${boost_ver} | awk -F. '{print $1"_"$2"_"$3}') + [ "${IPADDR_COUNTRY}"x == "CN"x ] && DOWN_ADDR_BOOST=${mirrorLink} || DOWN_ADDR_BOOST=http://downloads.sourceforge.net/project/boost/boost/${boost_version} + boostVersion2=$(echo ${boost_version} | awk -F. '{print $1}')_$(echo ${boost_version} | awk -F. '{print $2}')_$(echo ${boost_version} | awk -F. '{print $3}') src_url=${DOWN_ADDR_BOOST}/boost_${boostVersion2}.tar.gz && Download_src fi - case "${db_option}" in + case "${DB_version}" in 1) - # MySQL 8.4 - DOWN_ADDR_MYSQL=https://cdn.mysql.com/Downloads/MySQL-8.4 - if [ "${dbinstallmethod}" == '1' ]; then - echo "Download MySQL 8.4 binary package..." - FILE_NAME=mysql-${mysql84_ver}-linux-glibc2.28-x86_64.tar.xz - elif [ "${dbinstallmethod}" == '2' ]; then - echo "Download MySQL 8.4 source package..." - FILE_NAME=mysql-${mysql84_ver}.tar.gz + # MySQL 5.7 + if [ "${IPADDR_COUNTRY}"x == "CN"x -a "${IPADDR_ISP}" == "aliyun" -a "$(../include/check_port.py aliyun-oss.linuxeye.com 80)" == "True" ]; then + DOWN_ADDR_MYSQL=http://aliyun-oss.linuxeye.com/mysql/MySQL-5.7 + else + if [ "${IPADDR_COUNTRY}"x == "CN"x ]; then + if [ "$(../include/check_port.py mirrors.tuna.tsinghua.edu.cn 443)" == "True" ]; then + DOWN_ADDR_MYSQL=https://mirrors.tuna.tsinghua.edu.cn/mysql/downloads/MySQL-5.7 + DOWN_ADDR_MYSQL_BK=http://mirrors.ustc.edu.cn/mysql-ftp/Downloads/MySQL-5.7 + else + DOWN_ADDR_MYSQL=http://mirrors.ustc.edu.cn/mysql-ftp/Downloads/MySQL-5.7 + DOWN_ADDR_MYSQL_BK=https://mirrors.tuna.tsinghua.edu.cn/mysql/downloads/MySQL-5.7 + fi + else + if [ "$(../include/check_port.py cdn.mysql.com 80)" == "True" ]; then + DOWN_ADDR_MYSQL=http://cdn.mysql.com/Downloads/MySQL-5.7 + DOWN_ADDR_MYSQL_BK=http://mysql.he.net/Downloads/MySQL-5.7 + else + DOWN_ADDR_MYSQL=http://mysql.he.net/Downloads/MySQL-5.7 + DOWN_ADDR_MYSQL_BK=http://cdn.mysql.com/Downloads/MySQL-5.7 + fi + fi + fi + if [ "${dbInstallMethods}" == '1' ]; then + echo "Download MySQL 5.7 binary package..." + FILE_NAME=mysql-${mysql57_version}-linux-glibc2.5-${SYS_BIT_b}.tar.gz + elif [ "${dbInstallMethods}" == '2' ]; then + echo "Download MySQL 5.7 source package..." + FILE_NAME=mysql-${mysql57_version}.tar.gz fi # start download - src_url=${DOWN_ADDR_MYSQL}/${FILE_NAME} && Download_src - src_url=${DOWN_ADDR_MYSQL}/${FILE_NAME}.md5 && Download_src + wget --tries=6 -c --no-check-certificate ${DOWN_ADDR_MYSQL}/${FILE_NAME} # verifying download - MYSQL_TAR_MD5=$(awk '{print $1}' ${FILE_NAME}.md5) - [ -z "${MYSQL_TAR_MD5}" ] && MYSQL_TAR_MD5=$(curl -s ${DOWN_ADDR_MYSQL}/${FILE_NAME}.md5 | grep ${FILE_NAME} | awk '{print $1}') + MYSQL_TAR_MD5=$(curl -Lk ${DOWN_ADDR_MYSQL}/${FILE_NAME}.md5 | grep ${FILE_NAME} | awk '{print $1}') + [ -z "${MYSQL_TAR_MD5}" ] && MYSQL_TAR_MD5=$(curl -Lk ${DOWN_ADDR_MYSQL_BK}/${FILE_NAME}.md5 | grep ${FILE_NAME} | awk '{print $1}') tryDlCount=0 while [ "$(md5sum ${FILE_NAME} | awk '{print $1}')" != "${MYSQL_TAR_MD5}" ]; do - wget -c --no-check-certificate ${DOWN_ADDR_MYSQL}/${FILE_NAME};sleep 1 + wget -c --no-check-certificate ${DOWN_ADDR_MYSQL_BK}/${FILE_NAME};sleep 1 let "tryDlCount++" [ "$(md5sum ${FILE_NAME} | awk '{print $1}')" == "${MYSQL_TAR_MD5}" -o "${tryDlCount}" == '6' ] && break || continue done if [ "${tryDlCount}" == '6' ]; then echo "${CFAILURE}${FILE_NAME} download failed, Please contact the author! ${CEND}" - kill -9 $$; exit 1; + kill -9 $$ + else + echo "[${CMSG}${FILE_NAME}${CEND}] found." fi ;; + 2) - # MySQL 8.0 - DOWN_ADDR_MYSQL=https://cdn.mysql.com/Downloads/MySQL-8.0 - if [ "${dbinstallmethod}" == '1' ]; then - echo "Download MySQL 8.0 binary package..." - FILE_NAME=mysql-${mysql80_ver}-linux-glibc2.28-x86_64.tar.xz - elif [ "${dbinstallmethod}" == '2' ]; then - echo "Download MySQL 8.0 source package..." - FILE_NAME=mysql-${mysql80_ver}.tar.gz + # MySQL 5.6 + if [ "${IPADDR_COUNTRY}"x == "CN"x -a "${IPADDR_ISP}" == "aliyun" -a "$(../include/check_port.py aliyun-oss.linuxeye.com 80)" == "True" ]; then + DOWN_ADDR_MYSQL=http://aliyun-oss.linuxeye.com/mysql/MySQL-5.6 + else + if [ "${IPADDR_COUNTRY}"x == "CN"x ]; then + if [ "$(../include/check_port.py mirrors.tuna.tsinghua.edu.cn 443)" == "True" ]; then + DOWN_ADDR_MYSQL=https://mirrors.tuna.tsinghua.edu.cn/mysql/downloads/MySQL-5.6 + DOWN_ADDR_MYSQL_BK=http://mirrors.ustc.edu.cn/mysql-ftp/Downloads/MySQL-5.6 + else + DOWN_ADDR_MYSQL=http://mirrors.ustc.edu.cn/mysql-ftp/Downloads/MySQL-5.6 + DOWN_ADDR_MYSQL_BK=https://mirrors.tuna.tsinghua.edu.cn/mysql/downloads/MySQL-5.6 + fi + else + if [ "$(../include/check_port.py cdn.mysql.com 80)" == "True" ]; then + DOWN_ADDR_MYSQL=http://cdn.mysql.com/Downloads/MySQL-5.6 + DOWN_ADDR_MYSQL_BK=http://mysql.he.net/Downloads/MySQL-5.6 + else + DOWN_ADDR_MYSQL=http://mysql.he.net/Downloads/MySQL-5.6 + DOWN_ADDR_MYSQL_BK=http://cdn.mysql.com/Downloads/MySQL-5.6 + fi + fi fi - # start download - src_url=${DOWN_ADDR_MYSQL}/${FILE_NAME} && Download_src - src_url=${DOWN_ADDR_MYSQL}/${FILE_NAME}.md5 && Download_src + if [ "${dbInstallMethods}" == '1' ]; then + echo "Download MySQL 5.6 binary package..." + FILE_NAME=mysql-${mysql56_version}-linux-glibc2.5-${SYS_BIT_b}.tar.gz + elif [ "${dbInstallMethods}" == '2' ]; then + echo "Download MySQL 5.6 source package..." + FILE_NAME=mysql-${mysql56_version}.tar.gz + fi + wget --tries=6 -c --no-check-certificate ${DOWN_ADDR_MYSQL}/${FILE_NAME} # verifying download - MYSQL_TAR_MD5=$(awk '{print $1}' ${FILE_NAME}.md5) - [ -z "${MYSQL_TAR_MD5}" ] && MYSQL_TAR_MD5=$(curl -s ${DOWN_ADDR_MYSQL}/${FILE_NAME}.md5 | grep ${FILE_NAME} | awk '{print $1}') + MYSQL_TAR_MD5=$(curl -Lk ${DOWN_ADDR_MYSQL}/${FILE_NAME}.md5 | grep ${FILE_NAME} | awk '{print $1}') + [ -z "${MYSQL_TAR_MD5}" ] && MYSQL_TAR_MD5=$(curl -Lk ${DOWN_ADDR_MYSQL_BK}/${FILE_NAME}.md5 | grep ${FILE_NAME} | awk '{print $1}') tryDlCount=0 while [ "$(md5sum ${FILE_NAME} | awk '{print $1}')" != "${MYSQL_TAR_MD5}" ]; do - wget -c --no-check-certificate ${DOWN_ADDR_MYSQL}/${FILE_NAME};sleep 1 + wget -c --no-check-certificate ${DOWN_ADDR_MYSQL_BK}/${FILE_NAME};sleep 1 let "tryDlCount++" [ "$(md5sum ${FILE_NAME} | awk '{print $1}')" == "${MYSQL_TAR_MD5}" -o "${tryDlCount}" == '6' ] && break || continue done if [ "${tryDlCount}" == '6' ]; then echo "${CFAILURE}${FILE_NAME} download failed, Please contact the author! ${CEND}" - kill -9 $$; exit 1; + kill -9 $$ + else + echo "[${CMSG}${FILE_NAME}${CEND}] found." fi ;; + 3) - # MySQL 5.7 - DOWN_ADDR_MYSQL=https://cdn.mysql.com/Downloads/MySQL-5.7 - if [ "${dbinstallmethod}" == '1' ]; then - echo "Download MySQL 5.7 binary package..." - FILE_NAME=mysql-${mysql57_ver}-linux-glibc2.12-x86_64.tar.gz - elif [ "${dbinstallmethod}" == '2' ]; then - echo "Download MySQL 5.7 source package..." - FILE_NAME=mysql-${mysql57_ver}.tar.gz + # MySQL 5.5 + if [ "${IPADDR_COUNTRY}"x == "CN"x -a "${IPADDR_ISP}" == "aliyun" -a "$(../include/check_port.py aliyun-oss.linuxeye.com 80)" == "True" ]; then + DOWN_ADDR_MYSQL=http://aliyun-oss.linuxeye.com/mysql/MySQL-5.5 + else + if [ "${IPADDR_COUNTRY}"x == "CN"x ]; then + if [ "$(../include/check_port.py mirrors.tuna.tsinghua.edu.cn 443)" == "True" ]; then + DOWN_ADDR_MYSQL=https://mirrors.tuna.tsinghua.edu.cn/mysql/downloads/MySQL-5.5 + DOWN_ADDR_MYSQL_BK=http://mirrors.ustc.edu.cn/mysql-ftp/Downloads/MySQL-5.5 + else + DOWN_ADDR_MYSQL=http://mirrors.ustc.edu.cn/mysql-ftp/Downloads/MySQL-5.5 + DOWN_ADDR_MYSQL_BK=https://mirrors.tuna.tsinghua.edu.cn/mysql/downloads/MySQL-5.5 + fi + else + if [ "$(../include/check_port.py cdn.mysql.com 80)" == "True" ]; then + DOWN_ADDR_MYSQL=http://cdn.mysql.com/Downloads/MySQL-5.5 + DOWN_ADDR_MYSQL_BK=http://mysql.he.net/Downloads/MySQL-5.5 + else + DOWN_ADDR_MYSQL=http://mysql.he.net/Downloads/MySQL-5.5 + DOWN_ADDR_MYSQL_BK=http://cdn.mysql.com/Downloads/MySQL-5.5 + fi + fi fi - # start download - src_url=${DOWN_ADDR_MYSQL}/${FILE_NAME} && Download_src - src_url=${DOWN_ADDR_MYSQL}/${FILE_NAME}.md5 && Download_src + if [ "${dbInstallMethods}" == '1' ]; then + echo "Download MySQL 5.5 binary package..." + FILE_NAME=mysql-${mysql55_version}-linux-glibc2.5-${SYS_BIT_b}.tar.gz + elif [ "${dbInstallMethods}" == '2' ]; then + echo "Download MySQL 5.5 source package..." + FILE_NAME=mysql-${mysql55_version}.tar.gz + src_url=${mirrorLink}/mysql-5.5-fix-arm-client_plugin.patch && Download_src + fi + wget --tries=6 -c --no-check-certificate ${DOWN_ADDR_MYSQL}/${FILE_NAME} # verifying download - MYSQL_TAR_MD5=$(awk '{print $1}' ${FILE_NAME}.md5) - [ -z "${MYSQL_TAR_MD5}" ] && MYSQL_TAR_MD5=$(curl -s ${DOWN_ADDR_MYSQL}/${FILE_NAME}.md5 | grep ${FILE_NAME} | awk '{print $1}') + MYSQL_TAR_MD5=$(curl -Lk ${DOWN_ADDR_MYSQL}/${FILE_NAME}.md5 | grep ${FILE_NAME} | awk '{print $1}') + [ -z "${MYSQL_TAR_MD5}" ] && MYSQL_TAR_MD5=$(curl -Lk ${DOWN_ADDR_MYSQL_BK}/${FILE_NAME}.md5 | grep ${FILE_NAME} | awk '{print $1}') tryDlCount=0 while [ "$(md5sum ${FILE_NAME} | awk '{print $1}')" != "${MYSQL_TAR_MD5}" ]; do - wget -c --no-check-certificate ${DOWN_ADDR_MYSQL}/${FILE_NAME};sleep 1 + wget -c --no-check-certificate ${DOWN_ADDR_MYSQL_BK}/${FILE_NAME};sleep 1 let "tryDlCount++" [ "$(md5sum ${FILE_NAME} | awk '{print $1}')" == "${MYSQL_TAR_MD5}" -o "${tryDlCount}" == '6' ] && break || continue done if [ "${tryDlCount}" == '6' ]; then echo "${CFAILURE}${FILE_NAME} download failed, Please contact the author! ${CEND}" - kill -9 $$; exit 1; + kill -9 $$ + else + echo "[${CMSG}${FILE_NAME}${CEND}] found." fi ;; + 4) - # MySQL 5.5 - DOWN_ADDR_MYSQL=http://mirrors.aliyun.com/mysql/MySQL-5.5 - if [ "${dbinstallmethod}" == '1' ]; then - echo "Download MySQL 5.5 binary package..." - FILE_NAME=mysql-${mysql55_ver}-linux-glibc2.12-x86_64.tar.gz - elif [ "${dbinstallmethod}" == '2' ]; then - echo "Download MySQL 5.5 source package..." - FILE_NAME=mysql-${mysql55_ver}.tar.gz - src_url=${mirror_link}/src/mysql-5.5-fix-arm-client_plugin.patch && Download_src + # MariaDB 10.1 + if [ "${dbInstallMethods}" == '1' ]; then + echo "Download MariaDB 10.1 binary package..." + FILE_NAME=mariadb-${mariadb101_version}-${GLIBC_FLAG}-${SYS_BIT_b}.tar.gz + if [ "${IPADDR_COUNTRY}"x == "CN"x ]; then + DOWN_ADDR_MARIADB=https://mirrors.tuna.tsinghua.edu.cn/mariadb/mariadb-${mariadb101_version}/bintar-${GLIBC_FLAG}-${SYS_BIT_a} + MARAIDB_TAR_MD5=$(curl -Lk ${DOWN_ADDR_MARIADB}/md5sums.txt | grep ${FILE_NAME} | awk '{print $1}') + [ -z "${MARAIDB_TAR_MD5}" ] && { DOWN_ADDR_MARIADB=https://mirrors.ustc.edu.cn/mariadb/mariadb-${mariadb101_version}/bintar-${GLIBC_FLAG}-${SYS_BIT_a}; MARAIDB_TAR_MD5=$(curl -Lk ${DOWN_ADDR_MARIADB}/md5sums.txt | grep ${FILE_NAME} | awk '{print $1}'); } + else + DOWN_ADDR_MARIADB=https://downloads.mariadb.org/interstitial/mariadb-${mariadb101_version}/bintar-${GLIBC_FLAG}-${SYS_BIT_a} + MARAIDB_TAR_MD5=$(curl -Lk http://archive.mariadb.org/mariadb-${mariadb101_version}/bintar-${GLIBC_FLAG}-${SYS_BIT_a}/md5sums.txt | grep ${FILE_NAME} | awk '{print $1}') + fi + elif [ "${dbInstallMethods}" == '2' ]; then + echo "Download MariaDB 10.1 source package..." + FILE_NAME=mariadb-${mariadb101_version}.tar.gz + if [ "${IPADDR_COUNTRY}"x == "CN"x ]; then + DOWN_ADDR_MARIADB=https://mirrors.tuna.tsinghua.edu.cn/mariadb/mariadb-${mariadb101_version}/source + MARAIDB_TAR_MD5=$(curl -Lk ${DOWN_ADDR_MARIADB}/md5sums.txt | grep ${FILE_NAME} | awk '{print $1}') + [ -z "${MARAIDB_TAR_MD5}" ] && { DOWN_ADDR_MARIADB=https://mirrors.ustc.edu.cn/mariadb/mariadb-${mariadb101_version}/source; MARAIDB_TAR_MD5=$(curl -Lk ${DOWN_ADDR_MARIADB}/md5sums.txt | grep ${FILE_NAME} | awk '{print $1}'); } + else + DOWN_ADDR_MARIADB=https://downloads.mariadb.org/interstitial/mariadb-${mariadb101_version}/source + MARAIDB_TAR_MD5=$(curl -Lk http://archive.mariadb.org/mariadb-${mariadb101_version}/source/md5sums.txt | grep ${FILE_NAME} | awk '{print $1}') + fi fi - # start download - src_url=${DOWN_ADDR_MYSQL}/${FILE_NAME} && Download_src - src_url=${DOWN_ADDR_MYSQL}/${FILE_NAME}.md5 && Download_src - # verifying download - MYSQL_TAR_MD5=$(awk '{print $1}' ${FILE_NAME}.md5) - [ -z "${MYSQL_TAR_MD5}" ] && MYSQL_TAR_MD5=$(curl -s ${DOWN_ADDR_MYSQL}/${FILE_NAME}.md5 | grep ${FILE_NAME} | awk '{print $1}') tryDlCount=0 - while [ "$(md5sum ${FILE_NAME} | awk '{print $1}')" != "${MYSQL_TAR_MD5}" ]; do - wget -c --no-check-certificate ${DOWN_ADDR_MYSQL}/${FILE_NAME};sleep 1 + while [ "$(md5sum ${FILE_NAME} | awk '{print $1}')" != "${MARAIDB_TAR_MD5}" ]; do + wget -c --no-check-certificate ${DOWN_ADDR_MARIADB}/${FILE_NAME};sleep 1 let "tryDlCount++" - [ "$(md5sum ${FILE_NAME} | awk '{print $1}')" == "${MYSQL_TAR_MD5}" -o "${tryDlCount}" == '6' ] && break || continue + [ "$(md5sum ${FILE_NAME} | awk '{print $1}')" == "${MARAIDB_TAR_MD5}" -o "${tryDlCount}" == '6' ] && break || continue done if [ "${tryDlCount}" == '6' ]; then echo "${CFAILURE}${FILE_NAME} download failed, Please contact the author! ${CEND}" - kill -9 $$; exit 1; - fi - ;; - [5-8]) - case "${db_option}" in - 5) - mariadb_ver=${mariadb118_ver} - ;; - 6) - mariadb_ver=${mariadb114_ver} - ;; - 7) - mariadb_ver=${mariadb1011_ver} - ;; - 8) - mariadb_ver=${mariadb55_ver} - ;; - esac - - if [ "${dbinstallmethod}" == '1' ]; then - FILE_NAME=mariadb-${mariadb_ver}-linux-systemd-x86_64.tar.gz - FILE_TYPE=bintar-linux-systemd-x86_64 - elif [ "${dbinstallmethod}" == '2' ]; then - FILE_NAME=mariadb-${mariadb_ver}.tar.gz - FILE_TYPE=source - fi - - if [ "${OUTIP_STATE}"x == "China"x ]; then - DOWN_ADDR_MARIADB=http://mirrors.tuna.tsinghua.edu.cn/mariadb/mariadb-${mariadb_ver}/${FILE_TYPE} - DOWN_ADDR_MARIADB_BK=http://mirrors.ustc.edu.cn/mariadb/mariadb-${mariadb_ver}/${FILE_TYPE} + kill -9 $$ else - DOWN_ADDR_MARIADB=https://archive.mariadb.org/mariadb-${mariadb_ver}/${FILE_TYPE} - DOWN_ADDR_MARIADB_BK=http://mirror.nodesdirect.com/mariadb/mariadb-${mariadb_ver}/${FILE_TYPE} + echo "[${CMSG}${FILE_NAME}${CEND}] found." fi + ;; - if [ "${db_option}" == '8' ]; then - DOWN_ADDR_MARIADB=https://archive.mariadb.org/mariadb-${mariadb_ver}/${FILE_TYPE} - DOWN_ADDR_MARIADB_BK=${DOWN_ADDR_MARIADB} + 5) + # MariaDB 10.0 + if [ "${dbInstallMethods}" == '1' ]; then + echo "Download MariaDB 10.0 binary package..." + FILE_NAME=mariadb-${mariadb100_version}-${GLIBC_FLAG}-${SYS_BIT_b}.tar.gz + if [ "${IPADDR_COUNTRY}"x == "CN"x ]; then + DOWN_ADDR_MARIADB=https://mirrors.tuna.tsinghua.edu.cn/mariadb/mariadb-${mariadb100_version}/bintar-${GLIBC_FLAG}-${SYS_BIT_a} + MARAIDB_TAR_MD5=$(curl -Lk ${DOWN_ADDR_MARIADB}/md5sums.txt | grep ${FILE_NAME} | awk '{print $1}') + [ -z "${MARAIDB_TAR_MD5}" ] && { DOWN_ADDR_MARIADB=https://mirrors.ustc.edu.cn/mariadb/mariadb-${mariadb100_version}/bintar-${GLIBC_FLAG}-${SYS_BIT_a}; MARAIDB_TAR_MD5=$(curl -Lk ${DOWN_ADDR_MARIADB}/md5sums.txt | grep ${FILE_NAME} | awk '{print $1}'); } + else + DOWN_ADDR_MARIADB=https://downloads.mariadb.org/interstitial/mariadb-${mariadb100_version}/bintar-${GLIBC_FLAG}-${SYS_BIT_a} + MARAIDB_TAR_MD5=$(curl -Lk http://archive.mariadb.org/mariadb-${mariadb100_version}/bintar-${GLIBC_FLAG}-${SYS_BIT_a}/md5sums.txt | grep ${FILE_NAME} | awk '{print $1}') + fi + elif [ "${dbInstallMethods}" == '2' ]; then + echo "Download MariaDB 10.0 source package..." + FILE_NAME=mariadb-${mariadb100_version}.tar.gz + if [ "${IPADDR_COUNTRY}"x == "CN"x ]; then + DOWN_ADDR_MARIADB=https://mirrors.tuna.tsinghua.edu.cn/mariadb/mariadb-${mariadb100_version}/source + MARAIDB_TAR_MD5=$(curl -Lk ${DOWN_ADDR_MARIADB}/md5sums.txt | grep ${FILE_NAME} | awk '{print $1}') + [ -z "${MARAIDB_TAR_MD5}" ] && { DOWN_ADDR_MARIADB=https://mirrors.ustc.edu.cn/mariadb/mariadb-${mariadb100_version}/source; MARAIDB_TAR_MD5=$(curl -Lk ${DOWN_ADDR_MARIADB}/md5sums.txt | grep ${FILE_NAME} | awk '{print $1}'); } + else + DOWN_ADDR_MARIADB=https://downloads.mariadb.org/interstitial/mariadb-${mariadb100_version}/source + MARAIDB_TAR_MD5=$(curl -Lk http://archive.mariadb.org/mariadb-${mariadb100_version}/source/md5sums.txt | grep ${FILE_NAME} | awk '{print $1}') + fi fi - - echo "Download MariaDB ${FILE_NAME} package..." - src_url=${DOWN_ADDR_MARIADB}/${FILE_NAME} && Download_src - wget --tries=6 -c --no-check-certificate ${DOWN_ADDR_MARIADB}/md5sums.txt -O ${FILE_NAME}.md5 - MARAIDB_TAR_MD5=$(awk '{print $1}' ${FILE_NAME}.md5) - [ -z "${MARAIDB_TAR_MD5}" ] && MARAIDB_TAR_MD5=$(curl -s ${DOWN_ADDR_MARIADB_BK}/md5sums.txt | grep ${FILE_NAME} | awk '{print $1}') tryDlCount=0 while [ "$(md5sum ${FILE_NAME} | awk '{print $1}')" != "${MARAIDB_TAR_MD5}" ]; do - wget -c --no-check-certificate ${DOWN_ADDR_MARIADB_BK}/${FILE_NAME};sleep 1 + wget -c --no-check-certificate ${DOWN_ADDR_MARIADB}/${FILE_NAME};sleep 1 let "tryDlCount++" [ "$(md5sum ${FILE_NAME} | awk '{print $1}')" == "${MARAIDB_TAR_MD5}" -o "${tryDlCount}" == '6' ] && break || continue done if [ "${tryDlCount}" == '6' ]; then echo "${CFAILURE}${FILE_NAME} download failed, Please contact the author! ${CEND}" - kill -9 $$; exit 1; + kill -9 $$ + else + echo "[${CMSG}${FILE_NAME}${CEND}] found." fi ;; - 9) - # Percona 8.4 - if [ "${dbinstallmethod}" == '1' ]; then - echo "Download Percona 8.4 binary package..." - FILE_NAME=Percona-Server-${percona84_ver}-Linux.x86_64.glibc2.35.tar.gz - DOWN_ADDR_PERCONA=https://downloads.percona.com/downloads/Percona-Server-8.4/Percona-Server-${percona84_ver}/binary/tarball - elif [ "${dbinstallmethod}" == '2' ]; then - echo "Download Percona 8.4 source package..." - FILE_NAME=percona-server-${percona84_ver}.tar.gz - if [ "${OUTIP_STATE}"x == "China"x ]; then - DOWN_ADDR_PERCONA=${mirror_link}/src + + 6) + # MariaDB 5.5 + if [ "${dbInstallMethods}" == '1' ]; then + echo "Download MariaDB 5.5 binary package..." + FILE_NAME=mariadb-${mariadb55_version}-${GLIBC_FLAG}-${SYS_BIT_b}.tar.gz + if [ "${IPADDR_COUNTRY}"x == "CN"x ]; then + DOWN_ADDR_MARIADB=https://mirrors.tuna.tsinghua.edu.cn/mariadb/mariadb-${mariadb55_version}/bintar-${GLIBC_FLAG}-${SYS_BIT_a} + MARAIDB_TAR_MD5=$(curl -Lk ${DOWN_ADDR_MARIADB}/md5sums.txt | grep ${FILE_NAME} | awk '{print $1}') + [ -z "${MARAIDB_TAR_MD5}" ] && { DOWN_ADDR_MARIADB=https://mirrors.ustc.edu.cn/mariadb/mariadb-${mariadb55_version}/bintar-${GLIBC_FLAG}-${SYS_BIT_a}; MARAIDB_TAR_MD5=$(curl -Lk ${DOWN_ADDR_MARIADB}/md5sums.txt | grep ${FILE_NAME} | awk '{print $1}'); } else - DOWN_ADDR_PERCONA=https://downloads.percona.com/downloads/Percona-Server-8.4/Percona-Server-${percona84_ver}/source/tarball + DOWN_ADDR_MARIADB=https://downloads.mariadb.org/interstitial/mariadb-${mariadb55_version}/bintar-${GLIBC_FLAG}-${SYS_BIT_a} + MARAIDB_TAR_MD5=$(curl -Lk http://archive.mariadb.org/mariadb-${mariadb55_version}/bintar-${GLIBC_FLAG}-${SYS_BIT_a}/md5sums.txt | grep ${FILE_NAME} | awk '{print $1}') + fi + elif [ "${dbInstallMethods}" == '2' ]; then + echo "Download MariaDB 5.5 source package..." + FILE_NAME=mariadb-${mariadb55_version}.tar.gz + if [ "${IPADDR_COUNTRY}"x == "CN"x ]; then + DOWN_ADDR_MARIADB=https://mirrors.tuna.tsinghua.edu.cn/mariadb/mariadb-${mariadb55_version}/source + MARAIDB_TAR_MD5=$(curl -Lk ${DOWN_ADDR_MARIADB}/md5sums.txt | grep ${FILE_NAME} | awk '{print $1}') + [ -z "${MARAIDB_TAR_MD5}" ] && { DOWN_ADDR_MARIADB=https://mirrors.ustc.edu.cn/mariadb/mariadb-${mariadb55_version}/source; MARAIDB_TAR_MD5=$(curl -Lk ${DOWN_ADDR_MARIADB}/md5sums.txt | grep ${FILE_NAME} | awk '{print $1}'); } + else + DOWN_ADDR_MARIADB=https://downloads.mariadb.org/interstitial/mariadb-${mariadb55_version}/source + MARAIDB_TAR_MD5=$(curl -Lk http://archive.mariadb.org/mariadb-${mariadb55_version}/source/md5sums.txt | grep ${FILE_NAME} | awk '{print $1}') fi fi - # start download - src_url=${DOWN_ADDR_PERCONA}/${FILE_NAME} && Download_src - src_url=${mirror_link}/src/${FILE_NAME}.md5sum && Download_src - # verifying download - PERCONA_TAR_MD5=$(awk '{print $1}' ${FILE_NAME}.md5sum) - [ -z "${PERCONA_TAR_MD5}" ] && PERCONA_TAR_MD5=$(curl -s ${mirror_link}/src/${FILE_NAME}.md5sum | grep ${FILE_NAME} | awk '{print $1}') tryDlCount=0 - while [ "$(md5sum ${FILE_NAME} | awk '{print $1}')" != "${PERCONA_TAR_MD5}" ]; do - wget -c --no-check-certificate ${DOWN_ADDR_PERCONA}/${FILE_NAME}; sleep 1 + while [ "$(md5sum ${FILE_NAME} | awk '{print $1}')" != "${MARAIDB_TAR_MD5}" ]; do + wget -c --no-check-certificate ${DOWN_ADDR_MARIADB}/${FILE_NAME};sleep 1 let "tryDlCount++" - [ "$(md5sum ${FILE_NAME} | awk '{print $1}')" == "${PERCONA_TAR_MD5}" -o "${tryDlCount}" == '6' ] && break || continue + [ "$(md5sum ${FILE_NAME} | awk '{print $1}')" == "${MARAIDB_TAR_MD5}" -o "${tryDlCount}" == '6' ] && break || continue done if [ "${tryDlCount}" == '6' ]; then echo "${CFAILURE}${FILE_NAME} download failed, Please contact the author! ${CEND}" - kill -9 $$; exit 1; + kill -9 $$ + else + echo "[${CMSG}${FILE_NAME}${CEND}] found." fi ;; - 10) - # Percona 8.0 - if [ "${dbinstallmethod}" == '1' ]; then - echo "Download Percona 8.0 binary package..." - FILE_NAME=Percona-Server-${percona80_ver}-Linux.x86_64.glibc2.35.tar.gz - DOWN_ADDR_PERCONA=https://downloads.percona.com/downloads/Percona-Server-8.0/Percona-Server-${percona80_ver}/binary/tarball - elif [ "${dbinstallmethod}" == '2' ]; then - echo "Download Percona 8.0 source package..." - FILE_NAME=percona-server-${percona80_ver}.tar.gz - if [ "${OUTIP_STATE}"x == "China"x ]; then - DOWN_ADDR_PERCONA=${mirror_link}/src + + 7) + # Precona 5.7 + if [ "${dbInstallMethods}" == '1' ]; then + echo "Download Percona 5.7 binary package..." + FILE_NAME=Percona-Server-${percona57_version}-Linux.${SYS_BIT_b}.${sslLibVer}.tar.gz + DOWN_ADDR_PERCONA=https://www.percona.com/downloads/Percona-Server-5.7/Percona-Server-${percona57_version}/binary/tarball + PERCONA_TAR_MD5=$(curl -Lk https://www.percona.com/downloads/Percona-Server-5.7/Percona-Server-${percona57_version}/binary/tarball/${FILE_NAME}.md5sum | grep ${FILE_NAME} | awk '{print $1}') + elif [ "${dbInstallMethods}" == '2' ]; then + echo "Download Percona 5.7 source package..." + FILE_NAME=percona-server-${percona57_version}.tar.gz + if [ "${IPADDR_COUNTRY}"x == "CN"x ]; then + DOWN_ADDR_PERCONA=${mirrorLink} + DOWN_ADDR_PERCONA_BK=https://www.percona.com/downloads/Percona-Server-5.7/Percona-Server-${percona57_version}/source/tarball + PERCONA_TAR_MD5=$(curl -Lk ${DOWN_ADDR_PERCONA}/${FILE_NAME}.md5sum | grep ${FILE_NAME} | awk '{print $1}') + [ -z "${PERCONA_TAR_MD5}" ] && { DOWN_ADDR_PERCONA=${DOWN_ADDR_PERCONA_BK}; PERCONA_TAR_MD5=$(curl -Lk ${DOWN_ADDR_PERCONA_BK}/${FILE_NAME}.md5sum | grep ${FILE_NAME} | awk '{print $1}'); } else - DOWN_ADDR_PERCONA=https://downloads.percona.com/downloads/Percona-Server-8.0/Percona-Server-${percona80_ver}/source/tarball + DOWN_ADDR_PERCONA=https://www.percona.com/downloads/Percona-Server-5.7/Percona-Server-${percona57_version}/source/tarball + PERCONA_TAR_MD5=$(curl -Lk ${DOWN_ADDR_PERCONA}/${FILE_NAME}.md5sum | grep ${FILE_NAME} | awk '{print $1}') fi fi - # start download - src_url=${DOWN_ADDR_PERCONA}/${FILE_NAME} && Download_src - src_url=${mirror_link}/src/${FILE_NAME}.md5sum && Download_src - # verifying download - PERCONA_TAR_MD5=$(awk '{print $1}' ${FILE_NAME}.md5sum) - [ -z "${PERCONA_TAR_MD5}" ] && PERCONA_TAR_MD5=$(curl -s ${mirror_link}/src/${FILE_NAME}.md5sum | grep ${FILE_NAME} | awk '{print $1}') tryDlCount=0 while [ "$(md5sum ${FILE_NAME} | awk '{print $1}')" != "${PERCONA_TAR_MD5}" ]; do wget -c --no-check-certificate ${DOWN_ADDR_PERCONA}/${FILE_NAME}; sleep 1 @@ -322,30 +392,33 @@ checkDownload() { done if [ "${tryDlCount}" == '6' ]; then echo "${CFAILURE}${FILE_NAME} download failed, Please contact the author! ${CEND}" - kill -9 $$; exit 1; + kill -9 $$ + else + echo "[${CMSG}${FILE_NAME}${CEND}] found." fi ;; - 11) - # Precona 5.7 - if [ "${dbinstallmethod}" == '1' ]; then - echo "Download Percona 5.7 binary package..." - FILE_NAME=Percona-Server-${percona57_ver}-Linux.x86_64.glibc2.35.tar.gz - DOWN_ADDR_PERCONA=https://downloads.percona.com/downloads/Percona-Server-5.7/Percona-Server-${percona57_ver}/binary/tarball - elif [ "${dbinstallmethod}" == '2' ]; then - echo "Download Percona 5.7 source package..." - FILE_NAME=percona-server-${percona57_ver}.tar.gz - if [ "${OUTIP_STATE}"x == "China"x ]; then - DOWN_ADDR_PERCONA=${mirror_link}/src + + 8) + # Precona 5.6 + if [ "${dbInstallMethods}" == '1' ]; then + echo "Download Percona 5.6 binary package..." + perconaVerStr1=$(echo ${percona56_version} | sed "s@-@-rel@") + FILE_NAME=Percona-Server-${perconaVerStr1}-Linux.${SYS_BIT_b}.${sslLibVer}.tar.gz + DOWN_ADDR_PERCONA=https://www.percona.com/downloads/Percona-Server-5.6/Percona-Server-${percona56_version}/binary/tarball + PERCONA_TAR_MD5=$(curl -Lk https://www.percona.com/downloads/Percona-Server-5.6/Percona-Server-${percona56_version}/binary/tarball/${FILE_NAME}.md5sum | grep ${FILE_NAME} | awk '{print $1}') + elif [ "${dbInstallMethods}" == '2' ]; then + echo "Download Percona 5.6 source package..." + FILE_NAME=percona-server-${percona56_version}.tar.gz + if [ "${IPADDR_COUNTRY}"x == "CN"x ]; then + DOWN_ADDR_PERCONA=${mirrorLink} + DOWN_ADDR_PERCONA_BK=https://www.percona.com/downloads/Percona-Server-5.6/Percona-Server-${percona56_version}/source/tarball + PERCONA_TAR_MD5=$(curl -Lk ${DOWN_ADDR_PERCONA}/${FILE_NAME}.md5sum | grep ${FILE_NAME} | awk '{print $1}') + [ -z "${PERCONA_TAR_MD5}" ] && { DOWN_ADDR_PERCONA=${DOWN_ADDR_PERCONA_BK}; PERCONA_TAR_MD5=$(curl -Lk ${DOWN_ADDR_PERCONA_BK}/${FILE_NAME}.md5sum | grep ${FILE_NAME} | awk '{print $1}'); } else - DOWN_ADDR_PERCONA=https://downloads.percona.com/downloads/Percona-Server-5.7/Percona-Server-${percona57_ver}/source/tarball + DOWN_ADDR_PERCONA=https://www.percona.com/downloads/Percona-Server-5.6/Percona-Server-${percona56_version}/source/tarball + PERCONA_TAR_MD5=$(curl -Lk ${DOWN_ADDR_PERCONA}/${FILE_NAME}.md5sum | grep ${FILE_NAME} | awk '{print $1}') fi fi - # start download - src_url=${DOWN_ADDR_PERCONA}/${FILE_NAME} && Download_src - src_url=${mirror_link}/src/${FILE_NAME}.md5sum && Download_src - # verifying download - PERCONA_TAR_MD5=$(awk '{print $1}' ${FILE_NAME}.md5sum) - [ -z "${PERCONA_TAR_MD5}" ] && PERCONA_TAR_MD5=$(curl -s ${mirror_link}/src/${FILE_NAME}.md5sum | grep ${FILE_NAME} | awk '{print $1}') tryDlCount=0 while [ "$(md5sum ${FILE_NAME} | awk '{print $1}')" != "${PERCONA_TAR_MD5}" ]; do wget -c --no-check-certificate ${DOWN_ADDR_PERCONA}/${FILE_NAME}; sleep 1 @@ -354,31 +427,33 @@ checkDownload() { done if [ "${tryDlCount}" == '6' ]; then echo "${CFAILURE}${FILE_NAME} download failed, Please contact the author! ${CEND}" - kill -9 $$; exit 1; + kill -9 $$ + else + echo "[${CMSG}${FILE_NAME}${CEND}] found." fi ;; - 12) + + 9) # Percona 5.5 - if [ "${dbinstallmethod}" == '1' ]; then + if [ "${dbInstallMethods}" == '1' ]; then echo "Download Percona 5.5 binary package..." - perconaVerStr1=$(echo ${percona55_ver} | sed "s@-@-rel@") - FILE_NAME=Percona-Server-${perconaVerStr1}-Linux.x86_64.${sslLibVer}.tar.gz - DOWN_ADDR_PERCONA=https://downloads.percona.com/downloads/Percona-Server-5.5/Percona-Server-${percona55_ver}/binary/tarball - elif [ "${dbinstallmethod}" == '2' ]; then + perconaVerStr1=$(echo ${percona55_version} | sed "s@-@-rel@") + FILE_NAME=Percona-Server-${perconaVerStr1}-Linux.${SYS_BIT_b}.${sslLibVer}.tar.gz + DOWN_ADDR_PERCONA=https://www.percona.com/downloads/Percona-Server-5.5/Percona-Server-${percona55_version}/binary/tarball + PERCONA_TAR_MD5=$(curl -Lk https://www.percona.com/downloads/Percona-Server-5.5/Percona-Server-${percona55_version}/binary/tarball/${FILE_NAME}.md5sum | grep ${FILE_NAME} | awk '{print $1}') + elif [ "${dbInstallMethods}" == '2' ]; then echo "Download Percona 5.5 source package..." - FILE_NAME=percona-server-${percona55_ver}.tar.gz - if [ "${OUTIP_STATE}"x == "China"x ]; then - DOWN_ADDR_PERCONA=${mirror_link}/src + FILE_NAME=percona-server-${percona55_version}.tar.gz + if [ "${IPADDR_COUNTRY}"x == "CN"x ]; then + DOWN_ADDR_PERCONA=${mirrorLink} + DOWN_ADDR_PERCONA_BK=https://www.percona.com/downloads/Percona-Server-5.5/Percona-Server-${percona55_version}/source/tarball + PERCONA_TAR_MD5=$(curl -Lk ${DOWN_ADDR_PERCONA}/${FILE_NAME}.md5sum | grep ${FILE_NAME} | awk '{print $1}') + [ -z "${PERCONA_TAR_MD5}" ] && { DOWN_ADDR_PERCONA=${DOWN_ADDR_PERCONA_BK}; PERCONA_TAR_MD5=$(curl -Lk ${DOWN_ADDR_PERCONA_BK}/${FILE_NAME}.md5sum | grep ${FILE_NAME} | awk '{print $1}'); } else - DOWN_ADDR_PERCONA=https://downloads.percona.com/downloads/Percona-Server-5.5/Percona-Server-${percona55_ver}/source/tarball + DOWN_ADDR_PERCONA=https://www.percona.com/downloads/Percona-Server-5.5/Percona-Server-${percona55_version}/source/tarball + PERCONA_TAR_MD5=$(curl -Lk ${DOWN_ADDR_PERCONA}/${FILE_NAME}.md5sum | grep ${FILE_NAME} | awk '{print $1}') fi fi - # start download - src_url=${DOWN_ADDR_PERCONA}/${FILE_NAME} && Download_src - src_url=${mirror_link}/src/${FILE_NAME}.md5sum && Download_src - # verifying download - PERCONA_TAR_MD5=$(awk '{print $1}' ${FILE_NAME}.md5sum) - [ -z "${PERCONA_TAR_MD5}" ] && PERCONA_TAR_MD5=$(curl -s ${mirror_link}/src/${FILE_NAME}.md5sum | grep ${FILE_NAME} | awk '{print $1}') tryDlCount=0 while [ "$(md5sum ${FILE_NAME} | awk '{print $1}')" != "${PERCONA_TAR_MD5}" ]; do wget -c --no-check-certificate ${DOWN_ADDR_PERCONA}/${FILE_NAME}; sleep 1 @@ -387,159 +462,104 @@ checkDownload() { done if [ "${tryDlCount}" == '6' ]; then echo "${CFAILURE}${FILE_NAME} download failed, Please contact the author! ${CEND}" - kill -9 $$; exit 1; - fi - ;; - 13) - FILE_NAME=postgresql-${pgsql_ver}.tar.gz - if [ "${OUTIP_STATE}"x == "China"x ]; then - DOWN_ADDR_PGSQL=https://mirrors.tuna.tsinghua.edu.cn/postgresql/source/v${pgsql_ver} - DOWN_ADDR_PGSQL_BK=https://mirrors.ustc.edu.cn/postgresql/source/v${pgsql_ver} + kill -9 $$ else - DOWN_ADDR_PGSQL=https://ftp.postgresql.org/pub/source/v${pgsql_ver} - DOWN_ADDR_PGSQL_BK=https://ftp.heanet.ie/mirrors/postgresql/source/v${pgsql_ver} - fi - src_url=${DOWN_ADDR_PGSQL}/${FILE_NAME} && Download_src - src_url=${DOWN_ADDR_PGSQL}/${FILE_NAME}.md5 && Download_src - PGSQL_TAR_MD5=$(awk '{print $1}' ${FILE_NAME}.md5) - [ -z "${PGSQL_TAR_MD5}" ] && PGSQL_TAR_MD5=$(curl -s ${DOWN_ADDR_PGSQL_BK}/${FILE_NAME}.md5 | grep ${FILE_NAME} | awk '{print $1}') - tryDlCount=0 - while [ "$(md5sum ${FILE_NAME} | awk '{print $1}')" != "${PGSQL_TAR_MD5}" ]; do - wget -c --no-check-certificate ${DOWN_ADDR_PGSQL_BK}/${FILE_NAME};sleep 1 - let "tryDlCount++" - [ "$(md5sum ${FILE_NAME} | awk '{print $1}')" == "${PGSQL_TAR_MD5}" -o "${tryDlCount}" == '6' ] && break || continue - done - if [ "${tryDlCount}" == '6' ]; then - echo "${CFAILURE}${FILE_NAME} download failed, Please contact the author! ${CEND}" - kill -9 $$; exit 1; + echo "[${CMSG}${FILE_NAME}${CEND}] found." fi ;; - 14) - # MongoDB - echo "Download MongoDB binary package..." - FILE_NAME=mongodb-linux-x86_64-${mongodb_ver}.tgz - if [ "${OUTIP_STATE}"x == "China"x ]; then - DOWN_ADDR_MongoDB=${mirror_link}/src - else - DOWN_ADDR_MongoDB=https://fastdl.mongodb.org/linux - fi - src_url=${DOWN_ADDR_MongoDB}/${FILE_NAME} && Download_src - src_url=${DOWN_ADDR_MongoDB}/${FILE_NAME}.md5 && Download_src - MongoDB_TAR_MD5=$(awk '{print $1}' ${FILE_NAME}.md5) - [ -z "${MongoDB_TAR_MD5}" ] && MongoDB_TAR_MD5=$(curl -s ${DOWN_ADDR_MongoDB}/${FILE_NAME}.md5 | grep ${FILE_NAME} | awk '{print $1}') - tryDlCount=0 - while [ "$(md5sum ${FILE_NAME} | awk '{print $1}')" != "${MongoDB_TAR_MD5}" ]; do - wget -c --no-check-certificate ${DOWN_ADDR_MongoDB}/${FILE_NAME};sleep 1 - let "tryDlCount++" - [ "$(md5sum ${FILE_NAME} | awk '{print $1}')" == "${MongoDB_TAR_MD5}" -o "${tryDlCount}" == '6' ] && break || continue + + 10) + # AliSQL 5.6 + DOWN_ADDR_ALISQL=$mirrorLink + echo "Download AliSQL 5.6 source package..." + FILE_NAME=alisql-${alisql56_version}.tar.gz + wget --tries=6 -c --no-check-certificate ${DOWN_ADDR_ALISQL}/${FILE_NAME} + wget --tries=6 -c --no-check-certificate ${DOWN_ADDR_ALISQL}/${FILE_NAME}.md5 + ALISQL_TAR_MD5=$(awk '{print $1}' ${FILE_NAME}.md5) + while [ "$(md5sum ${FILE_NAME} | awk '{print $1}')" != "${ALISQL_TAR_MD5}" ];do + wget -4c --no-check-certificate ${DOWN_ADDR_ALISQL}/${FILE_NAME};sleep 1 + [ "$(md5sum ${FILE_NAME} | awk '{print $1}')" == "${ALISQL_TAR_MD5}" ] && break || continue done - if [ "${tryDlCount}" == '6' ]; then - echo "${CFAILURE}${FILE_NAME} download failed, Please contact the author! ${CEND}" - kill -9 $$; exit 1; - fi ;; esac fi - # PHP - if [[ "${php_option}" =~ ^[1-9]$|^1[0-5]$ ]] || [[ "${mphp_ver}" =~ ^5[3-6]$|^7[0-4]$|^8[0-5]$ ]]; then + if [ "${PHP_yn}" == 'y' ]; then + # php 5.3 5.4 5.5 5.6 5.7 echo "PHP common..." - src_url=${mirror_link}/src/libiconv-${libiconv_ver}.tar.gz && Download_src - src_url=https://curl.haxx.se/download/curl-${curl_ver}.tar.gz && Download_src - src_url=https://downloads.sourceforge.net/project/mhash/mhash/${mhash_ver}/mhash-${mhash_ver}.tar.gz && Download_src - src_url=https://downloads.sourceforge.net/project/mcrypt/Libmcrypt/${libmcrypt_ver}/libmcrypt-${libmcrypt_ver}.tar.gz && Download_src - src_url=https://downloads.sourceforge.net/project/mcrypt/MCrypt/${mcrypt_ver}/mcrypt-${mcrypt_ver}.tar.gz && Download_src - src_url=${mirror_link}/src/freetype-${freetype_ver}.tar.gz && Download_src - fi - - if [ "${php_option}" == '1' ] || [ "${mphp_ver}" == '53' ]; then - src_url=${mirror_link}/src/debian_patches_disable_SSLv2_for_openssl_1_0_0.patch && Download_src - src_url=${mirror_link}/src/php5.3patch && Download_src - src_url=https://secure.php.net/distributions/php-${php53_ver}.tar.gz && Download_src - src_url=${mirror_link}/src/fpm-race-condition.patch && Download_src - elif [ "${php_option}" == '2' ] || [ "${mphp_ver}" == '54' ]; then - src_url=https://secure.php.net/distributions/php-${php54_ver}.tar.gz && Download_src - src_url=${mirror_link}/src/fpm-race-condition.patch && Download_src - elif [ "${php_option}" == '3' ] || [ "${mphp_ver}" == '55' ]; then - src_url=https://secure.php.net/distributions/php-${php55_ver}.tar.gz && Download_src - src_url=${mirror_link}/src/fpm-race-condition.patch && Download_src - elif [ "${php_option}" == '4' ] || [ "${mphp_ver}" == '56' ]; then - src_url=https://secure.php.net/distributions/php-${php56_ver}.tar.gz && Download_src - elif [ "${php_option}" == '5' ] || [ "${mphp_ver}" == '70' ]; then - src_url=https://secure.php.net/distributions/php-${php70_ver}.tar.gz && Download_src - elif [ "${php_option}" == '6' ] || [ "${mphp_ver}" == '71' ]; then - src_url=https://secure.php.net/distributions/php-${php71_ver}.tar.gz && Download_src - elif [ "${php_option}" == '7' ] || [ "${mphp_ver}" == '72' ]; then - src_url=https://secure.php.net/distributions/php-${php72_ver}.tar.gz && Download_src - src_url=${mirror_link}/src/argon2-${argon2_ver}.tar.gz && Download_src - src_url=${mirror_link}/src/libsodium-${libsodium_ver}.tar.gz && Download_src - elif [ "${php_option}" == '8' ] || [ "${mphp_ver}" == '73' ]; then - src_url=https://secure.php.net/distributions/php-${php73_ver}.tar.gz && Download_src - src_url=${mirror_link}/src/argon2-${argon2_ver}.tar.gz && Download_src - src_url=${mirror_link}/src/libsodium-${libsodium_ver}.tar.gz && Download_src - elif [ "${php_option}" == '9' ] || [ "${mphp_ver}" == '74' ]; then - src_url=https://secure.php.net/distributions/php-${php74_ver}.tar.gz && Download_src - src_url=${mirror_link}/src/argon2-${argon2_ver}.tar.gz && Download_src - src_url=${mirror_link}/src/libsodium-${libsodium_ver}.tar.gz && Download_src - src_url=${mirror_link}/src/libzip-${libzip_ver}.tar.gz && Download_src - elif [ "${php_option}" == '10' ] || [ "${mphp_ver}" == '80' ]; then - src_url=https://secure.php.net/distributions/php-${php80_ver}.tar.gz && Download_src - src_url=${mirror_link}/src/argon2-${argon2_ver}.tar.gz && Download_src - src_url=${mirror_link}/src/libsodium-${libsodium_ver}.tar.gz && Download_src - src_url=${mirror_link}/src/libzip-${libzip_ver}.tar.gz && Download_src - elif [ "${php_option}" == '11' ] || [ "${mphp_ver}" == '81' ]; then - src_url=https://secure.php.net/distributions/php-${php81_ver}.tar.gz && Download_src - src_url=${mirror_link}/src/argon2-${argon2_ver}.tar.gz && Download_src - src_url=${mirror_link}/src/libsodium-${libsodium_ver}.tar.gz && Download_src - src_url=${mirror_link}/src/libzip-${libzip_ver}.tar.gz && Download_src - elif [ "${php_option}" == '12' ] || [ "${mphp_ver}" == '82' ]; then - src_url=https://secure.php.net/distributions/php-${php82_ver}.tar.gz && Download_src - src_url=${mirror_link}/src/argon2-${argon2_ver}.tar.gz && Download_src - src_url=${mirror_link}/src/libsodium-${libsodium_ver}.tar.gz && Download_src - src_url=${mirror_link}/src/libzip-${libzip_ver}.tar.gz && Download_src - elif [ "${php_option}" == '13' ] || [ "${mphp_ver}" == '83' ]; then - src_url=https://secure.php.net/distributions/php-${php83_ver}.tar.gz && Download_src - src_url=${mirror_link}/src/argon2-${argon2_ver}.tar.gz && Download_src - src_url=${mirror_link}/src/libsodium-${libsodium_ver}.tar.gz && Download_src - src_url=${mirror_link}/src/libzip-${libzip_ver}.tar.gz && Download_src - src_url=${mirror_link}/src/binutils-${binutils_ver}.tar.gz && Download_src - elif [ "${php_option}" == '14' ] || [ "${mphp_ver}" == '84' ]; then - src_url=https://secure.php.net/distributions/php-${php84_ver}.tar.gz && Download_src - src_url=${mirror_link}/src/argon2-${argon2_ver}.tar.gz && Download_src - src_url=${mirror_link}/src/libsodium-${libsodium_ver}.tar.gz && Download_src - src_url=${mirror_link}/src/libzip-${libzip_ver}.tar.gz && Download_src - src_url=${mirror_link}/src/binutils-${binutils_ver}.tar.gz && Download_src - elif [ "${php_option}" == '15' ] || [ "${mphp_ver}" == '85' ]; then - src_url=https://secure.php.net/distributions/php-${php85_ver}.tar.gz && Download_src - src_url=${mirror_link}/src/argon2-${argon2_ver}.tar.gz && Download_src - src_url=${mirror_link}/src/libsodium-${libsodium_ver}.tar.gz && Download_src - src_url=${mirror_link}/src/libzip-${libzip_ver}.tar.gz && Download_src - src_url=${mirror_link}/src/binutils-${binutils_ver}.tar.gz && Download_src + src_url=http://ftp.gnu.org/pub/gnu/libiconv/libiconv-${libiconv_version}.tar.gz && Download_src + src_url=https://curl.haxx.se/download/curl-${curl_version}.tar.gz && Download_src + src_url=http://downloads.sourceforge.net/project/mcrypt/Libmcrypt/${libmcrypt_version}/libmcrypt-${libmcrypt_version}.tar.gz && Download_src + src_url=http://downloads.sourceforge.net/project/mhash/mhash/${mhash_version}/mhash-${mhash_version}.tar.gz && Download_src + src_url=http://downloads.sourceforge.net/project/mcrypt/MCrypt/${mcrypt_version}/mcrypt-${mcrypt_version}.tar.gz && Download_src + src_url=${mirrorLink}/libiconv-glibc-2.16.patch && Download_src + + case "${PHP_version}" in + 1) + # php 5.3 + src_url=${mirrorLink}/debian_patches_disable_SSLv2_for_openssl_1_0_0.patch && Download_src + src_url=${mirrorLink}/php5.3patch && Download_src + # Use the special ssl for php5.3 + if [ "${Debian_version}" == '8' -o "${Ubuntu_version}" == "16" ]; then + if [ ! -e "/usr/local/openssl100s/lib/libcrypto.a" ]; then + src_url=${mirrorLink}/openssl-1.0.0s.tar.gz && Download_src + src_url=${mirrorLink}/curl-7.35.0.tar.gz && Download_src + fi + fi + src_url=http://www.php.net/distributions/php-${php53_version}.tar.gz && Download_src + src_url=${mirrorLink}/fpm-race-condition.patch && Download_src + ;; + 2) + src_url=http://www.php.net/distributions/php-${php54_version}.tar.gz && Download_src + src_url=${mirrorLink}/fpm-race-condition.patch && Download_src + ;; + 3) + src_url=http://www.php.net/distributions/php-${php55_version}.tar.gz && Download_src + src_url=${mirrorLink}/fpm-race-condition.patch && Download_src + ;; + 4) + src_url=http://www.php.net/distributions/php-${php56_version}.tar.gz && Download_src + ;; + 5) + src_url=http://www.php.net/distributions/php-${php70_version}.tar.gz && Download_src + ;; + 6) + src_url=http://www.php.net/distributions/php-${php71_version}.tar.gz && Download_src + ;; + esac fi # PHP OPCache - case "${phpcache_option}" in + case "${PHP_cache}" in 1) - if [[ "${php_option}" =~ ^[1-2]$ ]]; then + if [[ "$PHP_version" =~ ^[1,2]$ ]]; then # php 5.3 5.4 echo "Download Zend OPCache..." - src_url=https://pecl.php.net/get/zendopcache-${zendopcache_ver}.tgz && Download_src + src_url=https://pecl.php.net/get/zendopcache-${zendopcache_version}.tgz && Download_src fi ;; 2) + if [[ "$PHP_version" =~ ^[1-4]$ ]]; then + # php 5.3 5.4 5.5 5.6 + echo "Download xcache..." + src_url=http://xcache.lighttpd.net/pub/Releases/${xcache_version}/xcache-${xcache_version}.tar.gz && Download_src + fi + ;; + 3) + # php 5.3 5.4 5.5 5.6 7.0 7.1 echo "Download apcu..." - if [[ "${php_option}" =~ ^[1-4]$ ]]; then - src_url=https://pecl.php.net/get/apcu-4.0.11.tgz && Download_src + if [[ "$PHP_version" =~ ^[1-4]$ ]]; then + src_url=http://pecl.php.net/get/apcu-${apcu_version}.tgz && Download_src else - src_url=https://pecl.php.net/get/apcu-${apcu_ver}.tgz && Download_src + src_url=http://pecl.php.net/get/apcu-${apcu_for_php7_version}.tgz && Download_src fi ;; - 3) + 4) # php 5.3 5.4 - if [ "${php_option}" == '1' ]; then + if [ "${PHP_version}" == '1' ]; then echo "Download eaccelerator 0.9..." - src_url=https://github.com/downloads/eaccelerator/eaccelerator/eaccelerator-${eaccelerator_ver}.tar.bz2 && Download_src - elif [ "${php_option}" == '2' ]; then + src_url=https://github.com/downloads/eaccelerator/eaccelerator/eaccelerator-${eaccelerator_version}.tar.bz2 && Download_src + elif [ "${PHP_version}" == '2' ]; then echo "Download eaccelerator 1.0 dev..." src_url=https://github.com/eaccelerator/eaccelerator/tarball/master && Download_src fi @@ -547,162 +567,160 @@ checkDownload() { esac # Zend Guard Loader - if [ "${pecl_zendguardloader}" == '1' -a "${armplatform}" != 'y' ]; then - case "${php_option}" in + if [ "${ZendGuardLoader_yn}" == 'y' -a "${armPlatform}" != 'y' ]; then + case "${PHP_version}" in 4) - echo "Download zend loader for php 5.6..." - src_url=${mirror_link}/src/zend-loader-php5.6-linux-x86_64.tar.gz && Download_src + if [ "${OS_BIT}" == "64" ]; then + # 64 bit + echo "Download zend loader for php 5.6..." + src_url=${mirrorLink}/zend-loader-php5.6-linux-x86_64.tar.gz && Download_src + else + # 32 bit + echo "Download zend loader for php 5.6..." + src_url=${mirrorLink}/zend-loader-php5.6-linux-i386.tar.gz && Download_src + fi ;; 3) - echo "Download zend loader for php 5.5..." - src_url=${mirror_link}/src/zend-loader-php5.5-linux-x86_64.tar.gz && Download_src + if [ "${OS_BIT}" == "64" ]; then + # 64 bit + echo "Download zend loader for php 5.5..." + src_url=${mirrorLink}/zend-loader-php5.5-linux-x86_64.tar.gz && Download_src + else + # 32 bit + echo "Download zend loader for php 5.5..." + src_url=${mirrorLink}/zend-loader-php5.5-linux-i386.tar.gz && Download_src + fi ;; 2) - echo "Download zend loader for php 5.4..." - src_url=${mirror_link}/src/ZendGuardLoader-70429-PHP-5.4-linux-glibc23-x86_64.tar.gz && Download_src + if [ "${OS_BIT}" == "64" ]; then + # 64 bit + echo "Download zend loader for php 5.4..." + src_url=${mirrorLink}/ZendGuardLoader-70429-PHP-5.4-linux-glibc23-x86_64.tar.gz && Download_src + else + # 32 bit + echo "Download zend loader for php 5.4..." + src_url=${mirrorLink}/ZendGuardLoader-70429-PHP-5.4-linux-glibc23-i386.tar.gz && Download_src + fi ;; 1) - echo "Download zend loader for php 5.3..." - src_url=${mirror_link}/src/ZendGuardLoader-php-5.3-linux-glibc23-x86_64.tar.gz && Download_src + if [ "${OS_BIT}" == "64" ]; then + # 64 bit + echo "Download zend loader for php 5.3..." + src_url=${mirrorLink}/ZendGuardLoader-php-5.3-linux-glibc23-x86_64.tar.gz && Download_src + else + # 32 bit + echo "Download zend loader for php 5.3..." + src_url=${mirrorLink}/ZendGuardLoader-php-5.3-linux-glibc23-i386.tar.gz && Download_src + fi ;; esac fi - # ioncube - if [ "${pecl_ioncube}" == '1' ]; then + if [ "${ionCube_yn}" == 'y' ]; then echo "Download ioncube..." - src_url=https://downloads.ioncube.com/loader_downloads/ioncube_loaders_lin_${SYS_ARCH_i}.tar.gz && Download_src - fi - - # SourceGuardian - if [ "${pecl_sourceguardian}" == '1' ]; then - echo "Download SourceGuardian..." - src_url=${mirror_link}/src/loaders.linux-${ARCH}.tar.gz && Download_src - fi - - # imageMagick - if [ "${pecl_imagick}" == '1' ]; then - echo "Download ImageMagick..." - src_url=${mirror_link}/src/ImageMagick-${imagemagick_ver}.tar.gz && Download_src - echo "Download imagick..." - if [[ "${php_option}" =~ ^1$ ]]; then - src_url=https://pecl.php.net/get/imagick-3.4.4.tgz && Download_src - elif [[ "${php_option}" =~ ^[2-3]$ ]]; then - src_url=https://pecl.php.net/get/imagick-3.7.0.tgz && Download_src + if [ "${OS_BIT}" == '64' ]; then + src_url=http://downloads3.ioncube.com/loader_downloads/ioncube_loaders_lin_x86-64.tar.gz && Download_src else - src_url=https://pecl.php.net/get/imagick-${imagick_ver}.tgz && Download_src + if [ "${TARGET_ARCH}" == "armv7" ]; then + src_url=http://downloads3.ioncube.com/loader_downloads/ioncube_loaders_lin_armv7l.tar.gz && Download_src + else + src_url=http://downloads3.ioncube.com/loader_downloads/ioncube_loaders_lin_x86.tar.gz && Download_src + fi fi fi - # graphicsmagick - if [ "${pecl_gmagick}" == '1' ]; then - echo "Download graphicsmagick..." - src_url=https://downloads.sourceforge.net/project/graphicsmagick/graphicsmagick/${graphicsmagick_ver}/GraphicsMagick-${graphicsmagick_ver}.tar.xz && Download_src - if [[ "${php_option}" =~ ^[1-4]$ ]]; then - echo "Download gmagick for php..." - src_url=https://pecl.php.net/get/gmagick-1.1.7RC3.tgz && Download_src + if [ "${Magick_yn}" == 'y' ]; then + if [ "${Magick}" == '1' ]; then + echo "Download ImageMagick..." + src_url=${mirrorLink}/ImageMagick-${ImageMagick_version}.tar.gz && Download_src + if [ "${PHP_version}" == '1' ]; then + echo "Download image for php 5.3..." + src_url=https://pecl.php.net/get/imagick-${imagick_for_php53_version}.tgz && Download_src + else + echo "Download imagick..." + src_url=http://pecl.php.net/get/imagick-${imagick_version}.tgz && Download_src + fi else - echo "Download gmagick for php 7.x..." - src_url=https://pecl.php.net/get/gmagick-${gmagick_ver}.tgz && Download_src + echo "Download graphicsmagick..." + src_url=http://downloads.sourceforge.net/project/graphicsmagick/graphicsmagick/${GraphicsMagick_version}/GraphicsMagick-${GraphicsMagick_version}.tar.gz && Download_src + if [[ "$PHP_version" =~ ^[5-6]$ ]]; then + echo "Download gmagick for php 7.x..." + src_url=https://pecl.php.net/get/gmagick-${gmagick_for_php7_version}.tgz && Download_src + else + echo "Download gmagick for php..." + src_url=http://pecl.php.net/get/gmagick-${gmagick_version}.tgz && Download_src + fi fi fi - # redis-server - if [ "${redis_flag}" == 'y' ]; then - echo "Download redis-server..." - src_url=http://download.redis.io/releases/redis-${redis_ver}.tar.gz && Download_src - fi - - # pecl_redis - if [ "${pecl_redis}" == '1' ]; then - if [[ "${php_option}" =~ ^[1-4]$ ]]; then - echo "Download pecl_redis for php 5.x..." - src_url=https://pecl.php.net/get/redis-4.3.0.tgz && Download_src - elif [[ "${php_option}" =~ ^[5-6]$ ]]; then - echo "Download pecl_redis for php 7.0~7.1..." - src_url=https://pecl.php.net/get/redis-5.3.7.tgz && Download_src - elif [[ "${php_option}" =~ ^[7-8]$ ]]; then - echo "Download pecl_redis for php 7.2~7.3..." - src_url=https://pecl.php.net/get/redis-6.0.2.tgz && Download_src - else - echo "Download pecl_redis for php 7.4+..." - src_url=https://pecl.php.net/get/redis-${pecl_redis_ver}.tgz && Download_src - fi + if [ "${FTP_yn}" == 'y' ]; then + echo "Download pureftpd..." + src_url=https://download.pureftpd.org/pub/pure-ftpd/releases/pure-ftpd-${pureftpd_version}.tar.gz && Download_src fi - # memcached-server - if [ "${memcached_flag}" == 'y' ]; then - echo "Download memcached-server..." - [ "${OUTIP_STATE}"x == "China"x ] && DOWN_ADDR=${mirror_link}/src || DOWN_ADDR=http://www.memcached.org/files - src_url=${DOWN_ADDR}/memcached-${memcached_ver}.tar.gz && Download_src + if [ "${phpMyAdmin_yn}" == 'y' ]; then + echo "Download phpMyAdmin..." + src_url=https://files.phpmyadmin.net/phpMyAdmin/${phpMyAdmin_version}/phpMyAdmin-${phpMyAdmin_version}-all-languages.tar.gz && Download_src fi - # pecl_memcached - if [ "${pecl_memcached}" == '1' ]; then - echo "Download libmemcached..." - src_url=https://launchpad.net/libmemcached/1.0/${libmemcached_ver}/+download/libmemcached-${libmemcached_ver}.tar.gz && Download_src - if [[ "${php_option}" =~ ^[1-4]$ ]]; then - echo "Download pecl_memcached for php..." - src_url=https://pecl.php.net/get/memcached-2.2.0.tgz && Download_src - else - echo "Download pecl_memcached for php 7.x..." - src_url=https://pecl.php.net/get/memcached-${pecl_memcached_ver}.tgz && Download_src + if [ "${redis_yn}" == 'y' ]; then + echo "Download redis..." + src_url=http://download.redis.io/releases/redis-${redis_version}.tar.gz && Download_src + if [ "${OS}" == "CentOS" ]; then + echo "Download start-stop-daemon.c for CentOS..." + src_url=${mirrorLink}/start-stop-daemon.c && Download_src fi - fi - - # memcached-server pecl_memcached pecl_memcache - if [ "${pecl_memcache}" == '1' ]; then - if [[ "${php_option}" =~ ^[1-4]$ ]]; then - echo "Download pecl_memcache for php 5.x..." - src_url=https://pecl.php.net/get/memcache-3.0.8.tgz && Download_src - elif [[ "${php_option}" =~ ^[5-9]$ ]]; then - echo "Download pecl_memcache for php 7.x..." - src_url=https://pecl.php.net/get/memcache-4.0.5.2.tgz && Download_src + # redis addon + if [[ "$PHP_version" =~ ^[5-6]$ ]]; then + echo "Download redis pecl for php 7.x..." + src_url=http://pecl.php.net/get/redis-${redis_pecl_for_php7_version}.tgz && Download_src else - echo "Download pecl_memcache for php 8.x..." - src_url=https://pecl.php.net/get/memcache-${pecl_memcache_ver}.tgz && Download_src + echo "Download redis pecl..." + src_url=http://pecl.php.net/get/redis-${redis_pecl_version}.tgz && Download_src fi fi - # pecl_mongodb - if [ "${pecl_mongodb}" == '1' ]; then - if [[ "${php_option}" =~ ^[1-4]$ ]]; then - echo "Download pecl mongo for php 5.x..." - src_url=https://pecl.php.net/get/mongo-1.6.16.tgz && Download_src - elif [[ "${php_option}" =~ ^5$ ]]; then - echo "Download pecl mongo for php 7.0..." - src_url=https://pecl.php.net/get/mongodb-1.9.2.tgz && Download_src - elif [[ "${php_option}" =~ ^[6-8]$ ]]; then - echo "Download pecl mongo for php 7.1~7.3..." - src_url=https://pecl.php.net/get/mongodb-1.16.2.tgz && Download_src + if [ "${memcached_yn}" == 'y' ]; then + echo "Download memcached..." + src_url=http://www.memcached.org/files/memcached-${memcached_version}.tar.gz && Download_src + if [[ "$PHP_version" =~ ^[5-6]$ ]]; then + echo "Download pecl memcache for php 7.x..." + # src_url=https://codeload.github.com/websupport-sk/pecl-memcache/zip/php7 && Download_src + src_url=${mirrorLink}/pecl-memcache-php7.tgz && Download_src + echo "Download pecl memcached for php 7.x..." + src_url=https://pecl.php.net/get/memcached-${memcached_pecl_php7_version}.tgz && Download_src else - echo "Download pecl mongodb for php..." - src_url=https://pecl.php.net/get/mongodb-${pecl_mongodb_ver}.tgz && Download_src + echo "Download pecl memcache for php..." + src_url=http://pecl.php.net/get/memcache-${memcache_pecl_version}.tgz && Download_src + echo "Download pecl memcached for php..." + src_url=http://pecl.php.net/get/memcached-${memcached_pecl_version}.tgz && Download_src fi - fi - # nodejs - if [ "${nodejs_flag}" == 'y' ]; then - echo "Download Nodejs..." - [ "${OUTIP_STATE}"x == "China"x ] && DOWN_ADDR_NODE=https://mirrors.tuna.tsinghua.edu.cn/nodejs-release || DOWN_ADDR_NODE=https://nodejs.org/dist - src_url=${DOWN_ADDR_NODE}/v${nodejs_ver}/node-v${nodejs_ver}-linux-${SYS_ARCH_n}.tar.gz && Download_src + echo "Download libmemcached..." + src_url=https://launchpad.net/libmemcached/1.0/${libmemcached_version}/+download/libmemcached-${libmemcached_version}.tar.gz && Download_src fi - # pureftpd - if [ "${pureftpd_flag}" == 'y' ]; then - echo "Download pureftpd..." - src_url=https://download.pureftpd.org/pub/pure-ftpd/releases/pure-ftpd-${pureftpd_ver}.tar.gz && Download_src + if [[ $Nginx_version =~ ^[1-3]$ ]] || [ "$DB_yn" == 'y' -a "$DB_version" != '10' ]; then + echo "Download jemalloc..." + src_url=${mirrorLink}/jemalloc-${jemalloc_version}.tar.bz2 && Download_src fi - # phpMyAdmin - if [ "${phpmyadmin_flag}" == 'y' ]; then - echo "Download phpMyAdmin..." - if [[ "${php_option}" =~ ^[1-5]$ ]] || [[ "${mphp_ver}" =~ ^5[3-6]$|^70$ ]]; then - src_url=${mirror_link}/src/phpMyAdmin-4.4.15.10-all-languages.tar.gz && Download_src - else - src_url=${mirror_link}/src/phpMyAdmin-${phpmyadmin_ver}-all-languages.tar.gz && Download_src + # others + if [ "${downloadDepsSrc}" == '1' ]; then + if [ "${OS}" == "CentOS" ]; then + echo "Download tmux for CentOS..." + src_url=${mirrorLink}/libevent-${libevent_version}.tar.gz && Download_src + src_url=https://github.com/tmux/tmux/releases/download/${tmux_version}/tmux-${tmux_version}.tar.gz && Download_src + + echo "Download htop for CentOS..." + src_url=http://hisham.hm/htop/releases/${htop_version}/htop-${htop_version}.tar.gz && Download_src + fi + + if [[ "${Ubuntu_version}" =~ ^14$|^15$ ]]; then + echo "Download bison for Ubuntu..." + src_url=http://ftp.gnu.org/gnu/bison/bison-${bison_version}.tar.gz && Download_src fi fi - popd > /dev/null + popd } diff --git a/include/check_os.sh b/include/check_os.sh index dc8225a6..dea1e0e6 100644 --- a/include/check_os.sh +++ b/include/check_os.sh @@ -1,137 +1,92 @@ #!/bin/bash # Author: yeho -# BLOG: https://linuxeye.com +# BLOG: https://blog.linuxeye.com +# +# Notes: OneinStack for CentOS/RadHat 5+ Debian 6+ and Ubuntu 12+ +# +# Project home page: +# https://oneinstack.com +# https://github.com/lj2007331/oneinstack -if [ -e "/etc/os-release" ]; then - . /etc/os-release -else - echo "${CFAILURE}/etc/os-release does not exist! ${CEND}" - kill -9 $$; exit 1; -fi - -# Get OS Version -Platform=${ID,,} -VERSION_MAIN_ID=${VERSION_ID%%.*} -ARCH=$(arch) -if [[ "${Platform}" =~ ^centos$|^rhel$|^almalinux$|^rocky$|^fedora$|^amzn$|^ol$|^alinux$|^anolis$|^tencentos$|^opencloudos$|^hce$|^openeuler$|^kylin$|^uos$|^kylinsecos$ ]]; then - PM=yum - Family=rhel - RHEL_ver=${VERSION_MAIN_ID} - if [[ "${Platform}" =~ ^centos$ ]]; then - if [ "${VERSION_MAIN_ID}" == '6' ]; then - sed -i "s@centos/\$releasever@centos-vault/6.10@g" /etc/yum.repos.d/CentOS-Base.repo - sed -i 's@centos/RPM-GPG@centos-vault/RPM-GPG@g' /etc/yum.repos.d/CentOS-Base.repo - [ -e /etc/yum.repos.d/epel.repo ] && rm -f /etc/yum.repos.d/epel.repo - fi - elif [[ "${Platform}" =~ ^fedora$ ]]; then - Fedora_ver=${VERSION_MAIN_ID} - [ ${VERSION_MAIN_ID} -ge 19 ] && [ ${VERSION_MAIN_ID} -lt 28 ] && RHEL_ver=7 - [ ${VERSION_MAIN_ID} -ge 28 ] && [ ${VERSION_MAIN_ID} -lt 34 ] && RHEL_ver=8 - [ ${VERSION_MAIN_ID} -ge 34 ] && RHEL_ver=9 - elif [[ "${Platform}" =~ ^amzn$|^alinux$|^tencentos$ ]]; then - [[ "${VERSION_MAIN_ID}" =~ ^2$ ]] && RHEL_ver=7 - [[ "${VERSION_MAIN_ID}" =~ ^3$ ]] && RHEL_ver=8 - [[ "${VERSION_MAIN_ID}" =~ ^4$ ]] && RHEL_ver=9 - elif [[ "${Platform}" =~ ^openeuler$ ]]; then - [[ "${RHEL_ver}" =~ ^20$ ]] && RHEL_ver=7 - [[ "${RHEL_ver}" =~ ^2[1,2]$ ]] && RHEL_ver=8 - elif [[ "${Platform}" =~ ^hce$ ]]; then - [[ "${VERSION_MAIN_ID}" =~ ^2$ ]] && RHEL_ver=8 - elif [[ "${Platform}" =~ ^kylin$ ]]; then - [[ "${RHEL_ver}" =~ ^V10$ ]] && RHEL_ver=7 - elif [[ "${Platform}" =~ ^uos$ ]]; then - [[ "${RHEL_ver}" =~ ^20$ ]] && RHEL_ver=8 - elif [[ "${Platform}" =~ ^kylinsecos$ ]]; then - [[ "${VERSION_ID}" =~ ^3.4 ]] && RHEL_ver=7 - [[ "${VERSION_ID}" =~ ^3.5 ]] && RHEL_ver=8 - fi -elif [[ "${Platform}" =~ ^debian$|^deepin$|^kali$ ]]; then - PM=apt-get - Family=debian - Debian_ver=${VERSION_MAIN_ID} - if [[ "${Platform}" =~ ^deepin$ ]]; then - [[ "${Debian_ver}" =~ ^20$ ]] && Debian_ver=10 - [[ "${Debian_ver}" =~ ^23$ ]] && Debian_ver=11 - elif [[ "${Platform}" =~ ^kali$ ]]; then - [[ "${Debian_ver}" =~ ^202 ]] && Debian_ver=10 - fi -elif [[ "${Platform}" =~ ^ubuntu$|^linuxmint$|^elementary$ ]]; then - PM=apt-get - Family=ubuntu - Ubuntu_ver=${VERSION_MAIN_ID} - if [[ "${Platform}" =~ ^linuxmint$ ]]; then - [[ "${VERSION_MAIN_ID}" =~ ^18$ ]] && Ubuntu_ver=16 - [[ "${VERSION_MAIN_ID}" =~ ^19$ ]] && Ubuntu_ver=18 - [[ "${VERSION_MAIN_ID}" =~ ^20$ ]] && Ubuntu_ver=20 - [[ "${VERSION_MAIN_ID}" =~ ^21$ ]] && Ubuntu_ver=22 - elif [[ "${Platform}" =~ ^elementary$ ]]; then - [[ "${VERSION_MAIN_ID}" =~ ^5$ ]] && Ubuntu_ver=18 - [[ "${VERSION_MAIN_ID}" =~ ^6$ ]] && Ubuntu_ver=20 - [[ "${VERSION_MAIN_ID}" =~ ^7$ ]] && Ubuntu_ver=22 +if [ -n "$(grep 'Aliyun Linux release' /etc/issue)" -o -e /etc/redhat-release ]; then + OS=CentOS + [ -n "$(grep ' 7\.' /etc/redhat-release 2> /dev/null)" ] && CentOS_RHEL_version=7 + [ -n "$(grep ' 6\.' /etc/redhat-release 2> /dev/null)" -o -n "$(grep 'Aliyun Linux release6 15' /etc/issue)" ] && CentOS_RHEL_version=6 + [ -n "$(grep ' 5\.' /etc/redhat-release 2> /dev/null)" -o -n "$(grep 'Aliyun Linux release5' /etc/issue)" ] && CentOS_RHEL_version=5 +elif [ -n "$(grep 'Amazon Linux AMI release' /etc/issue)" -o -e /etc/system-release ]; then + OS=CentOS + CentOS_RHEL_version=6 +elif [ -n "$(grep 'bian' /etc/issue)" -o "$(lsb_release -is 2>/dev/null)" == "Debian" ]; then + OS=Debian + [ ! -e "$(which lsb_release)" ] && { apt-get -y update; apt-get -y install lsb-release; clear; } + Debian_version=$(lsb_release -sr | awk -F. '{print $1}') +elif [ -n "$(grep 'Deepin' /etc/issue)" -o "$(lsb_release -is 2>/dev/null)" == "Deepin" ]; then + OS=Debian + [ ! -e "$(which lsb_release)" ] && { apt-get -y update; apt-get -y install lsb-release; clear; } + Debian_version=$(lsb_release -sr | awk -F. '{print $1}') +# kali rolling +elif [ -n "$(grep 'Kali GNU/Linux Rolling' /etc/issue)" -o "$(lsb_release -is 2>/dev/null)" == "Kali" ]; then + OS=Debian + [ ! -e "$(which lsb_release)" ] && { apt-get -y update; apt-get -y install lsb-release; clear; } + if [ -n "$(grep 'VERSION="2016.*"' /etc/os-release)" ]; then + Debian_version=8 + else + echo "${CFAILURE}Does not support this OS, Please contact the author! ${CEND}" + kill -9 $$ fi +elif [ -n "$(grep 'Ubuntu' /etc/issue)" -o "$(lsb_release -is 2>/dev/null)" == "Ubuntu" -o -n "$(grep 'Linux Mint' /etc/issue)" ]; then + OS=Ubuntu + [ ! -e "$(which lsb_release)" ] && { apt-get -y update; apt-get -y install lsb-release; clear; } + Ubuntu_version=$(lsb_release -sr | awk -F. '{print $1}') + [ -n "$(grep 'Linux Mint 18' /etc/issue)" ] && Ubuntu_version=16 +elif [ -n "$(grep 'elementary' /etc/issue)" -o "$(lsb_release -is 2>/dev/null)" == 'elementary' ]; then + OS=Ubuntu + [ ! -e "$(which lsb_release)" ] && { apt-get -y update; apt-get -y install lsb-release; clear; } + Ubuntu_version=16 else - echo "${CFAILURE}Does not support this OS ${CEND}" - kill -9 $$; exit 1; + echo "${CFAILURE}Does not support this OS, Please contact the author! ${CEND}" + kill -9 $$ fi -# Check OS Version -if [ ${RHEL_ver} -lt 7 >/dev/null 2>&1 ] || [ ${Debian_ver} -lt 9 >/dev/null 2>&1 ] || [ ${Ubuntu_ver} -lt 16 >/dev/null 2>&1 ]; then - echo "${CFAILURE}Does not support this OS, Please install CentOS 7+,Debian 9+,Ubuntu 16+ ${CEND}" - kill -9 $$; exit 1; +if [ "$(getconf WORD_BIT)" == "32" ] && [ "$(getconf LONG_BIT)" == "64" ]; then + OS_BIT=64 + SYS_BIG_FLAG=x64 #jdk + SYS_BIT_a=x86_64;SYS_BIT_b=x86_64; #mariadb +else + OS_BIT=32 + SYS_BIG_FLAG=i586 + SYS_BIT_a=x86;SYS_BIT_b=i686; fi -command -v gcc > /dev/null 2>&1 || $PM -y install gcc -gcc_ver=$(gcc -dumpversion | awk -F. '{print $1}') +LIBC_YN=$(awk -v A=$(getconf -a | grep GNU_LIBC_VERSION | awk '{print $NF}') -v B=2.14 'BEGIN{print(A>=B)?"0":"1"}') +[ $LIBC_YN == '0' ] && GLIBC_FLAG=linux-glibc_214 || GLIBC_FLAG=linux -[ ${gcc_ver} -lt 5 >/dev/null 2>&1 ] && redis_ver=6.2.14 - -if uname -m | grep -Eqi "arm|aarch64"; then - armplatform="y" +if uname -m | grep -Eqi "arm"; then + armPlatform="y" if uname -m | grep -Eqi "armv7"; then TARGET_ARCH="armv7" elif uname -m | grep -Eqi "armv8"; then TARGET_ARCH="arm64" - elif uname -m | grep -Eqi "aarch64"; then - TARGET_ARCH="aarch64" else TARGET_ARCH="unknown" fi fi -if [ "$(uname -r | awk -F- '{print $3}' 2>/dev/null)" == "Microsoft" ]; then - Wsl=true -fi +THREAD=$(grep 'processor' /proc/cpuinfo | sort -u | wc -l) -if [ "$(getconf WORD_BIT)" == "32" ] && [ "$(getconf LONG_BIT)" == "64" ]; then - if [ "${TARGET_ARCH}" == 'aarch64' ]; then - SYS_ARCH=arm64 - SYS_ARCH_i=aarch64 - SYS_ARCH_n=arm64 +# Percona +if [[ "${OS}" =~ ^Ubuntu$|^Debian$ ]]; then + if [ "${Debian_version}" == '6' ]; then + sslLibVer=ssl098 else - SYS_ARCH=amd64 #openjdk - SYS_ARCH_i=x86-64 #ioncube - SYS_ARCH_n=x64 #nodejs + sslLibVer=ssl100 + fi +elif [ "${OS}" == "CentOS" ]; then + if [ "${CentOS_RHEL_version}" == '5' ]; then + sslLibVer=ssl098e + else + sslLibVer=ssl101 fi -else - echo "${CWARNING}32-bit OS are not supported! ${CEND}" - kill -9 $$; exit 1; -fi - -THREAD=$(grep 'processor' /proc/cpuinfo | sort -u | wc -l) - -# Percona binary: https://docs.percona.com/percona-server/5.7/installation/binary-tarball.html -if [ ${Debian_ver} -lt 9 >/dev/null 2>&1 ]; then - sslLibVer=ssl100 -elif [ "${RHEL_ver}" == '7' ] && [ "${Platform}" != 'fedora' ]; then - sslLibVer=ssl101 -elif [ ${Debian_ver} -ge 9 >/dev/null 2>&1 ] || [ ${Ubuntu_ver} -ge 16 >/dev/null 2>&1 ]; then - sslLibVer=ssl102 -elif [ ${Fedora_ver} -ge 27 >/dev/null 2>&1 ]; then - sslLibVer=ssl102 -elif [ "${RHEL_ver}" == '8' ]; then - sslLibVer=ssl1:111 else sslLibVer=unknown fi - -[ -e ~/.oneinstack ] && /bin/mv ~/.oneinstack ~/.lnmp diff --git a/include/check_port.py b/include/check_port.py new file mode 100755 index 00000000..4d57ce68 --- /dev/null +++ b/include/check_port.py @@ -0,0 +1,13 @@ +#!/usr/bin/env python +import sys,os,socket +def IsOpen(ip,port): + socket.setdefaulttimeout(5) + s = socket.socket(socket.AF_INET,socket.SOCK_STREAM) + try: + s.connect((ip,int(port))) + s.shutdown(2) + print True + except: + print False +if __name__ == '__main__': + IsOpen(sys.argv[1],int(sys.argv[2])) diff --git a/include/check_sw.sh b/include/check_sw.sh index 97f20d74..2db26dbe 100644 --- a/include/check_sw.sh +++ b/include/check_sw.sh @@ -1,157 +1,168 @@ #!/bin/bash # Author: Alpha Eva +# +# Notes: OneinStack for CentOS/RadHat 5+ Debian 6+ and Ubuntu 12+ +# +# Project home page: +# https://oneinstack.com +# https://github.com/lj2007331/oneinstack installDepsDebian() { echo "${CMSG}Removing the conflicting packages...${CEND}" - if [ "${apache_flag}" == 'y' ]; then - killall apache2 - pkgList="apache2 apache2-doc apache2-utils apache2.2-common apache2.2-bin apache2-mpm-prefork apache2-doc apache2-mpm-worker php5 php5-common php5-cgi php5-cli php5-mysql php5-curl php5-gd" - for Package in ${pkgList};do - apt-get -y purge ${Package} - done - dpkg -l | grep ^rc | awk '{print $2}' | xargs dpkg -P - fi - - if [[ "${db_option}" =~ ^[1-9]$|^1[0-2]$ ]]; then - pkgList="mysql-client mysql-server mysql-common mysql-server-core-5.5 mysql-client-5.5 mariadb-client mariadb-server mariadb-common" - for Package in ${pkgList};do - apt-get -y purge ${Package} - done - dpkg -l | grep ^rc | awk '{print $2}' | xargs dpkg -P - fi + pkgList="apache2 apache2-data apache2-doc apache2-utils apache2.2-common apache2.2-bin apache2-mpm-prefork apache2-mpm-worker mysql-client mysql-server mysql-common libmysqlclient18 php5 php5-common php5-cgi php5-mysql php5-curl php5-gd libmysql* mysql-*" + for Package in ${pkgList};do + apt-get -y remove --purge ${Package} + done + dpkg -l | grep ^rc | awk '{print $2}' | xargs dpkg -P - echo "${CMSG}Installing dependencies packages...${CEND}" apt-get -y update - apt-get -y autoremove - apt-get -yf install - export DEBIAN_FRONTEND=noninteractive - + echo "${CMSG}Installing dependencies packages...${CEND}" # critical security updates grep security /etc/apt/sources.list > /tmp/security.sources.list apt-get -y upgrade -o Dir::Etc::SourceList=/tmp/security.sources.list + apt-get autoremove + # Install needed packages - case "${Debian_ver}" in - 9|10|11|12) - pkgList="debian-keyring debian-archive-keyring build-essential gcc g++ make cmake autoconf libjpeg62-turbo-dev libjpeg-dev libpng-dev libgd-dev libxml2 libxml2-dev zlib1g zlib1g-dev libc6 libc6-dev libc-client2007e-dev libglib2.0-0 libglib2.0-dev bzip2 libzip-dev libbz2-1.0 libncurses5 libncurses5-dev libaio1 libaio-dev numactl libreadline-dev curl libcurl3-gnutls libcurl4-openssl-dev e2fsprogs libkrb5-3 libkrb5-dev libltdl-dev libidn11 libidn11-dev openssl net-tools libssl-dev libtool libevent-dev bison re2c libsasl2-dev libxslt1-dev libicu-dev libpsl-dev locales patch vim zip unzip tmux htop bc dc expect libexpat1-dev libonig-dev libtirpc-dev rsync git lsof lrzsz rsyslog cron logrotate chrony libsqlite3-dev psmisc wget sysv-rc apt-transport-https ca-certificates software-properties-common gnupg ufw" + case "${Debian_version}" in + [6,7]) + pkgList="gcc g++ make cmake autoconf libjpeg8 libjpeg8-dev libjpeg-dev libpng12-0 libpng12-dev libpng3 libfreetype6 libfreetype6-dev libxml2 libxml2-dev zlib1g zlib1g-dev libc6 libc6-dev libglib2.0-0 libglib2.0-dev bzip2 libzip-dev libbz2-1.0 libncurses5 libncurses5-dev libaio1 libaio-dev numactl libreadline-dev curl libcurl3 libcurl4-openssl-dev libcurl4-gnutls-dev e2fsprogs libkrb5-3 libkrb5-dev libltdl-dev libidn11 libidn11-dev openssl libssl-dev libtool libevent-dev bison re2c libsasl2-dev libxslt1-dev libicu-dev locales libcloog-ppl0 patch vim zip unzip tmux htop bc dc expect rsync git lsof lrzsz iptables rsyslog cron logrotate ntpdate libsqlite3-dev psmisc wget sysv-rc" + ;; + 8) + pkgList="gcc g++ make cmake autoconf libjpeg8 libjpeg62-turbo-dev libjpeg-dev libpng12-0 libpng12-dev libpng3 libfreetype6 libfreetype6-dev libxml2 libxml2-dev zlib1g zlib1g-dev libc6 libc6-dev libglib2.0-0 libglib2.0-dev bzip2 libzip-dev libbz2-1.0 libncurses5 libncurses5-dev libaio1 libaio-dev numactl libreadline-dev curl libcurl3 libcurl4-openssl-dev libcurl4-gnutls-dev e2fsprogs libkrb5-3 libkrb5-dev libltdl-dev libidn11 libidn11-dev openssl libssl-dev libtool libevent-dev bison re2c libsasl2-dev libxslt1-dev libicu-dev locales libcloog-ppl0 patch vim zip unzip tmux htop bc dc expect rsync git lsof lrzsz iptables rsyslog cron logrotate ntpdate libsqlite3-dev psmisc wget sysv-rc" ;; *) - echo "${CFAILURE}Your system Debian ${Debian_ver} are not supported!${CEND}" - kill -9 $$; exit 1; + echo "${CFAILURE}Your system Debian ${Debian_version} are not supported!${CEND}" + kill -9 $$ ;; esac + for Package in ${pkgList}; do - apt-get --no-install-recommends -y install ${Package} + apt-get -y install ${Package} done } -installDepsRHEL() { - [ -e '/etc/yum.conf' ] && sed -i 's@^exclude@#exclude@' /etc/yum.conf - if [ "${RHEL_ver}" == '9' ]; then - if [[ "${Platform}" =~ "rhel" ]]; then - subscription-manager repos --enable codeready-builder-for-rhel-9-${ARCH}-rpms - dnf -y install chrony oniguruma-devel rpcgen - elif [[ "${Platform}" =~ "ol" ]]; then - dnf config-manager --set-enabled ol9_codeready_builder - dnf -y install chrony oniguruma-devel rpcgen - else - dnf -y --enablerepo=crb install chrony oniguruma-devel rpcgen libtirpc-devel - fi - systemctl enable chronyd - elif [ "${RHEL_ver}" == '8' ]; then - if [[ "${Platform}" =~ "rhel" ]]; then - subscription-manager repos --enable codeready-builder-for-rhel-8-${ARCH}-rpms - dnf -y install chrony oniguruma-devel rpcgen - elif [[ "${Platform}" =~ "ol" ]]; then - dnf config-manager --set-enabled ol8_codeready_builder - dnf -y install chrony oniguruma-devel rpcgen - else - [ -z "`grep -w epel /etc/yum.repos.d/*.repo`" ] && yum -y install epel-release - if grep -qw "^\[PowerTools\]" /etc/yum.repos.d/*.repo; then - dnf -y --enablerepo=PowerTools install chrony oniguruma-devel rpcgen - elif grep -qw "^\[powertools\]" /etc/yum.repos.d/*.repo; then - dnf -y --enablerepo=powertools install chrony oniguruma-devel rpcgen - fi - fi - systemctl enable chronyd - elif [ "${RHEL_ver}" == '7' ]; then - [ -z "`grep -w epel /etc/yum.repos.d/*.repo`" ] && yum -y install epel-release - yum -y groupremove "Basic Web Server" "MySQL Database server" "MySQL Database client" - fi +installDepsCentOS() { + sed -i 's@^exclude@#exclude@' /etc/yum.conf + yum clean all - if [ "${RHEL_ver}" == '9' ]; then - [ ! -e "/usr/lib64/libtinfo.so.5" ] && ln -s /usr/lib64/libtinfo.so.6 /usr/lib64/libtinfo.so.5 - [ ! -e "/usr/lib64/libncurses.so.5" ] && ln -s /usr/lib64/libncurses.so.6 /usr/lib64/libncurses.so.5 + yum makecache + # Uninstall the conflicting packages + echo "${CMSG}Removing the conflicting packages...${CEND}" + if [ "${CentOS_RHEL_version}" == '7' ]; then + yum -y groupremove "Basic Web Server" "MySQL Database server" "MySQL Database client" "File and Print Server" + yum -y install iptables-services + systemctl mask firewalld.service + systemctl enable iptables.service + elif [ "${CentOS_RHEL_version}" == '6' ]; then + yum -y groupremove "FTP Server" "PostgreSQL Database client" "PostgreSQL Database server" "MySQL Database server" "MySQL Database client" "Web Server" "Office Suite and Productivity" "E-mail server" "Ruby Support" "Printing client" + elif [ "${CentOS_RHEL_version}" == '5' ]; then + yum -y groupremove "FTP Server" "Windows File Server" "PostgreSQL Database" "News Server" "MySQL Database" "DNS Name Server" "Web Server" "Dialup Networking Support" "Mail Server" "Ruby" "Office/Productivity" "Sound and Video" "Printing Support" "OpenFabrics Enterprise Distribution" fi echo "${CMSG}Installing dependencies packages...${CEND}" + yum check-update # Install needed packages - pkgList="perl-FindBin libtime-piece-perl deltarpm drpm gcc gcc-c++ make cmake autoconf libjpeg libjpeg-devel libjpeg-turbo libjpeg-turbo-devel libpng libpng-devel libxml2 libxml2-devel zlib zlib-devel libzip libzip-devel glibc glibc-devel krb5-devel libc-client libc-client-devel glib2 glib2-devel bzip2 bzip2-devel ncurses ncurses-devel ncurses-compat-libs libaio numactl numactl-libs readline-devel curl curl-devel e2fsprogs e2fsprogs-devel krb5-devel libidn libidn-devel openssl openssl-devel net-tools libxslt-devel libicu-devel libpsl-devel libevent-devel libtool libtool-ltdl bison gd-devel vim-enhanced pcre-devel libmcrypt libmcrypt-devel mhash mhash-devel mcrypt zip unzip chrony oniguruma-devel rpcgen sqlite-devel sysstat patch bc expect expat-devel perl-devel perl-IPC-Cmd perl-Time-Piece oniguruma oniguruma-devel libtirpc-devel nss libnsl rsync rsyslog git lsof lrzsz psmisc wget which libatomic tmux chkconfig firewalld" + pkgList="deltarpm gcc gcc-c++ make cmake autoconf libjpeg libjpeg-devel libpng libpng-devel freetype freetype-devel libxml2 libxml2-devel zlib zlib-devel glibc glibc-devel glib2 glib2-devel bzip2 bzip2-devel ncurses ncurses-devel libaio numactl-libs readline-devel curl curl-devel e2fsprogs e2fsprogs-devel krb5-devel libidn libidn-devel openssl openssl-devel libxslt-devel libicu-devel libevent-devel libtool libtool-ltdl bison gd-devel vim-enhanced pcre-devel zip unzip ntpdate sqlite-devel sysstat patch bc expect rsync rsyslog git lsof lrzsz wget" for Package in ${pkgList}; do yum -y install ${Package} done - [ ${RHEL_ver} -lt 8 >/dev/null 2>&1 ] && yum -y install cmake3 yum -y update bash openssl glibc + + # use gcc-4.4 + if [ -n "$(gcc --version | head -n1 | grep '4\.1\.')" ]; then + yum -y install gcc44 gcc44-c++ libstdc++44-devel + export CC="gcc44" CXX="g++44" + fi } installDepsUbuntu() { # Uninstall the conflicting software echo "${CMSG}Removing the conflicting packages...${CEND}" - if [ "${apache_flag}" == 'y' ]; then - killall apache2 - pkgList="apache2 apache2-doc apache2-utils apache2.2-common apache2.2-bin apache2-mpm-prefork apache2-doc apache2-mpm-worker php5 php5-common php5-cgi php5-cli php5-mysql php5-curl php5-gd" - for Package in ${pkgList};do - apt-get -y purge ${Package} - done - dpkg -l | grep ^rc | awk '{print $2}' | xargs dpkg -P - fi + pkgList="apache2 apache2-data apache2-doc apache2-utils apache2.2-common apache2.2-bin apache2-mpm-prefork apache2-mpm-worker mysql-client mysql-server mysql-common libmysqlclient18 php5 php5-common php5-cgi php5-mysql php5-curl php5-gd libmysql* mysql-*" + for Package in ${pkgList}; do + apt-get -y remove --purge ${Package} + done + dpkg -l | grep ^rc | awk '{print $2}' | xargs dpkg -P - if [[ "${db_option}" =~ ^[1-9]$|^1[0-2]$ ]]; then - pkgList="mysql-client mysql-server mysql-common mysql-server-core-5.5 mysql-client-5.5 mariadb-client mariadb-server mariadb-common" - for Package in ${pkgList};do - apt-get -y purge ${Package} - done - dpkg -l | grep ^rc | awk '{print $2}' | xargs dpkg -P - fi + apt-get autoremove echo "${CMSG}Installing dependencies packages...${CEND}" apt-get -y update - apt-get -y autoremove - apt-get -yf install - export DEBIAN_FRONTEND=noninteractive - [[ "${Ubuntu_ver}" =~ ^22$ ]] && apt-get -y --allow-downgrades install libicu70=70.1-2 libglib2.0-0=2.72.1-1 libxml2-dev - # critical security updates grep security /etc/apt/sources.list > /tmp/security.sources.list apt-get -y upgrade -o Dir::Etc::SourceList=/tmp/security.sources.list # Install needed packages - pkgList="libperl-dev debian-keyring debian-archive-keyring build-essential gcc g++ make cmake autoconf libjpeg8 libjpeg8-dev libpng-dev libpng12-0 libpng12-dev libpng3 libxml2 libxml2-dev zlib1g zlib1g-dev libc6 libc6-dev libc-client2007e-dev libglib2.0-0 libglib2.0-dev bzip2 libzip-dev libbz2-1.0 libncurses5 libncurses5-dev libaio1 libaio-dev numactl libreadline-dev curl libcurl3-gnutls libcurl4-gnutls-dev libcurl4-openssl-dev e2fsprogs libkrb5-3 libkrb5-dev libltdl-dev libidn11 libidn11-dev openssl net-tools libssl-dev libtool libevent-dev re2c libsasl2-dev libxslt1-dev libicu-dev libpsl-dev libsqlite3-dev libcloog-ppl1 bison patch vim zip unzip tmux htop bc dc expect libexpat1-dev rsyslog libonig-dev libtirpc-dev libnss3 rsync git lsof lrzsz chrony psmisc wget sysv-rc apt-transport-https ca-certificates software-properties-common gnupg ufw" - export DEBIAN_FRONTEND=noninteractive + pkgList="gcc g++ make cmake autoconf libjpeg8 libjpeg8-dev libpng12-0 libpng12-dev libpng3 libfreetype6 libfreetype6-dev libxml2 libxml2-dev zlib1g zlib1g-dev libc6 libc6-dev libglib2.0-0 libglib2.0-dev bzip2 libzip-dev libbz2-1.0 libncurses5 libncurses5-dev libaio1 libaio-dev numactl libreadline-dev curl libcurl3 libcurl4-openssl-dev e2fsprogs libkrb5-3 libkrb5-dev libltdl-dev libidn11 libidn11-dev openssl libssl-dev libtool libevent-dev re2c libsasl2-dev libxslt1-dev libicu-dev libsqlite3-dev patch vim zip unzip tmux htop bc dc expect iptables rsyslog rsync git lsof lrzsz ntpdate wget sysv-rc" for Package in ${pkgList}; do - apt-get --no-install-recommends -y install ${Package} + apt-get -y install ${Package} --force-yes done - [[ "${Ubuntu_ver}" =~ ^24$ ]] && ln -s /usr/lib/x86_64-linux-gnu/libaio.so.1t64.0.2 /usr/lib/x86_64-linux-gnu/libaio.so.1 + + if [[ "${Ubuntu_version}" =~ ^14$|^15$ ]]; then + apt-get -y install libcloog-ppl1 + apt-get -y remove bison + ln -sf /usr/include/freetype2 /usr/include/freetype2/freetype + elif [ "${Ubuntu_version}" == "13" ]; then + apt-get -y install bison libcloog-ppl1 + elif [ "${Ubuntu_version}" == "12" ]; then + apt-get -y install bison libcloog-ppl0 + else + apt-get -y install bison libcloog-ppl1 + fi } installDepsBySrc() { - pushd ${current_dir}/src > /dev/null - if ! command -v icu-config > /dev/null 2>&1 || icu-config --version | grep '^3.' || [ "${Ubuntu_ver}" == "20" ]; then - tar xzf icu4c-${icu4c_ver}-src.tgz - pushd icu/source > /dev/null - ./configure --prefix=/usr/local - make -j ${THREAD} && make install - popd > /dev/null - rm -rf icu - fi + pushd ${oneinstack_dir}/src + + if [ "${OS}" == "Ubuntu" ]; then + if [[ "${Ubuntu_version}" =~ ^14$|^15$ ]]; then + # Install bison on ubt 14.x 15.x + tar xzf bison-${bison_version}.tar.gz + pushd bison-${bison_version} + ./configure + make -j ${THREAD} && make install + popd + rm -rf bison-${bison_version} + fi + elif [ "${OS}" == "CentOS" ]; then + # Install tmux + if [ ! -e "$(which tmux)" ]; then + # Install libevent first + tar xzf libevent-${libevent_version}.tar.gz + pushd libevent-${libevent_version} + ./configure + make -j ${THREAD} && make install + popd + rm -rf libevent-${libevent_version} + + tar xzf tmux-${tmux_version}.tar.gz + pushd tmux-${tmux_version} + CFLAGS="-I/usr/local/include" LDFLAGS="-L/usr/local/lib" ./configure + make -j ${THREAD} && make install + unset LDFLAGS + popd + rm -rf tmux-${tmux_version} + + if [ "${OS_BIT}" == "64" ]; then + ln -s /usr/local/lib/libevent-2.0.so.5 /usr/lib64/libevent-2.0.so.5 + else + ln -s /usr/local/lib/libevent-2.0.so.5 /usr/lib/libevent-2.0.so.5 + fi + fi - if command -v lsof >/dev/null 2>&1; then - echo 'already initialize' > ~/.lnmp + # install htop + if [ ! -e "$(which htop)" ]; then + tar xzf htop-${htop_version}.tar.gz + pushd htop-${htop_version} + ./configure + make -j ${THREAD} && make install + popd + rm -rf htop-${htop_version} + fi else - echo "${CFAILURE}${PM} config error parsing file failed${CEND}" - kill -9 $$; exit 1; + echo "No need to install software from source packages." fi - - popd > /dev/null + popd } diff --git a/include/check_web.sh b/include/check_web.sh new file mode 100644 index 00000000..62e89f33 --- /dev/null +++ b/include/check_web.sh @@ -0,0 +1,13 @@ +#!/bin/bash +# Author: yeho +# BLOG: https://blog.linuxeye.com +# +# Notes: OneinStack for CentOS/RadHat 5+ Debian 6+ and Ubuntu 12+ +# +# Project home page: +# http://oneinstack.com +# https://github.com/lj2007331/oneinstack + +[ -e "$nginx_install_dir/sbin/nginx" ] && web_install_dir=$nginx_install_dir +[ -e "$tengine_install_dir/sbin/nginx" ] && web_install_dir=$tengine_install_dir +[ -e "$openresty_install_dir/nginx/sbin/nginx" ] && web_install_dir=$openresty_install_dir/nginx diff --git a/include/color.sh b/include/color.sh index abedc52d..16019004 100644 --- a/include/color.sh +++ b/include/color.sh @@ -1,6 +1,12 @@ #!/bin/bash # Author: yeho -# BLOG: https://linuxeye.com +# BLOG: https://blog.linuxeye.com +# +# Notes: OneinStack for CentOS/RadHat 5+ Debian 6+ and Ubuntu 12+ +# +# Project home page: +# https://oneinstack.com +# https://github.com/lj2007331/oneinstack echo=echo for cmd in echo /bin/echo; do diff --git a/include/composer.sh b/include/composer.sh deleted file mode 100644 index e2bd80bf..00000000 --- a/include/composer.sh +++ /dev/null @@ -1,35 +0,0 @@ -#!/bin/bash -# Author: yeho -# BLOG: https://linuxeye.com - -Install_composer() { - if [ -e "${php_install_dir}/bin/phpize" ]; then - if [ -e "/usr/local/bin/composer" ]; then - echo "${CWARNING}PHP Composer already installed! ${CEND}" - else - pushd ${current_dir}/src > /dev/null - if [ "${OUTIP_STATE}"x == "China"x ]; then - wget --no-check-certificate -c https://mirrors.aliyun.com/composer/composer.phar -O /usr/local/bin/composer > /dev/null 2>&1 - ${php_install_dir}/bin/php /usr/local/bin/composer config -g repo.packagist composer https://packagist.phpcomposer.com - else - wget --no-check-certificate -c https://getcomposer.org/composer.phar -O /usr/local/bin/composer > /dev/null 2>&1 - fi - chmod +x /usr/local/bin/composer - if [ -e "/usr/local/bin/composer" ]; then - echo; echo "${CSUCCESS}PHP Composer installed successfully! ${CEND}" - else - echo; echo "${CFAILURE}PHP Composer install failed, Please try again! ${CEND}" - fi - popd > /dev/null - fi - fi -} - -Uninstall_composer() { - if [ -e "/usr/local/bin/composer" ]; then - rm -f /usr/local/bin/composer - echo; echo "${CMSG}Composer uninstall completed${CEND}"; - else - echo; echo "${CWARNING}Composer does not exist! ${CEND}" - fi -} diff --git a/include/demo.sh b/include/demo.sh index 514c9f69..4042d562 100644 --- a/include/demo.sh +++ b/include/demo.sh @@ -1,29 +1,50 @@ #!/bin/bash # Author: yeho -# BLOG: https://linuxeye.com +# BLOG: https://blog.linuxeye.com +# +# Notes: OneinStack for CentOS/RadHat 5+ Debian 6+ and Ubuntu 12+ +# +# Project home page: +# https://oneinstack.com +# https://github.com/lj2007331/oneinstack DEMO() { - pushd ${current_dir}/src > /dev/null - if [ ! -e ${wwwroot_dir}/default/index.html ]; then - /bin/cp ${current_dir}/config/index.html ${wwwroot_dir}/default/ - fi + pushd ${oneinstack_dir}/src + + [ "${IPADDR_COUNTRY}"x == "CN"x ] && /bin/cp ${oneinstack_dir}/config/index_cn.html ${wwwroot_dir}/default/index.html || /bin/cp ${oneinstack_dir}/config/index.html ${wwwroot_dir}/default if [ -e "${php_install_dir}/bin/php" ]; then - src_url=${mirror_link}/src/xprober.php && Download_src - /bin/cp xprober.php ${wwwroot_dir}/default + if [ "${IPADDR_COUNTRY}"x == "CN"x ]; then + src_url=http://mirrors.linuxeye.com/oneinstack/src/tz.zip && Download_src + unzip -q tz.zip -d ${wwwroot_dir}/default + else + src_url=http://mirrors.linuxeye.com/oneinstack/src/tz_e.zip && Download_src + unzip -q tz_e.zip -d ${wwwroot_dir}/default;/bin/mv ${wwwroot_dir}/default/{tz_e.php,proberv.php} + sed -i 's@https://ajax.googleapis.com/ajax/libs/jquery/1.7.0/jquery.min.js@http://lib.sinaapp.com/js/jquery/1.7/jquery.min.js@' ${wwwroot_dir}/default/proberv.php + fi echo "" > ${wwwroot_dir}/default/phpinfo.php - case "${phpcache_option}" in + case "${PHP_cache}" in 1) - src_url=${mirror_link}/src/ocp.php && Download_src + src_url=http://mirrors.linuxeye.com/oneinstack/src/ocp.php && Download_src /bin/cp ocp.php ${wwwroot_dir}/default ;; + 2) + sed -i 's@Opcache@xcache@' ${wwwroot_dir}/default/index.html + ;; + 3) + sed -i 's@Opcache@APC@' ${wwwroot_dir}/default/index.html + ;; 4) /bin/cp eaccelerator-*/control.php ${wwwroot_dir}/default + sed -i 's@Opcache@eAccelerator@' ${wwwroot_dir}/default/index.html + ;; + *) + sed -i 's@Opcache@@' ${wwwroot_dir}/default/index.html ;; esac fi - chown -R ${run_user}:${run_group} ${wwwroot_dir}/default - [ -e /bin/systemctl ] && systemctl daemon-reload - popd > /dev/null + chown -R ${run_user}.${run_user} ${wwwroot_dir}/default + [ -e /usr/bin/systemctl ] && systemctl daemon-reload + popd } diff --git a/include/download.sh b/include/download.sh index 90df0c6c..cc4e0f0a 100644 --- a/include/download.sh +++ b/include/download.sh @@ -1,11 +1,17 @@ #!/bin/bash # Author: yeho -# BLOG: https://linuxeye.com +# BLOG: https://blog.linuxeye.com +# +# Notes: OneinStack for CentOS/RadHat 5+ Debian 6+ and Ubuntu 12+ +# +# Project home page: +# https://oneinstack.com +# https://github.com/lj2007331/oneinstack Download_src() { - [ -s "${src_url##*/}" ] && echo "[${CMSG}${src_url##*/}${CEND}] found" || { wget --limit-rate=100M --tries=6 -c --no-check-certificate ${src_url}; sleep 1; } + [ -s "${src_url##*/}" ] && echo "[${CMSG}${src_url##*/}${CEND}] found" || { wget --tries=6 -c --no-check-certificate $src_url; sleep 1; } if [ ! -e "${src_url##*/}" ]; then - echo "${CFAILURE}Auto download failed! You can manually download ${src_url} into the src/ directory.${CEND}" - kill -9 $$; exit 1; + echo "${CFAILURE}${src_url##*/} download failed, Please contact the author! ${CEND}" + kill -9 $$ fi } diff --git a/include/eaccelerator.sh b/include/eaccelerator.sh index 8e55532b..9c2729bf 100644 --- a/include/eaccelerator.sh +++ b/include/eaccelerator.sh @@ -1,29 +1,37 @@ #!/bin/bash # Author: yeho -# BLOG: https://linuxeye.com +# BLOG: https://blog.linuxeye.com +# +# Notes: OneinStack for CentOS/RadHat 5+ Debian 6+ and Ubuntu 12+ +# +# Project home page: +# https://oneinstack.com +# https://github.com/lj2007331/oneinstack Install_eAccelerator() { - if [ -e "${php_install_dir}/bin/phpize" ]; then - pushd ${current_dir}/src > /dev/null - PHP_detail_ver=$(${php_install_dir}/bin/php-config --version) - PHP_main_ver=${PHP_detail_ver%.*} - phpExtensionDir=$(${php_install_dir}/bin/php-config --extension-dir) - if [[ "${PHP_main_ver}" =~ ^5.[3-4]$ ]]; then - if [ "${PHP_main_ver}" == '5.3' ]; then - tar jxf eaccelerator-${eaccelerator_ver}.tar.bz2 - pushd eaccelerator-${eaccelerator_ver} > /dev/null - elif [ "${PHP_main_ver}" == '5.4' ]; then - /bin/mv master eaccelerator-eaccelerator-42067ac.tar.gz - tar xzf eaccelerator-eaccelerator-42067ac.tar.gz - pushd eaccelerator-eaccelerator-42067ac > /dev/null - fi - ${php_install_dir}/bin/phpize - ./configure --enable-eaccelerator=shared --with-php-config=${php_install_dir}/bin/php-config - make -j ${THREAD} && make install - popd > /dev/null - if [ -f "${phpExtensionDir}/eaccelerator.so" ]; then - mkdir /var/eaccelerator_cache;chown -R ${run_user}:${run_group} /var/eaccelerator_cache - cat > ${php_install_dir}/etc/php.d/02-eaccelerator.ini << EOF + pushd ${oneinstack_dir}/src + phpExtensionDir=$(${php_install_dir}/bin/php-config --extension-dir) + case "${PHP_version}" in + 1) + tar jxf eaccelerator-${eaccelerator_version}.tar.bz2 + pushd eaccelerator-${eaccelerator_version} + ;; + 2) + /bin/mv master eaccelerator-eaccelerator-42067ac.tar.gz + tar xzf eaccelerator-eaccelerator-42067ac.tar.gz + pushd eaccelerator-eaccelerator-42067ac + ;; + *) + echo "${CWARNING}Your php does not support eAccelerator! ${CEND}" + kill -9 $$ + esac + ${php_install_dir}/bin/phpize + ./configure --enable-eaccelerator=shared --with-php-config=${php_install_dir}/bin/php-config + make -j ${THREAD} && make install + popd + if [ -f "${phpExtensionDir}/eaccelerator.so" ]; then + mkdir /var/eaccelerator_cache;chown -R ${run_user}.${run_user} /var/eaccelerator_cache + cat > ${php_install_dir}/etc/php.d/ext-eaccelerator.ini << EOF [eaccelerator] zend_extension=${phpExtensionDir}/eaccelerator.so eaccelerator.shm_size=64 @@ -43,25 +51,12 @@ eaccelerator.keys=disk_only eaccelerator.sessions=disk_only eaccelerator.content=disk_only EOF - [ -z "$(grep 'kernel.shmmax = 67108864' /etc/sysctl.conf)" ] && echo "kernel.shmmax = 67108864" >> /etc/sysctl.conf - sysctl -p - echo "${CSUCCESS}PHP eaccelerator module installed successfully! ${CEND}" - rm -rf eaccelerator-${eaccelerator_ver} eaccelerator-eaccelerator-42067ac - else - echo "${CFAILURE}PHP eaccelerator module install failed, Please contact the author! ${CEND}" && grep -Ew 'NAME|ID|ID_LIKE|VERSION_ID|PRETTY_NAME' /etc/os-release - fi - else - echo; echo "${CWARNING}Your php ${PHP_detail_ver} does not support eAccelerator! ${CEND}"; - fi - popd > /dev/null - fi -} - -Uninstall_eAccelerator() { - if [ -e "${php_install_dir}/etc/php.d/02-eaccelerator.ini" ]; then - rm -rf ${php_install_dir}/etc/php.d/02-eaccelerator.ini /var/eaccelerator_cache - echo; echo "${CMSG}PHP eaccelerator module uninstall completed${CEND}" + echo "${CSUCCESS}Accelerator module installed successfully! ${CEND}" + [ -z "$(grep 'kernel.shmmax = 67108864' /etc/sysctl.conf)" ] && echo "kernel.shmmax = 67108864" >> /etc/sysctl.conf + sysctl -p + rm -rf eaccelerator-${eaccelerator_version} eaccelerator-eaccelerator-42067ac else - echo; echo "${CWARNING}PHP eaccelerator module does not exist! ${CEND}" + echo "${CFAILURE}Accelerator module install failed, Please contact the author! ${CEND}" fi + popd } diff --git a/include/fail2ban.sh b/include/fail2ban.sh deleted file mode 100644 index 10fdb5fb..00000000 --- a/include/fail2ban.sh +++ /dev/null @@ -1,90 +0,0 @@ -#!/bin/bash -# Author: yeho -# BLOG: https://linuxeye.com - -Install_fail2ban() { - pushd ${current_dir}/src > /dev/null - src_url=${mirror_link}/src/fail2ban-${fail2ban_ver}.tar.gz && Download_src - tar xzf fail2ban-${fail2ban_ver}.tar.gz - pushd fail2ban-${fail2ban_ver} > /dev/null - if command -v python3 > /dev/null 2>&1; then - python3 setup.py install - else - python setup.py install - fi - /bin/cp build/fail2ban.service /lib/systemd/system/ - systemctl enable fail2ban - [ -z "`grep ^Port /etc/ssh/sshd_config`" ] && now_ssh_port=22 || now_ssh_port=`grep ^Port /etc/ssh/sshd_config | awk '{print $2}' | head -1` - if [ "${PM}" == 'yum' ]; then - cat > /etc/fail2ban/jail.local << EOF -[DEFAULT] -ignoreip = 127.0.0.1/8 -bantime = 86400 -findtime = 600 -maxretry = 5 -backend = auto -banaction = firewallcmd-ipset -action = %(action_mwl)s - -[sshd] -enabled = true -filter = sshd -port = ${now_ssh_port} -action = %(action_mwl)s -logpath = /var/log/secure -bantime = 86400 -findtime = 600 -maxretry = 5 -EOF - elif [ "${PM}" == 'apt-get' ]; then - if ufw status | grep -wq inactive; then - ufw default allow incoming - ufw --force enable - fi - cat > /etc/fail2ban/jail.local << EOF -[DEFAULT] -ignoreip = 127.0.0.1/8 -bantime = 86400 -findtime = 600 -maxretry = 5 -backend = auto -banaction = ufw -action = %(action_mwl)s - -[sshd] -enabled = true -filter = sshd -port = ${now_ssh_port} -action = %(action_mwl)s -logpath = /var/log/auth.log -bantime = 86400 -findtime = 600 -maxretry = 5 -EOF - fi - cat > /etc/logrotate.d/fail2ban << EOF -/var/log/fail2ban.log { - missingok - notifempty - postrotate - /usr/local/bin/fail2ban-client flushlogs >/dev/null || true - endscript -} -EOF - kill -9 `ps -ef | grep fail2ban | grep -v grep | awk '{print $2}'` > /dev/null 2>&1 - systemctl start fail2ban - popd > /dev/null - if [ -e "/usr/local/bin/fail2ban-server" ]; then - echo; echo "${CSUCCESS}fail2ban installed successfully! ${CEND}" - else - echo; echo "${CFAILURE}fail2ban install failed, Please try again! ${CEND}" - fi - popd > /dev/null -} - -Uninstall_fail2ban() { - systemctl stop fail2ban - systemctl disable fail2ban - rm -rf /usr/local/bin/fail2ban* /etc/init.d/fail2ban /etc/fail2ban /etc/logrotate.d/fail2ban /var/log/fail2ban.* /var/run/fail2ban /lib/systemd/system/fail2ban.service - echo; echo "${CMSG}fail2ban uninstall completed${CEND}"; -} diff --git a/include/get_char.sh b/include/get_char.sh index c5ad1a0a..229059de 100644 --- a/include/get_char.sh +++ b/include/get_char.sh @@ -1,6 +1,12 @@ #!/bin/bash # Author: yeho -# BLOG: https://linuxeye.com +# BLOG: https://blog.linuxeye.com +# +# Notes: OneinStack for CentOS/RadHat 5+ Debian 6+ and Ubuntu 12+ +# +# Project home page: +# https://oneinstack.com +# https://github.com/lj2007331/oneinstack get_char() { SAVEDSTTY=`stty -g` diff --git a/include/get_ipaddr.py b/include/get_ipaddr.py new file mode 100755 index 00000000..c9d1d46f --- /dev/null +++ b/include/get_ipaddr.py @@ -0,0 +1,22 @@ +#!/usr/bin/env python +import socket +def Get_local_ip(): + """ + Returns the actual ip of the local machine. + This code figures out what source address would be used if some traffic + were to be sent out to some well known address on the Internet. In this + case, a Google DNS server is used, but the specific address does not + matter much. No traffic is actually sent. + """ + try: + csock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM) + csock.connect(('8.8.8.8', 80)) + (addr, port) = csock.getsockname() + csock.close() + return addr + except socket.error: + return "127.0.0.1" + +if __name__ == "__main__": + IPADDR = Get_local_ip() + print IPADDR diff --git a/include/get_ipaddr_state.py b/include/get_ipaddr_state.py new file mode 100755 index 00000000..088872f2 --- /dev/null +++ b/include/get_ipaddr_state.py @@ -0,0 +1,15 @@ +#!/usr/bin/env python +#coding:utf-8 +import sys,urllib2,socket +try: + socket.setdefaulttimeout(10) + apiurl = "http://ip.taobao.com/service/getIpInfo.php?ip=%s" % sys.argv[1] + content = urllib2.urlopen(apiurl).read() + data = eval(content)['data'] + code = eval(content)['code'] + if code == 0: + print data['country_id'],data['isp_id'] + else: + print data +except: + print "Usage:%s IP" % sys.argv[0] diff --git a/include/get_public_ipaddr.py b/include/get_public_ipaddr.py new file mode 100755 index 00000000..14254594 --- /dev/null +++ b/include/get_public_ipaddr.py @@ -0,0 +1,21 @@ +#!/usr/bin/env python +import re,urllib2 +class Get_public_ip: + def getip(self): + try: + myip = self.visit("http://ip.chinaz.com/getip.aspx") + except: + try: + myip = self.visit("http://ipv4.icanhazip.com/") + except: + myip = "So sorry!!!" + return myip + def visit(self,url): + opener = urllib2.urlopen(url) + if url == opener.geturl(): + str = opener.read() + return re.search('\d+\.\d+\.\d+\.\d+',str).group(0) + +if __name__ == "__main__": + getmyip = Get_public_ip() + print getmyip.getip() diff --git a/include/hhvm_CentOS.sh b/include/hhvm_CentOS.sh new file mode 100644 index 00000000..eb934d22 --- /dev/null +++ b/include/hhvm_CentOS.sh @@ -0,0 +1,158 @@ +#!/bin/bash +# Author: yeho +# BLOG: https://blog.linuxeye.com +# +# Notes: OneinStack for CentOS/RadHat 5+ Debian 6+ and Ubuntu 12+ +# +# Project home page: +# https://oneinstack.com +# https://github.com/lj2007331/oneinstack + +Install_hhvm_CentOS() { + + id -u ${run_user} >/dev/null 2>&1 + [ $? -ne 0 ] && useradd -M -s /sbin/nologin ${run_user} + + if [ "${CentOS_RHEL_version}" == '7' ]; then + [ ! -e /etc/yum.repos.d/epel.repo ] && cat > /etc/yum.repos.d/epel.repo << EOF +[epel] +name=Extra Packages for Enterprise Linux 7 - \$basearch +#baseurl=http://download.fedoraproject.org/pub/epel/7/\$basearch +mirrorlist=https://mirrors.fedoraproject.org/metalink?repo=epel-7&arch=\$basearch +failovermethod=priority +enabled=1 +gpgcheck=0 +EOF + cat > /etc/yum.repos.d/hhvm.repo << EOF +[hhvm] +name=gleez hhvm-repo +baseurl=http://mirrors.linuxeye.com/hhvm-repo/7/\$basearch/ +enabled=1 +gpgcheck=0 +EOF + yum -y install hhvm + [ ! -e "/usr/bin/hhvm" -a "/usr/local/bin/hhvm" ] && ln -s /usr/local/bin/hhvm /usr/bin/hhvm + fi + + if [ "${CentOS_RHEL_version}" == '6' ]; then + [ ! -e /etc/yum.repos.d/epel.repo ] && cat > /etc/yum.repos.d/epel.repo << EOF +[epel] +name=Extra Packages for Enterprise Linux 6 - \$basearch +#baseurl=http://download.fedoraproject.org/pub/epel/6/\$basearch +mirrorlist=https://mirrors.fedoraproject.org/metalink?repo=epel-6&arch=\$basearch +failovermethod=priority +enabled=1 +gpgcheck=0 +EOF + # Install needed packages + pkgList="libmcrypt-devel glog-devel jemalloc-devel tbb-devel libdwarf-devel libxml2-devel libicu-devel pcre-devel gd-devel boost-devel sqlite-devel pam-devel bzip2-devel oniguruma-devel openldap-devel readline-devel libc-client-devel libcap-devel libevent-devel libcurl-devel libmemcached-devel lcms2 inotify-tools" + for Package in ${pkgList}; do + yum -y install ${Package} + done + # Uninstall the conflicting packages + yum -y remove libwebp boost-system boost-filesystem + + cat > /etc/yum.repos.d/hhvm.repo << EOF +[hhvm] +name=gleez hhvm-repo +baseurl=http://mirrors.linuxeye.com/hhvm-repo/6/\$basearch/ +enabled=1 +gpgcheck=0 +EOF + yum --disablerepo=epel -y install mysql mysql-devel mysql-libs + yum --disablerepo=epel -y install hhvm + fi + + userdel -r nginx;userdel -r saslauth + rm -rf /var/log/hhvm + mkdir /var/log/hhvm + chown -R ${run_user}.${run_user} /var/log/hhvm + cat > /etc/hhvm/config.hdf << EOF +ResourceLimit { + CoreFileSize = 0 # in bytes + MaxSocket = 10000 # must be not 0, otherwise HHVM will not start + SocketDefaultTimeout = 5 # in seconds + MaxRSS = 0 + MaxRSSPollingCycle = 0 # in seconds, how often to check max memory + DropCacheCycle = 0 # in seconds, how often to drop disk cache +} + +Log { + Level = Info + AlwaysLogUnhandledExceptions = true + RuntimeErrorReportingLevel = 8191 + UseLogFile = true + UseSyslog = false + File = /var/log/hhvm/error.log + Access { + * { + File = /var/log/hhvm/access.log + Format = %h %l %u % t \"%r\" %>s %b + } + } +} + +MySQL { + ReadOnly = false + ConnectTimeout = 1000 # in ms + ReadTimeout = 1000 # in ms + SlowQueryThreshold = 1000 # in ms, log slow queries as errors + KillOnTimeout = false +} + +Mail { + SendmailPath = /usr/sbin/sendmail -t -i + ForceExtraParameters = +} +EOF + + cat > /etc/hhvm/server.ini << EOF +; php options +pid = /var/log/hhvm/pid + +; hhvm specific +;hhvm.server.port = 9001 +hhvm.server.file_socket = /var/log/hhvm/sock +hhvm.server.type = fastcgi +hhvm.server.default_document = index.php +hhvm.log.use_log_file = true +hhvm.log.file = /var/log/hhvm/error.log +hhvm.repo.central.path = /var/log/hhvm/hhvm.hhbc +EOF + + cat > /etc/hhvm/php.ini << EOF +hhvm.mysql.socket = /tmp/mysql.sock +expose_php = 0 +memory_limit = 400000000 +post_max_size = 50000000 +EOF + + if [ -e "${web_install_dir}/sbin/nginx" -a -e "/usr/bin/hhvm" -a ! -e "${php_install_dir}" ]; then + sed -i 's@/dev/shm/php-cgi.sock@/var/log/hhvm/sock@' ${web_install_dir}/conf/nginx.conf + [ -z "$(grep 'fastcgi_param SCRIPT_FILENAME' ${web_install_dir}/conf/nginx.conf)" ] && sed -i "s@fastcgi_index index.php;@&\n\t\tfastcgi_param SCRIPT_FILENAME \$document_root\$fastcgi_script_name;@" ${web_install_dir}/conf/nginx.conf + sed -i 's@include fastcgi.conf;@include fastcgi_params;@' ${web_install_dir}/conf/nginx.conf + service nginx reload + fi + + rm -rf /etc/ld.so.conf.d/*_64.conf + ldconfig + # Supervisor + yum -y install python-setuptools + ping pypi.python.org -c 4 >/dev/null 2>&1 + easy_install supervisor + echo_supervisord_conf > /etc/supervisord.conf + sed -i 's@pidfile=/tmp/supervisord.pid@pidfile=/var/run/supervisord.pid@' /etc/supervisord.conf + [ -z "$(grep 'program:hhvm' /etc/supervisord.conf)" ] && cat >> /etc/supervisord.conf << EOF +[program:hhvm] +command=/usr/bin/hhvm --mode server --user ${run_user} --config /etc/hhvm/server.ini --config /etc/hhvm/php.ini --config /etc/hhvm/config.hdf +numprocs=1 ; number of processes copies to start (def 1) +directory=/tmp ; directory to cwd to before exec (def no cwd) +autostart=true ; start at supervisord start (default: true) +autorestart=unexpected ; whether/when to restart (default: unexpected) +stopwaitsecs=10 ; max num secs to wait b4 SIGKILL (default 10) +EOF + /bin/cp ${oneinstack_dir}/init.d/Supervisor-init-CentOS /etc/init.d/supervisord + chmod +x /etc/init.d/supervisord + chkconfig supervisord on + service supervisord start +} diff --git a/include/init_CentOS.sh b/include/init_CentOS.sh new file mode 100644 index 00000000..782643e8 --- /dev/null +++ b/include/init_CentOS.sh @@ -0,0 +1,160 @@ +#!/bin/bash +# Author: yeho +# BLOG: https://blog.linuxeye.com +# +# Notes: OneinStack for CentOS/RadHat 5+ Debian 6+ and Ubuntu 12+ +# +# Project home page: +# https://oneinstack.com +# https://github.com/lj2007331/oneinstack + +# closed Unnecessary services and remove obsolete rpm package +[ "${CentOS_RHEL_version}" == '7' ] && [ "$(systemctl is-active NetworkManager.service)" == 'active' ] && NM_flag=1 +for Service in $(chkconfig --list | grep 3:on | awk '{print $1}' | grep -vE 'nginx|httpd|tomcat|mysqld|php-fpm|pureftpd|redis-server|memcached|supervisord|aegis|NetworkManager');do chkconfig --level 3 ${Service} off;done +[ "${NM_flag}" == '1' ] && systemctl enable NetworkManager.service +for Service in sshd network crond iptables messagebus irqbalance syslog rsyslog;do chkconfig --level 3 ${Service} on;done + +# Close SELINUX +setenforce 0 +sed -i 's/^SELINUX=.*$/SELINUX=disabled/' /etc/selinux/config + +# Custom profile +cat > /etc/profile.d/oneinstack.sh << EOF +HISTSIZE=10000 +PS1="\[\e[37;40m\][\[\e[32;40m\]\u\[\e[37;40m\]@\h \[\e[35;40m\]\W\[\e[0m\]]\\\\$ " +HISTTIMEFORMAT="%F %T \$(whoami) " + +alias l='ls -AFhlt' +alias lh='l | head' +alias vi=vim + +GREP_OPTIONS="--color=auto" +alias grep='grep --color' +alias egrep='egrep --color' +alias fgrep='fgrep --color' +EOF + +[ -z "$(grep ^'PROMPT_COMMAND=' /etc/bashrc)" ] && cat >> /etc/bashrc << EOF +PROMPT_COMMAND='{ msg=\$(history 1 | { read x y; echo \$y; });logger "[euid=\$(whoami)]":\$(who am i):[\`pwd\`]"\$msg"; }' +EOF + +# /etc/security/limits.conf +[ -e /etc/security/limits.d/*nproc.conf ] && rename nproc.conf nproc.conf_bk /etc/security/limits.d/*nproc.conf +sed -i '/^# End of file/,$d' /etc/security/limits.conf +cat >> /etc/security/limits.conf < /etc/resolv.conf << EOF +#nameserver 114.114.114.114 +#nameserver 8.8.8.8 +#EOF + +# ip_conntrack table full dropping packets +[ ! -e "/etc/sysconfig/modules/iptables.modules" ] && { echo -e "modprobe nf_conntrack\nmodprobe nf_conntrack_ipv4" > /etc/sysconfig/modules/iptables.modules; chmod +x /etc/sysconfig/modules/iptables.modules; } +modprobe nf_conntrack +modprobe nf_conntrack_ipv4 +echo options nf_conntrack hashsize=131072 > /etc/modprobe.d/nf_conntrack.conf + +# /etc/sysctl.conf +[ ! -e "/etc/sysctl.conf_bk" ] && /bin/mv /etc/sysctl.conf{,_bk} +cat > /etc/sysctl.conf << EOF +fs.file-max=65535 +net.ipv4.tcp_max_tw_buckets = 60000 +net.ipv4.tcp_sack = 1 +net.ipv4.tcp_window_scaling = 1 +net.ipv4.tcp_rmem = 4096 87380 4194304 +net.ipv4.tcp_wmem = 4096 16384 4194304 +net.ipv4.tcp_max_syn_backlog = 65536 +net.core.netdev_max_backlog = 32768 +net.core.somaxconn = 32768 +net.core.wmem_default = 8388608 +net.core.rmem_default = 8388608 +net.core.rmem_max = 16777216 +net.core.wmem_max = 16777216 +net.ipv4.tcp_timestamps = 1 +net.ipv4.tcp_fin_timeout = 20 +net.ipv4.tcp_synack_retries = 2 +net.ipv4.tcp_syn_retries = 2 +net.ipv4.tcp_syncookies = 1 +#net.ipv4.tcp_tw_len = 1 +net.ipv4.tcp_tw_reuse = 1 +net.ipv4.tcp_mem = 94500000 915000000 927000000 +net.ipv4.tcp_max_orphans = 3276800 +net.ipv4.ip_local_port_range = 1024 65000 +net.nf_conntrack_max = 6553500 +net.netfilter.nf_conntrack_max = 6553500 +net.netfilter.nf_conntrack_tcp_timeout_close_wait = 60 +net.netfilter.nf_conntrack_tcp_timeout_fin_wait = 120 +net.netfilter.nf_conntrack_tcp_timeout_time_wait = 120 +net.netfilter.nf_conntrack_tcp_timeout_established = 3600 +EOF +sysctl -p + +if [ "${CentOS_RHEL_version}" == '5' ]; then + sed -i 's@^[3-6]:2345:respawn@#&@g' /etc/inittab + sed -i 's@^ca::ctrlaltdel@#&@' /etc/inittab + sed -i 's@LANG=.*$@LANG="en_US.UTF-8"@g' /etc/sysconfig/i18n +elif [ "${CentOS_RHEL_version}" == '6' ]; then + sed -i 's@^ACTIVE_CONSOLES.*@ACTIVE_CONSOLES=/dev/tty[1-2]@' /etc/sysconfig/init + sed -i 's@^start@#start@' /etc/init/control-alt-delete.conf + sed -i 's@LANG=.*$@LANG="en_US.UTF-8"@g' /etc/sysconfig/i18n +elif [ "${CentOS_RHEL_version}" == '7' ]; then + sed -i 's@LANG=.*$@LANG="en_US.UTF-8"@g' /etc/locale.conf +fi + +# Update time +ntpdate pool.ntp.org +[ ! -e "/var/spool/cron/root" -o -z "$(grep 'ntpdate' /var/spool/cron/root)" ] && { echo "*/20 * * * * $(which ntpdate) pool.ntp.org > /dev/null 2>&1" >> /var/spool/cron/root;chmod 600 /var/spool/cron/root; } + +# iptables +if [ -e "/etc/sysconfig/iptables" ] && [ -n "$(grep '^:INPUT DROP' /etc/sysconfig/iptables)" -a -n "$(grep 'NEW -m tcp --dport 22 -j ACCEPT' /etc/sysconfig/iptables)" -a -n "$(grep 'NEW -m tcp --dport 80 -j ACCEPT' /etc/sysconfig/iptables)" ]; then + IPTABLES_STATUS=yes +else + IPTABLES_STATUS=no +fi + +if [ "$IPTABLES_STATUS" == "no" ]; then + [ -e "/etc/sysconfig/iptables" ] && /bin/mv /etc/sysconfig/iptables{,_bk} + cat > /etc/sysconfig/iptables << EOF +# Firewall configuration written by system-config-securitylevel +# Manual customization of this file is not recommended. +*filter +:INPUT DROP [0:0] +:FORWARD ACCEPT [0:0] +:OUTPUT ACCEPT [0:0] +:syn-flood - [0:0] +-A INPUT -i lo -j ACCEPT +-A INPUT -m state --state RELATED,ESTABLISHED -j ACCEPT +-A INPUT -p tcp -m state --state NEW -m tcp --dport 22 -j ACCEPT +-A INPUT -p tcp -m state --state NEW -m tcp --dport 80 -j ACCEPT +-A INPUT -p tcp -m state --state NEW -m tcp --dport 443 -j ACCEPT +-A INPUT -p icmp -m limit --limit 1/sec --limit-burst 10 -j ACCEPT +-A INPUT -f -m limit --limit 100/sec --limit-burst 100 -j ACCEPT +-A INPUT -p tcp -m tcp --tcp-flags FIN,SYN,RST,ACK SYN -j syn-flood +-A INPUT -j REJECT --reject-with icmp-host-prohibited +-A syn-flood -p tcp -m limit --limit 3/sec --limit-burst 6 -j RETURN +-A syn-flood -j REJECT --reject-with icmp-port-unreachable +COMMIT +EOF +fi + +FW_PORT_FLAG=$(grep -ow "dport ${SSH_PORT}" /etc/sysconfig/iptables) +[ -z "${FW_PORT_FLAG}" -a "${SSH_PORT}" != "22" ] && sed -i "s@dport 22 -j ACCEPT@&\n-A INPUT -p tcp -m state --state NEW -m tcp --dport ${SSH_PORT} -j ACCEPT@" /etc/sysconfig/iptables +service rsyslog restart +service iptables restart +service sshd restart + +. /etc/profile diff --git a/include/init_Debian.sh b/include/init_Debian.sh index 06285b93..55db4fe1 100644 --- a/include/init_Debian.sh +++ b/include/init_Debian.sh @@ -1,9 +1,15 @@ #!/bin/bash # Author: yeho -# BLOG: https://linuxeye.com +# BLOG: https://blog.linuxeye.com +# +# Notes: OneinStack for CentOS/RadHat 5+ Debian 6+ and Ubuntu 12+ +# +# Project home page: +# https://oneinstack.com +# https://github.com/lj2007331/oneinstack # Custom profile -cat > /etc/profile.d/lnmp.sh << EOF +cat > /etc/profile.d/oneinstack.sh << EOF HISTSIZE=10000 PS1='\${debian_chroot:+(\$debian_chroot)}\\[\\e[1;32m\\]\\u@\\h\\[\\033[00m\\]:\\[\\033[01;34m\\]\\w\\[\\033[00m\\]\\$ ' HISTTIMEFORMAT="%F %T \$(whoami) " @@ -31,14 +37,14 @@ sed -i 's@^"syntax on@syntax on@' /etc/vim/vimrc sed -i '/^# End of file/,$d' /etc/security/limits.conf cat >> /etc/security/limits.conf < /etc/resolv.conf << EOF @@ -56,21 +62,21 @@ ln -s /usr/share/zoneinfo/${timezone} /etc/localtime # /etc/sysctl.conf [ -z "$(grep 'fs.file-max' /etc/sysctl.conf)" ] && cat >> /etc/sysctl.conf << EOF -fs.file-max = 1000000 +fs.file-max=65535 fs.inotify.max_user_instances = 8192 net.ipv4.tcp_syncookies = 1 net.ipv4.tcp_fin_timeout = 30 net.ipv4.tcp_tw_reuse = 1 net.ipv4.ip_local_port_range = 1024 65000 -net.ipv4.tcp_max_syn_backlog = 16384 +net.ipv4.tcp_max_syn_backlog = 65536 net.ipv4.tcp_max_tw_buckets = 6000 net.ipv4.route.gc_timeout = 100 net.ipv4.tcp_syn_retries = 1 net.ipv4.tcp_synack_retries = 1 -net.core.somaxconn = 32768 -net.core.netdev_max_backlog = 32768 +net.core.somaxconn = 65535 +net.core.netdev_max_backlog = 262144 net.ipv4.tcp_timestamps = 0 -net.ipv4.tcp_max_orphans = 32768 +net.ipv4.tcp_max_orphans = 262144 EOF sysctl -p @@ -78,17 +84,52 @@ sed -i 's@^ACTIVE_CONSOLES.*@ACTIVE_CONSOLES="/dev/tty[1-2]"@' /etc/default/cons sed -i 's@^# en_US.UTF-8@en_US.UTF-8@' /etc/locale.gen init q -# ufw -if [ "${firewall_flag}" == 'y' ]; then - ufw allow 22/tcp - [ "${ssh_port}" != "22" ] && ufw allow ${ssh_port}/tcp - ufw allow 80/tcp - ufw allow 443/tcp - ufw --force enable +# Update time +ntpdate pool.ntp.org +[ ! -e "/var/spool/cron/crontabs/root" -o -z "$(grep ntpdate /var/spool/cron/crontabs/root 2>/dev/null)" ] && { echo "*/20 * * * * $(which ntpdate) pool.ntp.org > /dev/null 2>&1" >> /var/spool/cron/crontabs/root;chmod 600 /var/spool/cron/crontabs/root; } + +# iptables +if [ -e "/etc/iptables.up.rules" ] && [ -n "$(grep '^:INPUT DROP' /etc/iptables.up.rules)" -a -n "$(grep 'NEW -m tcp --dport 22 -j ACCEPT' /etc/iptables.up.rules)" -a -n "$(grep 'NEW -m tcp --dport 80 -j ACCEPT' /etc/iptables.up.rules)" ]; then + IPTABLES_STATUS=yes else - ufw --force disable + IPTABLES_STATUS=no +fi + +if [ "${IPTABLES_STATUS}" == "no" ]; then + [ -e "/etc/iptables.up.rules" ] && /bin/mv /etc/iptables.up.rules{,_bk} + cat > /etc/iptables.up.rules << EOF +# Firewall configuration written by system-config-securitylevel +# Manual customization of this file is not recommended. +*filter +:INPUT DROP [0:0] +:FORWARD ACCEPT [0:0] +:OUTPUT ACCEPT [0:0] +:syn-flood - [0:0] +-A INPUT -i lo -j ACCEPT +-A INPUT -m state --state RELATED,ESTABLISHED -j ACCEPT +-A INPUT -p tcp -m state --state NEW -m tcp --dport 22 -j ACCEPT +-A INPUT -p tcp -m state --state NEW -m tcp --dport 80 -j ACCEPT +-A INPUT -p tcp -m state --state NEW -m tcp --dport 443 -j ACCEPT +-A INPUT -p icmp -m limit --limit 1/sec --limit-burst 10 -j ACCEPT +-A INPUT -f -m limit --limit 100/sec --limit-burst 100 -j ACCEPT +-A INPUT -p tcp -m tcp --tcp-flags FIN,SYN,RST,ACK SYN -j syn-flood +-A INPUT -j REJECT --reject-with icmp-host-prohibited +-A syn-flood -p tcp -m limit --limit 3/sec --limit-burst 6 -j RETURN +-A syn-flood -j REJECT --reject-with icmp-port-unreachable +COMMIT +EOF fi -systemctl restart rsyslog ssh + +FW_PORT_FLAG=$(grep -ow "dport ${SSH_PORT}" /etc/iptables.up.rules) +[ -z "${FW_PORT_FLAG}" -a "${SSH_PORT}" != "22" ] && sed -i "s@dport 22 -j ACCEPT@&\n-A INPUT -p tcp -m state --state NEW -m tcp --dport ${SSH_PORT} -j ACCEPT@" /etc/iptables.up.rules +iptables-restore < /etc/iptables.up.rules +cat > /etc/network/if-pre-up.d/iptables << EOF +#!/bin/bash +/sbin/iptables-restore < /etc/iptables.up.rules +EOF +chmod +x /etc/network/if-pre-up.d/iptables +service rsyslog restart +service ssh restart . /etc/profile . ~/.bashrc diff --git a/include/init_RHEL.sh b/include/init_RHEL.sh deleted file mode 100644 index 77d90f82..00000000 --- a/include/init_RHEL.sh +++ /dev/null @@ -1,107 +0,0 @@ -#!/bin/bash -# Author: yeho -# BLOG: https://linuxeye.com - -# Close SELINUX -setenforce 0 -sed -i 's/^SELINUX=.*$/SELINUX=disabled/' /etc/selinux/config - -# Custom profile -cat > /etc/profile.d/lnmp.sh << EOF -HISTSIZE=10000 -PS1="\[\e[37;40m\][\[\e[32;40m\]\u\[\e[37;40m\]@\h \[\e[35;40m\]\W\[\e[0m\]]\\\\$ " -HISTTIMEFORMAT="%F %T \$(whoami) " - -alias l='ls -AFhlt' -alias lh='l | head' -alias vi=vim - -GREP_OPTIONS="--color=auto" -alias grep='grep --color' -alias egrep='egrep --color' -alias fgrep='fgrep --color' -EOF -[[ "${Platform}" =~ ^hce$|^openeuler$ ]] && sed -i '/HISTTIMEFORMAT=/d' /etc/profile.d/lnmp.sh - -[[ ! "${Platform}" =~ ^hce$|^openeuler$ ]] && [ -z "$(grep ^'PROMPT_COMMAND=' /etc/bashrc)" ] && cat >> /etc/bashrc << EOF -PROMPT_COMMAND='{ msg=\$(history 1 | { read x y; echo \$y; });logger "[euid=\$(whoami)]":\$(who am i):[\`pwd\`]"\$msg"; }' -EOF - -# /etc/security/limits.conf -[ -e /etc/security/limits.d/*nproc.conf ] && rename nproc.conf nproc.conf_bk /etc/security/limits.d/*nproc.conf -sed -i '/^# End of file/,$d' /etc/security/limits.conf -cat >> /etc/security/limits.conf < /etc/sysconfig/modules/nf_conntrack.modules -chmod +x /etc/sysconfig/modules/nf_conntrack.modules -modprobe nf_conntrack -modprobe nf_conntrack_ipv4 -echo options nf_conntrack hashsize=131072 > /etc/modprobe.d/nf_conntrack.conf - -# /etc/sysctl.conf -[ ! -e "/etc/sysctl.conf_bk" ] && /bin/mv /etc/sysctl.conf{,_bk} -cat > /etc/sysctl.conf << EOF -fs.file-max=1000000 -net.ipv4.tcp_max_tw_buckets = 6000 -net.ipv4.tcp_sack = 1 -net.ipv4.tcp_window_scaling = 1 -net.ipv4.tcp_rmem = 4096 87380 4194304 -net.ipv4.tcp_wmem = 4096 16384 4194304 -net.ipv4.tcp_max_syn_backlog = 16384 -net.core.netdev_max_backlog = 32768 -net.core.somaxconn = 32768 -net.core.wmem_default = 8388608 -net.core.rmem_default = 8388608 -net.core.rmem_max = 16777216 -net.core.wmem_max = 16777216 -net.ipv4.tcp_timestamps = 0 -net.ipv4.tcp_fin_timeout = 20 -net.ipv4.tcp_synack_retries = 2 -net.ipv4.tcp_syn_retries = 2 -net.ipv4.tcp_syncookies = 1 -#net.ipv4.tcp_tw_len = 1 -net.ipv4.tcp_tw_reuse = 1 -net.ipv4.tcp_mem = 94500000 915000000 927000000 -net.ipv4.tcp_max_orphans = 3276800 -net.ipv4.ip_local_port_range = 1024 65000 -net.nf_conntrack_max = 6553500 -net.netfilter.nf_conntrack_max = 6553500 -net.netfilter.nf_conntrack_tcp_timeout_close_wait = 60 -net.netfilter.nf_conntrack_tcp_timeout_fin_wait = 120 -net.netfilter.nf_conntrack_tcp_timeout_time_wait = 120 -net.netfilter.nf_conntrack_tcp_timeout_established = 3600 -EOF -sysctl -p - -if [ ${RHEL_ver} -ge 7 >/dev/null 2>&1 ]; then - sed -i 's@LANG=.*$@LANG="en_US.UTF-8"@g' /etc/locale.conf -fi - -# firewall -if [ "${firewall_flag}" == 'y' ]; then - systemctl enable firewalld - systemctl start firewalld - firewall-cmd --permanent --zone=public --add-port={22/tcp,80/tcp,443/tcp} - [ "${ssh_port}" != "22" ] && firewall-cmd --permanent --zone=public --add-port=${ssh_port}/tcp - firewall-cmd --reload -else - systemctl stop firewalld - systemctl disable firewalld -fi -systemctl restart rsyslog sshd - -. /etc/profile diff --git a/include/init_Ubuntu.sh b/include/init_Ubuntu.sh index 8debc6bb..d8cdf1b3 100644 --- a/include/init_Ubuntu.sh +++ b/include/init_Ubuntu.sh @@ -1,9 +1,15 @@ #!/bin/bash # Author: yeho -# BLOG: https://linuxeye.com +# BLOG: https://blog.linuxeye.com +# +# Notes: OneinStack for CentOS/RadHat 5+ Debian 6+ and Ubuntu 12+ +# +# Project home page: +# https://oneinstack.com +# https://github.com/lj2007331/oneinstack # Custom profile -cat > /etc/profile.d/lnmp.sh << EOF +cat > /etc/profile.d/oneinstack.sh << EOF HISTSIZE=10000 HISTTIMEFORMAT="%F %T \$(whoami) " @@ -33,14 +39,14 @@ sed -i 's@^"syntax on@syntax on@' /etc/vim/vimrc sed -i '/^# End of file/,$d' /etc/security/limits.conf cat >> /etc/security/limits.conf < /etc/resolv.conf << EOF +#nameserver 114.114.114.114 +#nameserver 8.8.8.8 +#EOF # /etc/sysctl.conf [ -z "$(grep 'fs.file-max' /etc/sysctl.conf)" ] && cat >> /etc/sysctl.conf << EOF -fs.file-max = 1000000 +fs.file-max=65535 fs.inotify.max_user_instances = 8192 net.ipv4.tcp_syncookies = 1 net.ipv4.tcp_fin_timeout = 30 net.ipv4.tcp_tw_reuse = 1 net.ipv4.ip_local_port_range = 1024 65000 -net.ipv4.tcp_max_syn_backlog = 16384 +net.ipv4.tcp_max_syn_backlog = 65536 net.ipv4.tcp_max_tw_buckets = 6000 net.ipv4.route.gc_timeout = 100 net.ipv4.tcp_syn_retries = 1 net.ipv4.tcp_synack_retries = 1 -net.core.somaxconn = 32768 -net.core.netdev_max_backlog = 32768 +net.core.somaxconn = 65535 +net.core.netdev_max_backlog = 262144 net.ipv4.tcp_timestamps = 0 -net.ipv4.tcp_max_orphans = 32768 +net.ipv4.tcp_max_orphans = 262144 EOF sysctl -p sed -i 's@^ACTIVE_CONSOLES.*@ACTIVE_CONSOLES="/dev/tty[1-2]"@' /etc/default/console-setup -locale-gen en_US.UTF-8 -[ -d "/var/lib/locales/supported.d" ] && echo "en_US.UTF-8 UTF-8" > /var/lib/locales/supported.d/local -cat > /etc/default/locale << EOF -LANG=en_US.UTF-8 -LANGUAGE=en_US:en -EOF +sed -i 's@^@#@g' /etc/init/tty[3-6].conf +echo "en_US.UTF-8 UTF-8" > /var/lib/locales/supported.d/local +sed -i 's@^@#@g' /etc/init/control-alt-delete.conf + +# Update time +ntpdate pool.ntp.org +[ ! -e "/var/spool/cron/crontabs/root" -o -z "$(grep ntpdate /var/spool/cron/crontabs/root 2>/dev/null)" ] && { echo "*/20 * * * * $(which ntpdate) pool.ntp.org > /dev/null 2>&1" >> /var/spool/cron/crontabs/root;chmod 600 /var/spool/cron/crontabs/root; } -# ufw -if [ "${firewall_flag}" == 'y' ]; then - ufw allow 22/tcp - [ "${ssh_port}" != "22" ] && ufw allow ${ssh_port}/tcp - ufw allow 80/tcp - ufw allow 443/tcp - ufw --force enable +# iptables +if [ -e "/etc/iptables.up.rules" ] && [ -n "$(grep '^:INPUT DROP' /etc/iptables.up.rules)" -a -n "$(grep 'NEW -m tcp --dport 22 -j ACCEPT' /etc/iptables.up.rules)" -a -n "$(grep 'NEW -m tcp --dport 80 -j ACCEPT' /etc/iptables.up.rules)" ]; then + IPTABLES_STATUS=yes else - ufw --force disable + IPTABLES_STATUS=no fi -systemctl restart rsyslog ssh + +if [ "${IPTABLES_STATUS}" == "no" ]; then + [ -e "/etc/iptables.up.rules" ] && /bin/mv /etc/iptables.up.rules{,_bk} + cat > /etc/iptables.up.rules << EOF +# Firewall configuration written by system-config-securitylevel +# Manual customization of this file is not recommended. +*filter +:INPUT DROP [0:0] +:FORWARD ACCEPT [0:0] +:OUTPUT ACCEPT [0:0] +:syn-flood - [0:0] +-A INPUT -i lo -j ACCEPT +-A INPUT -m state --state RELATED,ESTABLISHED -j ACCEPT +-A INPUT -p tcp -m state --state NEW -m tcp --dport 22 -j ACCEPT +-A INPUT -p tcp -m state --state NEW -m tcp --dport 80 -j ACCEPT +-A INPUT -p tcp -m state --state NEW -m tcp --dport 443 -j ACCEPT +-A INPUT -p icmp -m limit --limit 1/sec --limit-burst 10 -j ACCEPT +-A INPUT -f -m limit --limit 100/sec --limit-burst 100 -j ACCEPT +-A INPUT -p tcp -m tcp --tcp-flags FIN,SYN,RST,ACK SYN -j syn-flood +-A INPUT -j REJECT --reject-with icmp-host-prohibited +-A syn-flood -p tcp -m limit --limit 3/sec --limit-burst 6 -j RETURN +-A syn-flood -j REJECT --reject-with icmp-port-unreachable +COMMIT +EOF +fi + +FW_PORT_FLAG=$(grep -ow "dport ${SSH_PORT}" /etc/iptables.up.rules) +[ -z "${FW_PORT_FLAG}" -a "${SSH_PORT}" != "22" ] && sed -i "s@dport 22 -j ACCEPT@&\n-A INPUT -p tcp -m state --state NEW -m tcp --dport ${SSH_PORT} -j ACCEPT@" /etc/iptables.up.rules +iptables-restore < /etc/iptables.up.rules +cat > /etc/network/if-pre-up.d/iptables << EOF +#!/bin/bash +/sbin/iptables-restore < /etc/iptables.up.rules +EOF +chmod +x /etc/network/if-pre-up.d/iptables +service rsyslog restart +service ssh restart . /etc/profile . ~/.bashrc diff --git a/include/ioncube.sh b/include/ioncube.sh index 2ac55ef0..3fb7ed4d 100644 --- a/include/ioncube.sh +++ b/include/ioncube.sh @@ -1,37 +1,57 @@ #!/bin/bash # Author: yeho -# BLOG: https://linuxeye.com +# BLOG: https://blog.linuxeye.com +# +# Notes: OneinStack for CentOS/RadHat 5+ Debian 6+ and Ubuntu 12+ +# +# Project home page: +# https://oneinstack.com +# https://github.com/lj2007331/oneinstack Install_ionCube() { - if [ -e "${php_install_dir}/bin/phpize" ]; then - pushd ${current_dir}/src > /dev/null - PHP_detail_ver=`${php_install_dir}/bin/php-config --version` - PHP_main_ver=${PHP_detail_ver%.*} - phpExtensionDir=`${php_install_dir}/bin/php-config --extension-dir` - [ ! -d "${phpExtensionDir}" ] && mkdir -p ${phpExtensionDir} - [ -e "ioncube_loaders_lin_${SYS_ARCH_i}.tar.gz" ] && tar xzf ioncube_loaders_lin_${SYS_ARCH_i}.tar.gz - if [ -z "`echo ${phpExtensionDir} | grep 'non-zts'`" ]; then - /bin/mv ioncube/ioncube_loader_lin_${PHP_main_ver}_ts.so ${phpExtensionDir} - zend_extension="${phpExtensionDir}/ioncube_loader_lin_${PHP_main_ver}_ts.so" + pushd ${oneinstack_dir}/src + PHP_detail_version=`${php_install_dir}/bin/php -r 'echo PHP_VERSION;'` + PHP_main_version=${PHP_detail_version%.*} + phpExtensionDir=`${php_install_dir}/bin/php-config --extension-dir` + if [ "${OS_BIT}" == '64' ]; then + tar xzf ioncube_loaders_lin_x86-64.tar.gz + else + if [ "${TARGET_ARCH}" == "armv7" ]; then + tar xzf ioncube_loaders_lin_armv7l.tar.gz else - /bin/mv ioncube/ioncube_loader_lin_${PHP_main_ver}.so ${phpExtensionDir} - zend_extension="${phpExtensionDir}/ioncube_loader_lin_${PHP_main_ver}.so" - fi - - if [ -f "${zend_extension}" ]; then - echo "zend_extension=${zend_extension}" > ${php_install_dir}/etc/php.d/00-ioncube.ini - echo "${CSUCCESS}PHP ionCube module installed successfully! ${CEND}" - rm -rf ioncube + tar xzf ioncube_loaders_lin_x86.tar.gz fi - popd > /dev/null fi -} -Uninstall_ionCube() { - if [ -e "${php_install_dir}/etc/php.d/00-ioncube.ini" ]; then - rm -f ${php_install_dir}/etc/php.d/00-ioncube.ini - echo; echo "${CMSG}PHP ionCube module uninstall completed${CEND}" - else - echo; echo "${CWARNING}PHP ionCube module does not exist! ${CEND}" - fi + [ ! -d "${phpExtensionDir}" ] && mkdir -p ${phpExtensionDir} + case "${PHP_main_version}" in + 7.0) + /bin/cp ioncube/ioncube_loader_lin_7.0.so ${phpExtensionDir} + zend_extension="${phpExtensionDir}/ioncube_loader_lin_7.0.so" + ;; + 5.6) + /bin/cp ioncube/ioncube_loader_lin_5.6.so ${phpExtensionDir} + zend_extension="${phpExtensionDir}/ioncube_loader_lin_5.6.so" + ;; + 5.5) + /bin/cp ioncube/ioncube_loader_lin_5.5.so ${phpExtensionDir} + zend_extension="${phpExtensionDir}/ioncube_loader_lin_5.5.so" + ;; + 5.4) + /bin/cp ioncube/ioncube_loader_lin_5.4.so ${phpExtensionDir} + zend_extension="${phpExtensionDir}/ioncube_loader_lin_5.4.so" + ;; + 5.3) + /bin/cp ioncube/ioncube_loader_lin_5.3.so ${phpExtensionDir} + zend_extension="${phpExtensionDir}/ioncube_loader_lin_5.3.so" + ;; + *) + echo "Error! Your PHP ${PHP_detail_version} does not support ionCube!" + exit 1 + ;; + esac + + echo "zend_extension=${zend_extension}" > ${php_install_dir}/etc/php.d/ext-0ioncube.ini + rm -rf ioncube + popd } diff --git a/include/jdk-1.6.sh b/include/jdk-1.6.sh new file mode 100644 index 00000000..4466a6d5 --- /dev/null +++ b/include/jdk-1.6.sh @@ -0,0 +1,39 @@ +#!/bin/bash +# Author: yeho +# BLOG: https://blog.linuxeye.com +# +# Notes: OneinStack for CentOS/RadHat 5+ Debian 6+ and Ubuntu 12+ +# +# Project home page: +# https://oneinstack.com +# https://github.com/lj2007331/oneinstack + +Install-JDK16() { + pushd ${oneinstack_dir}/src + + JDK_FILE="jdk-`echo $jdk16_version | awk -F. '{print $2}'`u`echo $jdk16_version | awk -F_ '{print $NF}'`-linux-$SYS_BIG_FLAG.bin" + JAVA_dir=/usr/java + JDK_NAME="jdk$jdk16_version" + JDK_PATH=$JAVA_dir/$JDK_NAME + + [ "$OS" == 'CentOS' ] && [ -n "`rpm -qa | grep jdk`" ] && rpm -e `rpm -qa | grep jdk` + + chmod +x $JDK_FILE + ./$JDK_FILE + + if [ -d "$JDK_NAME" ]; then + rm -rf $JAVA_dir; mkdir -p $JAVA_dir + mv $JDK_NAME $JAVA_dir + [ -z "`grep ^'export JAVA_HOME=' /etc/profile`" ] && { [ -z "`grep ^'export PATH=' /etc/profile`" ] && echo "export JAVA_HOME=$JDK_PATH" >> /etc/profile || sed -i "s@^export PATH=@export JAVA_HOME=$JDK_PATH\nexport PATH=@" /etc/profile; } || sed -i "s@^export JAVA_HOME=.*@export JAVA_HOME=$JDK_PATH@" /etc/profile + [ -z "`grep ^'export CLASSPATH=' /etc/profile`" ] && sed -i "s@export JAVA_HOME=\(.*\)@export JAVA_HOME=\1\nexport CLASSPATH=\$JAVA_HOME/lib/tools.jar:\$JAVA_HOME/lib/dt.jar:\$JAVA_HOME/lib@" /etc/profile + [ -n "`grep ^'export PATH=' /etc/profile`" -a -z "`grep '$JAVA_HOME/bin' /etc/profile`" ] && sed -i "s@^export PATH=\(.*\)@export PATH=\$JAVA_HOME/bin:\1@" /etc/profile + [ -z "`grep ^'export PATH=' /etc/profile | grep '$JAVA_HOME/bin'`" ] && echo 'export PATH=$JAVA_HOME/bin:$PATH' >> /etc/profile + . /etc/profile + echo "${CSUCCESS}$JDK_NAME installed successfully! ${CEND}" + else + rm -rf $JAVA_dir + echo "${CFAILURE}JDK install failed, Please contact the author! ${CEND}" + kill -9 $$ + fi +popd +} diff --git a/include/jdk-1.7.sh b/include/jdk-1.7.sh new file mode 100644 index 00000000..e551c79a --- /dev/null +++ b/include/jdk-1.7.sh @@ -0,0 +1,38 @@ +#!/bin/bash +# Author: yeho +# BLOG: https://blog.linuxeye.com +# +# Notes: OneinStack for CentOS/RadHat 5+ Debian 6+ and Ubuntu 12+ +# +# Project home page: +# https://oneinstack.com +# https://github.com/lj2007331/oneinstack + +Install-JDK17() { + pushd ${oneinstack_dir}/src + + JDK_FILE="jdk-`echo $jdk17_version | awk -F. '{print $2}'`u`echo $jdk17_version | awk -F_ '{print $NF}'`-linux-$SYS_BIG_FLAG.tar.gz" + JAVA_dir=/usr/java + JDK_NAME="jdk$jdk17_version" + JDK_PATH=$JAVA_dir/$JDK_NAME + + [ "$OS" == 'CentOS' ] && [ -n "`rpm -qa | grep jdk`" ] && rpm -e `rpm -qa | grep jdk` + + tar xzf $JDK_FILE + + if [ -d "$JDK_NAME" ]; then + rm -rf $JAVA_dir; mkdir -p $JAVA_dir + mv $JDK_NAME $JAVA_dir + [ -z "`grep ^'export JAVA_HOME=' /etc/profile`" ] && { [ -z "`grep ^'export PATH=' /etc/profile`" ] && echo "export JAVA_HOME=$JDK_PATH" >> /etc/profile || sed -i "s@^export PATH=@export JAVA_HOME=$JDK_PATH\nexport PATH=@" /etc/profile; } || sed -i "s@^export JAVA_HOME=.*@export JAVA_HOME=$JDK_PATH@" /etc/profile + [ -z "`grep ^'export CLASSPATH=' /etc/profile`" ] && sed -i "s@export JAVA_HOME=\(.*\)@export JAVA_HOME=\1\nexport CLASSPATH=\$JAVA_HOME/lib/tools.jar:\$JAVA_HOME/lib/dt.jar:\$JAVA_HOME/lib@" /etc/profile + [ -n "`grep ^'export PATH=' /etc/profile`" -a -z "`grep '$JAVA_HOME/bin' /etc/profile`" ] && sed -i "s@^export PATH=\(.*\)@export PATH=\$JAVA_HOME/bin:\1@" /etc/profile + [ -z "`grep ^'export PATH=' /etc/profile | grep '$JAVA_HOME/bin'`" ] && echo 'export PATH=$JAVA_HOME/bin:$PATH' >> /etc/profile + . /etc/profile + echo "${CSUCCESS}$JDK_NAME installed successfully! ${CEND}" + else + rm -rf $JAVA_dir + echo "${CFAILURE}JDK install failed, Please contact the author! ${CEND}" + kill -9 $$ + fi + popd +} diff --git a/include/jdk-1.8.sh b/include/jdk-1.8.sh new file mode 100644 index 00000000..feca0aef --- /dev/null +++ b/include/jdk-1.8.sh @@ -0,0 +1,38 @@ +#!/bin/bash +# Author: yeho +# BLOG: https://blog.linuxeye.com +# +# Notes: OneinStack for CentOS/RadHat 5+ Debian 6+ and Ubuntu 12+ +# +# Project home page: +# https://oneinstack.com +# https://github.com/lj2007331/oneinstack + +Install-JDK18() { + pushd ${oneinstack_dir}/src + + JDK_FILE="jdk-`echo $jdk18_version | awk -F. '{print $2}'`u`echo $jdk18_version | awk -F_ '{print $NF}'`-linux-$SYS_BIG_FLAG.tar.gz" + JAVA_dir=/usr/java + JDK_NAME="jdk$jdk18_version" + JDK_PATH=$JAVA_dir/$JDK_NAME + + [ "$OS" == 'CentOS' ] && [ -n "`rpm -qa | grep jdk`" ] && rpm -e `rpm -qa | grep jdk` + + tar xzf $JDK_FILE + + if [ -d "$JDK_NAME" ]; then + rm -rf $JAVA_dir; mkdir -p $JAVA_dir + mv $JDK_NAME $JAVA_dir + [ -z "`grep ^'export JAVA_HOME=' /etc/profile`" ] && { [ -z "`grep ^'export PATH=' /etc/profile`" ] && echo "export JAVA_HOME=$JDK_PATH" >> /etc/profile || sed -i "s@^export PATH=@export JAVA_HOME=$JDK_PATH\nexport PATH=@" /etc/profile; } || sed -i "s@^export JAVA_HOME=.*@export JAVA_HOME=$JDK_PATH@" /etc/profile + [ -z "`grep ^'export CLASSPATH=' /etc/profile`" ] && sed -i "s@export JAVA_HOME=\(.*\)@export JAVA_HOME=\1\nexport CLASSPATH=\$JAVA_HOME/lib/tools.jar:\$JAVA_HOME/lib/dt.jar:\$JAVA_HOME/lib@" /etc/profile + [ -n "`grep ^'export PATH=' /etc/profile`" -a -z "`grep '$JAVA_HOME/bin' /etc/profile`" ] && sed -i "s@^export PATH=\(.*\)@export PATH=\$JAVA_HOME/bin:\1@" /etc/profile + [ -z "`grep ^'export PATH=' /etc/profile | grep '$JAVA_HOME/bin'`" ] && echo 'export PATH=$JAVA_HOME/bin:$PATH' >> /etc/profile + . /etc/profile + echo "${CSUCCESS}$JDK_NAME installed successfully! ${CEND}" + else + rm -rf $JAVA_dir + echo "${CFAILURE}JDK install failed, Please contact the author! ${CEND}" + kill -9 $$ + fi + popd +} diff --git a/include/jemalloc.sh b/include/jemalloc.sh index 7f799680..bdefab70 100644 --- a/include/jemalloc.sh +++ b/include/jemalloc.sh @@ -1,29 +1,36 @@ #!/bin/bash # Author: yeho -# BLOG: https://linuxeye.com +# BLOG: https://blog.linuxeye.com +# +# Notes: OneinStack for CentOS/RadHat 5+ Debian 6+ and Ubuntu 12+ +# +# Project home page: +# https://oneinstack.com +# https://github.com/lj2007331/oneinstack Install_Jemalloc() { if [ ! -e "/usr/local/lib/libjemalloc.so" ]; then - pushd ${current_dir}/src > /dev/null - tar xjf jemalloc-${jemalloc_ver}.tar.bz2 - pushd jemalloc-${jemalloc_ver} > /dev/null - ./configure + pushd ${oneinstack_dir}/src + tar xjf jemalloc-$jemalloc_version.tar.bz2 + pushd jemalloc-$jemalloc_version + LDFLAGS="${LDFLAGS} -lrt" ./configure make -j ${THREAD} && make install - popd > /dev/null + unset LDFLAGS + popd if [ -f "/usr/local/lib/libjemalloc.so" ]; then - if [ "${Family}" == 'rhel' ]; then + if [ "$OS_BIT" == '64' -a "$OS" == 'CentOS' ]; then ln -s /usr/local/lib/libjemalloc.so.2 /usr/lib64/libjemalloc.so.1 else ln -s /usr/local/lib/libjemalloc.so.2 /usr/lib/libjemalloc.so.1 fi - [ -z "`grep /usr/local/lib /etc/ld.so.conf.d/*.conf`" ] && echo '/usr/local/lib' > /etc/ld.so.conf.d/local.conf + echo '/usr/local/lib' > /etc/ld.so.conf.d/local.conf ldconfig echo "${CSUCCESS}jemalloc module installed successfully! ${CEND}" - rm -rf jemalloc-${jemalloc_ver} + rm -rf jemalloc-${jemalloc_version} else - echo "${CFAILURE}jemalloc install failed, Please contact the author! ${CEND}" && grep -Ew 'NAME|ID|ID_LIKE|VERSION_ID|PRETTY_NAME' /etc/os-release - kill -9 $$; exit 1; + echo "${CFAILURE}jemalloc install failed, Please contact the author! ${CEND}" + kill -9 $$ fi - popd > /dev/null + popd fi } diff --git a/include/mariadb-10.11.sh b/include/mariadb-10.0.sh similarity index 81% rename from include/mariadb-10.11.sh rename to include/mariadb-10.0.sh index f062f545..3ebf8cfe 100644 --- a/include/mariadb-10.11.sh +++ b/include/mariadb-10.0.sh @@ -1,29 +1,32 @@ #!/bin/bash # Author: yeho -# BLOG: https://linuxeye.com +# BLOG: https://blog.linuxeye.com +# +# Notes: OneinStack for CentOS/RadHat 5+ Debian 6+ and Ubuntu 12+ +# +# Project home page: +# https://oneinstack.com +# https://github.com/lj2007331/oneinstack + +Install_MariaDB100() { + pushd ${oneinstack_dir}/src -Install_MariaDB1011() { - pushd ${current_dir}/src > /dev/null id -u mysql >/dev/null 2>&1 [ $? -ne 0 ] && useradd -M -s /sbin/nologin mysql [ ! -d "${mariadb_install_dir}" ] && mkdir -p ${mariadb_install_dir} - mkdir -p ${mariadb_data_dir};chown mysql:mysql -R ${mariadb_data_dir} + mkdir -p ${mariadb_data_dir};chown mysql.mysql -R ${mariadb_data_dir} - if [ "${dbinstallmethod}" == "1" ]; then - tar zxf mariadb-${mariadb1011_ver}-linux-systemd-x86_64.tar.gz - mv mariadb-${mariadb1011_ver}-linux-systemd-x86_64/* ${mariadb_install_dir} + if [ "${dbInstallMethods}" == "1" ]; then + tar zxf mariadb-${mariadb100_version}-${GLIBC_FLAG}-${SYS_BIT_b}.tar.gz + mv mariadb-${mariadb100_version}-*-${SYS_BIT_b}/* ${mariadb_install_dir} sed -i 's@executing mysqld_safe@executing mysqld_safe\nexport LD_PRELOAD=/usr/local/lib/libjemalloc.so@' ${mariadb_install_dir}/bin/mysqld_safe sed -i "s@/usr/local/mysql@${mariadb_install_dir}@g" ${mariadb_install_dir}/bin/mysqld_safe - elif [ "${dbinstallmethod}" == "2" ]; then - boostVersion2=$(echo ${boost_oldver} | awk -F. '{print $1"_"$2"_"$3}') - tar xzf boost_${boostVersion2}.tar.gz - tar xzf mariadb-${mariadb1011_ver}.tar.gz - pushd mariadb-${mariadb1011_ver} + elif [ "${dbInstallMethods}" == "2" ]; then + tar xvf mariadb-${mariadb100_version}.tar.gz + pushd mariadb-${mariadb100_version} cmake . -DCMAKE_INSTALL_PREFIX=${mariadb_install_dir} \ -DMYSQL_DATADIR=${mariadb_data_dir} \ - -DDOWNLOAD_BOOST=1 \ - -DWITH_BOOST=../boost_${boostVersion2} \ -DSYSCONFDIR=/etc \ -DWITH_INNOBASE_STORAGE_ENGINE=1 \ -DWITH_PARTITION_STORAGE_ENGINE=1 \ @@ -43,25 +46,25 @@ Install_MariaDB1011() { fi if [ -d "${mariadb_install_dir}/support-files" ]; then - sed -i "s+^dbrootpwd.*+dbrootpwd='${dbrootpwd}'+" ../options.conf echo "${CSUCCESS}MariaDB installed successfully! ${CEND}" - if [ "${dbinstallmethod}" == "1" ]; then - rm -rf mariadb-${mariadb1011_ver}-linux-systemd-x86_64 - elif [ "${dbinstallmethod}" == "2" ]; then - rm -rf mariadb-${mariadb1011_ver} boost_${boostVersion2} + if [ "${dbInstallMethods}" == "1" ]; then + rm -rf mariadb-${mariadb100_version}-*-${SYS_BIT_b} + elif [ "${dbInstallMethods}" == "2" ]; then + rm -rf mariadb-${mariadb100_version} fi else rm -rf ${mariadb_install_dir} - echo "${CFAILURE}MariaDB install failed, Please contact the author! ${CEND}" && grep -Ew 'NAME|ID|ID_LIKE|VERSION_ID|PRETTY_NAME' /etc/os-release - kill -9 $$; exit 1; + rm -rf mariadb-${mariadb100_version} + echo "${CFAILURE}MariaDB install failed, Please contact the author! ${CEND}" + kill -9 $$ fi /bin/cp ${mariadb_install_dir}/support-files/mysql.server /etc/init.d/mysqld sed -i "s@^basedir=.*@basedir=${mariadb_install_dir}@" /etc/init.d/mysqld sed -i "s@^datadir=.*@datadir=${mariadb_data_dir}@" /etc/init.d/mysqld chmod +x /etc/init.d/mysqld - [ "${PM}" == 'yum' ] && { chkconfig --add mysqld; chkconfig mysqld on; } - [ "${PM}" == 'apt-get' ] && update-rc.d mysqld defaults + [ "${OS}" == "CentOS" ] && { chkconfig --add mysqld; chkconfig mysqld on; } + [[ "${OS}" =~ ^Ubuntu$|^Debian$ ]] && update-rc.d mysqld defaults popd # my.cnf @@ -133,16 +136,19 @@ innodb_open_files = 500 innodb_buffer_pool_size = 64M innodb_write_io_threads = 4 innodb_read_io_threads = 4 +innodb_thread_concurrency = 0 innodb_purge_threads = 1 innodb_flush_log_at_trx_commit = 2 innodb_log_buffer_size = 2M innodb_log_file_size = 32M +innodb_log_files_in_group = 3 innodb_max_dirty_pages_pct = 90 innodb_lock_wait_timeout = 120 bulk_insert_buffer_size = 8M myisam_sort_buffer_size = 8M myisam_max_sort_file_size = 10G +myisam_repair_threads = 1 interactive_timeout = 28800 wait_timeout = 28800 @@ -187,8 +193,7 @@ EOF ${mariadb_install_dir}/scripts/mysql_install_db --user=mysql --basedir=${mariadb_install_dir} --datadir=${mariadb_data_dir} - [ "${Wsl}" == true ] && chmod 600 /etc/my.cnf - chown mysql:mysql -R ${mariadb_data_dir} + chown mysql.mysql -R ${mariadb_data_dir} [ -d "/etc/mysql" ] && /bin/mv /etc/mysql{,_bk} service mysqld start [ -z "$(grep ^'export PATH=' /etc/profile)" ] && echo "export PATH=${mariadb_install_dir}/bin:\$PATH" >> /etc/profile @@ -197,13 +202,13 @@ EOF ${mariadb_install_dir}/bin/mysql -e "grant all privileges on *.* to root@'127.0.0.1' identified by \"${dbrootpwd}\" with grant option;" ${mariadb_install_dir}/bin/mysql -e "grant all privileges on *.* to root@'localhost' identified by \"${dbrootpwd}\" with grant option;" - ${mariadb_install_dir}/bin/mysql -uroot -p${dbrootpwd} -e "delete from mysql.user where Password='' and User not like 'mariadb.%';" + ${mariadb_install_dir}/bin/mysql -uroot -p${dbrootpwd} -e "delete from mysql.user where Password='';" ${mariadb_install_dir}/bin/mysql -uroot -p${dbrootpwd} -e "delete from mysql.db where User='';" ${mariadb_install_dir}/bin/mysql -uroot -p${dbrootpwd} -e "delete from mysql.proxies_priv where Host!='localhost';" ${mariadb_install_dir}/bin/mysql -uroot -p${dbrootpwd} -e "drop database test;" ${mariadb_install_dir}/bin/mysql -uroot -p${dbrootpwd} -e "reset master;" - rm -rf /etc/ld.so.conf.d/{mysql,mariadb,percona}*.conf - echo "${mariadb_install_dir}/lib" > /etc/ld.so.conf.d/z-mariadb.conf + rm -rf /etc/ld.so.conf.d/{mysql,mariadb,percona,alisql}*.conf + echo "${mariadb_install_dir}/lib" > /etc/ld.so.conf.d/mariadb.conf ldconfig service mysqld stop } diff --git a/include/mariadb-11.4.sh b/include/mariadb-10.1.sh similarity index 72% rename from include/mariadb-11.4.sh rename to include/mariadb-10.1.sh index fcf91138..07db957d 100644 --- a/include/mariadb-11.4.sh +++ b/include/mariadb-10.1.sh @@ -1,29 +1,32 @@ #!/bin/bash # Author: yeho -# BLOG: https://linuxeye.com +# BLOG: https://blog.linuxeye.com +# +# Notes: OneinStack for CentOS/RadHat 5+ Debian 6+ and Ubuntu 12+ +# +# Project home page: +# https://oneinstack.com +# https://github.com/lj2007331/oneinstack + +Install_MariaDB101() { + pushd ${oneinstack_dir}/src -Install_MariaDB114() { - pushd ${current_dir}/src > /dev/null id -u mysql >/dev/null 2>&1 [ $? -ne 0 ] && useradd -M -s /sbin/nologin mysql [ ! -d "${mariadb_install_dir}" ] && mkdir -p ${mariadb_install_dir} - mkdir -p ${mariadb_data_dir};chown mysql:mysql -R ${mariadb_data_dir} + mkdir -p ${mariadb_data_dir};chown mysql.mysql -R ${mariadb_data_dir} - if [ "${dbinstallmethod}" == "1" ]; then - tar zxf mariadb-${mariadb114_ver}-linux-systemd-x86_64.tar.gz - mv mariadb-${mariadb114_ver}-linux-systemd-x86_64/* ${mariadb_install_dir} + if [ "${dbInstallMethods}" == "1" ]; then + tar zxf mariadb-${mariadb101_version}-${GLIBC_FLAG}-${SYS_BIT_b}.tar.gz + mv mariadb-${mariadb101_version}-*-${SYS_BIT_b}/* ${mariadb_install_dir} sed -i 's@executing mysqld_safe@executing mysqld_safe\nexport LD_PRELOAD=/usr/local/lib/libjemalloc.so@' ${mariadb_install_dir}/bin/mysqld_safe sed -i "s@/usr/local/mysql@${mariadb_install_dir}@g" ${mariadb_install_dir}/bin/mysqld_safe - elif [ "${dbinstallmethod}" == "2" ]; then - boostVersion2=$(echo ${boost_oldver} | awk -F. '{print $1"_"$2"_"$3}') - tar xzf boost_${boostVersion2}.tar.gz - tar xzf mariadb-${mariadb114_ver}.tar.gz - pushd mariadb-${mariadb114_ver} + elif [ "${dbInstallMethods}" == "2" ]; then + tar xvf mariadb-${mariadb101_version}.tar.gz + pushd mariadb-${mariadb101_version} cmake . -DCMAKE_INSTALL_PREFIX=${mariadb_install_dir} \ -DMYSQL_DATADIR=${mariadb_data_dir} \ - -DDOWNLOAD_BOOST=1 \ - -DWITH_BOOST=../boost_${boostVersion2} \ -DSYSCONFDIR=/etc \ -DWITH_INNOBASE_STORAGE_ENGINE=1 \ -DWITH_PARTITION_STORAGE_ENGINE=1 \ @@ -43,25 +46,25 @@ Install_MariaDB114() { fi if [ -d "${mariadb_install_dir}/support-files" ]; then - sed -i "s+^dbrootpwd.*+dbrootpwd='${dbrootpwd}'+" ../options.conf echo "${CSUCCESS}MariaDB installed successfully! ${CEND}" - if [ "${dbinstallmethod}" == "1" ]; then - rm -rf mariadb-${mariadb114_ver}-linux-systemd-x86_64 - elif [ "${dbinstallmethod}" == "2" ]; then - rm -rf mariadb-${mariadb114_ver} boost_${boostVersion2} + if [ "${dbInstallMethods}" == "1" ]; then + rm -rf mariadb-${mariadb101_version}-*-${SYS_BIT_b} + elif [ "${dbInstallMethods}" == "2" ]; then + rm -rf mariadb-${mariadb101_version} fi else rm -rf ${mariadb_install_dir} - echo "${CFAILURE}MariaDB install failed, Please contact the author! ${CEND}" && grep -Ew 'NAME|ID|ID_LIKE|VERSION_ID|PRETTY_NAME' /etc/os-release - kill -9 $$; exit 1; + rm -rf mariadb-${mariadb101_version} + echo "${CFAILURE}MariaDB install failed, Please contact the author! ${CEND}" + kill -9 $$ fi /bin/cp ${mariadb_install_dir}/support-files/mysql.server /etc/init.d/mysqld sed -i "s@^basedir=.*@basedir=${mariadb_install_dir}@" /etc/init.d/mysqld sed -i "s@^datadir=.*@datadir=${mariadb_data_dir}@" /etc/init.d/mysqld chmod +x /etc/init.d/mysqld - [ "${PM}" == 'yum' ] && { chkconfig --add mysqld; chkconfig mysqld on; } - [ "${PM}" == 'apt-get' ] && update-rc.d mysqld defaults + [ "${OS}" == "CentOS" ] && { chkconfig --add mysqld; chkconfig mysqld on; } + [[ "${OS}" =~ ^Ubuntu$|^Debian$ ]] && update-rc.d mysqld defaults popd # my.cnf @@ -133,16 +136,19 @@ innodb_open_files = 500 innodb_buffer_pool_size = 64M innodb_write_io_threads = 4 innodb_read_io_threads = 4 +innodb_thread_concurrency = 0 innodb_purge_threads = 1 innodb_flush_log_at_trx_commit = 2 innodb_log_buffer_size = 2M innodb_log_file_size = 32M +innodb_log_files_in_group = 3 innodb_max_dirty_pages_pct = 90 innodb_lock_wait_timeout = 120 bulk_insert_buffer_size = 8M myisam_sort_buffer_size = 8M myisam_max_sort_file_size = 10G +myisam_repair_threads = 1 interactive_timeout = 28800 wait_timeout = 28800 @@ -187,23 +193,22 @@ EOF ${mariadb_install_dir}/scripts/mysql_install_db --user=mysql --basedir=${mariadb_install_dir} --datadir=${mariadb_data_dir} - [ "${Wsl}" == true ] && chmod 600 /etc/my.cnf - chown mysql:mysql -R ${mariadb_data_dir} + chown mysql.mysql -R ${mariadb_data_dir} [ -d "/etc/mysql" ] && /bin/mv /etc/mysql{,_bk} service mysqld start [ -z "$(grep ^'export PATH=' /etc/profile)" ] && echo "export PATH=${mariadb_install_dir}/bin:\$PATH" >> /etc/profile [ -n "$(grep ^'export PATH=' /etc/profile)" -a -z "$(grep ${mariadb_install_dir} /etc/profile)" ] && sed -i "s@^export PATH=\(.*\)@export PATH=${mariadb_install_dir}/bin:\1@" /etc/profile . /etc/profile - ${mariadb_install_dir}/bin/mariadb -e "grant all privileges on *.* to root@'127.0.0.1' identified by \"${dbrootpwd}\" with grant option;" - ${mariadb_install_dir}/bin/mariadb -e "grant all privileges on *.* to root@'localhost' identified by \"${dbrootpwd}\" with grant option;" - ${mariadb_install_dir}/bin/mariadb -uroot -p${dbrootpwd} -e "delete from mysql.user where Password='' and User not like 'mariadb.%';" - ${mariadb_install_dir}/bin/mariadb -uroot -p${dbrootpwd} -e "delete from mysql.db where User='';" - ${mariadb_install_dir}/bin/mariadb -uroot -p${dbrootpwd} -e "delete from mysql.proxies_priv where Host!='localhost';" - ${mariadb_install_dir}/bin/mariadb -uroot -p${dbrootpwd} -e "drop database test;" - ${mariadb_install_dir}/bin/mariadb -uroot -p${dbrootpwd} -e "reset master;" - rm -rf /etc/ld.so.conf.d/{mysql,mariadb,percona}*.conf - echo "${mariadb_install_dir}/lib" > /etc/ld.so.conf.d/z-mariadb.conf + ${mariadb_install_dir}/bin/mysql -e "grant all privileges on *.* to root@'127.0.0.1' identified by \"${dbrootpwd}\" with grant option;" + ${mariadb_install_dir}/bin/mysql -e "grant all privileges on *.* to root@'localhost' identified by \"${dbrootpwd}\" with grant option;" + ${mariadb_install_dir}/bin/mysql -uroot -p${dbrootpwd} -e "delete from mysql.user where Password='';" + ${mariadb_install_dir}/bin/mysql -uroot -p${dbrootpwd} -e "delete from mysql.db where User='';" + ${mariadb_install_dir}/bin/mysql -uroot -p${dbrootpwd} -e "delete from mysql.proxies_priv where Host!='localhost';" + ${mariadb_install_dir}/bin/mysql -uroot -p${dbrootpwd} -e "drop database test;" + ${mariadb_install_dir}/bin/mysql -uroot -p${dbrootpwd} -e "reset master;" + rm -rf /etc/ld.so.conf.d/{mysql,mariadb,percona,alisql}*.conf + echo "${mariadb_install_dir}/lib" > /etc/ld.so.conf.d/mariadb.conf ldconfig service mysqld stop } diff --git a/include/mariadb-11.8.sh b/include/mariadb-11.8.sh deleted file mode 100644 index aa7be9d6..00000000 --- a/include/mariadb-11.8.sh +++ /dev/null @@ -1,209 +0,0 @@ -#!/bin/bash -# Author: yeho -# BLOG: https://linuxeye.com - -Install_MariaDB118() { - pushd ${current_dir}/src > /dev/null - id -u mysql >/dev/null 2>&1 - [ $? -ne 0 ] && useradd -M -s /sbin/nologin mysql - - [ ! -d "${mariadb_install_dir}" ] && mkdir -p ${mariadb_install_dir} - mkdir -p ${mariadb_data_dir};chown mysql:mysql -R ${mariadb_data_dir} - - if [ "${dbinstallmethod}" == "1" ]; then - tar zxf mariadb-${mariadb118_ver}-linux-systemd-x86_64.tar.gz - mv mariadb-${mariadb118_ver}-linux-systemd-x86_64/* ${mariadb_install_dir} - sed -i 's@executing mysqld_safe@executing mysqld_safe\nexport LD_PRELOAD=/usr/local/lib/libjemalloc.so@' ${mariadb_install_dir}/bin/mysqld_safe - sed -i "s@/usr/local/mysql@${mariadb_install_dir}@g" ${mariadb_install_dir}/bin/mysqld_safe - elif [ "${dbinstallmethod}" == "2" ]; then - boostVersion2=$(echo ${boost_oldver} | awk -F. '{print $1"_"$2"_"$3}') - tar xzf boost_${boostVersion2}.tar.gz - tar xzf mariadb-${mariadb118_ver}.tar.gz - pushd mariadb-${mariadb118_ver} - cmake . -DCMAKE_INSTALL_PREFIX=${mariadb_install_dir} \ - -DMYSQL_DATADIR=${mariadb_data_dir} \ - -DDOWNLOAD_BOOST=1 \ - -DWITH_BOOST=../boost_${boostVersion2} \ - -DSYSCONFDIR=/etc \ - -DWITH_INNOBASE_STORAGE_ENGINE=1 \ - -DWITH_PARTITION_STORAGE_ENGINE=1 \ - -DWITH_FEDERATED_STORAGE_ENGINE=1 \ - -DWITH_BLACKHOLE_STORAGE_ENGINE=1 \ - -DWITH_MYISAM_STORAGE_ENGINE=1 \ - -DWITH_EMBEDDED_SERVER=1 \ - -DENABLE_DTRACE=0 \ - -DENABLED_LOCAL_INFILE=1 \ - -DDEFAULT_CHARSET=utf8mb4 \ - -DDEFAULT_COLLATION=utf8mb4_general_ci \ - -DEXTRA_CHARSETS=all \ - -DCMAKE_EXE_LINKER_FLAGS='-ljemalloc' - make -j ${THREAD} - make install - popd - fi - - if [ -d "${mariadb_install_dir}/support-files" ]; then - sed -i "s+^dbrootpwd.*+dbrootpwd='${dbrootpwd}'+" ../options.conf - echo "${CSUCCESS}MariaDB installed successfully! ${CEND}" - if [ "${dbinstallmethod}" == "1" ]; then - rm -rf mariadb-${mariadb118_ver}-linux-systemd-x86_64 - elif [ "${dbinstallmethod}" == "2" ]; then - rm -rf mariadb-${mariadb118_ver} boost_${boostVersion2} - fi - else - rm -rf ${mariadb_install_dir} - echo "${CFAILURE}MariaDB install failed, Please contact the author! ${CEND}" && grep -Ew 'NAME|ID|ID_LIKE|VERSION_ID|PRETTY_NAME' /etc/os-release - kill -9 $$; exit 1; - fi - - /bin/cp ${mariadb_install_dir}/support-files/mysql.server /etc/init.d/mysqld - sed -i "s@^basedir=.*@basedir=${mariadb_install_dir}@" /etc/init.d/mysqld - sed -i "s@^datadir=.*@datadir=${mariadb_data_dir}@" /etc/init.d/mysqld - chmod +x /etc/init.d/mysqld - [ "${PM}" == 'yum' ] && { chkconfig --add mysqld; chkconfig mysqld on; } - [ "${PM}" == 'apt-get' ] && update-rc.d mysqld defaults - popd - - # my.cnf - cat > /etc/my.cnf << EOF -[client] -port = 3306 -socket = /tmp/mysql.sock -default-character-set = utf8mb4 - -[mysqld] -port = 3306 -socket = /tmp/mysql.sock - -basedir = ${mariadb_install_dir} -datadir = ${mariadb_data_dir} -pid-file = ${mariadb_data_dir}/mysql.pid -user = mysql -bind-address = 0.0.0.0 -server-id = 1 - -init-connect = 'SET NAMES utf8mb4' -character-set-server = utf8mb4 - -skip-name-resolve -#skip-networking -back_log = 300 - -max_connections = 1000 -max_connect_errors = 6000 -open_files_limit = 65535 -table_open_cache = 128 -max_allowed_packet = 500M -binlog_cache_size = 1M -max_heap_table_size = 8M -tmp_table_size = 16M - -read_buffer_size = 2M -read_rnd_buffer_size = 8M -sort_buffer_size = 8M -join_buffer_size = 8M -key_buffer_size = 4M - -thread_cache_size = 8 - -query_cache_type = 1 -query_cache_size = 8M -query_cache_limit = 2M - -ft_min_word_len = 4 - -log_bin = mysql-bin -binlog_format = mixed -expire_logs_days = 7 - -log_error = ${mariadb_data_dir}/mysql-error.log -slow_query_log = 1 -long_query_time = 1 -slow_query_log_file = ${mariadb_data_dir}/mysql-slow.log - -performance_schema = 0 - -#lower_case_table_names = 1 - -skip-external-locking - -default_storage_engine = InnoDB -innodb_file_per_table = 1 -innodb_open_files = 500 -innodb_buffer_pool_size = 64M -innodb_write_io_threads = 4 -innodb_read_io_threads = 4 -innodb_purge_threads = 1 -innodb_flush_log_at_trx_commit = 2 -innodb_log_buffer_size = 2M -innodb_log_file_size = 32M -innodb_max_dirty_pages_pct = 90 -innodb_lock_wait_timeout = 120 - -bulk_insert_buffer_size = 8M -myisam_sort_buffer_size = 8M -myisam_max_sort_file_size = 10G - -interactive_timeout = 28800 -wait_timeout = 28800 - -[mysqldump] -quick -max_allowed_packet = 500M - -[myisamchk] -key_buffer_size = 8M -sort_buffer_size = 8M -read_buffer = 4M -write_buffer = 4M -EOF - - sed -i "s@max_connections.*@max_connections = $((${Mem}/3))@" /etc/my.cnf - if [ ${Mem} -gt 1500 -a ${Mem} -le 2500 ]; then - sed -i 's@^thread_cache_size.*@thread_cache_size = 16@' /etc/my.cnf - sed -i 's@^query_cache_size.*@query_cache_size = 16M@' /etc/my.cnf - sed -i 's@^myisam_sort_buffer_size.*@myisam_sort_buffer_size = 16M@' /etc/my.cnf - sed -i 's@^key_buffer_size.*@key_buffer_size = 16M@' /etc/my.cnf - sed -i 's@^innodb_buffer_pool_size.*@innodb_buffer_pool_size = 128M@' /etc/my.cnf - sed -i 's@^tmp_table_size.*@tmp_table_size = 32M@' /etc/my.cnf - sed -i 's@^table_open_cache.*@table_open_cache = 256@' /etc/my.cnf - elif [ ${Mem} -gt 2500 -a ${Mem} -le 3500 ]; then - sed -i 's@^thread_cache_size.*@thread_cache_size = 32@' /etc/my.cnf - sed -i 's@^query_cache_size.*@query_cache_size = 32M@' /etc/my.cnf - sed -i 's@^myisam_sort_buffer_size.*@myisam_sort_buffer_size = 32M@' /etc/my.cnf - sed -i 's@^key_buffer_size.*@key_buffer_size = 64M@' /etc/my.cnf - sed -i 's@^innodb_buffer_pool_size.*@innodb_buffer_pool_size = 512M@' /etc/my.cnf - sed -i 's@^tmp_table_size.*@tmp_table_size = 64M@' /etc/my.cnf - sed -i 's@^table_open_cache.*@table_open_cache = 512@' /etc/my.cnf - elif [ ${Mem} -gt 3500 ]; then - sed -i 's@^thread_cache_size.*@thread_cache_size = 64@' /etc/my.cnf - sed -i 's@^query_cache_size.*@query_cache_size = 64M@' /etc/my.cnf - sed -i 's@^myisam_sort_buffer_size.*@myisam_sort_buffer_size = 64M@' /etc/my.cnf - sed -i 's@^key_buffer_size.*@key_buffer_size = 256M@' /etc/my.cnf - sed -i 's@^innodb_buffer_pool_size.*@innodb_buffer_pool_size = 1024M@' /etc/my.cnf - sed -i 's@^tmp_table_size.*@tmp_table_size = 128M@' /etc/my.cnf - sed -i 's@^table_open_cache.*@table_open_cache = 1024@' /etc/my.cnf - fi - - ${mariadb_install_dir}/scripts/mysql_install_db --user=mysql --basedir=${mariadb_install_dir} --datadir=${mariadb_data_dir} - - [ "${Wsl}" == true ] && chmod 600 /etc/my.cnf - chown mysql:mysql -R ${mariadb_data_dir} - [ -d "/etc/mysql" ] && /bin/mv /etc/mysql{,_bk} - service mysqld start - [ -z "$(grep ^'export PATH=' /etc/profile)" ] && echo "export PATH=${mariadb_install_dir}/bin:\$PATH" >> /etc/profile - [ -n "$(grep ^'export PATH=' /etc/profile)" -a -z "$(grep ${mariadb_install_dir} /etc/profile)" ] && sed -i "s@^export PATH=\(.*\)@export PATH=${mariadb_install_dir}/bin:\1@" /etc/profile - . /etc/profile - - ${mariadb_install_dir}/bin/mariadb -e "grant all privileges on *.* to root@'127.0.0.1' identified by \"${dbrootpwd}\" with grant option;" - ${mariadb_install_dir}/bin/mariadb -e "grant all privileges on *.* to root@'localhost' identified by \"${dbrootpwd}\" with grant option;" - ${mariadb_install_dir}/bin/mariadb -uroot -p${dbrootpwd} -e "delete from mysql.user where Password='' and User not like 'mariadb.%';" - ${mariadb_install_dir}/bin/mariadb -uroot -p${dbrootpwd} -e "delete from mysql.db where User='';" - ${mariadb_install_dir}/bin/mariadb -uroot -p${dbrootpwd} -e "delete from mysql.proxies_priv where Host!='localhost';" - ${mariadb_install_dir}/bin/mariadb -uroot -p${dbrootpwd} -e "drop database test;" - ${mariadb_install_dir}/bin/mariadb -uroot -p${dbrootpwd} -e "reset master;" - rm -rf /etc/ld.so.conf.d/{mysql,mariadb,percona}*.conf - echo "${mariadb_install_dir}/lib" > /etc/ld.so.conf.d/z-mariadb.conf - ldconfig - service mysqld stop -} diff --git a/include/mariadb-5.5.sh b/include/mariadb-5.5.sh index c6c6e879..9ccace2a 100644 --- a/include/mariadb-5.5.sh +++ b/include/mariadb-5.5.sh @@ -1,24 +1,31 @@ #!/bin/bash # Author: yeho -# BLOG: https://linuxeye.com +# BLOG: https://blog.linuxeye.com +# +# Notes: OneinStack for CentOS/RadHat 5+ Debian 6+ and Ubuntu 12+ +# +# Project home page: +# https://oneinstack.com +# https://github.com/lj2007331/oneinstack Install_MariaDB55() { - pushd ${current_dir}/src > /dev/null + pushd ${oneinstack_dir}/src + id -u mysql >/dev/null 2>&1 [ $? -ne 0 ] && useradd -M -s /sbin/nologin mysql [ ! -d "${mariadb_install_dir}" ] && mkdir -p ${mariadb_install_dir} - mkdir -p ${mariadb_data_dir};chown mysql:mysql -R ${mariadb_data_dir} + mkdir -p ${mariadb_data_dir};chown mysql.mysql -R ${mariadb_data_dir} - if [ "${dbinstallmethod}" == "1" ]; then - tar zxf mariadb-${mariadb55_ver}-linux-systemd-x86_64.tar.gz - mv mariadb-${mariadb55_ver}-linux-systemd-x86_64/* ${mariadb_install_dir} + if [ "${dbInstallMethods}" == "1" ]; then + tar zxf mariadb-${mariadb55_version}-${GLIBC_FLAG}-${SYS_BIT_b}.tar.gz + mv mariadb-${mariadb55_version}-*-${SYS_BIT_b}/* ${mariadb_install_dir} sed -i 's@executing mysqld_safe@executing mysqld_safe\nexport LD_PRELOAD=/usr/local/lib/libjemalloc.so@' ${mariadb_install_dir}/bin/mysqld_safe sed -i "s@/usr/local/mysql@${mariadb_install_dir}@g" ${mariadb_install_dir}/bin/mysqld_safe - elif [ "${dbinstallmethod}" == "2" ]; then - tar xzf mariadb-${mariadb55_ver}.tar.gz - pushd mariadb-${mariadb55_ver} - [ "${armplatform}" == "y" ] && patch -p1 < ../mysql-5.5-fix-arm-client_plugin.patch + elif [ "${dbInstallMethods}" == "2" ]; then + tar xvf mariadb-${mariadb55_version}.tar.gz + pushd mariadb-${mariadb55_version} + [ "${armPlatform}" == "y" ] && patch -p1 < ../mysql-5.5-fix-arm-client_plugin.patch cmake . -DCMAKE_INSTALL_PREFIX=${mariadb_install_dir} \ -DMYSQL_DATADIR=${mariadb_data_dir} \ -DSYSCONFDIR=/etc \ @@ -41,25 +48,25 @@ Install_MariaDB55() { fi if [ -d "${mariadb_install_dir}/support-files" ]; then - sed -i "s+^dbrootpwd.*+dbrootpwd='${dbrootpwd}'+" ../options.conf echo "${CSUCCESS}MariaDB installed successfully! ${CEND}" - if [ "${dbinstallmethod}" == "1" ]; then - rm -rf mariadb-${mariadb55_ver}-linux-systemd-x86_64 - elif [ "${dbinstallmethod}" == "2" ]; then - rm -rf mariadb-${mariadb55_ver} + if [ "${dbInstallMethods}" == "1" ]; then + rm -rf mariadb-${mariadb55_version}-*-${SYS_BIT_b} + elif [ "${dbInstallMethods}" == "2" ]; then + rm -rf mariadb-${mariadb55_version} fi else rm -rf ${mariadb_install_dir} - echo "${CFAILURE}MariaDB install failed, Please contact the author! ${CEND}" && grep -Ew 'NAME|ID|ID_LIKE|VERSION_ID|PRETTY_NAME' /etc/os-release - kill -9 $$; exit 1; + rm -rf mariadb-${mariadb55_version} + echo "${CFAILURE}MariaDB install failed, Please contact the author! ${CEND}" + kill -9 $$ fi /bin/cp ${mariadb_install_dir}/support-files/mysql.server /etc/init.d/mysqld sed -i "s@^basedir=.*@basedir=${mariadb_install_dir}@" /etc/init.d/mysqld sed -i "s@^datadir=.*@datadir=${mariadb_data_dir}@" /etc/init.d/mysqld chmod +x /etc/init.d/mysqld - [ "${PM}" == 'yum' ] && { chkconfig --add mysqld; chkconfig mysqld on; } - [ "${PM}" == 'apt-get' ] && update-rc.d mysqld defaults + [ "${OS}" == "CentOS" ] && { chkconfig --add mysqld; chkconfig mysqld on; } + [[ "${OS}" =~ ^Ubuntu$|^Debian$ ]] && update-rc.d mysqld defaults popd # my.cnf @@ -67,6 +74,7 @@ Install_MariaDB55() { [client] port = 3306 socket = /tmp/mysql.sock +default-character-set = utf8mb4 [mysqld] port = 3306 @@ -111,7 +119,7 @@ ft_min_word_len = 4 log_bin = mysql-bin binlog_format = mixed -expire_logs_days = 7 +expire_logs_days = 30 log_error = ${mariadb_data_dir}/mysql-error.log slow_query_log = 1 @@ -188,8 +196,7 @@ EOF ${mariadb_install_dir}/scripts/mysql_install_db --user=mysql --basedir=${mariadb_install_dir} --datadir=${mariadb_data_dir} - [ "${Wsl}" == true ] && chmod 600 /etc/my.cnf - chown mysql:mysql -R ${mariadb_data_dir} + chown mysql.mysql -R ${mariadb_data_dir} [ -d "/etc/mysql" ] && /bin/mv /etc/mysql{,_bk} service mysqld start [ -z "$(grep ^'export PATH=' /etc/profile)" ] && echo "export PATH=${mariadb_install_dir}/bin:\$PATH" >> /etc/profile @@ -198,13 +205,13 @@ EOF ${mariadb_install_dir}/bin/mysql -e "grant all privileges on *.* to root@'127.0.0.1' identified by \"${dbrootpwd}\" with grant option;" ${mariadb_install_dir}/bin/mysql -e "grant all privileges on *.* to root@'localhost' identified by \"${dbrootpwd}\" with grant option;" - ${mariadb_install_dir}/bin/mysql -uroot -p${dbrootpwd} -e "delete from mysql.user where Password='' and User not like 'mariadb.%';" + ${mariadb_install_dir}/bin/mysql -uroot -p${dbrootpwd} -e "delete from mysql.user where Password='';" ${mariadb_install_dir}/bin/mysql -uroot -p${dbrootpwd} -e "delete from mysql.db where User='';" ${mariadb_install_dir}/bin/mysql -uroot -p${dbrootpwd} -e "delete from mysql.proxies_priv where Host!='localhost';" ${mariadb_install_dir}/bin/mysql -uroot -p${dbrootpwd} -e "drop database test;" ${mariadb_install_dir}/bin/mysql -uroot -p${dbrootpwd} -e "reset master;" - rm -rf /etc/ld.so.conf.d/{mysql,mariadb,percona}*.conf - echo "${mariadb_install_dir}/lib" > /etc/ld.so.conf.d/z-mariadb.conf + rm -rf /etc/ld.so.conf.d/{mysql,mariadb,percona,alisql}*.conf + echo "${mariadb_install_dir}/lib" > /etc/ld.so.conf.d/mariadb.conf ldconfig service mysqld stop } diff --git a/include/memcached.sh b/include/memcached.sh index bdd566b9..2fb13c9f 100644 --- a/include/memcached.sh +++ b/include/memcached.sh @@ -1,121 +1,110 @@ #!/bin/bash # Author: yeho -# BLOG: https://linuxeye.com +# BLOG: https://blog.linuxeye.com +# +# Notes: OneinStack for CentOS/RadHat 5+ Debian 6+ and Ubuntu 12+ +# +# Project home page: +# https://oneinstack.com +# https://github.com/lj2007331/oneinstack + +Install_memcached() { + pushd ${oneinstack_dir}/src -Install_memcached_server() { - pushd ${current_dir}/src > /dev/null # memcached server id -u memcached >/dev/null 2>&1 [ $? -ne 0 ] && useradd -M -s /sbin/nologin memcached - tar xzf memcached-${memcached_ver}.tar.gz - pushd memcached-${memcached_ver} > /dev/null + tar xzf memcached-${memcached_version}.tar.gz + pushd memcached-${memcached_version} [ ! -d "${memcached_install_dir}" ] && mkdir -p ${memcached_install_dir} ./configure --prefix=${memcached_install_dir} make -j ${THREAD} && make install - popd > /dev/null - if [ -f "${memcached_install_dir}/bin/memcached" ]; then + popd + if [ -d "${memcached_install_dir}/include/memcached" ]; then echo "${CSUCCESS}memcached installed successfully! ${CEND}" - rm -rf memcached-${memcached_ver} + rm -rf memcached-${memcached_version} ln -s ${memcached_install_dir}/bin/memcached /usr/bin/memcached - /bin/cp ../init.d/memcached.service /lib/systemd/system/ - systemctl enable memcached - systemctl start memcached - rm -rf memcached-${memcached_ver} + [ "${OS}" == "CentOS" ] && { /bin/cp ../init.d/Memcached-init-CentOS /etc/init.d/memcached; chkconfig --add memcached; chkconfig memcached on; } + [[ "${OS}" =~ ^Ubuntu$|^Debian$ ]] && { /bin/cp ../init.d/Memcached-init-Ubuntu /etc/init.d/memcached; update-rc.d memcached defaults; } + sed -i "s@/usr/local/memcached@${memcached_install_dir}@g" /etc/init.d/memcached + let memcachedCache="${Mem}/8" + [ -n "$(grep 'CACHESIZE=' /etc/init.d/memcached)" ] && sed -i "s@^CACHESIZE=.*@CACHESIZE=${memcachedCache}@" /etc/init.d/memcached + [ -n "$(grep 'start_instance default 256;' /etc/init.d/memcached)" ] && sed -i "s@start_instance default 256;@start_instance default ${memcachedCache};@" /etc/init.d/memcached + service memcached start + rm -rf memcached-${memcached_version} else rm -rf ${memcached_install_dir} - echo "${CFAILURE}memcached-server install failed, Please contact the author! ${CEND}" && grep -Ew 'NAME|ID|ID_LIKE|VERSION_ID|PRETTY_NAME' /etc/os-release - kill -9 $$; exit 1; + echo "${CFAILURE}memcached install failed, Please contact the author! ${CEND}" + kill -9 $$ fi - popd > /dev/null + popd } -Install_pecl_memcache() { +Install_php-memcache() { + pushd ${oneinstack_dir}/src if [ -e "${php_install_dir}/bin/phpize" ]; then - pushd ${current_dir}/src > /dev/null phpExtensionDir=$(${php_install_dir}/bin/php-config --extension-dir) - PHP_detail_ver=$(${php_install_dir}/bin/php-config --version) - PHP_main_ver=${PHP_detail_ver%.*} - if [ "$(${php_install_dir}/bin/php-config --version | awk -F. '{print $1}')" == '5' ]; then - tar xzf memcache-3.0.8.tgz - pushd memcache-3.0.8 > /dev/null - elif [ "$(${php_install_dir}/bin/php-config --version | awk -F. '{print $1}')" == '7' ]; then - tar xzf memcache-4.0.5.2.tgz - pushd memcache-4.0.5.2 > /dev/null - else + # php memcache extension + if [ "$(${php_install_dir}/bin/php -r 'echo PHP_VERSION;' | awk -F. '{print $1}')" == '7' ]; then #git clone https://github.com/websupport-sk/pecl-memcache.git - tar xzf memcache-${pecl_memcache_ver}.tgz - pushd memcache-${pecl_memcache_ver} > /dev/null + #cd pecl-memcache + tar xzf pecl-memcache-php7.tgz + pushd pecl-memcache-php7 + else + tar xzf memcache-${memcache_pecl_version}.tgz + pushd memcache-${memcache_pecl_version} fi ${php_install_dir}/bin/phpize ./configure --with-php-config=${php_install_dir}/bin/php-config make -j ${THREAD} && make install - popd > /dev/null + popd if [ -f "${phpExtensionDir}/memcache.so" ]; then - echo "extension=memcache.so" > ${php_install_dir}/etc/php.d/05-memcache.ini + echo "extension=memcache.so" > ${php_install_dir}/etc/php.d/ext-memcache.ini echo "${CSUCCESS}PHP memcache module installed successfully! ${CEND}" - rm -rf memcache-${pecl_memcache_ver} memcache-4.0.5.2 memcache-3.0.8 + rm -rf pecl-memcache-php7 memcache-${memcache_pecl_version} else - echo "${CFAILURE}PHP memcache module install failed, Please contact the author! ${CEND}" && grep -Ew 'NAME|ID|ID_LIKE|VERSION_ID|PRETTY_NAME' /etc/os-release + echo "${CFAILURE}PHP memcache module install failed, Please contact the author! ${CEND}" fi - popd > /dev/null fi + popd } -Install_pecl_memcached() { +Install_php-memcached() { + pushd ${oneinstack_dir}/src if [ -e "${php_install_dir}/bin/phpize" ]; then - pushd ${current_dir}/src > /dev/null phpExtensionDir=$(${php_install_dir}/bin/php-config --extension-dir) # php memcached extension - tar xzf libmemcached-${libmemcached_ver}.tar.gz - patch -d libmemcached-${libmemcached_ver} -p0 < libmemcached-build.patch - pushd libmemcached-${libmemcached_ver} > /dev/null - [ "${PM}" == 'yum' ] && yum -y install cyrus-sasl-devel - [ "${PM}" == 'apt-get' ] && sed -i "s@lthread -pthread -pthreads@lthread -lpthread -pthreads@" ./configure + tar xzf libmemcached-${libmemcached_version}.tar.gz + pushd libmemcached-${libmemcached_version} + [ "${OS}" == "CentOS" ] && yum -y install cyrus-sasl-devel + [[ "${OS}" =~ ^Ubuntu$|^Debian$ ]] && sed -i "s@lthread -pthread -pthreads@lthread -lpthread -pthreads@" ./configure ./configure --with-memcached=${memcached_install_dir} make -j ${THREAD} && make install - popd > /dev/null - rm -rf libmemcached-${libmemcached_ver} + popd + rm -rf libmemcached-${libmemcached_version} - if [ "$(${php_install_dir}/bin/php-config --version | awk -F. '{print $1}')" == '5' ]; then - tar xzf memcached-2.2.0.tgz - pushd memcached-2.2.0 > /dev/null + if [ "$(${php_install_dir}/bin/php -r 'echo PHP_VERSION;' | awk -F. '{print $1}')" == '7' ]; then + tar xzf memcached-${memcached_pecl_php7_version}.tgz + pushd memcached-${memcached_pecl_php7_version} else - tar xzf memcached-${pecl_memcached_ver}.tgz - pushd memcached-${pecl_memcached_ver} > /dev/null + tar xzf memcached-${memcached_pecl_version}.tgz + pushd memcached-${memcached_pecl_version} fi ${php_install_dir}/bin/phpize ./configure --with-php-config=${php_install_dir}/bin/php-config make -j ${THREAD} && make install - popd > /dev/null + popd if [ -f "${phpExtensionDir}/memcached.so" ]; then - cat > ${php_install_dir}/etc/php.d/05-memcached.ini << EOF + cat > ${php_install_dir}/etc/php.d/ext-memcached.ini << EOF extension=memcached.so memcached.use_sasl=1 EOF echo "${CSUCCESS}PHP memcached module installed successfully! ${CEND}" - rm -rf memcached-2.2.0 memcached-${pecl_memcached_ver} + rm -rf memcached-${memcached_pecl_version} memcached-${memcached_pecl_php7_version} else - echo "${CFAILURE}PHP memcached module install failed, Please contact the author! ${CEND}" && grep -Ew 'NAME|ID|ID_LIKE|VERSION_ID|PRETTY_NAME' /etc/os-release + echo "${CFAILURE}PHP memcached module install failed, Please contact the author! ${CEND}" fi - popd > /dev/null - fi -} - -Uninstall_pecl_memcache() { - if [ -e "${php_install_dir}/etc/php.d/05-memcache.ini" ]; then - rm -f ${php_install_dir}/etc/php.d/05-memcache.ini - echo; echo "${CMSG}PHP memcache module uninstall completed${CEND}" - else - echo; echo "${CWARNING}PHP memcache module does not exist! ${CEND}" - fi -} - -Uninstall_pecl_memcached() { - if [ -e "${php_install_dir}/etc/php.d/05-memcached.ini" ]; then - rm -f ${php_install_dir}/etc/php.d/05-memcached.ini - echo; echo "${CMSG}PHP memcached module uninstall completed${CEND}" - else - echo; echo "${CWARNING}PHP memcached module does not exist! ${CEND}" fi + popd } diff --git a/include/memory.sh b/include/memory.sh index aabb2d4a..e670d7c8 100644 --- a/include/memory.sh +++ b/include/memory.sh @@ -1,9 +1,13 @@ #!/bin/bash # Author: yeho -# BLOG: https://linuxeye.com +# BLOG: https://blog.linuxeye.com +# +# Notes: OneinStack for CentOS/RadHat 5+ Debian 6+ and Ubuntu 12+ +# +# Project home page: +# https://oneinstack.com +# https://github.com/lj2007331/oneinstack -export LANG=en_US.UTF-8 -export LANGUAGE=en_US:en Mem=`free -m | awk '/Mem:/{print $2}'` Swap=`free -m | awk '/Swap:/{print $2}'` @@ -31,12 +35,21 @@ elif [ $Mem -gt 8000 ]; then Memory_limit=448 fi -# add swapfile -if [ ! -e ~/.lnmp ] && [ "${Swap}" == '0' ] && [ ${Mem} -le 2048 ]; then - echo "${CWARNING}Add Swap file, It may take a few minutes... ${CEND}" - dd if=/dev/zero of=/swapfile count=2048 bs=1M +Make-swapfile() { + dd if=/dev/zero of=/swapfile count=$COUNT bs=1M mkswap /swapfile swapon /swapfile chmod 600 /swapfile [ -z "`grep swapfile /etc/fstab`" ] && echo '/swapfile swap swap defaults 0 0' >> /etc/fstab +} + +# add swapfile +if [ "$Swap" == '0' ]; then + if [ $Mem -le 1024 ]; then + COUNT=1024 + Make-swapfile + elif [ $Mem -gt 1024 -a $Mem -le 2048 ]; then + COUNT=2048 + Make-swapfile + fi fi diff --git a/include/mongodb.sh b/include/mongodb.sh deleted file mode 100644 index 8a932a94..00000000 --- a/include/mongodb.sh +++ /dev/null @@ -1,73 +0,0 @@ -#!/bin/bash -# Author: yeho -# BLOG: https://linuxeye.com - -Install_MongoDB() { - pushd ${current_dir}/src > /dev/null - id -u mongod >/dev/null 2>&1 - [ $? -ne 0 ] && useradd -s /sbin/nologin mongod - mkdir -p ${mongo_data_dir};chown mongod.mongod -R ${mongo_data_dir} - tar xzf mongodb-linux-x86_64-${mongodb_ver}.tgz - /bin/mv mongodb-linux-x86_64-${mongodb_ver} ${mongo_install_dir} - /bin/cp ${current_dir}/init.d/mongod.service /lib/systemd/system/ - sed -i "s@=/usr/local/mongodb@=${mongo_install_dir}@g" /lib/systemd/system/mongod.service - systemctl enable mongod - - cat > /etc/mongod.conf << EOF -# mongod.conf - -# for documentation of all options, see: -# http://docs.mongodb.org/manual/reference/configuration-options/ - -# where to write logging data. -systemLog: - destination: file - logAppend: true - path: ${mongo_data_dir}/mongod.log - -# Where and how to store data. -storage: - dbPath: ${mongo_data_dir} - journal: - enabled: true -# engine: -# mmapv1: -# wiredTiger: - -# how the process runs -processManagement: - fork: true # fork and run in background - pidFilePath: /var/run/mongodb/mongod.pid - -# network interfaces -net: - port: 27017 - bindIp: 0.0.0.0 - unixDomainSocket: - enabled: false - -#security: -# authorization: enabled - -#operationProfiling: -#replication: -#sharding: -EOF - systemctl start mongod - echo ${mongo_install_dir}/bin/mongo 127.0.0.1/admin --eval \"db.createUser\(\{user:\'root\',pwd:\'$dbmongopwd\',roles:[\'userAdminAnyDatabase\']\}\)\" | bash - sed -i 's@^#security:@security:@' /etc/mongod.conf - sed -i 's@^# authorization:@ authorization:@' /etc/mongod.conf - if [ -e "${mongo_install_dir}/bin/mongo" ]; then - sed -i "s+^dbmongopwd.*+dbmongopwd='$dbmongopwd'+" ../options.conf - echo "${CSUCCESS}MongoDB installed successfully! ${CEND}" - rm -rf mongodb-linux-x86_64-${mongodb_ver} - else - rm -rf ${mongo_install_dir} ${mongo_data_dir} - echo "${CFAILURE}MongoDB install failed, Please contact the author! ${CEND}" && grep -Ew 'NAME|ID|ID_LIKE|VERSION_ID|PRETTY_NAME' /etc/os-release - kill -9 $$; exit 1; - fi - popd - [ -z "$(grep ^'export PATH=' /etc/profile)" ] && echo "export PATH=${mongo_install_dir}/bin:\$PATH" >> /etc/profile - [ -n "$(grep ^'export PATH=' /etc/profile)" -a -z "$(grep ${mongo_install_dir} /etc/profile)" ] && sed -i "s@^export PATH=\(.*\)@export PATH=${mongo_install_dir}/bin:\1@" /etc/profile - . /etc/profile -} diff --git a/include/mphp.sh b/include/mphp.sh deleted file mode 100644 index d6f95c59..00000000 --- a/include/mphp.sh +++ /dev/null @@ -1,81 +0,0 @@ -#!/bin/bash -# Author: yeho -# BLOG: https://linuxeye.com - -Install_MPHP() { - if [ -e "${php_install_dir}/sbin/php-fpm" ]; then - if [ -e "${php_install_dir}${mphp_ver}/bin/phpize" ]; then - echo "${CWARNING}PHP${mphp_ver} already installed! ${CEND}" - else - [ -e "/lib/systemd/system/php-fpm.service" ] && /bin/mv /lib/systemd/system/php-fpm.service{,_bk} - php_install_dir=${php_install_dir}${mphp_ver} - case "${mphp_ver}" in - 53) - . include/php-5.3.sh - Install_PHP53 2>&1 | tee -a ${current_dir}/install.log - ;; - 54) - . include/php-5.4.sh - Install_PHP54 2>&1 | tee -a ${current_dir}/install.log - ;; - 55) - . include/php-5.5.sh - Install_PHP55 2>&1 | tee -a ${current_dir}/install.log - ;; - 56) - . include/php-5.6.sh - Install_PHP56 2>&1 | tee -a ${current_dir}/install.log - ;; - 70) - . include/php-7.0.sh - Install_PHP70 2>&1 | tee -a ${current_dir}/install.log - ;; - 71) - . include/php-7.1.sh - Install_PHP71 2>&1 | tee -a ${current_dir}/install.log - ;; - 72) - . include/php-7.2.sh - Install_PHP72 2>&1 | tee -a ${current_dir}/install.log - ;; - 73) - . include/php-7.3.sh - Install_PHP73 2>&1 | tee -a ${current_dir}/install.log - ;; - 74) - . include/php-7.4.sh - Install_PHP74 2>&1 | tee -a ${current_dir}/install.log - ;; - 80) - . include/php-8.0.sh - Install_PHP80 2>&1 | tee -a ${current_dir}/install.log - ;; - 81) - . include/php-8.1.sh - Install_PHP81 2>&1 | tee -a ${current_dir}/install.log - ;; - 82) - . include/php-8.2.sh - Install_PHP82 2>&1 | tee -a ${current_dir}/install.log - ;; - 83) - . include/php-8.3.sh - Install_PHP83 2>&1 | tee -a ${current_dir}/install.log - ;; - esac - if [ -e "${php_install_dir}/sbin/php-fpm" ]; then - systemctl stop php-fpm - sed -i "s@/dev/shm/php-cgi.sock@/dev/shm/php${mphp_ver}-cgi.sock@" ${php_install_dir}/etc/php-fpm.conf - [ -e "/lib/systemd/system/php-fpm.service" ] && /bin/mv /lib/systemd/system/php-fpm.service /lib/systemd/system/php${mphp_ver}-fpm.service - [ -e "/lib/systemd/system/php-fpm.service_bk" ] && /bin/mv /lib/systemd/system/php-fpm.service{_bk,} - systemctl enable php${mphp_ver}-fpm - systemctl enable php-fpm - systemctl start php-fpm - systemctl start php${mphp_ver}-fpm - sed -i "s@${php_install_dir}/bin:@@" /etc/profile - fi - fi - else - echo "${CWARNING}To use the multiple PHP versions, You need to use PHP-FPM! ${CEND}" - fi -} diff --git a/include/mysql-5.5.sh b/include/mysql-5.5.sh index 6943e067..9d113a11 100644 --- a/include/mysql-5.5.sh +++ b/include/mysql-5.5.sh @@ -1,24 +1,31 @@ #!/bin/bash # Author: yeho -# BLOG: https://linuxeye.com +# BLOG: https://blog.linuxeye.com +# +# Notes: OneinStack for CentOS/RadHat 5+ Debian 6+ and Ubuntu 12+ +# +# Project home page: +# https://oneinstack.com +# https://github.com/lj2007331/oneinstack Install_MySQL55() { - pushd ${current_dir}/src > /dev/null + pushd ${oneinstack_dir}/src + id -u mysql >/dev/null 2>&1 [ $? -ne 0 ] && useradd -M -s /sbin/nologin mysql [ ! -d "${mysql_install_dir}" ] && mkdir -p ${mysql_install_dir} - mkdir -p ${mysql_data_dir};chown mysql:mysql -R ${mysql_data_dir} + mkdir -p ${mysql_data_dir};chown mysql.mysql -R ${mysql_data_dir} - if [ "${dbinstallmethod}" == "1" ]; then - tar xzf mysql-${mysql55_ver}-linux-glibc2.12-x86_64.tar.gz - mv mysql-${mysql55_ver}-linux-glibc2.12-x86_64/* ${mysql_install_dir} + if [ "${dbInstallMethods}" == "1" ]; then + tar xvf mysql-${mysql55_version}-linux-glibc2.5-${SYS_BIT_b}.tar.gz + mv mysql-${mysql55_version}-linux-glibc2.5-${SYS_BIT_b}/* ${mysql_install_dir} sed -i 's@executing mysqld_safe@executing mysqld_safe\nexport LD_PRELOAD=/usr/local/lib/libjemalloc.so@' ${mysql_install_dir}/bin/mysqld_safe sed -i "s@/usr/local/mysql@${mysql_install_dir}@g" ${mysql_install_dir}/bin/mysqld_safe - elif [ "${dbinstallmethod}" == "2" ]; then - tar xzf mysql-${mysql55_ver}.tar.gz - pushd mysql-${mysql55_ver} - [ "${armplatform}" == "y" ] && patch -p1 < ../mysql-5.5-fix-arm-client_plugin.patch + elif [ "${dbInstallMethods}" == "2" ]; then + tar xvf mysql-${mysql55_version}.tar.gz + pushd mysql-${mysql55_version} + [ "${armPlatform}" == "y" ] && patch -p1 < ../mysql-5.5-fix-arm-client_plugin.patch cmake . -DCMAKE_INSTALL_PREFIX=${mysql_install_dir} \ -DMYSQL_DATADIR=${mysql_data_dir} \ -DSYSCONFDIR=/etc \ @@ -41,25 +48,25 @@ Install_MySQL55() { fi if [ -d "${mysql_install_dir}/support-files" ]; then - sed -i "s+^dbrootpwd.*+dbrootpwd='${dbrootpwd}'+" ../options.conf echo "${CSUCCESS}MySQL installed successfully! ${CEND}" - if [ "${dbinstallmethod}" == "1" ]; then - rm -rf mysql-${mysql55_ver}-*-x86_64 - elif [ "${dbinstallmethod}" == "2" ]; then - rm -rf mysql-${mysql55_ver} + if [ "${dbInstallMethods}" == "1" ]; then + rm -rf mysql-${mysql55_version}-*-${SYS_BIT_b} + elif [ "${dbInstallMethods}" == "2" ]; then + rm -rf mysql-${mysql55_version} fi else rm -rf ${mysql_install_dir} - echo "${CFAILURE}MySQL install failed, Please contact the author! ${CEND}" && grep -Ew 'NAME|ID|ID_LIKE|VERSION_ID|PRETTY_NAME' /etc/os-release - kill -9 $$; exit 1; + rm -rf mysql-${mysql55_version} + echo "${CFAILURE}MySQL install failed, Please contact the author! ${CEND}" + kill -9 $$ fi /bin/cp ${mysql_install_dir}/support-files/mysql.server /etc/init.d/mysqld sed -i "s@^basedir=.*@basedir=${mysql_install_dir}@" /etc/init.d/mysqld sed -i "s@^datadir=.*@datadir=${mysql_data_dir}@" /etc/init.d/mysqld chmod +x /etc/init.d/mysqld - [ "${PM}" == 'yum' ] && { chkconfig --add mysqld; chkconfig mysqld on; } - [ "${PM}" == 'apt-get' ] && update-rc.d mysqld defaults + [ "${OS}" == "CentOS" ] && { chkconfig --add mysqld; chkconfig mysqld on; } + [[ "${OS}" =~ ^Ubuntu$|^Debian$ ]] && update-rc.d mysqld defaults popd # my.cnf @@ -67,6 +74,7 @@ Install_MySQL55() { [client] port = 3306 socket = /tmp/mysql.sock +default-character-set = utf8mb4 [mysql] prompt="MySQL [\\d]> " @@ -191,8 +199,7 @@ EOF ${mysql_install_dir}/scripts/mysql_install_db --user=mysql --basedir=${mysql_install_dir} --datadir=${mysql_data_dir} - [ "${Wsl}" == true ] && chmod 600 /etc/my.cnf - chown mysql:mysql -R ${mysql_data_dir} + chown mysql.mysql -R ${mysql_data_dir} [ -d "/etc/mysql" ] && /bin/mv /etc/mysql{,_bk} service mysqld start [ -z "$(grep ^'export PATH=' /etc/profile)" ] && echo "export PATH=${mysql_install_dir}/bin:\$PATH" >> /etc/profile @@ -201,14 +208,14 @@ EOF ${mysql_install_dir}/bin/mysql -e "grant all privileges on *.* to root@'127.0.0.1' identified by \"${dbrootpwd}\" with grant option;" ${mysql_install_dir}/bin/mysql -e "grant all privileges on *.* to root@'localhost' identified by \"${dbrootpwd}\" with grant option;" - ${mysql_install_dir}/bin/mysql -uroot -p${dbrootpwd} -e "delete from mysql.user where Password='' and User not like 'mysql.%';" + ${mysql_install_dir}/bin/mysql -uroot -p${dbrootpwd} -e "delete from mysql.user where Password='';" ${mysql_install_dir}/bin/mysql -uroot -p${dbrootpwd} -e "delete from mysql.db where User='';" ${mysql_install_dir}/bin/mysql -uroot -p${dbrootpwd} -e "delete from mysql.proxies_priv where Host!='localhost';" ${mysql_install_dir}/bin/mysql -uroot -p${dbrootpwd} -e "drop database test;" ${mysql_install_dir}/bin/mysql -uroot -p${dbrootpwd} -e "reset master;" - rm -rf /etc/ld.so.conf.d/{mysql,mariadb,percona}*.conf - [ -e "${mysql_install_dir}/my.cnf" ] && rm -f ${mysql_install_dir}/my.cnf - echo "${mysql_install_dir}/lib" > /etc/ld.so.conf.d/z-mysql.conf + rm -rf /etc/ld.so.conf.d/{mysql,mariadb,percona,alisql}*.conf + [ -e "${mysql_install_dir}/my.cnf" ] && rm -rf ${mysql_install_dir}/my.cnf + echo "${mysql_install_dir}/lib" > /etc/ld.so.conf.d/mysql.conf ldconfig service mysqld stop } diff --git a/include/mysql-8.0.sh b/include/mysql-5.6.sh similarity index 65% rename from include/mysql-8.0.sh rename to include/mysql-5.6.sh index 6920eede..1a4ae82a 100644 --- a/include/mysql-8.0.sh +++ b/include/mysql-5.6.sh @@ -1,70 +1,70 @@ #!/bin/bash # Author: yeho -# BLOG: https://linuxeye.com +# BLOG: https://blog.linuxeye.com +# +# Notes: OneinStack for CentOS/RadHat 5+ Debian 6+ and Ubuntu 12+ +# +# Project home page: +# https://oneinstack.com +# https://github.com/lj2007331/oneinstack + +Install_MySQL56() { + pushd ${oneinstack_dir}/src -Install_MySQL80() { - pushd ${current_dir}/src > /dev/null id -u mysql >/dev/null 2>&1 [ $? -ne 0 ] && useradd -M -s /sbin/nologin mysql [ ! -d "${mysql_install_dir}" ] && mkdir -p ${mysql_install_dir} - mkdir -p ${mysql_data_dir};chown mysql:mysql -R ${mysql_data_dir} + mkdir -p ${mysql_data_dir};chown mysql.mysql -R ${mysql_data_dir} - if [ "${dbinstallmethod}" == "1" ]; then - tar xJf mysql-${mysql80_ver}-linux-glibc2.28-x86_64.tar.xz - mv mysql-${mysql80_ver}-linux-glibc2.28-x86_64/* ${mysql_install_dir} + if [ "${dbInstallMethods}" == "1" ]; then + tar xvf mysql-${mysql56_version}-linux-glibc2.5-${SYS_BIT_b}.tar.gz + mv mysql-${mysql56_version}-linux-glibc2.5-${SYS_BIT_b}/* ${mysql_install_dir} + sed -i 's@executing mysqld_safe@executing mysqld_safe\nexport LD_PRELOAD=/usr/local/lib/libjemalloc.so@' ${mysql_install_dir}/bin/mysqld_safe sed -i "s@/usr/local/mysql@${mysql_install_dir}@g" ${mysql_install_dir}/bin/mysqld_safe - elif [ "${dbinstallmethod}" == "2" ]; then - boostVersion2=$(echo ${boost_ver} | awk -F. '{print $1"_"$2"_"$3}') - tar xzf boost_${boostVersion2}.tar.gz - tar xzf mysql-${mysql80_ver}.tar.gz - pushd mysql-${mysql80_ver} - [ -e "/usr/bin/cmake3" ] && CMAKE=cmake3 || CMAKE=cmake - $CMAKE . -DCMAKE_INSTALL_PREFIX=${mysql_install_dir} \ + elif [ "${dbInstallMethods}" == "2" ]; then + tar xvf mysql-${mysql56_version}.tar.gz + pushd mysql-${mysql56_version} + cmake . -DCMAKE_INSTALL_PREFIX=${mysql_install_dir} \ -DMYSQL_DATADIR=${mysql_data_dir} \ - -DDOWNLOAD_BOOST=1 \ - -DWITH_BOOST=../boost_${boostVersion2} \ - -DFORCE_INSOURCE_BUILD=1 \ -DSYSCONFDIR=/etc \ -DWITH_INNOBASE_STORAGE_ENGINE=1 \ + -DWITH_PARTITION_STORAGE_ENGINE=1 \ -DWITH_FEDERATED_STORAGE_ENGINE=1 \ -DWITH_BLACKHOLE_STORAGE_ENGINE=1 \ -DWITH_MYISAM_STORAGE_ENGINE=1 \ + -DWITH_EMBEDDED_SERVER=1 \ + -DENABLE_DTRACE=0 \ -DENABLED_LOCAL_INFILE=1 \ - -DFORCE_INSOURCE_BUILD=1 \ - -DCMAKE_C_COMPILER=/usr/bin/gcc \ - -DCMAKE_CXX_COMPILER=/usr/bin/g++ \ - -DDEFAULT_CHARSET=utf8mb4 + -DDEFAULT_CHARSET=utf8mb4 \ + -DDEFAULT_COLLATION=utf8mb4_general_ci \ + -DEXTRA_CHARSETS=all \ + -DCMAKE_EXE_LINKER_FLAGS='-ljemalloc' make -j ${THREAD} make install popd fi - # backup openssl so - #[ ! -e "${mysql_install_dir}/lib/lib_bk" ] && mkdir ${mysql_install_dir}/lib/lib_bk - #/bin/mv ${mysql_install_dir}/lib/{libssl,libcrypto}.so* ${mysql_install_dir}/lib/lib_bk/ - if [ -d "${mysql_install_dir}/support-files" ]; then - sed -i 's@executing mysqld_safe@executing mysqld_safe\nexport LD_PRELOAD=/usr/local/lib/libjemalloc.so@' ${mysql_install_dir}/bin/mysqld_safe - sed -i "s+^dbrootpwd.*+dbrootpwd='${dbrootpwd}'+" ../options.conf echo "${CSUCCESS}MySQL installed successfully! ${CEND}" - if [ "${dbinstallmethod}" == "1" ]; then - rm -rf mysql-${mysql80_ver}-*-x86_64 - elif [ "${dbinstallmethod}" == "2" ]; then - rm -rf mysql-${mysql80_ver} boost_${boostVersion2} + if [ "${dbInstallMethods}" == "1" ]; then + rm -rf mysql-${mysql56_version}-*-${SYS_BIT_b} + elif [ "${dbInstallMethods}" == "2" ]; then + rm -rf mysql-${mysql56_version} fi else rm -rf ${mysql_install_dir} - echo "${CFAILURE}MySQL install failed, Please contact the author! ${CEND}" && grep -Ew 'NAME|ID|ID_LIKE|VERSION_ID|PRETTY_NAME' /etc/os-release - kill -9 $$; exit 1; + rm -rf mysql-${mysql56_version} + echo "${CFAILURE}MySQL install failed, Please contact the author! ${CEND}" + kill -9 $$ fi /bin/cp ${mysql_install_dir}/support-files/mysql.server /etc/init.d/mysqld sed -i "s@^basedir=.*@basedir=${mysql_install_dir}@" /etc/init.d/mysqld sed -i "s@^datadir=.*@datadir=${mysql_data_dir}@" /etc/init.d/mysqld chmod +x /etc/init.d/mysqld - [ "${PM}" == 'yum' ] && { chkconfig --add mysqld; chkconfig mysqld on; } - [ "${PM}" == 'apt-get' ] && update-rc.d mysqld defaults + [ "${OS}" == "CentOS" ] && { chkconfig --add mysqld; chkconfig mysqld on; } + [[ "${OS}" =~ ^Ubuntu$|^Debian$ ]] && update-rc.d mysqld defaults popd # my.cnf @@ -81,7 +81,6 @@ no-auto-rehash [mysqld] port = 3306 socket = /tmp/mysql.sock -default_authentication_plugin = mysql_native_password basedir = ${mysql_install_dir} datadir = ${mysql_data_dir} @@ -92,7 +91,6 @@ server-id = 1 init-connect = 'SET NAMES utf8mb4' character-set-server = utf8mb4 -collation-server = utf8mb4_0900_ai_ci skip-name-resolve #skip-networking @@ -115,11 +113,15 @@ key_buffer_size = 4M thread_cache_size = 8 +query_cache_type = 1 +query_cache_size = 8M +query_cache_limit = 2M + ft_min_word_len = 4 log_bin = mysql-bin binlog_format = mixed -binlog_expire_logs_seconds = 604800 +expire_logs_days = 7 log_error = ${mysql_data_dir}/mysql-error.log slow_query_log = 1 @@ -134,7 +136,6 @@ explicit_defaults_for_timestamp skip-external-locking default_storage_engine = InnoDB -#default-storage-engine = MyISAM innodb_file_per_table = 1 innodb_open_files = 500 innodb_buffer_pool_size = 64M @@ -152,6 +153,7 @@ innodb_lock_wait_timeout = 120 bulk_insert_buffer_size = 8M myisam_sort_buffer_size = 8M myisam_max_sort_file_size = 10G +myisam_repair_threads = 1 interactive_timeout = 28800 wait_timeout = 28800 @@ -170,6 +172,7 @@ EOF sed -i "s@max_connections.*@max_connections = $((${Mem}/3))@" /etc/my.cnf if [ ${Mem} -gt 1500 -a ${Mem} -le 2500 ]; then sed -i 's@^thread_cache_size.*@thread_cache_size = 16@' /etc/my.cnf + sed -i 's@^query_cache_size.*@query_cache_size = 16M@' /etc/my.cnf sed -i 's@^myisam_sort_buffer_size.*@myisam_sort_buffer_size = 16M@' /etc/my.cnf sed -i 's@^key_buffer_size.*@key_buffer_size = 16M@' /etc/my.cnf sed -i 's@^innodb_buffer_pool_size.*@innodb_buffer_pool_size = 128M@' /etc/my.cnf @@ -177,6 +180,7 @@ EOF sed -i 's@^table_open_cache.*@table_open_cache = 256@' /etc/my.cnf elif [ ${Mem} -gt 2500 -a ${Mem} -le 3500 ]; then sed -i 's@^thread_cache_size.*@thread_cache_size = 32@' /etc/my.cnf + sed -i 's@^query_cache_size.*@query_cache_size = 32M@' /etc/my.cnf sed -i 's@^myisam_sort_buffer_size.*@myisam_sort_buffer_size = 32M@' /etc/my.cnf sed -i 's@^key_buffer_size.*@key_buffer_size = 64M@' /etc/my.cnf sed -i 's@^innodb_buffer_pool_size.*@innodb_buffer_pool_size = 512M@' /etc/my.cnf @@ -184,6 +188,7 @@ EOF sed -i 's@^table_open_cache.*@table_open_cache = 512@' /etc/my.cnf elif [ ${Mem} -gt 3500 ]; then sed -i 's@^thread_cache_size.*@thread_cache_size = 64@' /etc/my.cnf + sed -i 's@^query_cache_size.*@query_cache_size = 64M@' /etc/my.cnf sed -i 's@^myisam_sort_buffer_size.*@myisam_sort_buffer_size = 64M@' /etc/my.cnf sed -i 's@^key_buffer_size.*@key_buffer_size = 256M@' /etc/my.cnf sed -i 's@^innodb_buffer_pool_size.*@innodb_buffer_pool_size = 1024M@' /etc/my.cnf @@ -191,24 +196,25 @@ EOF sed -i 's@^table_open_cache.*@table_open_cache = 1024@' /etc/my.cnf fi - ${mysql_install_dir}/bin/mysqld --initialize-insecure --user=mysql --basedir=${mysql_install_dir} --datadir=${mysql_data_dir} + ${mysql_install_dir}/scripts/mysql_install_db --user=mysql --basedir=${mysql_install_dir} --datadir=${mysql_data_dir} - [ "${Wsl}" == true ] && chmod 600 /etc/my.cnf - chown mysql:mysql -R ${mysql_data_dir} + chown mysql.mysql -R ${mysql_data_dir} [ -d "/etc/mysql" ] && /bin/mv /etc/mysql{,_bk} service mysqld start [ -z "$(grep ^'export PATH=' /etc/profile)" ] && echo "export PATH=${mysql_install_dir}/bin:\$PATH" >> /etc/profile [ -n "$(grep ^'export PATH=' /etc/profile)" -a -z "$(grep ${mysql_install_dir} /etc/profile)" ] && sed -i "s@^export PATH=\(.*\)@export PATH=${mysql_install_dir}/bin:\1@" /etc/profile . /etc/profile - ${mysql_install_dir}/bin/mysql -uroot -hlocalhost -e "create user root@'127.0.0.1' identified by \"${dbrootpwd}\";" - ${mysql_install_dir}/bin/mysql -uroot -hlocalhost -e "grant all privileges on *.* to root@'127.0.0.1' with grant option;" - ${mysql_install_dir}/bin/mysql -uroot -hlocalhost -e "grant all privileges on *.* to root@'localhost' with grant option;" - ${mysql_install_dir}/bin/mysql -uroot -hlocalhost -e "alter user root@'localhost' identified by \"${dbrootpwd}\";" + ${mysql_install_dir}/bin/mysql -e "grant all privileges on *.* to root@'127.0.0.1' identified by \"${dbrootpwd}\" with grant option;" + ${mysql_install_dir}/bin/mysql -e "grant all privileges on *.* to root@'localhost' identified by \"${dbrootpwd}\" with grant option;" + ${mysql_install_dir}/bin/mysql -uroot -p${dbrootpwd} -e "delete from mysql.user where Password='';" + ${mysql_install_dir}/bin/mysql -uroot -p${dbrootpwd} -e "delete from mysql.db where User='';" + ${mysql_install_dir}/bin/mysql -uroot -p${dbrootpwd} -e "delete from mysql.proxies_priv where Host!='localhost';" + ${mysql_install_dir}/bin/mysql -uroot -p${dbrootpwd} -e "drop database test;" ${mysql_install_dir}/bin/mysql -uroot -p${dbrootpwd} -e "reset master;" - rm -rf /etc/ld.so.conf.d/{mysql,mariadb,percona}*.conf - [ -e "${mysql_install_dir}/my.cnf" ] && rm -f ${mysql_install_dir}/my.cnf - echo "${mysql_install_dir}/lib" > /etc/ld.so.conf.d/z-mysql.conf + rm -rf /etc/ld.so.conf.d/{mysql,mariadb,percona,alisql}*.conf + [ -e "${mysql_install_dir}/my.cnf" ] && rm -rf ${mysql_install_dir}/my.cnf + echo "${mysql_install_dir}/lib" > /etc/ld.so.conf.d/mysql.conf ldconfig service mysqld stop } diff --git a/include/mysql-5.7.sh b/include/mysql-5.7.sh index 58b1e656..6c3c1eeb 100644 --- a/include/mysql-5.7.sh +++ b/include/mysql-5.7.sh @@ -1,29 +1,32 @@ #!/bin/bash # Author: yeho -# BLOG: https://linuxeye.com +# BLOG: https://blog.linuxeye.com +# +# Notes: OneinStack for CentOS/RadHat 5+ Debian 6+ and Ubuntu 12+ +# +# Project home page: +# https://oneinstack.com +# https://github.com/lj2007331/oneinstack Install_MySQL57() { - pushd ${current_dir}/src > /dev/null + pushd ${oneinstack_dir}/src + id -u mysql >/dev/null 2>&1 [ $? -ne 0 ] && useradd -M -s /sbin/nologin mysql [ ! -d "${mysql_install_dir}" ] && mkdir -p ${mysql_install_dir} - mkdir -p ${mysql_data_dir};chown mysql:mysql -R ${mysql_data_dir} + mkdir -p ${mysql_data_dir};chown mysql.mysql -R ${mysql_data_dir} - if [ "${dbinstallmethod}" == "1" ]; then - tar xzf mysql-${mysql57_ver}-linux-glibc2.12-x86_64.tar.gz - mv mysql-${mysql57_ver}-linux-glibc2.12-x86_64/* ${mysql_install_dir} + if [ "${dbInstallMethods}" == "1" ]; then + tar xvf mysql-${mysql57_version}-linux-glibc2.5-${SYS_BIT_b}.tar.gz + mv mysql-${mysql57_version}-linux-glibc2.5-${SYS_BIT_b}/* ${mysql_install_dir} sed -i 's@executing mysqld_safe@executing mysqld_safe\nexport LD_PRELOAD=/usr/local/lib/libjemalloc.so@' ${mysql_install_dir}/bin/mysqld_safe sed -i "s@/usr/local/mysql@${mysql_install_dir}@g" ${mysql_install_dir}/bin/mysqld_safe - elif [ "${dbinstallmethod}" == "2" ]; then - boostVersion2=$(echo ${boost_oldver} | awk -F. '{print $1"_"$2"_"$3}') - tar xzf boost_${boostVersion2}.tar.gz - tar xzf mysql-${mysql57_ver}.tar.gz - pushd mysql-${mysql57_ver} + elif [ "${dbInstallMethods}" == "2" ]; then + tar xvf mysql-${mysql57_version}.tar.gz + pushd mysql-${mysql57_version} cmake . -DCMAKE_INSTALL_PREFIX=${mysql_install_dir} \ -DMYSQL_DATADIR=${mysql_data_dir} \ - -DDOWNLOAD_BOOST=1 \ - -DWITH_BOOST=../boost_${boostVersion2} \ -DSYSCONFDIR=/etc \ -DWITH_INNOBASE_STORAGE_ENGINE=1 \ -DWITH_PARTITION_STORAGE_ENGINE=1 \ @@ -43,25 +46,25 @@ Install_MySQL57() { fi if [ -d "${mysql_install_dir}/support-files" ]; then - sed -i "s+^dbrootpwd.*+dbrootpwd='${dbrootpwd}'+" ../options.conf echo "${CSUCCESS}MySQL installed successfully! ${CEND}" - if [ "${dbinstallmethod}" == "1" ]; then - rm -rf mysql-${mysql57_ver}-*-x86_64 - elif [ "${dbinstallmethod}" == "2" ]; then - rm -rf mysql-${mysql57_ver} boost_${boostVersion2} + if [ "${dbInstallMethods}" == "1" ]; then + rm -rf mysql-${mysql57_version}-*-${SYS_BIT_b} + elif [ "${dbInstallMethods}" == "2" ]; then + rm -rf mysql-${mysql57_version} fi else rm -rf ${mysql_install_dir} - echo "${CFAILURE}MySQL install failed, Please contact the author! ${CEND}" && grep -Ew 'NAME|ID|ID_LIKE|VERSION_ID|PRETTY_NAME' /etc/os-release - kill -9 $$; exit 1; + rm -rf mysql-${mysql57_version} + echo "${CFAILURE}MySQL install failed, Please contact the author! ${CEND}" + kill -9 $$ fi /bin/cp ${mysql_install_dir}/support-files/mysql.server /etc/init.d/mysqld sed -i "s@^basedir=.*@basedir=${mysql_install_dir}@" /etc/init.d/mysqld sed -i "s@^datadir=.*@datadir=${mysql_data_dir}@" /etc/init.d/mysqld chmod +x /etc/init.d/mysqld - [ "${PM}" == 'yum' ] && { chkconfig --add mysqld; chkconfig mysqld on; } - [ "${PM}" == 'apt-get' ] && update-rc.d mysqld defaults + [ "${OS}" == "CentOS" ] && { chkconfig --add mysqld; chkconfig mysqld on; } + [[ "${OS}" =~ ^Ubuntu$|^Debian$ ]] && update-rc.d mysqld defaults popd # my.cnf @@ -69,6 +72,7 @@ Install_MySQL57() { [client] port = 3306 socket = /tmp/mysql.sock +default-character-set = utf8mb4 [mysql] prompt="MySQL [\\d]> " @@ -150,6 +154,7 @@ innodb_lock_wait_timeout = 120 bulk_insert_buffer_size = 8M myisam_sort_buffer_size = 8M myisam_max_sort_file_size = 10G +myisam_repair_threads = 1 interactive_timeout = 28800 wait_timeout = 28800 @@ -194,8 +199,7 @@ EOF ${mysql_install_dir}/bin/mysqld --initialize-insecure --user=mysql --basedir=${mysql_install_dir} --datadir=${mysql_data_dir} - [ "${Wsl}" == true ] && chmod 600 /etc/my.cnf - chown mysql:mysql -R ${mysql_data_dir} + chown mysql.mysql -R ${mysql_data_dir} [ -d "/etc/mysql" ] && /bin/mv /etc/mysql{,_bk} service mysqld start [ -z "$(grep ^'export PATH=' /etc/profile)" ] && echo "export PATH=${mysql_install_dir}/bin:\$PATH" >> /etc/profile @@ -205,9 +209,9 @@ EOF ${mysql_install_dir}/bin/mysql -e "grant all privileges on *.* to root@'127.0.0.1' identified by \"${dbrootpwd}\" with grant option;" ${mysql_install_dir}/bin/mysql -e "grant all privileges on *.* to root@'localhost' identified by \"${dbrootpwd}\" with grant option;" ${mysql_install_dir}/bin/mysql -uroot -p${dbrootpwd} -e "reset master;" - rm -rf /etc/ld.so.conf.d/{mysql,mariadb,percona}*.conf - [ -e "${mysql_install_dir}/my.cnf" ] && rm -f ${mysql_install_dir}/my.cnf - echo "${mysql_install_dir}/lib" > /etc/ld.so.conf.d/z-mysql.conf + rm -rf /etc/ld.so.conf.d/{mysql,mariadb,percona,alisql}*.conf + [ -e "${mysql_install_dir}/my.cnf" ] && rm -rf ${mysql_install_dir}/my.cnf + echo "${mysql_install_dir}/lib" > /etc/ld.so.conf.d/mysql.conf ldconfig service mysqld stop } diff --git a/include/mysql-8.4.sh b/include/mysql-8.4.sh deleted file mode 100644 index 44ac50b7..00000000 --- a/include/mysql-8.4.sh +++ /dev/null @@ -1,211 +0,0 @@ -#!/bin/bash -# Author: yeho -# BLOG: https://linuxeye.com - -Install_MySQL84() { - pushd ${current_dir}/src > /dev/null - id -u mysql >/dev/null 2>&1 - [ $? -ne 0 ] && useradd -M -s /sbin/nologin mysql - - [ ! -d "${mysql_install_dir}" ] && mkdir -p ${mysql_install_dir} - mkdir -p ${mysql_data_dir};chown mysql:mysql -R ${mysql_data_dir} - - if [ "${dbinstallmethod}" == "1" ]; then - tar xJf mysql-${mysql84_ver}-linux-glibc2.28-x86_64.tar.xz - mv mysql-${mysql84_ver}-linux-glibc2.28-x86_64/* ${mysql_install_dir} - sed -i "s@/usr/local/mysql@${mysql_install_dir}@g" ${mysql_install_dir}/bin/mysqld_safe - elif [ "${dbinstallmethod}" == "2" ]; then - boostVersion2=$(echo ${boost_ver} | awk -F. '{print $1"_"$2"_"$3}') - tar xzf boost_${boostVersion2}.tar.gz - tar xzf mysql-${mysql84_ver}.tar.gz - pushd mysql-${mysql84_ver} - [ -e "/usr/bin/cmake3" ] && CMAKE=cmake3 || CMAKE=cmake - $CMAKE . -DCMAKE_INSTALL_PREFIX=${mysql_install_dir} \ - -DMYSQL_DATADIR=${mysql_data_dir} \ - -DDOWNLOAD_BOOST=1 \ - -DWITH_BOOST=../boost_${boostVersion2} \ - -DFORCE_INSOURCE_BUILD=1 \ - -DSYSCONFDIR=/etc \ - -DWITH_INNOBASE_STORAGE_ENGINE=1 \ - -DWITH_FEDERATED_STORAGE_ENGINE=1 \ - -DWITH_BLACKHOLE_STORAGE_ENGINE=1 \ - -DWITH_MYISAM_STORAGE_ENGINE=1 \ - -DENABLED_LOCAL_INFILE=1 \ - -DFORCE_INSOURCE_BUILD=1 \ - -DCMAKE_C_COMPILER=/usr/bin/gcc \ - -DCMAKE_CXX_COMPILER=/usr/bin/g++ \ - -DDEFAULT_CHARSET=utf8mb4 - make -j ${THREAD} - make install - popd - fi - - # backup openssl so - #[ ! -e "${mysql_install_dir}/lib/lib_bk" ] && mkdir ${mysql_install_dir}/lib/lib_bk - #/bin/mv ${mysql_install_dir}/lib/{libssl,libcrypto}.so* ${mysql_install_dir}/lib/lib_bk/ - - if [ -d "${mysql_install_dir}/support-files" ]; then - sed -i 's@executing mysqld_safe@executing mysqld_safe\nexport LD_PRELOAD=/usr/local/lib/libjemalloc.so@' ${mysql_install_dir}/bin/mysqld_safe - sed -i "s+^dbrootpwd.*+dbrootpwd='${dbrootpwd}'+" ../options.conf - echo "${CSUCCESS}MySQL installed successfully! ${CEND}" - if [ "${dbinstallmethod}" == "1" ]; then - rm -rf mysql-${mysql84_ver}-*-x86_64 - elif [ "${dbinstallmethod}" == "2" ]; then - rm -rf mysql-${mysql84_ver} boost_${boostVersion2} - fi - else - rm -rf ${mysql_install_dir} - echo "${CFAILURE}MySQL install failed, Please contact the author! ${CEND}" && grep -Ew 'NAME|ID|ID_LIKE|VERSION_ID|PRETTY_NAME' /etc/os-release - kill -9 $$; exit 1; - fi - - /bin/cp ${mysql_install_dir}/support-files/mysql.server /etc/init.d/mysqld - sed -i "s@^basedir=.*@basedir=${mysql_install_dir}@" /etc/init.d/mysqld - sed -i "s@^datadir=.*@datadir=${mysql_data_dir}@" /etc/init.d/mysqld - chmod +x /etc/init.d/mysqld - [ "${PM}" == 'yum' ] && { chkconfig --add mysqld; chkconfig mysqld on; } - [ "${PM}" == 'apt-get' ] && update-rc.d mysqld defaults - popd - - # my.cnf - cat > /etc/my.cnf << EOF -[client] -port = 3306 -socket = /tmp/mysql.sock -default-character-set = utf8mb4 - -[mysql] -prompt="MySQL [\\d]> " -no-auto-rehash - -[mysqld] -port = 3306 -socket = /tmp/mysql.sock -mysql_native_password = on - -basedir = ${mysql_install_dir} -datadir = ${mysql_data_dir} -pid-file = ${mysql_data_dir}/mysql.pid -user = mysql -bind-address = 0.0.0.0 -server-id = 1 - -init-connect = 'SET NAMES utf8mb4' -character-set-server = utf8mb4 -collation-server = utf8mb4_0900_ai_ci - -skip-name-resolve -#skip-networking -back_log = 300 - -max_connections = 1000 -max_connect_errors = 6000 -open_files_limit = 65535 -table_open_cache = 128 -max_allowed_packet = 500M -binlog_cache_size = 1M -max_heap_table_size = 8M -tmp_table_size = 16M - -read_buffer_size = 2M -read_rnd_buffer_size = 8M -sort_buffer_size = 8M -join_buffer_size = 8M -key_buffer_size = 4M - -thread_cache_size = 8 - -ft_min_word_len = 4 - -log_bin = mysql-bin -binlog_expire_logs_seconds = 604800 - -log_error = ${mysql_data_dir}/mysql-error.log -slow_query_log = 1 -long_query_time = 1 -slow_query_log_file = ${mysql_data_dir}/mysql-slow.log - -performance_schema = 0 -explicit_defaults_for_timestamp - -#lower_case_table_names = 1 - -skip-external-locking - -default_storage_engine = InnoDB -#default-storage-engine = MyISAM -innodb_file_per_table = 1 -innodb_open_files = 500 -innodb_buffer_pool_size = 64M -innodb_write_io_threads = 4 -innodb_read_io_threads = 4 -innodb_thread_concurrency = 0 -innodb_purge_threads = 1 -innodb_flush_log_at_trx_commit = 2 -innodb_log_buffer_size = 2M -#innodb_redo_log_capacity = 2G -innodb_max_dirty_pages_pct = 90 -innodb_lock_wait_timeout = 120 - -bulk_insert_buffer_size = 8M -myisam_sort_buffer_size = 8M -myisam_max_sort_file_size = 10G - -interactive_timeout = 28800 -wait_timeout = 28800 - -[mysqldump] -quick -max_allowed_packet = 500M - -[myisamchk] -key_buffer_size = 8M -sort_buffer_size = 8M -read_buffer = 4M -write_buffer = 4M -EOF - - sed -i "s@max_connections.*@max_connections = $((${Mem}/3))@" /etc/my.cnf - if [ ${Mem} -gt 1500 -a ${Mem} -le 2500 ]; then - sed -i 's@^thread_cache_size.*@thread_cache_size = 16@' /etc/my.cnf - sed -i 's@^myisam_sort_buffer_size.*@myisam_sort_buffer_size = 16M@' /etc/my.cnf - sed -i 's@^key_buffer_size.*@key_buffer_size = 16M@' /etc/my.cnf - sed -i 's@^innodb_buffer_pool_size.*@innodb_buffer_pool_size = 128M@' /etc/my.cnf - sed -i 's@^tmp_table_size.*@tmp_table_size = 32M@' /etc/my.cnf - sed -i 's@^table_open_cache.*@table_open_cache = 256@' /etc/my.cnf - elif [ ${Mem} -gt 2500 -a ${Mem} -le 3500 ]; then - sed -i 's@^thread_cache_size.*@thread_cache_size = 32@' /etc/my.cnf - sed -i 's@^myisam_sort_buffer_size.*@myisam_sort_buffer_size = 32M@' /etc/my.cnf - sed -i 's@^key_buffer_size.*@key_buffer_size = 64M@' /etc/my.cnf - sed -i 's@^innodb_buffer_pool_size.*@innodb_buffer_pool_size = 512M@' /etc/my.cnf - sed -i 's@^tmp_table_size.*@tmp_table_size = 64M@' /etc/my.cnf - sed -i 's@^table_open_cache.*@table_open_cache = 512@' /etc/my.cnf - elif [ ${Mem} -gt 3500 ]; then - sed -i 's@^thread_cache_size.*@thread_cache_size = 64@' /etc/my.cnf - sed -i 's@^myisam_sort_buffer_size.*@myisam_sort_buffer_size = 64M@' /etc/my.cnf - sed -i 's@^key_buffer_size.*@key_buffer_size = 256M@' /etc/my.cnf - sed -i 's@^innodb_buffer_pool_size.*@innodb_buffer_pool_size = 1024M@' /etc/my.cnf - sed -i 's@^tmp_table_size.*@tmp_table_size = 128M@' /etc/my.cnf - sed -i 's@^table_open_cache.*@table_open_cache = 1024@' /etc/my.cnf - fi - - ${mysql_install_dir}/bin/mysqld --initialize-insecure --user=mysql --basedir=${mysql_install_dir} --datadir=${mysql_data_dir} - - [ "${Wsl}" == true ] && chmod 600 /etc/my.cnf - chown mysql:mysql -R ${mysql_data_dir} - [ -d "/etc/mysql" ] && /bin/mv /etc/mysql{,_bk} - service mysqld start - [ -z "$(grep ^'export PATH=' /etc/profile)" ] && echo "export PATH=${mysql_install_dir}/bin:\$PATH" >> /etc/profile - [ -n "$(grep ^'export PATH=' /etc/profile)" -a -z "$(grep ${mysql_install_dir} /etc/profile)" ] && sed -i "s@^export PATH=\(.*\)@export PATH=${mysql_install_dir}/bin:\1@" /etc/profile - . /etc/profile - - ${mysql_install_dir}/bin/mysql -uroot -hlocalhost -e "create user root@'127.0.0.1' identified by \"${dbrootpwd}\";" - ${mysql_install_dir}/bin/mysql -uroot -hlocalhost -e "grant all privileges on *.* to root@'127.0.0.1' with grant option;" - ${mysql_install_dir}/bin/mysql -uroot -hlocalhost -e "grant all privileges on *.* to root@'localhost' with grant option;" - ${mysql_install_dir}/bin/mysql -uroot -hlocalhost -e "alter user root@'localhost' identified by \"${dbrootpwd}\";" - rm -rf /etc/ld.so.conf.d/{mysql,mariadb,percona}*.conf - [ -e "${mysql_install_dir}/my.cnf" ] && rm -f ${mysql_install_dir}/my.cnf - echo "${mysql_install_dir}/lib" > /etc/ld.so.conf.d/z-mysql.conf - ldconfig - service mysqld stop -} diff --git a/include/nginx.sh b/include/nginx.sh index 1202a49a..78bf9f52 100644 --- a/include/nginx.sh +++ b/include/nginx.sh @@ -1,57 +1,63 @@ #!/bin/bash # Author: yeho -# BLOG: https://linuxeye.com +# BLOG: https://blog.linuxeye.com +# +# Notes: OneinStack for CentOS/RadHat 5+ Debian 6+ and Ubuntu 12+ +# +# Project home page: +# https://oneinstack.com +# https://github.com/lj2007331/oneinstack Install_Nginx() { - pushd ${current_dir}/src > /dev/null - id -g ${run_group} >/dev/null 2>&1 - [ $? -ne 0 ] && groupadd ${run_group} - id -u ${run_user} >/dev/null 2>&1 - [ $? -ne 0 ] && useradd -g ${run_group} -M -s /sbin/nologin ${run_user} - - tar xzf pcre-${pcre_ver}.tar.gz - tar xzf nginx-${nginx_ver}.tar.gz - tar xzf openssl-${openssl_ver}.tar.gz - pushd nginx-${nginx_ver} > /dev/null + pushd ${oneinstack_dir}/src + + id -u $run_user >/dev/null 2>&1 + [ $? -ne 0 ] && useradd -M -s /sbin/nologin $run_user + + tar xzf pcre-$pcre_version.tar.gz + tar xzf nginx-$nginx_version.tar.gz + tar xzf openssl-$openssl_version.tar.gz + pushd nginx-$nginx_version # Modify Nginx version #sed -i 's@#define NGINX_VERSION.*$@#define NGINX_VERSION "1.2"@' src/core/nginx.h #sed -i 's@#define NGINX_VER.*NGINX_VERSION$@#define NGINX_VER "Linuxeye/" NGINX_VERSION@' src/core/nginx.h #sed -i 's@Server: nginx@Server: linuxeye@' src/http/ngx_http_header_filter_module.c - + # close debug sed -i 's@CFLAGS="$CFLAGS -g"@#CFLAGS="$CFLAGS -g"@' auto/cc/gcc - - [ ! -d "${nginx_install_dir}" ] && mkdir -p ${nginx_install_dir} - ./configure --prefix=${nginx_install_dir} --user=${run_user} --group=${run_group} --with-http_stub_status_module --with-http_sub_module --with-http_v2_module --with-http_v3_module --with-http_ssl_module --with-stream --with-stream_ssl_preread_module --with-stream_ssl_module --with-http_gzip_static_module --with-http_realip_module --with-http_flv_module --with-http_mp4_module --with-openssl=../openssl-${openssl_ver} --with-pcre=../pcre-${pcre_ver} --with-pcre-jit --with-ld-opt='-ljemalloc' ${nginx_modules_options} + + [ ! -d "$nginx_install_dir" ] && mkdir -p $nginx_install_dir + ./configure --prefix=$nginx_install_dir --user=$run_user --group=$run_user --with-http_stub_status_module --with-http_v2_module --with-http_ssl_module --with-http_gzip_static_module --with-http_realip_module --with-http_flv_module --with-http_mp4_module --with-openssl=../openssl-$openssl_version --with-pcre=../pcre-$pcre_version --with-pcre-jit --with-ld-opt='-ljemalloc' $nginx_modules_options make -j ${THREAD} && make install - if [ -e "${nginx_install_dir}/conf/nginx.conf" ]; then - popd > /dev/null - rm -rf pcre-${pcre_ver} openssl-${openssl_ver} nginx-${nginx_ver} + if [ -e "$nginx_install_dir/conf/nginx.conf" ]; then + popd + rm -rf nginx-$nginx_version echo "${CSUCCESS}Nginx installed successfully! ${CEND}" else - rm -rf ${nginx_install_dir} + rm -rf $nginx_install_dir echo "${CFAILURE}Nginx install failed, Please Contact the author! ${CEND}" - kill -9 $$; exit 1; + kill -9 $$ fi - [ -z "`grep ^'export PATH=' /etc/profile`" ] && echo "export PATH=${nginx_install_dir}/sbin:\$PATH" >> /etc/profile - [ -n "`grep ^'export PATH=' /etc/profile`" -a -z "`grep ${nginx_install_dir} /etc/profile`" ] && sed -i "s@^export PATH=\(.*\)@export PATH=${nginx_install_dir}/sbin:\1@" /etc/profile + [ -z "`grep ^'export PATH=' /etc/profile`" ] && echo "export PATH=$nginx_install_dir/sbin:\$PATH" >> /etc/profile + [ -n "`grep ^'export PATH=' /etc/profile`" -a -z "`grep $nginx_install_dir /etc/profile`" ] && sed -i "s@^export PATH=\(.*\)@export PATH=$nginx_install_dir/sbin:\1@" /etc/profile . /etc/profile + + [ "$OS" == 'CentOS' ] && { /bin/cp ../init.d/Nginx-init-CentOS /etc/init.d/nginx; chkconfig --add nginx; chkconfig nginx on; } + [[ $OS =~ ^Ubuntu$|^Debian$ ]] && { /bin/cp ../init.d/Nginx-init-Ubuntu /etc/init.d/nginx; update-rc.d nginx defaults; } - /bin/cp ../init.d/nginx.service /lib/systemd/system/ - sed -i "s@/usr/local/nginx@${nginx_install_dir}@g" /lib/systemd/system/nginx.service - systemctl enable nginx - - mv ${nginx_install_dir}/conf/nginx.conf{,_bk} - if [ "${apache_flag}" == 'y' ] || [ -e "${apache_install_dir}/bin/httpd" ]; then - /bin/cp ../config/nginx_apache.conf ${nginx_install_dir}/conf/nginx.conf - elif { [[ ${tomcat_option} =~ ^[1-4]$ ]] || [ -e "${tomcat_install_dir}/conf/server.xml" ]; } && { [[ ! ${php_option} =~ ^[1-9]$|^1[0-5]$ ]] && [ ! -e "${php_install_dir}/bin/php" ]; }; then - /bin/cp ../config/nginx_tomcat.conf ${nginx_install_dir}/conf/nginx.conf + sed -i "s@/usr/local/nginx@$nginx_install_dir@g" /etc/init.d/nginx + + mv $nginx_install_dir/conf/nginx.conf{,_bk} + if [[ $Apache_version =~ ^[1-2]$ ]]; then + /bin/cp ../config/nginx_apache.conf $nginx_install_dir/conf/nginx.conf + elif [[ $Tomcat_version =~ ^[1-2]$ ]] && [ ! -e "$php_install_dir/bin/php" ]; then + /bin/cp ../config/nginx_tomcat.conf $nginx_install_dir/conf/nginx.conf else - /bin/cp ../config/nginx.conf ${nginx_install_dir}/conf/nginx.conf - [[ "${php_option}" =~ ^[1-9]$|^1[0-5]$ ]] && [ -z "`grep '/php-fpm_status' ${nginx_install_dir}/conf/nginx.conf`" ] && sed -i "s@index index.html index.php;@index index.html index.php;\n location ~ /php-fpm_status {\n #fastcgi_pass remote_php_ip:9000;\n fastcgi_pass unix:/dev/shm/php-cgi.sock;\n fastcgi_index index.php;\n include fastcgi.conf;\n allow 127.0.0.1;\n deny all;\n }@" ${nginx_install_dir}/conf/nginx.conf + /bin/cp ../config/nginx.conf $nginx_install_dir/conf/nginx.conf + [ "$PHP_yn" == 'y' ] && [ -z "`grep '/php-fpm_status' $nginx_install_dir/conf/nginx.conf`" ] && sed -i "s@index index.html index.php;@index index.html index.php;\n location ~ /php-fpm_status {\n #fastcgi_pass remote_php_ip:9000;\n fastcgi_pass unix:/dev/shm/php-cgi.sock;\n fastcgi_index index.php;\n include fastcgi.conf;\n allow 127.0.0.1;\n deny all;\n }@" $nginx_install_dir/conf/nginx.conf fi - cat > ${nginx_install_dir}/conf/proxy.conf << EOF + cat > $nginx_install_dir/conf/proxy.conf << EOF proxy_connect_timeout 300s; proxy_send_timeout 900; proxy_read_timeout 900; @@ -66,15 +72,14 @@ proxy_set_header Cookie \$http_cookie; proxy_set_header Host \$host; proxy_set_header X-Real-IP \$remote_addr; proxy_set_header X-Forwarded-For \$proxy_add_x_forwarded_for; -proxy_set_header X-Forwarded-Proto \$scheme; EOF - sed -i "s@/data/wwwroot/default@${wwwroot_dir}/default@" ${nginx_install_dir}/conf/nginx.conf - sed -i "s@/data/wwwlogs@${wwwlogs_dir}@g" ${nginx_install_dir}/conf/nginx.conf - sed -i "s@^user www www@user ${run_user} ${run_group}@" ${nginx_install_dir}/conf/nginx.conf - + sed -i "s@/data/wwwroot/default@$wwwroot_dir/default@" $nginx_install_dir/conf/nginx.conf + sed -i "s@/data/wwwlogs@$wwwlogs_dir@g" $nginx_install_dir/conf/nginx.conf + sed -i "s@^user www www@user $run_user $run_user@" $nginx_install_dir/conf/nginx.conf + # logrotate nginx log cat > /etc/logrotate.d/nginx << EOF -${wwwlogs_dir}/*nginx.log { +$wwwlogs_dir/*nginx.log { daily rotate 5 missingok @@ -87,7 +92,7 @@ ${wwwlogs_dir}/*nginx.log { endscript } EOF - popd > /dev/null + popd ldconfig - systemctl start nginx + service nginx start } diff --git a/include/ngx_lua_waf.sh b/include/ngx_lua_waf.sh deleted file mode 100644 index f31f61d4..00000000 --- a/include/ngx_lua_waf.sh +++ /dev/null @@ -1,181 +0,0 @@ -#!/bin/bash -# Author: yeho -# BLOG: https://linuxeye.com - -Nginx_lua_waf() { - pushd ${current_dir}/src > /dev/null - [ ! -e "${nginx_install_dir}/sbin/nginx" ] && echo "${CWARNING}Nginx is not installed on your system! ${CEND}" && exit 1 - if [ ! -e "/usr/local/lib/libluajit-5.1.so.2.1.0" ]; then - [ -e "/usr/local/lib/libluajit-5.1.so.2.0.5" ] && find /usr/local -name *luajit* | xargs rm -rf - src_url=${mirror_link}/src/luajit2-${luajit2_ver}.tar.gz && Download_src - tar xzf luajit2-${luajit2_ver}.tar.gz - pushd luajit2-${luajit2_ver} - make && make install - echo $? || { echo "${CFAILURE}LuaJIT install failed! ${CEND}"; kill -9 $$; exit 1; } - popd > /dev/null - rm -rf luajit2-${luajit2_ver} - fi - - src_url=${mirror_link}/src/lua-resty-core-${lua_resty_core_ver}.tar.gz && Download_src - tar xzf lua-resty-core-${lua_resty_core_ver}.tar.gz - pushd lua-resty-core-${lua_resty_core_ver} - make install - popd > /dev/null - rm -rf lua-resty-core-${lua_resty_core_ver} - - src_url=${mirror_link}/src/lua-resty-lrucache-${lua_resty_lrucache_ver}.tar.gz && Download_src - tar xzf lua-resty-lrucache-${lua_resty_lrucache_ver}.tar.gz - pushd lua-resty-lrucache-${lua_resty_lrucache_ver} - make install - popd > /dev/null - rm -rf lua-resty-lrucache-${lua_resty_lrucache_ver} - - [ ! -h "/usr/local/share/lua/5.1" ] && { rm -rf /usr/local/share/lua/5.1 ; ln -s /usr/local/lib/lua /usr/local/share/lua/5.1; } - if [ ! -e "/usr/local/lib/lua/5.1/cjson.so" ]; then - src_url=${mirror_link}/src/lua-cjson-${lua_cjson_ver}.tar.gz && Download_src - tar xzf lua-cjson-${lua_cjson_ver}.tar.gz - pushd lua-cjson-${lua_cjson_ver} - sed -i 's@^LUA_INCLUDE_DIR.*@&/luajit-2.1@' Makefile - make && make install - [ ! -e "/usr/local/lib/lua/5.1/cjson.so" ] && { echo "${CFAILURE}lua-cjson install failed! ${CEND}"; kill -9 $$; exit 1; } - popd > /dev/null - fi - ${nginx_install_dir}/sbin/nginx -V &> $$ - nginx_configure_args_tmp=`cat $$ | grep 'configure arguments:' | awk -F: '{print $2}'` - rm -rf $$ - nginx_configure_args=`echo ${nginx_configure_args_tmp} | sed "s@--with-openssl=../openssl-\w.\w.\w\+ @--with-openssl=../openssl-${openssl_ver} @" | sed "s@--with-pcre=../pcre-\w.\w\+ @--with-pcre=../pcre-${pcre_ver} @"` - if [ -z "`echo ${nginx_configure_args} | grep lua-nginx-module`" ]; then - src_url=http://nginx.org/download/nginx-${nginx_ver}.tar.gz && Download_src - src_url=${mirror_link}/src/openssl-${openssl_ver}.tar.gz && Download_src - src_url=${mirror_link}/src/pcre-${pcre_ver}.tar.gz && Download_src - src_url=${mirror_link}/src/ngx_devel_kit.tar.gz && Download_src - src_url=${mirror_link}/src/lua-nginx-module-${lua_nginx_module_ver}.tar.gz && Download_src - tar xzf nginx-${nginx_ver}.tar.gz - tar xzf openssl-${openssl_ver}.tar.gz - tar xzf pcre-${pcre_ver}.tar.gz - tar xzf ngx_devel_kit.tar.gz - tar xzf lua-nginx-module-${lua_nginx_module_ver}.tar.gz - pushd nginx-${nginx_ver} - make clean - sed -i 's@CFLAGS="$CFLAGS -g"@#CFLAGS="$CFLAGS -g"@' auto/cc/gcc # close debug - export LUAJIT_LIB=/usr/local/lib - export LUAJIT_INC=/usr/local/include/luajit-2.1 - ./configure ${nginx_configure_args} --with-ld-opt="-Wl,-rpath,/usr/local/lib" --add-module=../lua-nginx-module-${lua_nginx_module_ver} --add-module=../ngx_devel_kit - make -j ${THREAD} - if [ -f "objs/nginx" ]; then - /bin/mv ${nginx_install_dir}/sbin/nginx{,`date +%m%d`} - /bin/cp objs/nginx ${nginx_install_dir}/sbin/nginx - kill -USR2 `cat /var/run/nginx.pid` - sleep 1 - kill -QUIT `cat /var/run/nginx.pid.oldbin` - popd > /dev/null - echo "${CSUCCESS}lua-nginx-module installed successfully! ${CEND}" - sed -i "s@^nginx_modules_options='\(.*\)'@nginx_modules_options=\'\1 --with-ld-opt=\"-Wl,-rpath,/usr/local/lib\" --add-module=../lua-nginx-module-${lua_nginx_module_ver} --add-module=../ngx_devel_kit\'@" ../options.conf - rm -rf nginx-${nginx_ver} - else - echo "${CFAILURE}lua-nginx-module install failed! ${CEND}" - kill -9 $$; exit 1; - fi - fi - popd > /dev/null -} - -Tengine_lua_waf() { - pushd ${current_dir}/src > /dev/null - [ ! -e "${tengine_install_dir}/sbin/nginx" ] && echo "${CWARNING}Tengine is not installed on your system! ${CEND}" && exit 1 - if [ ! -e "/usr/local/lib/libluajit-5.1.so.2.1.0" ]; then - [ -e "/usr/local/lib/libluajit-5.1.so.2.0.5" ] && find /usr/local -name *luajit* | xargs rm -rf - src_url=${mirror_link}/src/luajit2-${luajit2_ver}.tar.gz && Download_src - tar xzf luajit2-${luajit2_ver}.tar.gz - pushd luajit2-${luajit2_ver} - make && make install - [ ! -e "/usr/local/lib/libluajit-5.1.so.2.1.0" ] && { echo "${CFAILURE}LuaJIT install failed! ${CEND}"; kill -9 $$; exit 1; } - popd > /dev/null - fi - if [ ! -e "/usr/local/lib/lua/5.1/cjson.so" ]; then - src_url=${mirror_link}/src/lua-cjson-${lua_cjson_ver}.tar.gz && Download_src - tar xzf lua-cjson-${lua_cjson_ver}.tar.gz - pushd lua-cjson-${lua_cjson_ver} - sed -i 's@^LUA_INCLUDE_DIR.*@&/luajit-2.1@' Makefile - make && make install - [ ! -e "/usr/local/lib/lua/5.1/cjson.so" ] && { echo "${CFAILURE}lua-cjson install failed! ${CEND}"; kill -9 $$; exit 1; } - popd > /dev/null - fi - ${tengine_install_dir}/sbin/nginx -V &> $$ - tengine_configure_args_tmp=`cat $$ | grep 'configure arguments:' | awk -F: '{print $2}'` - rm -rf $$ - tengine_configure_args=`echo ${tengine_configure_args_tmp} | sed "s@--with-openssl=../openssl-\w.\w.\w\+ @--with-openssl=../openssl-${openssl_ver} @" | sed "s@--with-pcre=../pcre-\w.\w\+ @--with-pcre=../pcre-${pcre_ver} @"` - if [ -z "`echo ${tengine_configure_args} | grep lua`" ]; then - src_url=http://tengine.taobao.org/download/tengine-${tengine_ver}.tar.gz && Download_src - src_url=${mirror_link}/src/openssl-${openssl_ver}.tar.gz && Download_src - src_url=${mirror_link}/src/pcre-${pcre_ver}.tar.gz && Download_src - src_url=${mirror_link}/src/ngx_devel_kit.tar.gz && Download_src - src_url=${mirror_link}/src/lua-nginx-module.tar.gz && Download_src - tar xzf tengine-${tengine_ver}.tar.gz - tar xzf openssl-${openssl_ver}.tar.gz - tar xzf pcre-${pcre_ver}.tar.gz - tar xzf ngx_devel_kit.tar.gz - tar xzf lua-nginx-module.tar.gz - pushd tengine-${tengine_ver} - make clean - export LUAJIT_LIB=/usr/local/lib - export LUAJIT_INC=/usr/local/include/luajit-2.1 - ./configure ${tengine_configure_args} --with-ld-opt="-Wl,-rpath,/usr/local/lib" --add-module=../lua-nginx-module --add-module=../ngx_devel_kit - make -j ${THREAD} - if [ -f "objs/nginx" ]; then - /bin/mv ${tengine_install_dir}/sbin/nginx{,`date +%m%d`} - /bin/mv ${tengine_install_dir}/modules{,`date +%m%d`} - /bin/cp objs/nginx ${tengine_install_dir}/sbin/nginx - chmod +x ${tengine_install_dir}/sbin/* - make install - kill -USR2 `cat /var/run/nginx.pid` - sleep 1 - kill -QUIT `cat /var/run/nginx.pid.oldbin` - popd > /dev/null - sed -i "s@^nginx_modules_options='\(.*\)'@nginx_modules_options=\'\1 --with-ld-opt=\"-Wl,-rpath,/usr/local/lib\" --add-module=../lua-nginx-module --add-module=../ngx_devel_kit\'@" ../options.conf - echo "${CSUCCESS}lua_module installed successfully! ${CEND}" - rm -rf tengine-${tengine_ver} - else - echo "${CFAILURE}lua_module install failed! ${CEND}" - kill -9 $$; exit 1; - fi - fi - popd > /dev/null -} - -enable_lua_waf() { - pushd ${current_dir}/src > /dev/null - . ../include/check_dir.sh - rm -f ngx_lua_waf.tar.gz - src_url=${mirror_link}/src/ngx_lua_waf.tar.gz && Download_src - tar xzf ngx_lua_waf.tar.gz -C ${web_install_dir}/conf - [ -e "${web_install_dir}/conf/resty" ] && /bin/mv ${web_install_dir}/conf/resty{,_bak} - sed -i "s@/usr/local/nginx@${web_install_dir}@g" ${web_install_dir}/conf/waf.conf - sed -i "s@/usr/local/nginx@${web_install_dir}@" ${web_install_dir}/conf/waf/config.lua - sed -i "s@/data/wwwlogs@${wwwlogs_dir}@" ${web_install_dir}/conf/waf/config.lua - [ -z "`grep 'include waf.conf;' ${web_install_dir}/conf/nginx.conf`" ] && sed -i "s@ vhost/\*.conf;@&\n include waf.conf;@" ${web_install_dir}/conf/nginx.conf - ${web_install_dir}/sbin/nginx -t - if [ $? -eq 0 ]; then - service nginx reload - echo "${CSUCCESS}ngx_lua_waf enabled successfully! ${CEND}" - chown ${run_user}:${run_group} ${wwwlogs_dir} - else - echo "${CFAILURE}ngx_lua_waf enable failed! ${CEND}" - fi - popd > /dev/null -} - -disable_lua_waf() { - pushd ${current_dir}/src > /dev/null - . ../include/check_dir.sh - sed -i '/include waf.conf;/d' ${web_install_dir}/conf/nginx.conf - ${web_install_dir}/sbin/nginx -t - if [ $? -eq 0 ]; then - rm -rf ${web_install_dir}/conf/{waf,waf.conf} - service nginx reload - echo "${CSUCCESS}ngx_lua_waf disabled successfully! ${CEND}" - else - echo "${CFAILURE}ngx_lua_waf disable failed! ${CEND}" - fi - popd > /dev/null -} diff --git a/include/nodejs.sh b/include/nodejs.sh deleted file mode 100644 index a92ad20f..00000000 --- a/include/nodejs.sh +++ /dev/null @@ -1,29 +0,0 @@ -#!/bin/bash -# Author: yeho -# BLOG: https://linuxeye.com - -Install_Nodejs() { - pushd ${current_dir}/src > /dev/null - tar xzf node-v${nodejs_ver}-linux-${SYS_ARCH_n}.tar.gz - /bin/mv node-v${nodejs_ver}-linux-${SYS_ARCH_n} ${nodejs_install_dir} - if [ -e "${nodejs_install_dir}/bin/node" ]; then - cat > /etc/profile.d/nodejs.sh << EOF -export NODE_HOME=${nodejs_install_dir} -export PATH=\$NODE_HOME/bin:\$PATH -EOF - . /etc/profile - echo "${CSUCCESS}Nodejs installed successfully! ${CEND}" - else - echo "${CFAILURE}Nodejs install failed, Please contact the author! ${CEND}" && grep -Ew 'NAME|ID|ID_LIKE|VERSION_ID|PRETTY_NAME' /etc/os-release - kill -9 $$; exit 1; - fi - popd > /dev/null -} - -Uninstall_Nodejs() { - if [ -e "${nodejs_install_dir}" ]; then - rm -rf ${nodejs_install_dir} /etc/profile.d/nodejs.sh - echo "${CMSG}Nodejs uninstall completed! ${CEND}" - fi -} - diff --git a/include/ois.aarch64 b/include/ois.aarch64 deleted file mode 100755 index 48720a18..00000000 Binary files a/include/ois.aarch64 and /dev/null differ diff --git a/include/ois.x86_64 b/include/ois.x86_64 deleted file mode 100755 index 38aeca7b..00000000 Binary files a/include/ois.x86_64 and /dev/null differ diff --git a/include/openjdk-11.sh b/include/openjdk-11.sh deleted file mode 100644 index 062dfc14..00000000 --- a/include/openjdk-11.sh +++ /dev/null @@ -1,43 +0,0 @@ -#!/bin/bash -# Author: yeho -# BLOG: https://linuxeye.com - -Install_OpenJDK11() { - if [ "${Family}" == 'rhel' ]; then - yum -y install java-11-openjdk-devel - JAVA_HOME=/usr/lib/jvm/java-11-openjdk - elif [ "${Family}" == 'debian' ]; then - if [[ "${Debian_ver}" =~ ^12$ ]]; then - cat ${current_dir}/src/adoptium.key | sudo apt-key add - - apt-add-repository --yes https://mirrors.tuna.tsinghua.edu.cn/Adoptium/deb - apt -y update - apt-get --no-install-recommends -y install temurin-11-jdk - JAVA_HOME=/usr/lib/jvm/temurin-11-jdk-${SYS_ARCH} - else - apt-get --no-install-recommends -y install openjdk-11-jdk - JAVA_HOME=/usr/lib/jvm/java-11-openjdk-${SYS_ARCH} - fi - elif [ "${Family}" == 'ubuntu' ]; then - if [[ "${Ubuntu_ver}" =~ ^16$ ]]; then - cat ${current_dir}/src/adoptium.key | sudo apt-key add - - apt-add-repository --yes https://mirrors.tuna.tsinghua.edu.cn/Adoptium/deb - apt -y update - apt-get --no-install-recommends -y install temurin-11-jdk - JAVA_HOME=/usr/lib/jvm/temurin-11-jdk-${SYS_ARCH} - else - apt-get --no-install-recommends -y install openjdk-11-jdk - JAVA_HOME=/usr/lib/jvm/java-11-openjdk-${SYS_ARCH} - fi - fi - if [ -e "${JAVA_HOME}/bin/java" ]; then - cat > /etc/profile.d/openjdk.sh << EOF -export JAVA_HOME=${JAVA_HOME} -export CLASSPATH=\$JAVA_HOME/lib/tools.jar:\$JAVA_HOME/lib/dt.jar:\$JAVA_HOME/lib -EOF - . /etc/profile.d/openjdk.sh - echo "${CSUCCESS}OpenJDK11 installed successfully! ${CEND}" - else - echo "${CFAILURE}OpenJDK11 install failed, Please contact the author! ${CEND}" && grep -Ew 'NAME|ID|ID_LIKE|VERSION_ID|PRETTY_NAME' /etc/os-release - kill -9 $$; exit 1; - fi -} diff --git a/include/openjdk-17.sh b/include/openjdk-17.sh deleted file mode 100644 index 8a78e1f9..00000000 --- a/include/openjdk-17.sh +++ /dev/null @@ -1,66 +0,0 @@ -#!/bin/bash -# Author: yeho -# BLOG: https://linuxeye.com - -Install_OpenJDK17() { - if [ "${Family}" == 'rhel' ]; then - if [[ "${RHEL_ver}" =~ ^7$ ]]; then - cat > /etc/yum.repos.d/adoptium.repo << EOF -[Adoptium] -name=Adoptium -baseurl=https://mirrors.tuna.tsinghua.edu.cn/Adoptium/rpm/rhel\$releasever-\$basearch/ -enabled=1 -gpgcheck=0 -EOF - yum -y install temurin-17-jdk - JAVA_HOME=/usr/lib/jvm/temurin-17-jdk - elif [[ "${Platform}" =~ ^hce$ ]]; then - cat > /etc/yum.repos.d/adoptium.repo << EOF - [Adoptium] -name=Adoptium -baseurl=https://mirrors.tuna.tsinghua.edu.cn/Adoptium/rpm/rhel8-\$basearch/ -enabled=1 -gpgcheck=0 -EOF - yum -y install temurin-17-jdk - JAVA_HOME=/usr/lib/jvm/temurin-17-jdk - else - yum -y install java-17-openjdk-devel - JAVA_HOME=/usr/lib/jvm/java-17-openjdk - fi - elif [ "${Family}" == 'debian' ]; then - if [[ "${Debian_ver}" =~ ^9$|^10$ ]]; then - #wget -qO - https://packages.adoptium.net/artifactory/api/gpg/key/public | apt-key add - - cat ${current_dir}/src/adoptium.key | sudo apt-key add - - apt-add-repository --yes https://mirrors.tuna.tsinghua.edu.cn/Adoptium/deb - apt -y update - apt-get --no-install-recommends -y install temurin-17-jdk - JAVA_HOME=/usr/lib/jvm/temurin-17-jdk-${SYS_ARCH} - else - apt-get --no-install-recommends -y install openjdk-17-jdk - JAVA_HOME=/usr/lib/jvm/java-17-openjdk-${SYS_ARCH} - fi - elif [ "${Family}" == 'ubuntu' ]; then - if [[ "${Ubuntu_ver}" =~ ^16$ ]]; then - cat ${current_dir}/src/adoptium.key | sudo apt-key add - - apt-add-repository --yes https://mirrors.tuna.tsinghua.edu.cn/Adoptium/deb - apt -y update - apt-get --no-install-recommends -y install temurin-17-jdk - JAVA_HOME=/usr/lib/jvm/temurin-17-jdk-${SYS_ARCH} - else - apt-get --no-install-recommends -y install openjdk-17-jdk - JAVA_HOME=/usr/lib/jvm/java-17-openjdk-${SYS_ARCH} - fi - fi - if [ -e "${JAVA_HOME}/bin/java" ]; then - cat > /etc/profile.d/openjdk.sh << EOF -export JAVA_HOME=${JAVA_HOME} -export CLASSPATH=\$JAVA_HOME/lib/tools.jar:\$JAVA_HOME/lib/dt.jar:\$JAVA_HOME/lib -EOF - . /etc/profile.d/openjdk.sh - echo "${CSUCCESS}OpenJDK17 installed successfully! ${CEND}" - else - echo "${CFAILURE}OpenJDK17 install failed, Please contact the author! ${CEND}" && grep -Ew 'NAME|ID|ID_LIKE|VERSION_ID|PRETTY_NAME' /etc/os-release - kill -9 $$; exit 1; - fi -} diff --git a/include/openjdk-8.sh b/include/openjdk-8.sh deleted file mode 100644 index 8aa31872..00000000 --- a/include/openjdk-8.sh +++ /dev/null @@ -1,36 +0,0 @@ -#!/bin/bash -# Author: yeho -# BLOG: https://linuxeye.com - -Install_OpenJDK8() { - if [ "${Family}" == 'rhel' ]; then - yum -y install java-1.8.0-openjdk-devel - JAVA_HOME=/usr/lib/jvm/java-1.8.0-openjdk - elif [ "${Family}" == 'debian' ]; then - if [[ "${Debian_ver}" =~ ^9$ ]]; then - apt-get --no-install-recommends -y install openjdk-8-jdk - JAVA_HOME=/usr/lib/jvm/java-8-openjdk-${SYS_ARCH} - else - #wget -qO - https://packages.adoptium.net/artifactory/api/gpg/key/public | apt-key add - - cat ${current_dir}/src/adoptium.key | sudo apt-key add - - apt-add-repository --yes https://mirrors.tuna.tsinghua.edu.cn/Adoptium/deb - apt -y update - apt-get --no-install-recommends -y install temurin-8-jdk - JAVA_HOME=/usr/lib/jvm/temurin-8-jdk-${SYS_ARCH} - fi - elif [ "${Family}" == 'ubuntu' ]; then - apt-get --no-install-recommends -y install openjdk-8-jdk - JAVA_HOME=/usr/lib/jvm/java-8-openjdk-${SYS_ARCH} - fi - if [ -e "${JAVA_HOME}/bin/java" ]; then - cat > /etc/profile.d/openjdk.sh << EOF -export JAVA_HOME=${JAVA_HOME} -export CLASSPATH=\$JAVA_HOME/lib/tools.jar:\$JAVA_HOME/lib/dt.jar:\$JAVA_HOME/lib -EOF - . /etc/profile.d/openjdk.sh - echo "${CSUCCESS}OpenJDK8 installed successfully! ${CEND}" - else - echo "${CFAILURE}OpenJDK8 install failed, Please contact the author! ${CEND}" && grep -Ew 'NAME|ID|ID_LIKE|VERSION_ID|PRETTY_NAME' /etc/os-release - kill -9 $$; exit 1; - fi -} diff --git a/include/openresty.sh b/include/openresty.sh index c893030f..cbb064b2 100644 --- a/include/openresty.sh +++ b/include/openresty.sh @@ -1,53 +1,60 @@ #!/bin/bash # Author: yeho -# BLOG: https://linuxeye.com +# BLOG: https://blog.linuxeye.com +# +# Notes: OneinStack for CentOS/RadHat 5+ Debian 6+ and Ubuntu 12+ +# +# Project home page: +# https://oneinstack.com +# https://github.com/lj2007331/oneinstack Install_OpenResty() { - pushd ${current_dir}/src > /dev/null - id -g ${run_group} >/dev/null 2>&1 - [ $? -ne 0 ] && groupadd ${run_group} - id -u ${run_user} >/dev/null 2>&1 - [ $? -ne 0 ] && useradd -g ${run_group} -M -s /sbin/nologin ${run_user} - - tar xzf pcre-${pcre_ver}.tar.gz - tar xzf openresty-${openresty_ver}.tar.gz - tar xzf openssl-${openssl_ver}.tar.gz - pushd openresty-${openresty_ver} > /dev/null - + pushd ${oneinstack_dir}/src + + id -u $run_user >/dev/null 2>&1 + [ $? -ne 0 ] && useradd -M -s /sbin/nologin $run_user + + tar xzf pcre-$pcre_version.tar.gz + tar xzf openresty-$openresty_version.tar.gz + tar xzf openssl-$openssl_version.tar.gz + pushd openresty-$openresty_version + # close debug - sed -i 's@CFLAGS="$CFLAGS -g"@#CFLAGS="$CFLAGS -g"@' bundle/nginx-${openresty_ver%.*}/auto/cc/gcc # close debug - - [ ! -d "${openresty_install_dir}" ] && mkdir -p ${openresty_install_dir} - ./configure --prefix=${openresty_install_dir} --user=${run_user} --group=${run_group} --with-http_stub_status_module --with-http_sub_module --with-http_v2_module --with-http_v3_module --with-http_ssl_module --with-http_gzip_static_module --with-http_realip_module --with-http_flv_module --with-http_mp4_module --with-openssl=../openssl-${openssl_ver} --with-pcre=../pcre-${pcre_ver} --with-pcre-jit --with-ld-opt='-ljemalloc -Wl,-u,pcre_version' ${nginx_modules_options} + openresty_version_tmp=${openresty_version%.*} + sed -i 's@CFLAGS="$CFLAGS -g"@#CFLAGS="$CFLAGS -g"@' bundle/nginx-$openresty_version_tmp/auto/cc/gcc # close debug + + [ ! -d "$openresty_install_dir" ] && mkdir -p $openresty_install_dir + ./configure --prefix=$openresty_install_dir --user=$run_user --group=$run_user --with-http_stub_status_module --with-http_v2_module --with-http_ssl_module --with-http_gzip_static_module --with-http_realip_module --with-http_flv_module --with-http_mp4_module --with-openssl=../openssl-$openssl_version --with-pcre=../pcre-$pcre_version --with-pcre-jit --with-ld-opt='-ljemalloc' $nginx_modules_options make -j ${THREAD} && make install - if [ -e "${openresty_install_dir}/nginx/conf/nginx.conf" ]; then - popd > /dev/null - rm -rf pcre-${pcre_ver} openssl-${openssl_ver} openresty-${openresty_ver} + if [ -e "$openresty_install_dir/nginx/conf/nginx.conf" ]; then + popd + rm -rf openresty-$openresty_version echo "${CSUCCESS}OpenResty installed successfully! ${CEND}" else - rm -rf ${openresty_install_dir} + rm -rf $openresty_install_dir echo "${CFAILURE}OpenResty install failed, Please Contact the author! ${CEND}" - kill -9 $$; exit 1; + kill -9 $$ fi - [ -z "`grep ^'export PATH=' /etc/profile`" ] && echo "export PATH=${openresty_install_dir}/nginx/sbin:\$PATH" >> /etc/profile - [ -n "`grep ^'export PATH=' /etc/profile`" -a -z "`grep ${openresty_install_dir} /etc/profile`" ] && sed -i "s@^export PATH=\(.*\)@export PATH=${openresty_install_dir}/nginx/sbin:\1@" /etc/profile + [ -z "`grep ^'export PATH=' /etc/profile`" ] && echo "export PATH=$openresty_install_dir/nginx/sbin:\$PATH" >> /etc/profile + [ -n "`grep ^'export PATH=' /etc/profile`" -a -z "`grep $openresty_install_dir /etc/profile`" ] && sed -i "s@^export PATH=\(.*\)@export PATH=$openresty_install_dir/nginx/sbin:\1@" /etc/profile . /etc/profile - - /bin/cp ../init.d/nginx.service /lib/systemd/system/ - sed -i "s@/usr/local/nginx@${openresty_install_dir}/nginx@g" /lib/systemd/system/nginx.service - systemctl enable nginx - - mv ${openresty_install_dir}/nginx/conf/nginx.conf{,_bk} - if [ "${apache_flag}" == 'y' ] || [ -e "${apache_install_dir}/bin/httpd" ]; then - /bin/cp ../config/nginx_apache.conf ${openresty_install_dir}/nginx/conf/nginx.conf - elif { [[ ${tomcat_option} =~ ^[1-4]$ ]] || [ -e "${tomcat_install_dir}/conf/server.xml" ]; } && { [[ ! ${php_option} =~ ^[1-9]$|^1[0-5]$ ]] && [ ! -e "${php_install_dir}/bin/php" ]; }; then - /bin/cp ../config/nginx_tomcat.conf ${openresty_install_dir}/nginx/conf/nginx.conf + + [ "$OS" == 'CentOS' ] && { /bin/cp ../init.d/Nginx-init-CentOS /etc/init.d/nginx; chkconfig --add nginx; chkconfig nginx on; } + [[ $OS =~ ^Ubuntu$|^Debian$ ]] && { /bin/cp ../init.d/Nginx-init-Ubuntu /etc/init.d/nginx; update-rc.d nginx defaults; } + + sed -i "s@/usr/local/nginx@$openresty_install_dir/nginx@g" /etc/init.d/nginx + + mv $openresty_install_dir/nginx/conf/nginx.conf{,_bk} + if [[ $Apache_version =~ ^[1-2]$ ]]; then + /bin/cp ../config/nginx_apache.conf $openresty_install_dir/nginx/conf/nginx.conf + elif [[ $Tomcat_version =~ ^[1-2]$ ]] && [ ! -e "$php_install_dir/bin/php" ]; then + /bin/cp ../config/nginx_tomcat.conf $openresty_install_dir/nginx/conf/nginx.conf else - /bin/cp ../config/nginx.conf ${openresty_install_dir}/nginx/conf/nginx.conf - [[ "${php_option}" =~ ^[1-9]$|^1[0-5]$ ]] && [ -z "`grep '/php-fpm_status' ${openresty_install_dir}/nginx/conf/nginx.conf`" ] && sed -i "s@index index.html index.php;@index index.html index.php;\n location ~ /php-fpm_status {\n #fastcgi_pass remote_php_ip:9000;\n fastcgi_pass unix:/dev/shm/php-cgi.sock;\n fastcgi_index index.php;\n include fastcgi.conf;\n allow 127.0.0.1;\n deny all;\n }@" ${openresty_install_dir}/nginx/conf/nginx.conf + /bin/cp ../config/nginx.conf $openresty_install_dir/nginx/conf/nginx.conf + [ "$PHP_yn" == 'y' ] && [ -z "`grep '/php-fpm_status' $openresty_install_dir/nginx/conf/nginx.conf`" ] && sed -i "s@index index.html index.php;@index index.html index.php;\n location ~ /php-fpm_status {\n #fastcgi_pass remote_php_ip:9000;\n fastcgi_pass unix:/dev/shm/php-cgi.sock;\n fastcgi_index index.php;\n include fastcgi.conf;\n allow 127.0.0.1;\n deny all;\n }@" $openresty_install_dir/nginx/conf/nginx.conf fi - cat > ${openresty_install_dir}/nginx/conf/proxy.conf << EOF + cat > $openresty_install_dir/nginx/conf/proxy.conf << EOF proxy_connect_timeout 300s; proxy_send_timeout 900; proxy_read_timeout 900; @@ -62,15 +69,14 @@ proxy_set_header Cookie \$http_cookie; proxy_set_header Host \$host; proxy_set_header X-Real-IP \$remote_addr; proxy_set_header X-Forwarded-For \$proxy_add_x_forwarded_for; -proxy_set_header X-Forwarded-Proto \$scheme; EOF - sed -i "s@/data/wwwroot/default@${wwwroot_dir}/default@" ${openresty_install_dir}/nginx/conf/nginx.conf - sed -i "s@/data/wwwlogs@${wwwlogs_dir}@g" ${openresty_install_dir}/nginx/conf/nginx.conf - sed -i "s@^user www www@user ${run_user} ${run_group}@" ${openresty_install_dir}/nginx/conf/nginx.conf - + sed -i "s@/data/wwwroot/default@$wwwroot_dir/default@" $openresty_install_dir/nginx/conf/nginx.conf + sed -i "s@/data/wwwlogs@$wwwlogs_dir@g" $openresty_install_dir/nginx/conf/nginx.conf + sed -i "s@^user www www@user $run_user $run_user@" $openresty_install_dir/nginx/conf/nginx.conf + # logrotate nginx log cat > /etc/logrotate.d/nginx << EOF -${wwwlogs_dir}/*nginx.log { +$wwwlogs_dir/*nginx.log { daily rotate 5 missingok @@ -83,7 +89,7 @@ ${wwwlogs_dir}/*nginx.log { endscript } EOF - popd > /dev/null + popd ldconfig - systemctl start nginx + service nginx start } diff --git a/include/openssl.sh b/include/openssl.sh index cb203b88..f5eed84a 100644 --- a/include/openssl.sh +++ b/include/openssl.sh @@ -1,188 +1,50 @@ #!/bin/bash # Author: yeho -# BLOG: https://linuxeye.com - -if openssl version | grep -Eqi 'OpenSSL 1.0.2*'; then - php5_with_openssl="--with-openssl" - php70_with_openssl="--with-openssl" - php71_with_openssl="--with-openssl" - php72_with_openssl="--with-openssl" - php73_with_openssl="--with-openssl" - php74_with_openssl="--with-openssl" - php80_with_openssl="--with-openssl" - php81_with_openssl="--with-openssl" - php82_with_openssl="--with-openssl" - php83_with_openssl="--with-openssl" - php84_with_openssl="--with-openssl" - php85_with_openssl="--with-openssl" - - php5_with_ssl="--with-ssl" - php70_with_ssl="--with-ssl" - php71_with_ssl="--with-ssl" - php72_with_ssl="--with-ssl" - php73_with_ssl="--with-ssl" - php74_with_ssl="--with-ssl" - php80_with_ssl="--with-ssl" - php81_with_ssl="--with-ssl" - php82_with_ssl="--with-ssl" - php83_with_ssl="--with-ssl" - php84_with_ssl="--with-ssl" - php85_with_ssl="--with-ssl" - - php5_with_curl="--with-curl" - php70_with_curl="--with-curl" - php71_with_curl="--with-curl" - php72_with_curl="--with-curl" - php73_with_curl="--with-curl" - php74_with_curl="--with-curl" - php80_with_curl="--with-curl" - php81_with_curl="--with-curl" - php82_with_curl="--with-curl" - php83_with_curl="--with-curl" - php84_with_curl="--with-curl" - php85_with_curl="--with-curl" -elif openssl version | grep -Eqi 'OpenSSL 1.1.*'; then - php5_with_openssl="--with-openssl=${openssl_install_dir}" - php70_with_openssl="--with-openssl" - php71_with_openssl="--with-openssl" - php72_with_openssl="--with-openssl" - php73_with_openssl="--with-openssl" - php74_with_openssl="--with-openssl" - php80_with_openssl="--with-openssl" - php81_with_openssl="--with-openssl" - php82_with_openssl="--with-openssl" - php83_with_openssl="--with-openssl" - php84_with_openssl="--with-openssl" - php85_with_openssl="--with-openssl" - - php5_with_ssl="--with-ssl=${openssl_install_dir}" - php70_with_ssl="--with-ssl" - php71_with_ssl="--with-ssl" - php72_with_ssl="--with-ssl" - php73_with_ssl="--with-ssl" - php74_with_ssl="--with-ssl" - php80_with_ssl="--with-ssl" - php81_with_ssl="--with-ssl" - php82_with_ssl="--with-ssl" - php83_with_ssl="--with-ssl" - php84_with_ssl="--with-ssl" - php85_with_ssl="--with-ssl" - - php5_with_curl="--with-curl=${curl_install_dir}" - php70_with_curl="--with-curl" - php71_with_curl="--with-curl" - php72_with_curl="--with-curl" - php73_with_curl="--with-curl" - php74_with_curl="--with-curl" - php80_with_curl="--with-curl" - php81_with_curl="--with-curl" - php82_with_curl="--with-curl" - php83_with_curl="--with-curl" - php84_with_curl="--with-curl" - php85_with_curl="--with-curl" - [[ ${php_option} =~ ^[1-4]$ ]] || [[ "${mphp_ver}" =~ ^5[3-6]$ ]] && with_old_openssl_flag=y -elif openssl version | grep -Eqi 'OpenSSL 3.*'; then - php5_with_openssl="--with-openssl=${openssl_install_dir}" - php70_with_openssl="--with-openssl=${openssl_install_dir}" - php71_with_openssl="--with-openssl" - php72_with_openssl="--with-openssl" - php73_with_openssl="--with-openssl" - php74_with_openssl="--with-openssl" - php80_with_openssl="--with-openssl" - php81_with_openssl="--with-openssl" - php82_with_openssl="--with-openssl" - php83_with_openssl="--with-openssl" - php84_with_openssl="--with-openssl" - php85_with_openssl="--with-openssl" - - php5_with_ssl="--with-ssl=${openssl_install_dir}" - php70_with_ssl="--with-ssl=${openssl_install_dir}" - php71_with_ssl="--with-ssl" - php72_with_ssl="--with-ssl" - php73_with_ssl="--with-ssl" - php74_with_ssl="--with-ssl" - php80_with_ssl="--with-ssl" - php81_with_ssl="--with-ssl" - php82_with_ssl="--with-ssl" - php83_with_ssl="--with-ssl" - php84_with_ssl="--with-ssl" - php85_with_ssl="--with-ssl" - - php5_with_curl="--with-curl=${curl_install_dir}" - php70_with_curl="--with-curl=${curl_install_dir}" - php71_with_curl="--with-curl" - php72_with_curl="--with-curl" - php73_with_curl="--with-curl" - php74_with_curl="--with-curl" - php80_with_curl="--with-curl" - php81_with_curl="--with-curl" - php82_with_curl="--with-curl" - php83_with_curl="--with-curl" - php84_with_curl="--with-curl" - php85_with_curl="--with-curl" - [[ ${php_option} =~ ^[1-5]$ ]] || [[ "${mphp_ver}" =~ ^5[3-6]$|^70$ ]] && with_old_openssl_flag=y -else - php5_with_openssl="--with-openssl=${openssl_install_dir}" - php70_with_openssl="--with-openssl=${openssl_install_dir}" - php71_with_openssl="--with-openssl=${openssl_install_dir}" - php72_with_openssl="--with-openssl=${openssl_install_dir}" - php73_with_openssl="--with-openssl=${openssl_install_dir}" - php74_with_openssl="--with-openssl=${openssl_install_dir} --with-openssl-dir=${openssl_install_dir}" - php80_with_openssl="--with-openssl=${openssl_install_dir} --with-openssl-dir=${openssl_install_dir}" - php81_with_openssl="--with-openssl=${openssl_install_dir} --with-openssl-dir=${openssl_install_dir}" - php82_with_openssl="--with-openssl=${openssl_install_dir} --with-openssl-dir=${openssl_install_dir}" - php83_with_openssl="--with-openssl=${openssl_install_dir} --with-openssl-dir=${openssl_install_dir}" - php84_with_openssl="--with-openssl=${openssl_install_dir} --with-openssl-dir=${openssl_install_dir}" - php85_with_openssl="--with-openssl=${openssl_install_dir} --with-openssl-dir=${openssl_install_dir}" - - php5_with_ssl="--with-ssl=${openssl_install_dir}" - php70_with_ssl="--with-ssl=${openssl_install_dir}" - php71_with_ssl="--with-ssl=${openssl_install_dir}" - php72_with_ssl="--with-ssl=${openssl_install_dir}" - php73_with_ssl="--with-ssl=${openssl_install_dir}" - php74_with_ssl="--with-ssl=${openssl_install_dir}" - php80_with_ssl="--with-ssl=${openssl_install_dir}" - php81_with_ssl="--with-ssl=${openssl_install_dir}" - php82_with_ssl="--with-ssl=${openssl_install_dir}" - php83_with_ssl="--with-ssl=${openssl_install_dir}" - php84_with_ssl="--with-ssl=${openssl_install_dir}" - php85_with_ssl="--with-ssl=${openssl_install_dir}" - - php5_with_curl="--with-curl=${curl_install_dir}" - php70_with_curl="--with-curl=${curl_install_dir}" - php71_with_curl="--with-curl=${curl_install_dir}" - php72_with_curl="--with-curl=${curl_install_dir}" - php73_with_curl="--with-curl=${curl_install_dir}" - php74_with_curl="--with-curl=${curl_install_dir}" - php80_with_curl="--with-curl=${curl_install_dir}" - php81_with_curl="--with-curl=${curl_install_dir}" - php82_with_curl="--with-curl=${curl_install_dir}" - php83_with_curl="--with-curl=${curl_install_dir}" - php84_with_curl="--with-curl=${curl_install_dir}" - php85_with_curl="--with-curl=${curl_install_dir}" - with_old_openssl_flag=y -fi +# BLOG: https://blog.linuxeye.com +# +# Notes: OneinStack for CentOS/RadHat 5+ Debian 6+ and Ubuntu 12+ +# +# Project home page: +# https://oneinstack.com +# https://github.com/lj2007331/oneinstack + +Install_openSSL102() { + if [ ! -e "${openssl_install_dir}/lib/libcrypto.a" ]; then + # install openssl-1.0.2 + pushd ${oneinstack_dir}/src + tar xzf openssl-${openssl_version}.tar.gz + pushd openssl-${openssl_version} + make clean + ./config --prefix=${openssl_install_dir} -fPIC shared zlib-dynamic + make -j ${THREAD} && make install + popd + if [ -f "${openssl_install_dir}/lib/libcrypto.a" ]; then + echo "${CSUCCESS}openssl-1.0.2 module installed successfully! ${CEND}" + rm -rf openssl-${openssl_version} + else + echo "${CFAILURE}openssl-1.0.2 install failed, Please contact the author! ${CEND}" + kill -9 $$ + fi + popd + fi +} -Install_openSSL() { - if [ "${with_old_openssl_flag}" == 'y' ]; then - if [ ! -e "${openssl_install_dir}/lib/libssl.a" ]; then - pushd ${current_dir}/src > /dev/null - tar xzf openssl-1.0.2u.tar.gz - pushd openssl-1.0.2u > /dev/null - make clean - ./config -Wl,-rpath=${openssl_install_dir}/lib -fPIC --prefix=${openssl_install_dir} --openssldir=${openssl_install_dir} - make depend - make -j ${THREAD} && make install - popd > /dev/null - if [ -f "${openssl_install_dir}/lib/libcrypto.a" ]; then - echo "${CSUCCESS}openSSL installed successfully! ${CEND}" - /bin/cp cacert.pem ${openssl_install_dir}/cert.pem - rm -rf openssl-1.0.2u - else - echo "${CFAILURE}openSSL install failed, Please contact the author! ${CEND}" && grep -Ew 'NAME|ID|ID_LIKE|VERSION_ID|PRETTY_NAME' /etc/os-release - kill -9 $$; exit 1; - fi - popd > /dev/null +Install_openSSL100() { + if [ ! -e '/usr/local/openssl100s/lib/libcrypto.a' ]; then + pushd ${oneinstack_dir}/src + tar xzf openssl-1.0.0s.tar.gz + pushd openssl-1.0.0s + make clean + ./config --prefix=/usr/local/openssl100s -fPIC shared zlib-dynamic + make -j ${THREAD} && make install + popd + if [ -f "/usr/local/openssl100s/lib/libcrypto.a" ]; then + echo "${CSUCCESS}openssl-1.0.0s module installed successfully! ${CEND}" + rm -rf openssl-1.0.0s + else + echo "${CFAILURE}openssl-1.0.0s install failed, Please contact the author! ${CEND}" + kill -9 $$ fi + popd fi } diff --git a/include/pecl_calendar.sh b/include/pecl_calendar.sh deleted file mode 100644 index 275ab6ce..00000000 --- a/include/pecl_calendar.sh +++ /dev/null @@ -1,35 +0,0 @@ -#!/bin/bash -# Author: yeho -# BLOG: https://linuxeye.com - -Install_pecl_calendar() { - if [ -e "${php_install_dir}/bin/phpize" ]; then - pushd ${current_dir}/src > /dev/null - phpExtensionDir=$(${php_install_dir}/bin/php-config --extension-dir) - PHP_detail_ver=$(${php_install_dir}/bin/php-config --version) - src_url=https://secure.php.net/distributions/php-${PHP_detail_ver}.tar.gz && Download_src - tar xzf php-${PHP_detail_ver}.tar.gz - pushd php-${PHP_detail_ver}/ext/calendar > /dev/null - ${php_install_dir}/bin/phpize - ./configure --with-php-config=${php_install_dir}/bin/php-config - make -j ${THREAD} && make install - popd > /dev/null - if [ -f "${phpExtensionDir}/calendar.so" ]; then - echo 'extension=calendar.so' > ${php_install_dir}/etc/php.d/04-calendar.ini - echo "${CSUCCESS}PHP calendar module installed successfully! ${CEND}" - rm -rf php-${PHP_detail_ver} - else - echo "${CFAILURE}PHP calendar module install failed, Please contact the author! ${CEND}" && grep -Ew 'NAME|ID|ID_LIKE|VERSION_ID|PRETTY_NAME' /etc/os-release - fi - popd > /dev/null - fi -} - -Uninstall_pecl_calendar() { - if [ -e "${php_install_dir}/etc/php.d/04-calendar.ini" ]; then - rm -f ${php_install_dir}/etc/php.d/04-calendar.ini - echo; echo "${CMSG}PHP calendar module uninstall completed${CEND}" - else - echo; echo "${CWARNING}PHP calendar module does not exist! ${CEND}" - fi -} diff --git a/include/pecl_fileinfo.sh b/include/pecl_fileinfo.sh deleted file mode 100644 index d28e4e28..00000000 --- a/include/pecl_fileinfo.sh +++ /dev/null @@ -1,44 +0,0 @@ -#!/bin/bash -# Author: yeho -# BLOG: https://linuxeye.com - -Install_pecl_fileinfo() { - if [ -e "${php_install_dir}/bin/phpize" ]; then - pushd ${current_dir}/src > /dev/null - phpExtensionDir=$(${php_install_dir}/bin/php-config --extension-dir) - PHP_detail_ver=$(${php_install_dir}/bin/php-config --version) - PHP_main_ver=${PHP_detail_ver%.*} - src_url=https://secure.php.net/distributions/php-${PHP_detail_ver}.tar.gz && Download_src - tar xzf php-${PHP_detail_ver}.tar.gz - if [[ "${PHP_main_ver}" =~ ^5.3$ ]]; then - pushd php-${PHP_detail_ver} > /dev/null - patch -p1 < ../php5.3-fileinfo.patch - popd > /dev/null - fi - pushd php-${PHP_detail_ver}/ext/fileinfo > /dev/null - ${php_install_dir}/bin/phpize - ./configure --with-php-config=${php_install_dir}/bin/php-config - if [[ ! "${PHP_main_ver}" =~ ^5.3$ ]]; then - sed -i 's@^CFLAGS =.*@CFLAGS = -std=c99 -g@' Makefile - fi - make -j ${THREAD} && make install - popd > /dev/null - if [ -f "${phpExtensionDir}/fileinfo.so" ]; then - echo 'extension=fileinfo.so' > ${php_install_dir}/etc/php.d/04-fileinfo.ini - echo "${CSUCCESS}PHP fileinfo module installed successfully! ${CEND}" - rm -rf php-${PHP_detail_ver} - else - echo "${CFAILURE}PHP fileinfo module install failed, Please contact the author! ${CEND}" && grep -Ew 'NAME|ID|ID_LIKE|VERSION_ID|PRETTY_NAME' /etc/os-release - fi - popd > /dev/null - fi -} - -Uninstall_pecl_fileinfo() { - if [ -e "${php_install_dir}/etc/php.d/04-fileinfo.ini" ]; then - rm -f ${php_install_dir}/etc/php.d/04-fileinfo.ini - echo; echo "${CMSG}PHP fileinfo module uninstall completed${CEND}" - else - echo; echo "${CWARNING}PHP fileinfo module does not exist! ${CEND}" - fi -} diff --git a/include/pecl_imap.sh b/include/pecl_imap.sh deleted file mode 100644 index bb733bc5..00000000 --- a/include/pecl_imap.sh +++ /dev/null @@ -1,52 +0,0 @@ -#!/bin/bash -# Author: yeho -# BLOG: https://linuxeye.com - -Install_pecl_imap() { - if [ -e "${php_install_dir}/bin/phpize" ]; then - pushd ${current_dir}/src > /dev/null - if [ "${PM}" == 'yum' ]; then - if [ "${RHEL_ver}" == '9' ]; then - cat > /etc/yum.repos.d/remi.repo << EOF -[remi] -name=Remi's RPM repository for Enterprise Linux 9 - \$basearch -mirrorlist=http://cdn.remirepo.net/enterprise/9/remi/\$basearch/mirror -enabled=0 -gpgcheck=0 -EOF - dnf -y --enablerepo=remi install uw-imap-devel - else - yum -y install libc-client-devel - [ ! -e /usr/lib/libc-client.so ] && ln -s /usr/lib64/libc-client.so /usr/lib/libc-client.so - fi - else - apt-get -y install libc-client2007e-dev - fi - phpExtensionDir=$(${php_install_dir}/bin/php-config --extension-dir) - PHP_detail_ver=$(${php_install_dir}/bin/php-config --version) - src_url=https://secure.php.net/distributions/php-${PHP_detail_ver}.tar.gz && Download_src - tar xzf php-${PHP_detail_ver}.tar.gz - pushd php-${PHP_detail_ver}/ext/imap > /dev/null - ${php_install_dir}/bin/phpize - ./configure --with-php-config=${php_install_dir}/bin/php-config --with-kerberos --with-imap --with-imap-ssl - make -j ${THREAD} && make install - popd > /dev/null - if [ -f "${phpExtensionDir}/imap.so" ]; then - echo 'extension=imap.so' > ${php_install_dir}/etc/php.d/04-imap.ini - echo "${CSUCCESS}PHP imap module installed successfully! ${CEND}" - rm -rf php-${PHP_detail_ver} - else - echo "${CFAILURE}PHP imap module install failed, Please contact the author! ${CEND}" && grep -Ew 'NAME|ID|ID_LIKE|VERSION_ID|PRETTY_NAME' /etc/os-release - fi - popd > /dev/null - fi -} - -Uninstall_pecl_imap() { - if [ -e "${php_install_dir}/etc/php.d/04-imap.ini" ]; then - rm -f ${php_install_dir}/etc/php.d/04-imap.ini - echo; echo "${CMSG}PHP imap module uninstall completed${CEND}" - else - echo; echo "${CWARNING}PHP imap module does not exist! ${CEND}" - fi -} diff --git a/include/pecl_ldap.sh b/include/pecl_ldap.sh deleted file mode 100644 index d0635633..00000000 --- a/include/pecl_ldap.sh +++ /dev/null @@ -1,46 +0,0 @@ -#!/bin/bash -# Author: yeho -# BLOG: https://linuxeye.com - -Install_pecl_ldap() { - if [ -e "${php_install_dir}/bin/phpize" ]; then - pushd ${current_dir}/src > /dev/null - phpExtensionDir=$(${php_install_dir}/bin/php-config --extension-dir) - PHP_detail_ver=$(${php_install_dir}/bin/php-config --version) - src_url=https://secure.php.net/distributions/php-${PHP_detail_ver}.tar.gz && Download_src - tar xzf php-${PHP_detail_ver}.tar.gz - pushd php-${PHP_detail_ver}/ext/ldap > /dev/null - if [ "${PM}" == 'yum' ]; then - yum -y install openldap-devel - else - apt-get -y install libldap2-dev - ln -s /usr/lib/${ARCH}-linux-gnu/libldap.so /usr/lib/ - ln -s /usr/lib/${ARCH}-linux-gnu/liblber.so /usr/lib/ - fi - ${php_install_dir}/bin/phpize - if [ "${PM}" == 'yum' ]; then - ./configure --with-php-config=${php_install_dir}/bin/php-config --with-ldap --with-libdir=lib64 - else - ./configure --with-php-config=${php_install_dir}/bin/php-config --with-ldap --with-libdir=lib/x86_64-linux-gnu - fi - make -j ${THREAD} && make install - popd > /dev/null - if [ -f "${phpExtensionDir}/ldap.so" ]; then - echo 'extension=ldap.so' > ${php_install_dir}/etc/php.d/04-ldap.ini - echo "${CSUCCESS}PHP ldap module installed successfully! ${CEND}" - rm -rf php-${PHP_detail_ver} - else - echo "${CFAILURE}PHP ldap module install failed, Please contact the author! ${CEND}" && grep -Ew 'NAME|ID|ID_LIKE|VERSION_ID|PRETTY_NAME' /etc/os-release - fi - popd > /dev/null - fi -} - -Uninstall_pecl_ldap() { - if [ -e "${php_install_dir}/etc/php.d/04-ldap.ini" ]; then - rm -f ${php_install_dir}/etc/php.d/04-ldap.ini - echo; echo "${CMSG}PHP ldap module uninstall completed${CEND}" - else - echo; echo "${CWARNING}PHP ldap module does not exist! ${CEND}" - fi -} diff --git a/include/pecl_mongodb.sh b/include/pecl_mongodb.sh deleted file mode 100644 index 19473b14..00000000 --- a/include/pecl_mongodb.sh +++ /dev/null @@ -1,71 +0,0 @@ -#!/bin/bash -# Author: yeho -# BLOG: https://linuxeye.com - -Install_pecl_mongodb() { - if [ -e "${php_install_dir}/bin/phpize" ]; then - pushd ${current_dir}/src > /dev/null - phpExtensionDir=$(${php_install_dir}/bin/php-config --extension-dir) - if [[ "$(${php_install_dir}/bin/php-config --version | awk -F. '{print $1$2}')" =~ ^5[3-6]$ ]]; then - src_url=https://pecl.php.net/get/mongo-1.6.16.tgz && Download_src - tar xzf mongo-1.6.16.tgz - pushd mongo-1.6.16 > /dev/null - ${php_install_dir}/bin/phpize - ./configure --with-php-config=${php_install_dir}/bin/php-config - make -j ${THREAD} && make install - popd > /dev/null - if [ -f "${phpExtensionDir}/mongo.so" ]; then - echo 'extension=mongo.so' > ${php_install_dir}/etc/php.d/07-mongo.ini - rm -rf mongo-1.6.16 - echo "${CSUCCESS}PHP mongo module installed successfully! ${CEND}" - else - echo "${CFAILURE}PHP mongo module install failed, Please contact the author! ${CEND}" && grep -Ew 'NAME|ID|ID_LIKE|VERSION_ID|PRETTY_NAME' /etc/os-release - fi - else - if [[ "$(${php_install_dir}/bin/php-config --version | awk -F. '{print $1$2}')" =~ ^70$ ]]; then - src_url=https://pecl.php.net/get/mongodb-1.9.2.tgz && Download_src - tar xzf mongodb-1.9.2.tgz - pushd mongodb-1.9.2 > /dev/null - elif [[ "$(${php_install_dir}/bin/php-config --version | awk -F. '{print $1$2}')" =~ ^7[1-3]$ ]]; then - src_url=https://pecl.php.net/get/mongodb-1.16.2.tgz && Download_src - tar xzf mongodb-1.16.2.tgz - pushd mongodb-1.16.2 > /dev/null - elif [[ "$(${php_install_dir}/bin/php-config --version | awk -F. '{print $1$2}')" =~ ^74|80$ ]]; then - src_url=https://pecl.php.net/get/mongodb-1.20.1.tgz && Download_src - tar xzf mongodb-1.20.1.tgz - pushd mongodb-1.20.1 > /dev/null - else - src_url=https://pecl.php.net/get/mongodb-${pecl_mongodb_ver}.tgz && Download_src - tar xzf mongodb-${pecl_mongodb_ver}.tgz - pushd mongodb-${pecl_mongodb_ver} > /dev/null - fi - ${php_install_dir}/bin/phpize - ./configure --with-php-config=${php_install_dir}/bin/php-config - make -j ${THREAD} && make install - popd > /dev/null - if [ -f "${phpExtensionDir}/mongodb.so" ]; then - echo 'extension=mongodb.so' > ${php_install_dir}/etc/php.d/07-mongodb.ini - echo "${CSUCCESS}PHP mongodb module installed successfully! ${CEND}" - rm -rf mongodb-1.9.2 mongodb-1.16.2 mongodb-${pecl_mongodb_ver} - else - echo "${CFAILURE}PHP mongodb module install failed, Please contact the author! ${CEND}" && grep -Ew 'NAME|ID|ID_LIKE|VERSION_ID|PRETTY_NAME' /etc/os-release - fi - fi - popd > /dev/null - fi -} - -Uninstall_pecl_mongodb() { - if [ -e "${php_install_dir}/etc/php.d/07-mongo.ini" ]; then - rm -f ${php_install_dir}/etc/php.d/07-mongo.ini - echo; echo "${CMSG}PHP mongo module uninstall completed${CEND}" - else - echo; echo "${CWARNING}PHP mongo module does not exist! ${CEND}" - fi - if [ -e "${php_install_dir}/etc/php.d/07-mongodb.ini" ]; then - rm -f ${php_install_dir}/etc/php.d/07-mongodb.ini - echo; echo "${CMSG}PHP mongodb module uninstall completed${CEND}" - else - echo; echo "${CWARNING}PHP mongodb module does not exist! ${CEND}" - fi -} diff --git a/include/pecl_pgsql.sh b/include/pecl_pgsql.sh deleted file mode 100644 index 5f6752b4..00000000 --- a/include/pecl_pgsql.sh +++ /dev/null @@ -1,40 +0,0 @@ -#!/bin/bash -# Author: yeho -# BLOG: https://linuxeye.com - -Install_pecl_pgsql() { - if [ -e "${php_install_dir}/bin/phpize" ]; then - pushd ${current_dir}/src > /dev/null - phpExtensionDir=`${php_install_dir}/bin/php-config --extension-dir` - PHP_detail_ver=$(${php_install_dir}/bin/php-config --version) - tar xzf php-${PHP_detail_ver}.tar.gz - pushd php-${PHP_detail_ver}/ext/pgsql > /dev/null - ${php_install_dir}/bin/phpize - ./configure --with-pgsql=${pgsql_install_dir} --with-php-config=${php_install_dir}/bin/php-config - make -j ${THREAD} && make install - popd > /dev/null - pushd php-${PHP_detail_ver}/ext/pdo_pgsql > /dev/null - ${php_install_dir}/bin/phpize - ./configure --with-pdo-pgsql=${pgsql_install_dir} --with-php-config=${php_install_dir}/bin/php-config - make -j ${THREAD} && make install - popd > /dev/null - if [ -f "${phpExtensionDir}/pgsql.so" -a -f "${phpExtensionDir}/pdo_pgsql.so" ]; then - echo 'extension=pgsql.so' > ${php_install_dir}/etc/php.d/07-pgsql.ini - echo 'extension=pdo_pgsql.so' >> ${php_install_dir}/etc/php.d/07-pgsql.ini - echo "${CSUCCESS}PHP pgsql module installed successfully! ${CEND}" - rm -rf php-${PHP_detail_ver} - else - echo "${CFAILURE}PHP pgsql module install failed, Please contact the author! ${CEND}" && grep -Ew 'NAME|ID|ID_LIKE|VERSION_ID|PRETTY_NAME' /etc/os-release - fi - popd > /dev/null - fi -} - -Uninstall_pecl_pgsql() { - if [ -e "${php_install_dir}/etc/php.d/07-pgsql.ini" ]; then - rm -f ${php_install_dir}/etc/php.d/07-pgsql.ini - echo; echo "${CMSG}PHP pgsql module uninstall completed${CEND}" - else - echo; echo "${CWARNING}PHP pgsql module does not exist! ${CEND}" - fi -} diff --git a/include/pecl_phalcon.sh b/include/pecl_phalcon.sh deleted file mode 100644 index cf8dafcb..00000000 --- a/include/pecl_phalcon.sh +++ /dev/null @@ -1,57 +0,0 @@ -#!/bin/bash -# Author: yeho -# BLOG: https://linuxeye.com - -Install_pecl_phalcon() { - if [ -e "${php_install_dir}/bin/phpize" ]; then - pushd ${current_dir}/src > /dev/null - PHP_detail_ver=$(${php_install_dir}/bin/php-config --version) - PHP_main_ver=${PHP_detail_ver%.*} - phpExtensionDir=$(${php_install_dir}/bin/php-config --extension-dir) - if [[ "${PHP_main_ver}" =~ ^5.[5-6]$|^7.[0-1]$ ]]; then - src_url=${mirror_link}/src/cphalcon-3.4.5.tar.gz && Download_src - tar xzf cphalcon-3.4.5.tar.gz - pushd cphalcon-3.4.5/build > /dev/null - echo "${CMSG}It may take a few minutes... ${CEND}" - ./install --phpize ${php_install_dir}/bin/phpize --php-config ${php_install_dir}/bin/php-config --arch 64bits - popd > /dev/null - elif [[ "${PHP_main_ver}" =~ ^7.[2-4]$ ]]; then - src_url=https://pecl.php.net/get/phalcon-5.4.0.tgz && Download_src - tar xzf phalcon-5.4.0tgz - pushd phalcon-5.4.0 > /dev/null - ${php_install_dir}/bin/phpize - echo "${CMSG}It may take a few minutes... ${CEND}" - ./configure --with-php-config=${php_install_dir}/bin/php-config - make -j ${THREAD} && make install - popd > /dev/null - elif [[ "${PHP_main_ver}" =~ ^8.[0-4]$ ]]; then - src_url=https://pecl.php.net/get/phalcon-${phalcon_ver}.tgz && Download_src - tar xzf phalcon-${phalcon_ver}.tgz - pushd phalcon-${phalcon_ver} > /dev/null - ${php_install_dir}/bin/phpize - echo "${CMSG}It may take a few minutes... ${CEND}" - ./configure --with-php-config=${php_install_dir}/bin/php-config - make -j ${THREAD} && make install - popd > /dev/null - else - echo "${CWARNING}Your php ${PHP_detail_ver} does not support phalcon! ${CEND}" - fi - if [ -f "${phpExtensionDir}/phalcon.so" ]; then - echo 'extension=phalcon.so' > ${php_install_dir}/etc/php.d/04-phalcon.ini - echo "${CSUCCESS}PHP phalcon module installed successfully! ${CEND}" - rm -rf cphalcon-3.4.5 phalcon-${phalcon_ver} - else - echo "${CFAILURE}PHP phalcon module install failed, Please contact the author! ${CEND}" && grep -Ew 'NAME|ID|ID_LIKE|VERSION_ID|PRETTY_NAME' /etc/os-release - fi - popd > /dev/null - fi -} - -Uninstall_pecl_phalcon() { - if [ -e "${php_install_dir}/etc/php.d/04-phalcon.ini" ]; then - rm -f ${php_install_dir}/etc/php.d/04-phalcon.ini - echo; echo "${CMSG}PHP phalcon module uninstall completed${CEND}" - else - echo; echo "${CWARNING}PHP phalcon module does not exist! ${CEND}" - fi -} diff --git a/include/pecl_swoole.sh b/include/pecl_swoole.sh deleted file mode 100644 index 3fec1100..00000000 --- a/include/pecl_swoole.sh +++ /dev/null @@ -1,68 +0,0 @@ -#!/bin/bash -# Author: yeho -# BLOG: https://linuxeye.com - -Install_pecl_swoole() { - if [ -e "${php_install_dir}/bin/phpize" ]; then - pushd ${current_dir}/src > /dev/null - phpExtensionDir=$(${php_install_dir}/bin/php-config --extension-dir) - PHP_detail_ver=$(${php_install_dir}/bin/php-config --version) - PHP_main_ver=${PHP_detail_ver%.*} - if [[ "${PHP_main_ver}" =~ ^5.[3-6]$ ]]; then - src_url=https://pecl.php.net/get/swoole-1.10.5.tgz && Download_src - tar xzf swoole-1.10.5.tgz - pushd swoole-1.10.5 > /dev/null - ${php_install_dir}/bin/phpize - ./configure --with-php-config=${php_install_dir}/bin/php-config --enable-openssl --with-openssl-dir=${openssl_install_dir} - elif [[ "${PHP_main_ver}" =~ ^7.[0-1]$ ]]; then - src_url=https://pecl.php.net/get/swoole-4.5.2.tgz && Download_src - tar xzf swoole-4.5.2.tgz - pushd swoole-4.5.2 > /dev/null - ${php_install_dir}/bin/phpize - ./configure --with-php-config=${php_install_dir}/bin/php-config --enable-openssl --with-openssl-dir=${openssl_install_dir} - elif [[ "${PHP_main_ver}" =~ ^7.[2-4]$ ]]; then - src_url=https://pecl.php.net/get/swoole-4.8.12.tgz && Download_src - tar xzf swoole-4.8.12.tgz - pushd swoole-4.8.12 > /dev/null - ${php_install_dir}/bin/phpize - ./configure --with-php-config=${php_install_dir}/bin/php-config --enable-openssl --with-openssl-dir=${openssl_install_dir} --enable-http2 --enable-swoole-json --enable-swoole-curl - elif [[ "${PHP_main_ver}" =~ ^80]$ ]]; then - src_url=https://pecl.php.net/get/swoole-5.1.7.tgz && Download_src - tar xzf swoole-5.1.7.tgz - pushd swoole-5.1.7 > /dev/null - ${php_install_dir}/bin/phpize - ./configure --with-php-config=${php_install_dir}/bin/php-config --enable-openssl --with-openssl-dir=${openssl_install_dir} --enable-http2 --enable-swoole-json --enable-swoole-curl - elif [[ "${PHP_main_ver}" =~ ^81]$ ]]; then - src_url=https://pecl.php.net/get/swoole-6.1.7.tgz && Download_src - tar xzf swoole-6.1.7.tgz - pushd swoole-6.1.7 > /dev/null - ${php_install_dir}/bin/phpize - ./configure --with-php-config=${php_install_dir}/bin/php-config --enable-openssl --with-openssl-dir=${openssl_install_dir} --enable-http2 --enable-swoole-json --enable-swoole-curl - else - src_url=https://pecl.php.net/get/swoole-${swoole_ver}.tgz && Download_src - tar xzf swoole-${swoole_ver}.tgz - pushd swoole-${swoole_ver} > /dev/null - ${php_install_dir}/bin/phpize - ./configure --with-php-config=${php_install_dir}/bin/php-config --enable-openssl --with-openssl-dir=${openssl_install_dir} --enable-http2 --enable-swoole-json --enable-swoole-curl - fi - make -j ${THREAD} && make install - popd > /dev/null - if [ -f "${phpExtensionDir}/swoole.so" ]; then - echo 'extension=swoole.so' > ${php_install_dir}/etc/php.d/06-swoole.ini - echo "${CSUCCESS}PHP swoole module installed successfully! ${CEND}" - rm -rf swoole-${swoole_ver} swoole-4.8.12 swoole-1.10.5 swoole-4.5.2 - else - echo "${CFAILURE}PHP swoole module install failed, Please contact the author! ${CEND}" && grep -Ew 'NAME|ID|ID_LIKE|VERSION_ID|PRETTY_NAME' /etc/os-release - fi - popd > /dev/null - fi -} - -Uninstall_pecl_swoole() { - if [ -e "${php_install_dir}/etc/php.d/06-swoole.ini" ]; then - rm -f ${php_install_dir}/etc/php.d/06-swoole.ini - echo; echo "${CMSG}PHP swoole module uninstall completed${CEND}" - else - echo; echo "${CWARNING}PHP swoole module does not exist! ${CEND}" - fi -} diff --git a/include/pecl_xdebug.sh b/include/pecl_xdebug.sh deleted file mode 100644 index 81d80f59..00000000 --- a/include/pecl_xdebug.sh +++ /dev/null @@ -1,62 +0,0 @@ -#!/bin/bash -# Author: yeho -# BLOG: https://linuxeye.com - -Install_pecl_xdebug() { - if [ -e "${php_install_dir}/bin/phpize" ]; then - pushd ${current_dir}/src > /dev/null - phpExtensionDir=$(${php_install_dir}/bin/php-config --extension-dir) - PHP_detail_ver=$(${php_install_dir}/bin/php-config --version) - PHP_main_ver=${PHP_detail_ver%.*} - if [[ "${PHP_main_ver}" =~ ^7.[0-4]$|^80$ ]]; then - if [[ "${PHP_main_ver}" =~ ^7.[0-1]$ ]]; then - src_url=https://pecl.php.net/get/xdebug-2.9.8.tgz && Download_src - tar xzf xdebug-2.9.8.tgz - pushd xdebug-2.9.8 > /dev/null - else - src_url=https://pecl.php.net/get/xdebug-${xdebug_ver}.tgz && Download_src - tar xzf xdebug-${xdebug_ver}.tgz - pushd xdebug-${xdebug_ver} > /dev/null - fi - ${php_install_dir}/bin/phpize - ./configure --with-php-config=${php_install_dir}/bin/php-config - make -j ${THREAD} && make install - popd > /dev/null - if [ -f "${phpExtensionDir}/xdebug.so" ]; then - src_url=${mirror_link}/src/webgrind-master.zip && Download_src - unzip -q webgrind-master.zip - /bin/mv webgrind-master ${wwwroot_dir}/default/webgrind - [ ! -e /tmp/xdebug ] && { mkdir /tmp/xdebug; chown ${run_user}:${run_group} /tmp/xdebug; } - [ ! -e /tmp/webgrind ] && { mkdir /tmp/webgrind; chown ${run_user}:${run_group} /tmp/webgrind; } - chown -R ${run_user}:${run_group} ${wwwroot_dir}/default/webgrind - sed -i 's@static $storageDir.*@static $storageDir = "/tmp/webgrind";@' ${wwwroot_dir}/default/webgrind/config.php - sed -i 's@static $profilerDir.*@static $profilerDir = "/tmp/xdebug";@' ${wwwroot_dir}/default/webgrind/config.php - cat > ${php_install_dir}/etc/php.d/08-xdebug.ini << EOF -[xdebug] -zend_extension=xdebug.so -xdebug.trace_output_dir=/tmp/xdebug -xdebug.profiler_output_dir = /tmp/xdebug -xdebug.profiler_enable = On -xdebug.profiler_enable_trigger = 1 -EOF - echo "${CSUCCESS}PHP xdebug module installed successfully! ${CEND}" - echo; echo "Webgrind URL: ${CMSG}http://{Public IP}/webgrind ${CEND}" - rm -rf xdebug-${xdebug_ver} xdebug-2.9.8 - else - echo "${CFAILURE}PHP xdebug module install failed, Please contact the author! ${CEND}" && grep -Ew 'NAME|ID|ID_LIKE|VERSION_ID|PRETTY_NAME' /etc/os-release - fi - else - echo "${CWARNING}Your php ${PHP_detail_ver} does not support xdebug! ${CEND}"; - fi - popd > /dev/null - fi -} - -Uninstall_pecl_xdebug() { - if [ -e "${php_install_dir}/etc/php.d/08-xdebug.ini" ]; then - rm -rf ${php_install_dir}/etc/php.d/08-xdebug.ini /tmp/{xdebug,webgrind} ${wwwroot_dir}/default/webgrind - echo; echo "${CMSG}PHP xdebug module uninstall completed${CEND}" - else - echo; echo "${CWARNING}PHP xdebug module does not exist! ${CEND}" - fi -} diff --git a/include/pecl_yaf.sh b/include/pecl_yaf.sh deleted file mode 100644 index 2ad6e339..00000000 --- a/include/pecl_yaf.sh +++ /dev/null @@ -1,40 +0,0 @@ -#!/bin/bash -# Author: yeho -# BLOG: https://linuxeye.com - -Install_pecl_yaf() { - if [ -e "${php_install_dir}/bin/phpize" ]; then - pushd ${current_dir}/src > /dev/null - PHP_detail_ver=$(${php_install_dir}/bin/php-config --version) - PHP_main_ver=${PHP_detail_ver%.*} - if [[ "${PHP_main_ver}" =~ ^7.[0-4]$|^8.[0-4]$ ]]; then - phpExtensionDir=$(${php_install_dir}/bin/php-config --extension-dir) - src_url=https://pecl.php.net/get/yaf-${yaf_ver}.tgz && Download_src - tar xzf yaf-${yaf_ver}.tgz - pushd yaf-${yaf_ver} > /dev/null - ${php_install_dir}/bin/phpize - ./configure --with-php-config=${php_install_dir}/bin/php-config - make -j ${THREAD} && make install - popd > /dev/null - if [ -f "${phpExtensionDir}/yaf.so" ]; then - echo 'extension=yaf.so' > ${php_install_dir}/etc/php.d/04-yaf.ini - echo "${CSUCCESS}PHP yaf module installed successfully! ${CEND}" - rm -rf yaf-${yaf_ver} - else - echo "${CFAILURE}PHP yaf module install failed, Please contact the author! ${CEND}" && grep -Ew 'NAME|ID|ID_LIKE|VERSION_ID|PRETTY_NAME' /etc/os-release - fi - else - echo "${CWARNING}Your php ${PHP_detail_ver} does not support yaf! ${CEND}"; - fi - popd > /dev/null - fi -} - -Uninstall_pecl_yaf() { - if [ -e "${php_install_dir}/etc/php.d/04-yaf.ini" ]; then - rm -f ${php_install_dir}/etc/php.d/04-yaf.ini - echo; echo "${CMSG}PHP yaf module uninstall completed${CEND}" - else - echo; echo "${CWARNING}PHP yaf module does not exist! ${CEND}" - fi -} diff --git a/include/pecl_yar.sh b/include/pecl_yar.sh deleted file mode 100644 index 77c094fa..00000000 --- a/include/pecl_yar.sh +++ /dev/null @@ -1,40 +0,0 @@ -#!/bin/bash -# Author: yeho -# BLOG: https://linuxeye.com - -Install_pecl_yar() { - if [ -e "${php_install_dir}/bin/phpize" ]; then - pushd ${current_dir}/src > /dev/null - PHP_detail_ver=$(${php_install_dir}/bin/php-config --version) - PHP_main_ver=${PHP_detail_ver%.*} - if [[ "${PHP_main_ver}" =~ ^7.[0-4]$|^8.[0-4]$ ]]; then - phpExtensionDir=$(${php_install_dir}/bin/php-config --extension-dir) - src_url=https://pecl.php.net/get/yar-${yar_ver}.tgz && Download_src - tar xzf yar-${yar_ver}.tgz - pushd yar-${yar_ver} > /dev/null - ${php_install_dir}/bin/phpize - ./configure --with-php-config=${php_install_dir}/bin/php-config --with-curl=${curl_install_dir} - make -j ${THREAD} && make install - popd > /dev/null - if [ -f "${phpExtensionDir}/yar.so" ]; then - echo 'extension=yar.so' > ${php_install_dir}/etc/php.d/04-yar.ini - echo "${CSUCCESS}PHP yar module installed successfully! ${CEND}" - rm -rf yar-${yar_ver} - else - echo "${CFAILURE}PHP yar module install failed, Please contact the author! ${CEND}" && grep -Ew 'NAME|ID|ID_LIKE|VERSION_ID|PRETTY_NAME' /etc/os-release - fi - else - echo "${CWARNING}Your php ${PHP_detail_ver} does not support yar! ${CEND}"; - fi - popd > /dev/null - fi -} - -Uninstall_pecl_yar() { - if [ -e "${php_install_dir}/etc/php.d/04-yar.ini" ]; then - rm -f ${php_install_dir}/etc/php.d/04-yar.ini - echo; echo "${CMSG}PHP yar module uninstall completed${CEND}" - else - echo; echo "${CWARNING}PHP yar module does not exist! ${CEND}" - fi -} diff --git a/include/percona-5.5.sh b/include/percona-5.5.sh index cb264ee6..986032f9 100644 --- a/include/percona-5.5.sh +++ b/include/percona-5.5.sh @@ -1,25 +1,32 @@ #!/bin/bash # Author: yeho -# BLOG: https://linuxeye.com +# BLOG: https://blog.linuxeye.com +# +# Notes: OneinStack for CentOS/RadHat 5+ Debian 6+ and Ubuntu 12+ +# +# Project home page: +# https://oneinstack.com +# https://github.com/lj2007331/oneinstack Install_Percona55() { - pushd ${current_dir}/src > /dev/null + pushd ${oneinstack_dir}/src + id -u mysql >/dev/null 2>&1 [ $? -ne 0 ] && useradd -M -s /sbin/nologin mysql [ ! -d "${percona_install_dir}" ] && mkdir -p ${percona_install_dir} - mkdir -p ${percona_data_dir};chown mysql:mysql -R ${percona_data_dir} + mkdir -p ${percona_data_dir};chown mysql.mysql -R ${percona_data_dir} - if [ "${dbinstallmethod}" == "1" ]; then - perconaVerStr1=$(echo ${percona55_ver} | sed "s@-@-rel@") - tar xzf ./Percona-Server-${perconaVerStr1}-Linux.x86_64.${sslLibVer}.tar.gz - mv Percona-Server-${perconaVerStr1}-Linux.x86_64.${sslLibVer}/* ${percona_install_dir} + if [ "${dbInstallMethods}" == "1" ]; then + perconaVerStr1=$(echo ${percona55_version} | sed "s@-@-rel@") + tar xvf Percona-Server-${perconaVerStr1}-Linux.${SYS_BIT_b}.${sslLibVer}.tar.gz + mv Percona-Server-${perconaVerStr1}-Linux.${SYS_BIT_b}.${sslLibVer}/* ${percona_install_dir} sed -i 's@executing mysqld_safe@executing mysqld_safe\nexport LD_PRELOAD=/usr/local/lib/libjemalloc.so@' ${percona_install_dir}/bin/mysqld_safe - sed -i "s@/usr/local/Percona-Server-${perconaVerStr1}-Linux.x86_64.${sslLibVer}@${percona_install_dir}@g" ${percona_install_dir}/bin/mysqld_safe - elif [ "${dbinstallmethod}" == "2" ]; then - tar xzf percona-server-${percona55_ver}.tar.gz - pushd percona-server-${percona55_ver} - [ "${armplatform}" == "y" ] && patch -p1 < ../mysql-5.5-fix-arm-client_plugin.patch + sed -i "s@/usr/local/Percona-Server-${perconaVerStr1}-Linux.${SYS_BIT_b}.${sslLibVer}@${percona_install_dir}@g" ${percona_install_dir}/bin/mysqld_safe + elif [ "${dbInstallMethods}" == "2" ]; then + tar xvf percona-server-${percona55_version}.tar.gz + pushd percona-server-${percona55_version} + [ "${armPlatform}" == "y" ] && patch -p1 < ../mysql-5.5-fix-arm-client_plugin.patch cmake . -DCMAKE_INSTALL_PREFIX=${percona_install_dir} \ -DMYSQL_DATADIR=${percona_data_dir} \ -DSYSCONFDIR=/etc \ @@ -42,25 +49,25 @@ Install_Percona55() { fi if [ -d "${percona_install_dir}/support-files" ]; then - sed -i "s+^dbrootpwd.*+dbrootpwd='${dbrootpwd}'+" ../options.conf echo "${CSUCCESS}Percona installed successfully! ${CEND}" - if [ "${dbinstallmethod}" == "1" ]; then - rm -rf Percona-Server-${perconaVerStr1}-Linux.x86_64.${sslLibVer} - elif [ "${dbinstallmethod}" == "2" ]; then - rm -rf percona-server-${percona55_ver} + if [ "${dbInstallMethods}" == "1" ]; then + rm -rf Percona-Server-${perconaVerStr1}-Linux.${SYS_BIT_b}.${sslLibVer} + elif [ "${dbInstallMethods}" == "2" ]; then + rm -rf percona-server-${percona55_version} fi else rm -rf ${percona_install_dir} - echo "${CFAILURE}Percona install failed, Please contact the author! ${CEND}" && grep -Ew 'NAME|ID|ID_LIKE|VERSION_ID|PRETTY_NAME' /etc/os-release - kill -9 $$; exit 1; + rm -rf percona-server-${percona55_version} + echo "${CFAILURE}Percona install failed, Please contact the author! ${CEND}" + kill -9 $$ fi /bin/cp ${percona_install_dir}/support-files/mysql.server /etc/init.d/mysqld sed -i "s@^basedir=.*@basedir=${percona_install_dir}@" /etc/init.d/mysqld sed -i "s@^datadir=.*@datadir=${percona_data_dir}@" /etc/init.d/mysqld chmod +x /etc/init.d/mysqld - [ "${PM}" == 'yum' ] && { chkconfig --add mysqld; chkconfig mysqld on; } - [ "${PM}" == 'apt-get' ] && update-rc.d mysqld defaults + [ "${OS}" == "CentOS" ] && { chkconfig --add mysqld; chkconfig mysqld on; } + [[ "${OS}" =~ ^Ubuntu$|^Debian$ ]] && update-rc.d mysqld defaults popd # my.cnf @@ -68,6 +75,7 @@ Install_Percona55() { [client] port = 3306 socket = /tmp/mysql.sock +default-character-set = utf8mb4 [mysql] prompt="Percona [\\d]> " @@ -192,8 +200,7 @@ EOF ${percona_install_dir}/scripts/mysql_install_db --user=mysql --basedir=${percona_install_dir} --datadir=${percona_data_dir} - [ "${Wsl}" == true ] && chmod 600 /etc/my.cnf - chown mysql:mysql -R ${percona_data_dir} + chown mysql.mysql -R ${percona_data_dir} [ -d "/etc/mysql" ] && /bin/mv /etc/mysql{,_bk} service mysqld start [ -z "$(grep ^'export PATH=' /etc/profile)" ] && echo "export PATH=${percona_install_dir}/bin:\$PATH" >> /etc/profile @@ -202,13 +209,13 @@ EOF ${percona_install_dir}/bin/mysql -e "grant all privileges on *.* to root@'127.0.0.1' identified by \"${dbrootpwd}\" with grant option;" ${percona_install_dir}/bin/mysql -e "grant all privileges on *.* to root@'localhost' identified by \"${dbrootpwd}\" with grant option;" - ${percona_install_dir}/bin/mysql -uroot -p${dbrootpwd} -e "delete from mysql.user where Password='' and User not like 'mysql.%';" + ${percona_install_dir}/bin/mysql -uroot -p${dbrootpwd} -e "delete from mysql.user where Password='';" ${percona_install_dir}/bin/mysql -uroot -p${dbrootpwd} -e "delete from mysql.db where User='';" ${percona_install_dir}/bin/mysql -uroot -p${dbrootpwd} -e "delete from mysql.proxies_priv where Host!='localhost';" ${percona_install_dir}/bin/mysql -uroot -p${dbrootpwd} -e "drop database test;" ${percona_install_dir}/bin/mysql -uroot -p${dbrootpwd} -e "reset master;" - rm -rf /etc/ld.so.conf.d/{mysql,mariadb,percona}*.conf - echo "${percona_install_dir}/lib" > /etc/ld.so.conf.d/z-percona.conf + rm -rf /etc/ld.so.conf.d/{mysql,mariadb,percona,alisql}*.conf + echo "${percona_install_dir}/lib" > /etc/ld.so.conf.d/percona.conf ldconfig service mysqld stop } diff --git a/include/percona-8.0.sh b/include/percona-5.6.sh similarity index 63% rename from include/percona-8.0.sh rename to include/percona-5.6.sh index 7ddce40c..d387ee53 100644 --- a/include/percona-8.0.sh +++ b/include/percona-5.6.sh @@ -1,71 +1,72 @@ #!/bin/bash # Author: yeho -# BLOG: https://linuxeye.com +# BLOG: https://blog.linuxeye.com +# +# Notes: OneinStack for CentOS/RadHat 5+ Debian 6+ and Ubuntu 12+ +# +# Project home page: +# https://oneinstack.com +# https://github.com/lj2007331/oneinstack + +Install_Percona56() { + pushd ${oneinstack_dir}/src -Install_Percona80() { - pushd ${current_dir}/src > /dev/null id -u mysql >/dev/null 2>&1 [ $? -ne 0 ] && useradd -M -s /sbin/nologin mysql [ ! -d "${percona_install_dir}" ] && mkdir -p ${percona_install_dir} - mkdir -p ${percona_data_dir};chown mysql:mysql -R ${percona_data_dir} - - if [ "${dbinstallmethod}" == "1" ]; then - tar xzf ./Percona-Server-${percona80_ver}-Linux.x86_64.glibc2.35.tar.gz - mv Percona-Server-${percona80_ver}-Linux.x86_64.glibc2.35/* ${percona_install_dir} - #sed -i 's@executing mysqld_safe@executing mysqld_safe\nexport LD_PRELOAD=/usr/local/lib/libjemalloc.so@' ${percona_install_dir}/bin/mysqld_safe - sed -i "s@/usr/local/Percona-Server-${percona80_ver}-Linux.x86_64.glibc2.35@${percona_install_dir}@g" ${percona_install_dir}/bin/mysqld_safe - elif [ "${dbinstallmethod}" == "2" ]; then - boostVersion2=$(echo ${boost_percona_ver} | awk -F. '{print $1"_"$2"_"$3}') - tar xzf boost_${boostVersion2}.tar.gz - tar xzf percona-server-${percona80_ver}.tar.gz - pushd percona-server-${percona80_ver} + mkdir -p ${percona_data_dir};chown mysql.mysql -R ${percona_data_dir} + + if [ "${dbInstallMethods}" == "1" ]; then + perconaVerStr1=$(echo ${percona56_version} | sed "s@-@-rel@") + tar xvf Percona-Server-${perconaVerStr1}-Linux.${SYS_BIT_b}.${sslLibVer}.tar.gz + mv Percona-Server-${perconaVerStr1}-Linux.${SYS_BIT_b}.${sslLibVer}/* ${percona_install_dir} + sed -i 's@executing mysqld_safe@executing mysqld_safe\nexport LD_PRELOAD=/usr/local/lib/libjemalloc.so@' ${percona_install_dir}/bin/mysqld_safe + sed -i "s@/usr/local/Percona-Server-${perconaVerStr1}-Linux.${SYS_BIT_b}.${sslLibVer}@${percona_install_dir}@g" ${percona_install_dir}/bin/mysqld_safe + elif [ "${dbInstallMethods}" == "2" ]; then + tar xvf percona-server-${percona56_version}.tar.gz + pushd percona-server-${percona56_version} cmake . -DCMAKE_INSTALL_PREFIX=${percona_install_dir} \ -DMYSQL_DATADIR=${percona_data_dir} \ - -DDOWNLOAD_BOOST=1 \ - -DWITH_BOOST=../boost_${boostVersion2} \ - -DFORCE_INSOURCE_BUILD=1 \ -DSYSCONFDIR=/etc \ -DWITH_INNOBASE_STORAGE_ENGINE=1 \ -DWITH_PARTITION_STORAGE_ENGINE=1 \ -DWITH_FEDERATED_STORAGE_ENGINE=1 \ -DWITH_BLACKHOLE_STORAGE_ENGINE=1 \ -DWITH_MYISAM_STORAGE_ENGINE=1 \ + -DWITH_ARCHIVE_STORAGE_ENGINE=1 \ -DWITH_EMBEDDED_SERVER=1 \ -DENABLE_DTRACE=0 \ -DENABLED_LOCAL_INFILE=1 \ -DDEFAULT_CHARSET=utf8mb4 \ - -DEXTRA_CHARSETS=all + -DDEFAULT_COLLATION=utf8mb4_general_ci \ + -DEXTRA_CHARSETS=all \ + -DCMAKE_EXE_LINKER_FLAGS='-ljemalloc' make -j ${THREAD} make install - sed -i 's@^load_jemalloc=1@load_jemalloc=0@' ${percona_install_dir}/bin/mysqld_safe popd fi - # backup openssl so - #[ ! -e "${percona_install_dir}/lib/lib_bk" ] && mkdir ${percona_install_dir}/lib/lib_bk - #/bin/mv ${percona_install_dir}/lib/{libssl,libcrypto}.so* ${percona_install_dir}/lib/lib_bk/ - if [ -d "${percona_install_dir}/support-files" ]; then - sed -i "s+^dbrootpwd.*+dbrootpwd='${dbrootpwd}'+" ../options.conf echo "${CSUCCESS}Percona installed successfully! ${CEND}" - if [ "${dbinstallmethod}" == "1" ]; then - rm -rf Percona-Server-${percona80_ver}-Linux.x86_64.glibc2.35 - elif [ "${dbinstallmethod}" == "2" ]; then - rm -rf percona-server-${percona80_ver} boost_${boostVersion2} + if [ "${dbInstallMethods}" == "1" ]; then + rm -rf Percona-Server-${perconaVerStr1}-Linux.${SYS_BIT_b}.${sslLibVer} + elif [ "${dbInstallMethods}" == "2" ]; then + rm -rf percona-server-${percona56_version} fi else rm -rf ${percona_install_dir} - echo "${CFAILURE}Percona install failed, Please contact the author! ${CEND}" && grep -Ew 'NAME|ID|ID_LIKE|VERSION_ID|PRETTY_NAME' /etc/os-release - kill -9 $$; exit 1; + rm -rf percona-server-${percona56_version} + echo "${CFAILURE}Percona install failed, Please contact the author! ${CEND}" + kill -9 $$ fi /bin/cp ${percona_install_dir}/support-files/mysql.server /etc/init.d/mysqld sed -i "s@^basedir=.*@basedir=${percona_install_dir}@" /etc/init.d/mysqld sed -i "s@^datadir=.*@datadir=${percona_data_dir}@" /etc/init.d/mysqld chmod +x /etc/init.d/mysqld - [ "${PM}" == 'yum' ] && { chkconfig --add mysqld; chkconfig mysqld on; } - [ "${PM}" == 'apt-get' ] && update-rc.d mysqld defaults + [ "${OS}" == "CentOS" ] && { chkconfig --add mysqld; chkconfig mysqld on; } + [[ "${OS}" =~ ^Ubuntu$|^Debian$ ]] && update-rc.d mysqld defaults popd # my.cnf @@ -82,7 +83,6 @@ no-auto-rehash [mysqld] port = 3306 socket = /tmp/mysql.sock -default_authentication_plugin = mysql_native_password basedir = ${percona_install_dir} datadir = ${percona_data_dir} @@ -93,7 +93,6 @@ server-id = 1 init-connect = 'SET NAMES utf8mb4' character-set-server = utf8mb4 -collation-server = utf8mb4_0900_ai_ci skip-name-resolve #skip-networking @@ -116,11 +115,15 @@ key_buffer_size = 4M thread_cache_size = 8 +query_cache_type = 1 +query_cache_size = 8M +query_cache_limit = 2M + ft_min_word_len = 4 log_bin = mysql-bin binlog_format = mixed -binlog_expire_logs_seconds = 604800 +expire_logs_days = 7 log_error = ${percona_data_dir}/mysql-error.log slow_query_log = 1 @@ -135,7 +138,6 @@ explicit_defaults_for_timestamp skip-external-locking default_storage_engine = InnoDB -#default-storage-engine = MyISAM innodb_file_per_table = 1 innodb_open_files = 500 innodb_buffer_pool_size = 64M @@ -153,6 +155,7 @@ innodb_lock_wait_timeout = 120 bulk_insert_buffer_size = 8M myisam_sort_buffer_size = 8M myisam_max_sort_file_size = 10G +myisam_repair_threads = 1 interactive_timeout = 28800 wait_timeout = 28800 @@ -171,6 +174,7 @@ EOF sed -i "s@max_connections.*@max_connections = $((${Mem}/3))@" /etc/my.cnf if [ ${Mem} -gt 1500 -a ${Mem} -le 2500 ]; then sed -i 's@^thread_cache_size.*@thread_cache_size = 16@' /etc/my.cnf + sed -i 's@^query_cache_size.*@query_cache_size = 16M@' /etc/my.cnf sed -i 's@^myisam_sort_buffer_size.*@myisam_sort_buffer_size = 16M@' /etc/my.cnf sed -i 's@^key_buffer_size.*@key_buffer_size = 16M@' /etc/my.cnf sed -i 's@^innodb_buffer_pool_size.*@innodb_buffer_pool_size = 128M@' /etc/my.cnf @@ -178,6 +182,7 @@ EOF sed -i 's@^table_open_cache.*@table_open_cache = 256@' /etc/my.cnf elif [ ${Mem} -gt 2500 -a ${Mem} -le 3500 ]; then sed -i 's@^thread_cache_size.*@thread_cache_size = 32@' /etc/my.cnf + sed -i 's@^query_cache_size.*@query_cache_size = 32M@' /etc/my.cnf sed -i 's@^myisam_sort_buffer_size.*@myisam_sort_buffer_size = 32M@' /etc/my.cnf sed -i 's@^key_buffer_size.*@key_buffer_size = 64M@' /etc/my.cnf sed -i 's@^innodb_buffer_pool_size.*@innodb_buffer_pool_size = 512M@' /etc/my.cnf @@ -185,6 +190,7 @@ EOF sed -i 's@^table_open_cache.*@table_open_cache = 512@' /etc/my.cnf elif [ ${Mem} -gt 3500 ]; then sed -i 's@^thread_cache_size.*@thread_cache_size = 64@' /etc/my.cnf + sed -i 's@^query_cache_size.*@query_cache_size = 64M@' /etc/my.cnf sed -i 's@^myisam_sort_buffer_size.*@myisam_sort_buffer_size = 64M@' /etc/my.cnf sed -i 's@^key_buffer_size.*@key_buffer_size = 256M@' /etc/my.cnf sed -i 's@^innodb_buffer_pool_size.*@innodb_buffer_pool_size = 1024M@' /etc/my.cnf @@ -192,24 +198,24 @@ EOF sed -i 's@^table_open_cache.*@table_open_cache = 1024@' /etc/my.cnf fi - ${percona_install_dir}/bin/mysqld --initialize-insecure --user=mysql --basedir=${percona_install_dir} --datadir=${percona_data_dir} + ${percona_install_dir}/scripts/mysql_install_db --user=mysql --basedir=${percona_install_dir} --datadir=${percona_data_dir} - [ "${Wsl}" == true ] && chmod 600 /etc/my.cnf - chown mysql:mysql -R ${percona_data_dir} + chown mysql.mysql -R ${percona_data_dir} [ -d "/etc/mysql" ] && /bin/mv /etc/mysql{,_bk} service mysqld start [ -z "$(grep ^'export PATH=' /etc/profile)" ] && echo "export PATH=${percona_install_dir}/bin:\$PATH" >> /etc/profile [ -n "$(grep ^'export PATH=' /etc/profile)" -a -z "$(grep ${percona_install_dir} /etc/profile)" ] && sed -i "s@^export PATH=\(.*\)@export PATH=${percona_install_dir}/bin:\1@" /etc/profile . /etc/profile - ${percona_install_dir}/bin/mysql -uroot -hlocalhost -e "create user root@'127.0.0.1' identified by \"${dbrootpwd}\";" - ${percona_install_dir}/bin/mysql -uroot -hlocalhost -e "grant all privileges on *.* to root@'127.0.0.1' with grant option;" - ${percona_install_dir}/bin/mysql -uroot -hlocalhost -e "grant all privileges on *.* to root@'localhost' with grant option;" - ${percona_install_dir}/bin/mysql -uroot -hlocalhost -e "alter user root@'localhost' identified by \"${dbrootpwd}\";" + ${percona_install_dir}/bin/mysql -e "grant all privileges on *.* to root@'127.0.0.1' identified by \"${dbrootpwd}\" with grant option;" + ${percona_install_dir}/bin/mysql -e "grant all privileges on *.* to root@'localhost' identified by \"${dbrootpwd}\" with grant option;" + ${percona_install_dir}/bin/mysql -uroot -p${dbrootpwd} -e "delete from mysql.user where Password='';" + ${percona_install_dir}/bin/mysql -uroot -p${dbrootpwd} -e "delete from mysql.db where User='';" + ${percona_install_dir}/bin/mysql -uroot -p${dbrootpwd} -e "delete from mysql.proxies_priv where Host!='localhost';" + ${percona_install_dir}/bin/mysql -uroot -p${dbrootpwd} -e "drop database test;" ${percona_install_dir}/bin/mysql -uroot -p${dbrootpwd} -e "reset master;" - rm -rf /etc/ld.so.conf.d/{mysql,mariadb,percona}*.conf - [ -e "${percona_install_dir}/my.cnf" ] && rm -f ${percona_install_dir}/my.cnf - echo "${percona_install_dir}/lib" > /etc/ld.so.conf.d/z-percona.conf + rm -rf /etc/ld.so.conf.d/{mysql,mariadb,percona,alisql}*.conf + echo "${percona_install_dir}/lib" > /etc/ld.so.conf.d/percona.conf ldconfig service mysqld stop } diff --git a/include/percona-5.7.sh b/include/percona-5.7.sh index 1ac6bef0..ffdfd37c 100644 --- a/include/percona-5.7.sh +++ b/include/percona-5.7.sh @@ -1,29 +1,32 @@ #!/bin/bash # Author: yeho -# BLOG: https://linuxeye.com +# BLOG: https://blog.linuxeye.com +# +# Notes: OneinStack for CentOS/RadHat 5+ Debian 6+ and Ubuntu 12+ +# +# Project home page: +# https://oneinstack.com +# https://github.com/lj2007331/oneinstack Install_Percona57() { - pushd ${current_dir}/src > /dev/null + pushd ${oneinstack_dir}/src + id -u mysql >/dev/null 2>&1 [ $? -ne 0 ] && useradd -M -s /sbin/nologin mysql [ ! -d "${percona_install_dir}" ] && mkdir -p ${percona_install_dir} - mkdir -p ${percona_data_dir};chown mysql:mysql -R ${percona_data_dir} + mkdir -p ${percona_data_dir};chown mysql.mysql -R ${percona_data_dir} - if [ "${dbinstallmethod}" == "1" ]; then - tar xzf Percona-Server-${percona57_ver}-Linux.x86_64.glibc2.35.tar.gz - mv Percona-Server-${percona57_ver}-Linux.x86_64.glibc2.35/* ${percona_install_dir} + if [ "${dbInstallMethods}" == "1" ]; then + tar xvf Percona-Server-${percona57_version}-Linux.${SYS_BIT_b}.${sslLibVer}.tar.gz + mv Percona-Server-${percona57_version}-Linux.${SYS_BIT_b}.${sslLibVer}/* ${percona_install_dir} sed -i 's@executing mysqld_safe@executing mysqld_safe\nexport LD_PRELOAD=/usr/local/lib/libjemalloc.so@' ${percona_install_dir}/bin/mysqld_safe - sed -i "s@Percona-Server-${percona57_ver}-Linux.x86_64.glibc2.35@${percona_install_dir}@g" ${percona_install_dir}/bin/mysqld_safe - elif [ "${dbinstallmethod}" == "2" ]; then - boostVersion2=$(echo ${boost_oldver} | awk -F. '{print $1"_"$2"_"$3}') - tar xzf boost_${boostVersion2}.tar.gz - tar xzf percona-server-${percona57_ver}.tar.gz - pushd percona-server-${percona57_ver} + sed -i "s@/usr/local/Percona-Server-${percona57_version}-Linux.${SYS_BIT_b}.${sslLibVer}@${percona_install_dir}@g" ${percona_install_dir}/bin/mysqld_safe + elif [ "${dbInstallMethods}" == "2" ]; then + tar xvf percona-server-${percona57_version}.tar.gz + pushd percona-server-${percona57_version} cmake . -DCMAKE_INSTALL_PREFIX=${percona_install_dir} \ -DMYSQL_DATADIR=${percona_data_dir} \ - -DDOWNLOAD_BOOST=1 \ - -DWITH_BOOST=../boost_${boostVersion2} \ -DSYSCONFDIR=/etc \ -DWITH_INNOBASE_STORAGE_ENGINE=1 \ -DWITH_PARTITION_STORAGE_ENGINE=1 \ @@ -45,25 +48,25 @@ Install_Percona57() { fi if [ -d "${percona_install_dir}/support-files" ]; then - sed -i "s+^dbrootpwd.*+dbrootpwd='${dbrootpwd}'+" ../options.conf echo "${CSUCCESS}Percona installed successfully! ${CEND}" - if [ "${dbinstallmethod}" == "1" ]; then - rm -rf Percona-Server-${percona57_ver}-Linux.x86_64.${sslLibVer} - elif [ "${dbinstallmethod}" == "2" ]; then - rm -rf percona-server-${percona57_ver} boost_${boostVersion2} + if [ "${dbInstallMethods}" == "1" ]; then + rm -rf Percona-Server-${percona57_version}-Linux.${SYS_BIT_b}.${sslLibVer} + elif [ "${dbInstallMethods}" == "2" ]; then + rm -rf percona-server-${percona57_version} fi else rm -rf ${percona_install_dir} - echo "${CFAILURE}Percona install failed, Please contact the author! ${CEND}" && grep -Ew 'NAME|ID|ID_LIKE|VERSION_ID|PRETTY_NAME' /etc/os-release - kill -9 $$; exit 1; + rm -rf percona-server-${percona57_version} + echo "${CFAILURE}Percona install failed, Please contact the author! ${CEND}" + kill -9 $$ fi /bin/cp ${percona_install_dir}/support-files/mysql.server /etc/init.d/mysqld sed -i "s@^basedir=.*@basedir=${percona_install_dir}@" /etc/init.d/mysqld sed -i "s@^datadir=.*@datadir=${percona_data_dir}@" /etc/init.d/mysqld chmod +x /etc/init.d/mysqld - [ "${PM}" == 'yum' ] && { chkconfig --add mysqld; chkconfig mysqld on; } - [ "${PM}" == 'apt-get' ] && update-rc.d mysqld defaults + [ "${OS}" == "CentOS" ] && { chkconfig --add mysqld; chkconfig mysqld on; } + [[ "${OS}" =~ ^Ubuntu$|^Debian$ ]] && update-rc.d mysqld defaults popd # my.cnf @@ -71,6 +74,7 @@ Install_Percona57() { [client] port = 3306 socket = /tmp/mysql.sock +default-character-set = utf8mb4 [mysql] prompt="Percona [\\d]> " @@ -151,6 +155,7 @@ innodb_lock_wait_timeout = 120 bulk_insert_buffer_size = 8M myisam_sort_buffer_size = 8M myisam_max_sort_file_size = 10G +myisam_repair_threads = 1 interactive_timeout = 28800 wait_timeout = 28800 @@ -195,8 +200,7 @@ EOF ${percona_install_dir}/bin/mysqld --initialize-insecure --user=mysql --basedir=${percona_install_dir} --datadir=${percona_data_dir} - [ "${Wsl}" == true ] && chmod 600 /etc/my.cnf - chown mysql:mysql -R ${percona_data_dir} + chown mysql.mysql -R ${percona_data_dir} [ -d "/etc/mysql" ] && /bin/mv /etc/mysql{,_bk} service mysqld start [ -z "$(grep ^'export PATH=' /etc/profile)" ] && echo "export PATH=${percona_install_dir}/bin:\$PATH" >> /etc/profile @@ -206,9 +210,9 @@ EOF ${percona_install_dir}/bin/mysql -e "grant all privileges on *.* to root@'127.0.0.1' identified by \"${dbrootpwd}\" with grant option;" ${percona_install_dir}/bin/mysql -e "grant all privileges on *.* to root@'localhost' identified by \"${dbrootpwd}\" with grant option;" ${percona_install_dir}/bin/mysql -uroot -p${dbrootpwd} -e "reset master;" - rm -rf /etc/ld.so.conf.d/{mysql,mariadb,percona}*.conf + rm -rf /etc/ld.so.conf.d/{mysql,mariadb,percona,alisql}*.conf [ -e "${percona_install_dir}/my.cnf" ] && rm -rf ${percona_install_dir}/my.cnf - echo "${percona_install_dir}/lib" > /etc/ld.so.conf.d/z-percona.conf + echo "${percona_install_dir}/lib" > /etc/ld.so.conf.d/mysql.conf ldconfig service mysqld stop } diff --git a/include/percona-8.4.sh b/include/percona-8.4.sh deleted file mode 100644 index e581fa3e..00000000 --- a/include/percona-8.4.sh +++ /dev/null @@ -1,212 +0,0 @@ -#!/bin/bash -# Author: yeho -# BLOG: https://linuxeye.com - -Install_Percona84() { - pushd ${current_dir}/src > /dev/null - id -u mysql >/dev/null 2>&1 - [ $? -ne 0 ] && useradd -M -s /sbin/nologin mysql - - [ ! -d "${percona_install_dir}" ] && mkdir -p ${percona_install_dir} - mkdir -p ${percona_data_dir};chown mysql:mysql -R ${percona_data_dir} - - if [ "${dbinstallmethod}" == "1" ]; then - tar xzf ./Percona-Server-${percona84_ver}-Linux.x86_64.glibc2.35.tar.gz - mv Percona-Server-${percona84_ver}-Linux.x86_64.glibc2.35/* ${percona_install_dir} - #sed -i 's@executing mysqld_safe@executing mysqld_safe\nexport LD_PRELOAD=/usr/local/lib/libjemalloc.so@' ${percona_install_dir}/bin/mysqld_safe - sed -i "s@/usr/local/Percona-Server-${percona84_ver}-Linux.x86_64.glibc2.35@${percona_install_dir}@g" ${percona_install_dir}/bin/mysqld_safe - elif [ "${dbinstallmethod}" == "2" ]; then - boostVersion2=$(echo ${boost_percona_ver} | awk -F. '{print $1"_"$2"_"$3}') - tar xzf boost_${boostVersion2}.tar.gz - tar xzf percona-server-${percona84_ver}.tar.gz - pushd percona-server-${percona84_ver} - cmake . -DCMAKE_INSTALL_PREFIX=${percona_install_dir} \ - -DMYSQL_DATADIR=${percona_data_dir} \ - -DDOWNLOAD_BOOST=1 \ - -DWITH_BOOST=../boost_${boostVersion2} \ - -DFORCE_INSOURCE_BUILD=1 \ - -DSYSCONFDIR=/etc \ - -DWITH_INNOBASE_STORAGE_ENGINE=1 \ - -DWITH_PARTITION_STORAGE_ENGINE=1 \ - -DWITH_FEDERATED_STORAGE_ENGINE=1 \ - -DWITH_BLACKHOLE_STORAGE_ENGINE=1 \ - -DWITH_MYISAM_STORAGE_ENGINE=1 \ - -DWITH_EMBEDDED_SERVER=1 \ - -DENABLE_DTRACE=0 \ - -DENABLED_LOCAL_INFILE=1 \ - -DDEFAULT_CHARSET=utf8mb4 \ - -DEXTRA_CHARSETS=all - make -j ${THREAD} - make install - sed -i 's@^load_jemalloc=1@load_jemalloc=0@' ${percona_install_dir}/bin/mysqld_safe - popd - fi - - # backup openssl so - #[ ! -e "${percona_install_dir}/lib/lib_bk" ] && mkdir ${percona_install_dir}/lib/lib_bk - #/bin/mv ${percona_install_dir}/lib/{libssl,libcrypto}.so* ${percona_install_dir}/lib/lib_bk/ - - if [ -d "${percona_install_dir}/support-files" ]; then - sed -i "s+^dbrootpwd.*+dbrootpwd='${dbrootpwd}'+" ../options.conf - echo "${CSUCCESS}Percona installed successfully! ${CEND}" - if [ "${dbinstallmethod}" == "1" ]; then - rm -rf Percona-Server-${percona84_ver}-Linux.x86_64.glibc2.35 - elif [ "${dbinstallmethod}" == "2" ]; then - rm -rf percona-server-${percona84_ver} boost_${boostVersion2} - fi - else - rm -rf ${percona_install_dir} - echo "${CFAILURE}Percona install failed, Please contact the author! ${CEND}" && grep -Ew 'NAME|ID|ID_LIKE|VERSION_ID|PRETTY_NAME' /etc/os-release - kill -9 $$; exit 1; - fi - - /bin/cp ${percona_install_dir}/support-files/mysql.server /etc/init.d/mysqld - sed -i "s@^basedir=.*@basedir=${percona_install_dir}@" /etc/init.d/mysqld - sed -i "s@^datadir=.*@datadir=${percona_data_dir}@" /etc/init.d/mysqld - chmod +x /etc/init.d/mysqld - [ "${PM}" == 'yum' ] && { chkconfig --add mysqld; chkconfig mysqld on; } - [ "${PM}" == 'apt-get' ] && update-rc.d mysqld defaults - popd - - # my.cnf - cat > /etc/my.cnf << EOF -[client] -port = 3306 -socket = /tmp/mysql.sock -default-character-set = utf8mb4 - -[mysql] -prompt="Percona [\\d]> " -no-auto-rehash - -[mysqld] -port = 3306 -socket = /tmp/mysql.sock -mysql_native_password = on - -basedir = ${percona_install_dir} -datadir = ${percona_data_dir} -pid-file = ${percona_data_dir}/mysql.pid -user = mysql -bind-address = 0.0.0.0 -server-id = 1 - -init-connect = 'SET NAMES utf8mb4' -character-set-server = utf8mb4 -collation-server = utf8mb4_0900_ai_ci - -skip-name-resolve -#skip-networking -back_log = 300 - -max_connections = 1000 -max_connect_errors = 6000 -open_files_limit = 65535 -table_open_cache = 128 -max_allowed_packet = 500M -binlog_cache_size = 1M -max_heap_table_size = 8M -tmp_table_size = 16M - -read_buffer_size = 2M -read_rnd_buffer_size = 8M -sort_buffer_size = 8M -join_buffer_size = 8M -key_buffer_size = 4M - -thread_cache_size = 8 - -ft_min_word_len = 4 - -log_bin = mysql-bin -binlog_expire_logs_seconds = 604800 - -log_error = ${percona_data_dir}/mysql-error.log -slow_query_log = 1 -long_query_time = 1 -slow_query_log_file = ${percona_data_dir}/mysql-slow.log - -performance_schema = 0 -explicit_defaults_for_timestamp - -#lower_case_table_names = 1 - -skip-external-locking - -default_storage_engine = InnoDB -#default-storage-engine = MyISAM -innodb_file_per_table = 1 -innodb_open_files = 500 -innodb_buffer_pool_size = 64M -innodb_write_io_threads = 4 -innodb_read_io_threads = 4 -innodb_thread_concurrency = 0 -innodb_purge_threads = 1 -innodb_flush_log_at_trx_commit = 2 -innodb_log_buffer_size = 2M -#innodb_redo_log_capacity = 2G -innodb_max_dirty_pages_pct = 90 -innodb_lock_wait_timeout = 120 - -bulk_insert_buffer_size = 8M -myisam_sort_buffer_size = 8M -myisam_max_sort_file_size = 10G - -interactive_timeout = 28800 -wait_timeout = 28800 - -[mysqldump] -quick -max_allowed_packet = 500M - -[myisamchk] -key_buffer_size = 8M -sort_buffer_size = 8M -read_buffer = 4M -write_buffer = 4M -EOF - - sed -i "s@max_connections.*@max_connections = $((${Mem}/3))@" /etc/my.cnf - if [ ${Mem} -gt 1500 -a ${Mem} -le 2500 ]; then - sed -i 's@^thread_cache_size.*@thread_cache_size = 16@' /etc/my.cnf - sed -i 's@^myisam_sort_buffer_size.*@myisam_sort_buffer_size = 16M@' /etc/my.cnf - sed -i 's@^key_buffer_size.*@key_buffer_size = 16M@' /etc/my.cnf - sed -i 's@^innodb_buffer_pool_size.*@innodb_buffer_pool_size = 128M@' /etc/my.cnf - sed -i 's@^tmp_table_size.*@tmp_table_size = 32M@' /etc/my.cnf - sed -i 's@^table_open_cache.*@table_open_cache = 256@' /etc/my.cnf - elif [ ${Mem} -gt 2500 -a ${Mem} -le 3500 ]; then - sed -i 's@^thread_cache_size.*@thread_cache_size = 32@' /etc/my.cnf - sed -i 's@^myisam_sort_buffer_size.*@myisam_sort_buffer_size = 32M@' /etc/my.cnf - sed -i 's@^key_buffer_size.*@key_buffer_size = 64M@' /etc/my.cnf - sed -i 's@^innodb_buffer_pool_size.*@innodb_buffer_pool_size = 512M@' /etc/my.cnf - sed -i 's@^tmp_table_size.*@tmp_table_size = 64M@' /etc/my.cnf - sed -i 's@^table_open_cache.*@table_open_cache = 512@' /etc/my.cnf - elif [ ${Mem} -gt 3500 ]; then - sed -i 's@^thread_cache_size.*@thread_cache_size = 64@' /etc/my.cnf - sed -i 's@^myisam_sort_buffer_size.*@myisam_sort_buffer_size = 64M@' /etc/my.cnf - sed -i 's@^key_buffer_size.*@key_buffer_size = 256M@' /etc/my.cnf - sed -i 's@^innodb_buffer_pool_size.*@innodb_buffer_pool_size = 1024M@' /etc/my.cnf - sed -i 's@^tmp_table_size.*@tmp_table_size = 128M@' /etc/my.cnf - sed -i 's@^table_open_cache.*@table_open_cache = 1024@' /etc/my.cnf - fi - - ${percona_install_dir}/bin/mysqld --initialize-insecure --user=mysql --basedir=${percona_install_dir} --datadir=${percona_data_dir} - - [ "${Wsl}" == true ] && chmod 600 /etc/my.cnf - chown mysql:mysql -R ${percona_data_dir} - [ -d "/etc/mysql" ] && /bin/mv /etc/mysql{,_bk} - service mysqld start - [ -z "$(grep ^'export PATH=' /etc/profile)" ] && echo "export PATH=${percona_install_dir}/bin:\$PATH" >> /etc/profile - [ -n "$(grep ^'export PATH=' /etc/profile)" -a -z "$(grep ${percona_install_dir} /etc/profile)" ] && sed -i "s@^export PATH=\(.*\)@export PATH=${percona_install_dir}/bin:\1@" /etc/profile - . /etc/profile - - ${percona_install_dir}/bin/mysql -uroot -hlocalhost -e "create user root@'127.0.0.1' identified by \"${dbrootpwd}\";" - ${percona_install_dir}/bin/mysql -uroot -hlocalhost -e "grant all privileges on *.* to root@'127.0.0.1' with grant option;" - ${percona_install_dir}/bin/mysql -uroot -hlocalhost -e "grant all privileges on *.* to root@'localhost' with grant option;" - ${percona_install_dir}/bin/mysql -uroot -hlocalhost -e "alter user root@'localhost' identified by \"${dbrootpwd}\";" - rm -rf /etc/ld.so.conf.d/{mysql,mariadb,percona}*.conf - [ -e "${percona_install_dir}/my.cnf" ] && rm -f ${percona_install_dir}/my.cnf - echo "${percona_install_dir}/lib" > /etc/ld.so.conf.d/z-percona.conf - ldconfig - service mysqld stop -} diff --git a/include/php-5.3.sh b/include/php-5.3.sh index 36e1a123..cfcc5722 100644 --- a/include/php-5.3.sh +++ b/include/php-5.3.sh @@ -1,162 +1,152 @@ #!/bin/bash # Author: yeho -# BLOG: https://linuxeye.com +# BLOG: https://blog.linuxeye.com +# +# Notes: OneinStack for CentOS/RadHat 5+ Debian 6+ and Ubuntu 12+ +# +# Project home page: +# https://oneinstack.com +# https://github.com/lj2007331/oneinstack Install_PHP53() { - pushd ${current_dir}/src > /dev/null - if [ ! -e "/usr/local/lib/libiconv.la" ]; then - tar xzf libiconv-${libiconv_ver}.tar.gz - pushd libiconv-${libiconv_ver} > /dev/null - ./configure - make -j ${THREAD} && make install - popd > /dev/null - rm -rf libiconv-${libiconv_ver} - fi - - if [ ! -e "${curl_install_dir}/lib/libcurl.la" ]; then - tar xzf curl-${curl_ver}.tar.gz - pushd curl-${curl_ver} > /dev/null - [ -e "/usr/local/lib/libnghttp2.so" ] && with_nghttp2='--with-nghttp2=/usr/local' - ./configure --prefix=${curl_install_dir} ${php5_with_ssl} ${with_nghttp2} - make -j ${THREAD} && make install - popd > /dev/null - rm -rf curl-${curl_ver} - fi - - if [ ! -e "${freetype_install_dir}/lib/libfreetype.la" ]; then - tar xzf freetype-${freetype_ver}.tar.gz - pushd freetype-${freetype_ver} > /dev/null - ./configure --prefix=${freetype_install_dir} --enable-freetype-config - make -j ${THREAD} && make install - ln -sf ${freetype_install_dir}/include/freetype2/* /usr/include/ - [ -d /usr/lib/pkgconfig ] && /bin/cp ${freetype_install_dir}/lib/pkgconfig/freetype2.pc /usr/lib/pkgconfig/ - popd > /dev/null - rm -rf freetype-${freetype_ver} - fi - - if [ ! -e "/usr/local/bin/libmcrypt-config" -a ! -e "/usr/bin/libmcrypt-config" ]; then - tar xzf libmcrypt-${libmcrypt_ver}.tar.gz - pushd libmcrypt-${libmcrypt_ver} > /dev/null - ./configure - make -j ${THREAD} && make install - ldconfig - pushd libltdl > /dev/null - ./configure --enable-ltdl-install - make -j ${THREAD} && make install - popd > /dev/null - popd > /dev/null - rm -rf libmcrypt-${libmcrypt_ver} + pushd ${oneinstack_dir}/src + + tar xzf libiconv-$libiconv_version.tar.gz + patch -d libiconv-$libiconv_version -p0 < libiconv-glibc-2.16.patch + pushd libiconv-$libiconv_version + ./configure --prefix=/usr/local + make -j ${THREAD} && make install + popd + rm -rf libiconv-$libiconv_version + + # Problem building php-5.3 with openssl + if [ "$Debian_version" == '8' -o "$Ubuntu_version" == '16' ]; then + OpenSSL_args='--with-openssl=/usr/local/openssl100s' + else + OpenSSL_args='--with-openssl' fi - - if [ ! -e "/usr/local/include/mhash.h" -a ! -e "/usr/include/mhash.h" ]; then - tar xzf mhash-${mhash_ver}.tar.gz - pushd mhash-${mhash_ver} > /dev/null - ./configure - make -j ${THREAD} && make install - popd > /dev/null - rm -rf mhash-${mhash_ver} + + if [ "$Debian_version" == '8' -o "$Ubuntu_version" == '16' ]; then + tar xzf curl-7.35.0.tar.gz + pushd curl-7.35.0 + LDFLAGS="-Wl,-rpath=/usr/local/openssl100s/lib" ./configure --prefix=/usr/local --with-ssl=/usr/local/openssl100s + else + tar xzf curl-$curl_version.tar.gz + pushd curl-$curl_version + ./configure --prefix=/usr/local fi - - [ -z "`grep /usr/local/lib /etc/ld.so.conf.d/*.conf`" ] && echo '/usr/local/lib' > /etc/ld.so.conf.d/local.conf + make -j ${THREAD} && make install + popd + rm -rf curl-7.35.0 curl-$curl_version + + tar xzf libmcrypt-$libmcrypt_version.tar.gz + pushd libmcrypt-$libmcrypt_version + ./configure + make -j ${THREAD} && make install ldconfig - - if [ "${PM}" == 'yum' ]; then - [ ! -e "/usr/bin/libmcrypt-config" ] && ln -s /usr/local/bin/libmcrypt-config /usr/bin/libmcrypt-config - [ ! -e "/lib64/libpcre.so.1" ] && ln -s /lib64/libpcre.so.0.0.1 /lib64/libpcre.so.1 - [ ! -e "/usr/lib/libc-client.so" ] && ln -s /usr/lib64/libc-client.so /usr/lib/libc-client.so - fi - - if [ ! -e "/usr/local/bin/mcrypt" -a ! -e "/usr/bin/mcrypt" ]; then - tar xzf mcrypt-${mcrypt_ver}.tar.gz - pushd mcrypt-${mcrypt_ver} > /dev/null - ldconfig - ./configure - make -j ${THREAD} && make install - popd > /dev/null - rm -rf mcrypt-${mcrypt_ver} - fi - - id -g ${run_group} >/dev/null 2>&1 - [ $? -ne 0 ] && groupadd ${run_group} - id -u ${run_user} >/dev/null 2>&1 - [ $? -ne 0 ] && useradd -g ${run_group} -M -s /sbin/nologin ${run_user} - - tar xzf php-${php53_ver}.tar.gz - patch -d php-${php53_ver} -p0 < fpm-race-condition.patch - pushd php-${php53_ver} > /dev/null + pushd libltdl + ./configure --enable-ltdl-install + make -j ${THREAD} && make install + popd;popd + rm -rf libmcrypt-$libmcrypt_version + + tar xzf mhash-$mhash_version.tar.gz + pushd mhash-$mhash_version + ./configure + make -j ${THREAD} && make install + popd + rm -rf mhash-$mhash_version + + echo '/usr/local/lib' > /etc/ld.so.conf.d/local.conf + ldconfig + [ "$OS" == 'CentOS' ] && { ln -s /usr/local/bin/libmcrypt-config /usr/bin/libmcrypt-config; [ "$OS_BIT" == '64' ] && ln -s /lib64/libpcre.so.0.0.1 /lib64/libpcre.so.1 || ln -s /lib/libpcre.so.0.0.1 /lib/libpcre.so.1; } + + [ ! -e '/usr/include/freetype2/freetype' ] && ln -s /usr/include/freetype2 /usr/include/freetype2/freetype + + tar xzf mcrypt-$mcrypt_version.tar.gz + pushd mcrypt-$mcrypt_version + ldconfig + ./configure + make -j ${THREAD} && make install + popd + rm -rf mcrypt-$mcrypt_version + + id -u $run_user >/dev/null 2>&1 + [ $? -ne 0 ] && useradd -M -s /sbin/nologin $run_user + + tar xzf php-$php53_version.tar.gz + patch -d php-$php53_version -p0 < fpm-race-condition.patch + pushd php-$php53_version patch -p1 < ../php5.3patch patch -p1 < ../debian_patches_disable_SSLv2_for_openssl_1_0_0.patch - patch -p1 < ../php5.3-fileinfo.patch make clean - [ ! -d "${php_install_dir}" ] && mkdir -p ${php_install_dir} - { [ ${RHEL_ver:-0} -ge 9 >/dev/null 2>&1 ] || [ ${Debian_ver:-0} -ge 10 >/dev/null 2>&1 ] || [ ${Ubuntu_ver:-0} -ge 19 >/dev/null 2>&1 ]; } || intl_modules_options='--enable-intl' - [[ "${Platform}" =~ ^hce$ ]] && unset intl_modules_options - if [ "${apache_mode_option}" == '2' ]; then - ./configure --prefix=${php_install_dir} --with-config-file-path=${php_install_dir}/etc \ - --with-config-file-scan-dir=${php_install_dir}/etc/php.d \ - --with-apxs2=${apache_install_dir}/bin/apxs --disable-fileinfo \ + [ ! -d "$php_install_dir" ] && mkdir -p $php_install_dir + if [[ $Apache_version =~ ^[1-2]$ ]] || [ -e "$apache_install_dir/bin/apxs" ]; then + ./configure --prefix=$php_install_dir --with-config-file-path=$php_install_dir/etc \ + --with-config-file-scan-dir=$php_install_dir/etc/php.d \ + --with-apxs2=$apache_install_dir/bin/apxs --disable-fileinfo \ --with-mysql=mysqlnd --with-mysqli=mysqlnd --with-pdo-mysql=mysqlnd \ - --with-iconv-dir=/usr/local --with-freetype-dir=${freetype_install_dir} --with-jpeg-dir --with-png-dir --with-zlib \ + --with-iconv-dir=/usr/local --with-freetype-dir --with-jpeg-dir --with-png-dir --with-zlib \ --with-libxml-dir=/usr --enable-xml --disable-rpath --enable-bcmath --enable-shmop --enable-exif \ - --enable-sysvsem --enable-inline-optimization ${php5_with_curl} --enable-mbregex \ - --enable-mbstring --with-mcrypt --with-gd --enable-gd-native-ttf ${php5_with_openssl} \ - --with-mhash --enable-pcntl --enable-sockets --with-xmlrpc --enable-ftp --with-xsl ${intl_modules_options} \ - --with-gettext --enable-zip --enable-soap --disable-debug ${php_modules_options} + --enable-sysvsem --enable-inline-optimization --with-curl=/usr/local --enable-mbregex \ + --enable-mbstring --with-mcrypt --with-gd --enable-gd-native-ttf $OpenSSL_args \ + --with-mhash --enable-pcntl --enable-sockets --with-xmlrpc --enable-ftp --enable-intl --with-xsl \ + --with-gettext --enable-zip --enable-soap --disable-debug $php_modules_options else - ./configure --prefix=${php_install_dir} --with-config-file-path=${php_install_dir}/etc \ - --with-config-file-scan-dir=${php_install_dir}/etc/php.d \ - --with-fpm-user=${run_user} --with-fpm-group=${run_group} --enable-fpm --disable-fileinfo \ + ./configure --prefix=$php_install_dir --with-config-file-path=$php_install_dir/etc \ + --with-config-file-scan-dir=$php_install_dir/etc/php.d \ + --with-fpm-user=$run_user --with-fpm-group=$run_user --enable-fpm --disable-fileinfo \ --with-mysql=mysqlnd --with-mysqli=mysqlnd --with-pdo-mysql=mysqlnd \ - --with-iconv-dir=/usr/local --with-freetype-dir=${freetype_install_dir} --with-jpeg-dir --with-png-dir --with-zlib \ + --with-iconv-dir=/usr/local --with-freetype-dir --with-jpeg-dir --with-png-dir --with-zlib \ --with-libxml-dir=/usr --enable-xml --disable-rpath --enable-bcmath --enable-shmop --enable-exif \ - --enable-sysvsem --enable-inline-optimization ${php5_with_curl} --enable-mbregex \ - --enable-mbstring --with-mcrypt --with-gd --enable-gd-native-ttf ${php5_with_openssl} \ - --with-mhash --enable-pcntl --enable-sockets --with-xmlrpc --enable-ftp --with-xsl ${intl_modules_options} \ - --with-gettext --enable-zip --enable-soap --disable-debug ${php_modules_options} + --enable-sysvsem --enable-inline-optimization --with-curl=/usr/local --enable-mbregex \ + --enable-mbstring --with-mcrypt --with-gd --enable-gd-native-ttf $OpenSSL_args \ + --with-mhash --enable-pcntl --enable-sockets --with-xmlrpc --enable-ftp --enable-intl --with-xsl \ + --with-gettext --enable-zip --enable-soap --disable-debug $php_modules_options fi - { [ "${Platform}" == "hce" ] || [ ${RHEL_ver:-0} -ge 9 >/dev/null 2>&1 ] || [ ${Debian_ver:-0} -ge 10 >/dev/null 2>&1 ] || [ ${Ubuntu_ver:-0} -ge 19 >/dev/null 2>&1 ]; } || sed -i '/^BUILD_/ s/\$(CC)/\$(CXX)/g' Makefile - [[ "${Platform}" =~ ^hce$ ]] && sed -i 's@-export-dynamic@-Wl,--export-dynamic@g' Makefile + sed -i '/^BUILD_/ s/\$(CC)/\$(CXX)/g' Makefile make ZEND_EXTRA_LIBS='-liconv' -j ${THREAD} make install - - if [ -e "${php_install_dir}/bin/phpize" ]; then - [ ! -e "${php_install_dir}/etc/php.d" ] && mkdir -p ${php_install_dir}/etc/php.d + + if [ -e "$php_install_dir/bin/phpize" ]; then echo "${CSUCCESS}PHP installed successfully! ${CEND}" else - rm -rf ${php_install_dir} + rm -rf $php_install_dir echo "${CFAILURE}PHP install failed, Please Contact the author! ${CEND}" - kill -9 $$; exit 1; + kill -9 $$ fi - - [ -z "`grep ^'export PATH=' /etc/profile`" ] && echo "export PATH=${php_install_dir}/bin:\$PATH" >> /etc/profile - [ -n "`grep ^'export PATH=' /etc/profile`" -a -z "`grep ${php_install_dir} /etc/profile`" ] && sed -i "s@^export PATH=\(.*\)@export PATH=${php_install_dir}/bin:\1@" /etc/profile + + [ -z "`grep ^'export PATH=' /etc/profile`" ] && echo "export PATH=$php_install_dir/bin:\$PATH" >> /etc/profile + [ -n "`grep ^'export PATH=' /etc/profile`" -a -z "`grep $php_install_dir /etc/profile`" ] && sed -i "s@^export PATH=\(.*\)@export PATH=$php_install_dir/bin:\1@" /etc/profile . /etc/profile - + # wget -c http://pear.php.net/go-pear.phar - # ${php_install_dir}/bin/php go-pear.phar - - /bin/cp php.ini-production ${php_install_dir}/etc/php.ini - - sed -i "s@^memory_limit.*@memory_limit = ${Memory_limit}M@" ${php_install_dir}/etc/php.ini - sed -i 's@^output_buffering =@output_buffering = On\noutput_buffering =@' ${php_install_dir}/etc/php.ini - #sed -i 's@^;cgi.fix_pathinfo.*@cgi.fix_pathinfo=0@' ${php_install_dir}/etc/php.ini - sed -i 's@^short_open_tag = Off@short_open_tag = On@' ${php_install_dir}/etc/php.ini - sed -i 's@^expose_php = On@expose_php = Off@' ${php_install_dir}/etc/php.ini - sed -i 's@^request_order.*@request_order = "CGP"@' ${php_install_dir}/etc/php.ini - sed -i "s@^;date.timezone.*@date.timezone = ${timezone}@" ${php_install_dir}/etc/php.ini - sed -i 's@^post_max_size.*@post_max_size = 100M@' ${php_install_dir}/etc/php.ini - sed -i 's@^upload_max_filesize.*@upload_max_filesize = 50M@' ${php_install_dir}/etc/php.ini - sed -i 's@^max_execution_time.*@max_execution_time = 5@' ${php_install_dir}/etc/php.ini - sed -i 's@^disable_functions.*@disable_functions = passthru,exec,system,chroot,chgrp,chown,shell_exec,proc_open,proc_get_status,ini_alter,ini_restore,dl,readlink,symlink,popepassthru,stream_socket_server,fsocket,popen@' ${php_install_dir}/etc/php.ini - [ -e /usr/sbin/sendmail ] && sed -i 's@^;sendmail_path.*@sendmail_path = /usr/sbin/sendmail -t -i@' ${php_install_dir}/etc/php.ini - - if [ "${apache_mode_option}" != '2' ]; then + # $php_install_dir/bin/php go-pear.phar + + [ ! -e "$php_install_dir/etc/php.d" ] && mkdir -p $php_install_dir/etc/php.d + /bin/cp php.ini-production $php_install_dir/etc/php.ini + + sed -i "s@^memory_limit.*@memory_limit = ${Memory_limit}M@" $php_install_dir/etc/php.ini + sed -i 's@^output_buffering =@output_buffering = On\noutput_buffering =@' $php_install_dir/etc/php.ini + sed -i 's@^;cgi.fix_pathinfo.*@cgi.fix_pathinfo=0@' $php_install_dir/etc/php.ini + sed -i 's@^short_open_tag = Off@short_open_tag = On@' $php_install_dir/etc/php.ini + sed -i 's@^expose_php = On@expose_php = Off@' $php_install_dir/etc/php.ini + sed -i 's@^request_order.*@request_order = "CGP"@' $php_install_dir/etc/php.ini + sed -i 's@^;date.timezone.*@date.timezone = Asia/Shanghai@' $php_install_dir/etc/php.ini + sed -i 's@^post_max_size.*@post_max_size = 100M@' $php_install_dir/etc/php.ini + sed -i 's@^upload_max_filesize.*@upload_max_filesize = 50M@' $php_install_dir/etc/php.ini + sed -i 's@^max_execution_time.*@max_execution_time = 5@' $php_install_dir/etc/php.ini + sed -i 's@^disable_functions.*@disable_functions = passthru,exec,system,chroot,chgrp,chown,shell_exec,proc_open,proc_get_status,ini_alter,ini_restore,dl,openlog,syslog,readlink,symlink,popepassthru,stream_socket_server,fsocket,popen@' $php_install_dir/etc/php.ini + [ -e /usr/sbin/sendmail ] && sed -i 's@^;sendmail_path.*@sendmail_path = /usr/sbin/sendmail -t -i@' $php_install_dir/etc/php.ini + + if [[ ! $Apache_version =~ ^[1-2]$ ]] && [ ! -e "$apache_install_dir/bin/apxs" ]; then # php-fpm Init Script - /bin/cp ${current_dir}/init.d/php-fpm.service /lib/systemd/system/ - sed -i "s@/usr/local/php@${php_install_dir}@g" /lib/systemd/system/php-fpm.service - systemctl enable php-fpm + /bin/cp sapi/fpm/init.d.php-fpm /etc/init.d/php-fpm + chmod +x /etc/init.d/php-fpm + [ "$OS" == 'CentOS' ] && { chkconfig --add php-fpm; chkconfig php-fpm on; } + [[ $OS =~ ^Ubuntu$|^Debian$ ]] && update-rc.d php-fpm defaults - cat > ${php_install_dir}/etc/php-fpm.conf < $php_install_dir/etc/php-fpm.conf < /dev/null - [ -e "${php_install_dir}/bin/phpize" ] && rm -rf php-${php53_ver} - popd > /dev/null + popd + [ -e "$php_install_dir/bin/phpize" ] && rm -rf php-$php53_version + popd } diff --git a/include/php-5.4.sh b/include/php-5.4.sh index ceaddbaa..1e17f58c 100644 --- a/include/php-5.4.sh +++ b/include/php-5.4.sh @@ -1,157 +1,134 @@ #!/bin/bash # Author: yeho -# BLOG: https://linuxeye.com +# BLOG: https://blog.linuxeye.com +# +# Notes: OneinStack for CentOS/RadHat 5+ Debian 6+ and Ubuntu 12+ +# +# Project home page: +# https://oneinstack.com +# https://github.com/lj2007331/oneinstack Install_PHP54() { - pushd ${current_dir}/src > /dev/null - if [ ! -e "/usr/local/lib/libiconv.la" ]; then - tar xzf libiconv-${libiconv_ver}.tar.gz - pushd libiconv-${libiconv_ver} > /dev/null - ./configure - make -j ${THREAD} && make install - popd > /dev/null - rm -rf libiconv-${libiconv_ver} - fi - - if [ ! -e "${curl_install_dir}/lib/libcurl.la" ]; then - tar xzf curl-${curl_ver}.tar.gz - pushd curl-${curl_ver} > /dev/null - [ -e "/usr/local/lib/libnghttp2.so" ] && with_nghttp2='--with-nghttp2=/usr/local' - ./configure --prefix=${curl_install_dir} ${php5_with_ssl} ${with_nghttp2} - make -j ${THREAD} && make install - popd > /dev/null - rm -rf curl-${curl_ver} - fi - - if [ ! -e "${freetype_install_dir}/lib/libfreetype.la" ]; then - tar xzf freetype-${freetype_ver}.tar.gz - pushd freetype-${freetype_ver} > /dev/null - ./configure --prefix=${freetype_install_dir} --enable-freetype-config - make -j ${THREAD} && make install - ln -sf ${freetype_install_dir}/include/freetype2/* /usr/include/ - [ -d /usr/lib/pkgconfig ] && /bin/cp ${freetype_install_dir}/lib/pkgconfig/freetype2.pc /usr/lib/pkgconfig/ - popd > /dev/null - rm -rf freetype-${freetype_ver} - fi - - if [ ! -e "/usr/local/bin/libmcrypt-config" -a ! -e "/usr/bin/libmcrypt-config" ]; then - tar xzf libmcrypt-${libmcrypt_ver}.tar.gz - pushd libmcrypt-${libmcrypt_ver} > /dev/null - ./configure - make -j ${THREAD} && make install - ldconfig - pushd libltdl > /dev/null - ./configure --enable-ltdl-install - make -j ${THREAD} && make install - popd > /dev/null - popd > /dev/null - rm -rf libmcrypt-${libmcrypt_ver} - fi - - if [ ! -e "/usr/local/include/mhash.h" -a ! -e "/usr/include/mhash.h" ]; then - tar xzf mhash-${mhash_ver}.tar.gz - pushd mhash-${mhash_ver} > /dev/null - ./configure - make -j ${THREAD} && make install - popd > /dev/null - rm -rf mhash-${mhash_ver} - fi - - [ -z "`grep /usr/local/lib /etc/ld.so.conf.d/*.conf`" ] && echo '/usr/local/lib' > /etc/ld.so.conf.d/local.conf + pushd ${oneinstack_dir}/src + + tar xzf libiconv-$libiconv_version.tar.gz + patch -d libiconv-$libiconv_version -p0 < libiconv-glibc-2.16.patch + pushd libiconv-$libiconv_version + ./configure --prefix=/usr/local + make -j ${THREAD} && make install + popd + rm -rf libiconv-$libiconv_version + + tar xzf curl-$curl_version.tar.gz + pushd curl-$curl_version + ./configure --prefix=/usr/local + make -j ${THREAD} && make install + popd + rm -rf curl-$curl_version + + tar xzf libmcrypt-$libmcrypt_version.tar.gz + pushd libmcrypt-$libmcrypt_version + ./configure + make -j ${THREAD} && make install ldconfig - - if [ "${PM}" == 'yum' ]; then - [ ! -e "/usr/bin/libmcrypt-config" ] && ln -s /usr/local/bin/libmcrypt-config /usr/bin/libmcrypt-config - [ ! -e "/lib64/libpcre.so.1" ] && ln -s /lib64/libpcre.so.0.0.1 /lib64/libpcre.so.1 - [ ! -e "/usr/lib/libc-client.so" ] && ln -s /usr/lib64/libc-client.so /usr/lib/libc-client.so - fi - - if [ ! -e "/usr/local/bin/mcrypt" -a ! -e "/usr/bin/mcrypt" ]; then - tar xzf mcrypt-${mcrypt_ver}.tar.gz - pushd mcrypt-${mcrypt_ver} > /dev/null - ldconfig - ./configure - make -j ${THREAD} && make install - popd > /dev/null - rm -rf mcrypt-${mcrypt_ver} - fi - - id -g ${run_group} >/dev/null 2>&1 - [ $? -ne 0 ] && groupadd ${run_group} - id -u ${run_user} >/dev/null 2>&1 - [ $? -ne 0 ] && useradd -g ${run_group} -M -s /sbin/nologin ${run_user} - - tar xzf php-${php54_ver}.tar.gz - patch -d php-${php54_ver} -p0 < fpm-race-condition.patch - pushd php-${php54_ver} > /dev/null + pushd libltdl + ./configure --enable-ltdl-install + make -j ${THREAD} && make install + popd;popd + rm -rf libmcrypt-$libmcrypt_version + + tar xzf mhash-$mhash_version.tar.gz + pushd mhash-$mhash_version + ./configure + make -j ${THREAD} && make install + popd + rm -rf mhash-$mhash_version + + echo '/usr/local/lib' > /etc/ld.so.conf.d/local.conf + ldconfig + [ "$OS" == 'CentOS' ] && { ln -s /usr/local/bin/libmcrypt-config /usr/bin/libmcrypt-config; [ "$OS_BIT" == '64' ] && ln -s /lib64/libpcre.so.0.0.1 /lib64/libpcre.so.1 || ln -s /lib/libpcre.so.0.0.1 /lib/libpcre.so.1; } + + tar xzf mcrypt-$mcrypt_version.tar.gz + pushd mcrypt-$mcrypt_version + ldconfig + ./configure + make -j ${THREAD} && make install + popd + rm -rf mcrypt-$mcrypt_version + + id -u $run_user >/dev/null 2>&1 + [ $? -ne 0 ] && useradd -M -s /sbin/nologin $run_user + + tar xzf php-$php54_version.tar.gz + patch -d php-$php54_version -p0 < fpm-race-condition.patch + pushd php-$php54_version make clean - [ ! -d "${php_install_dir}" ] && mkdir -p ${php_install_dir} - { [ ${RHEL_ver:-0} -ge 9 >/dev/null 2>&1 ] || [ ${Debian_ver:-0} -ge 10 >/dev/null 2>&1 ] || [ ${Ubuntu_ver:-0} -ge 19 >/dev/null 2>&1 ]; } || intl_modules_options='--enable-intl' - [[ "${Platform}" =~ ^hce$ ]] && unset intl_modules_options - if [ "${apache_mode_option}" == '2' ]; then - ./configure --prefix=${php_install_dir} --with-config-file-path=${php_install_dir}/etc \ - --with-config-file-scan-dir=${php_install_dir}/etc/php.d \ - --with-apxs2=${apache_install_dir}/bin/apxs --disable-fileinfo \ + [ ! -d "$php_install_dir" ] && mkdir -p $php_install_dir + if [[ $Apache_version =~ ^[1-2]$ ]] || [ -e "$apache_install_dir/bin/apxs" ]; then + ./configure --prefix=$php_install_dir --with-config-file-path=$php_install_dir/etc \ + --with-config-file-scan-dir=$php_install_dir/etc/php.d \ + --with-apxs2=$apache_install_dir/bin/apxs --disable-fileinfo \ --with-mysql=mysqlnd --with-mysqli=mysqlnd --with-pdo-mysql=mysqlnd \ - --with-iconv-dir=/usr/local --with-freetype-dir=${freetype_install_dir} --with-jpeg-dir --with-png-dir --with-zlib \ + --with-iconv-dir=/usr/local --with-freetype-dir --with-jpeg-dir --with-png-dir --with-zlib \ --with-libxml-dir=/usr --enable-xml --disable-rpath --enable-bcmath --enable-shmop --enable-exif \ - --enable-sysvsem --enable-inline-optimization ${php5_with_curl} --enable-mbregex \ - --enable-mbstring --with-mcrypt --with-gd --enable-gd-native-ttf ${php5_with_openssl} \ - --with-mhash --enable-pcntl --enable-sockets --with-xmlrpc --enable-ftp --with-xsl ${intl_modules_options} \ - --with-gettext --enable-zip --enable-soap --disable-debug ${php_modules_options} + --enable-sysvsem --enable-inline-optimization --with-curl=/usr/local --enable-mbregex \ + --enable-mbstring --with-mcrypt --with-gd --enable-gd-native-ttf --with-openssl \ + --with-mhash --enable-pcntl --enable-sockets --with-xmlrpc --enable-ftp --enable-intl --with-xsl \ + --with-gettext --enable-zip --enable-soap --disable-debug $php_modules_options else - ./configure --prefix=${php_install_dir} --with-config-file-path=${php_install_dir}/etc \ - --with-config-file-scan-dir=${php_install_dir}/etc/php.d \ - --with-fpm-user=${run_user} --with-fpm-group=${run_group} --enable-fpm --disable-fileinfo \ + ./configure --prefix=$php_install_dir --with-config-file-path=$php_install_dir/etc \ + --with-config-file-scan-dir=$php_install_dir/etc/php.d \ + --with-fpm-user=$run_user --with-fpm-group=$run_user --enable-fpm --disable-fileinfo \ --with-mysql=mysqlnd --with-mysqli=mysqlnd --with-pdo-mysql=mysqlnd \ - --with-iconv-dir=/usr/local --with-freetype-dir=${freetype_install_dir} --with-jpeg-dir --with-png-dir --with-zlib \ + --with-iconv-dir=/usr/local --with-freetype-dir --with-jpeg-dir --with-png-dir --with-zlib \ --with-libxml-dir=/usr --enable-xml --disable-rpath --enable-bcmath --enable-shmop --enable-exif \ - --enable-sysvsem --enable-inline-optimization ${php5_with_curl} --enable-mbregex \ - --enable-mbstring --with-mcrypt --with-gd --enable-gd-native-ttf ${php5_with_openssl} \ - --with-mhash --enable-pcntl --enable-sockets --with-xmlrpc --enable-ftp --with-xsl ${intl_modules_options} \ - --with-gettext --enable-zip --enable-soap --disable-debug ${php_modules_options} + --enable-sysvsem --enable-inline-optimization --with-curl=/usr/local --enable-mbregex \ + --enable-mbstring --with-mcrypt --with-gd --enable-gd-native-ttf --with-openssl \ + --with-mhash --enable-pcntl --enable-sockets --with-xmlrpc --enable-ftp --enable-intl --with-xsl \ + --with-gettext --enable-zip --enable-soap --disable-debug $php_modules_options fi make ZEND_EXTRA_LIBS='-liconv' -j ${THREAD} make install - - if [ -e "${php_install_dir}/bin/phpize" ]; then - [ ! -e "${php_install_dir}/etc/php.d" ] && mkdir -p ${php_install_dir}/etc/php.d + + if [ -e "$php_install_dir/bin/phpize" ]; then echo "${CSUCCESS}PHP installed successfully! ${CEND}" else - rm -rf ${php_install_dir} + rm -rf $php_install_dir echo "${CFAILURE}PHP install failed, Please Contact the author! ${CEND}" - kill -9 $$; exit 1; + kill -9 $$ fi - - [ -z "`grep ^'export PATH=' /etc/profile`" ] && echo "export PATH=${php_install_dir}/bin:\$PATH" >> /etc/profile - [ -n "`grep ^'export PATH=' /etc/profile`" -a -z "`grep ${php_install_dir} /etc/profile`" ] && sed -i "s@^export PATH=\(.*\)@export PATH=${php_install_dir}/bin:\1@" /etc/profile + + [ -z "`grep ^'export PATH=' /etc/profile`" ] && echo "export PATH=$php_install_dir/bin:\$PATH" >> /etc/profile + [ -n "`grep ^'export PATH=' /etc/profile`" -a -z "`grep $php_install_dir /etc/profile`" ] && sed -i "s@^export PATH=\(.*\)@export PATH=$php_install_dir/bin:\1@" /etc/profile . /etc/profile - + # wget -c http://pear.php.net/go-pear.phar - # ${php_install_dir}/bin/php go-pear.phar - - /bin/cp php.ini-production ${php_install_dir}/etc/php.ini - - sed -i "s@^memory_limit.*@memory_limit = ${Memory_limit}M@" ${php_install_dir}/etc/php.ini - sed -i 's@^output_buffering =@output_buffering = On\noutput_buffering =@' ${php_install_dir}/etc/php.ini - #sed -i 's@^;cgi.fix_pathinfo.*@cgi.fix_pathinfo=0@' ${php_install_dir}/etc/php.ini - sed -i 's@^short_open_tag = Off@short_open_tag = On@' ${php_install_dir}/etc/php.ini - sed -i 's@^expose_php = On@expose_php = Off@' ${php_install_dir}/etc/php.ini - sed -i 's@^request_order.*@request_order = "CGP"@' ${php_install_dir}/etc/php.ini - sed -i "s@^;date.timezone.*@date.timezone = ${timezone}@" ${php_install_dir}/etc/php.ini - sed -i 's@^post_max_size.*@post_max_size = 100M@' ${php_install_dir}/etc/php.ini - sed -i 's@^upload_max_filesize.*@upload_max_filesize = 50M@' ${php_install_dir}/etc/php.ini - sed -i 's@^max_execution_time.*@max_execution_time = 5@' ${php_install_dir}/etc/php.ini - sed -i 's@^disable_functions.*@disable_functions = passthru,exec,system,chroot,chgrp,chown,shell_exec,proc_open,proc_get_status,ini_alter,ini_restore,dl,readlink,symlink,popepassthru,stream_socket_server,fsocket,popen@' ${php_install_dir}/etc/php.ini - [ -e /usr/sbin/sendmail ] && sed -i 's@^;sendmail_path.*@sendmail_path = /usr/sbin/sendmail -t -i@' ${php_install_dir}/etc/php.ini - - if [ "${apache_mode_option}" != '2' ]; then + # $php_install_dir/bin/php go-pear.phar + + [ ! -e "$php_install_dir/etc/php.d" ] && mkdir -p $php_install_dir/etc/php.d + /bin/cp php.ini-production $php_install_dir/etc/php.ini + + sed -i "s@^memory_limit.*@memory_limit = ${Memory_limit}M@" $php_install_dir/etc/php.ini + sed -i 's@^output_buffering =@output_buffering = On\noutput_buffering =@' $php_install_dir/etc/php.ini + sed -i 's@^;cgi.fix_pathinfo.*@cgi.fix_pathinfo=0@' $php_install_dir/etc/php.ini + sed -i 's@^short_open_tag = Off@short_open_tag = On@' $php_install_dir/etc/php.ini + sed -i 's@^expose_php = On@expose_php = Off@' $php_install_dir/etc/php.ini + sed -i 's@^request_order.*@request_order = "CGP"@' $php_install_dir/etc/php.ini + sed -i 's@^;date.timezone.*@date.timezone = Asia/Shanghai@' $php_install_dir/etc/php.ini + sed -i 's@^post_max_size.*@post_max_size = 100M@' $php_install_dir/etc/php.ini + sed -i 's@^upload_max_filesize.*@upload_max_filesize = 50M@' $php_install_dir/etc/php.ini + sed -i 's@^max_execution_time.*@max_execution_time = 5@' $php_install_dir/etc/php.ini + sed -i 's@^disable_functions.*@disable_functions = passthru,exec,system,chroot,chgrp,chown,shell_exec,proc_open,proc_get_status,ini_alter,ini_restore,dl,openlog,syslog,readlink,symlink,popepassthru,stream_socket_server,fsocket,popen@' $php_install_dir/etc/php.ini + [ -e /usr/sbin/sendmail ] && sed -i 's@^;sendmail_path.*@sendmail_path = /usr/sbin/sendmail -t -i@' $php_install_dir/etc/php.ini + + if [[ ! $Apache_version =~ ^[1-2]$ ]] && [ ! -e "$apache_install_dir/bin/apxs" ]; then # php-fpm Init Script - /bin/cp ${current_dir}/init.d/php-fpm.service /lib/systemd/system/ - sed -i "s@/usr/local/php@${php_install_dir}@g" /lib/systemd/system/php-fpm.service - systemctl enable php-fpm + /bin/cp sapi/fpm/init.d.php-fpm /etc/init.d/php-fpm + chmod +x /etc/init.d/php-fpm + [ "$OS" == 'CentOS' ] && { chkconfig --add php-fpm; chkconfig php-fpm on; } + [[ $OS =~ ^Ubuntu$|^Debian$ ]] && update-rc.d php-fpm defaults - cat > ${php_install_dir}/etc/php-fpm.conf < $php_install_dir/etc/php-fpm.conf < /dev/null - [ -e "${php_install_dir}/bin/phpize" ] && rm -rf php-${php54_ver} - popd > /dev/null + popd + [ -e "$php_install_dir/bin/phpize" ] && rm -rf php-$php54_version + popd } diff --git a/include/php-5.5.sh b/include/php-5.5.sh index a022ecfb..99d4beed 100644 --- a/include/php-5.5.sh +++ b/include/php-5.5.sh @@ -1,170 +1,147 @@ #!/bin/bash # Author: yeho -# BLOG: https://linuxeye.com +# BLOG: https://blog.linuxeye.com +# +# Notes: OneinStack for CentOS/RadHat 5+ Debian 6+ and Ubuntu 12+ +# +# Project home page: +# https://oneinstack.com +# https://github.com/lj2007331/oneinstack Install_PHP55() { - pushd ${current_dir}/src > /dev/null - if [ ! -e "/usr/local/lib/libiconv.la" ]; then - tar xzf libiconv-${libiconv_ver}.tar.gz - pushd libiconv-${libiconv_ver} > /dev/null - ./configure - make -j ${THREAD} && make install - popd > /dev/null - rm -rf libiconv-${libiconv_ver} - fi - - if [ ! -e "${curl_install_dir}/lib/libcurl.la" ]; then - tar xzf curl-${curl_ver}.tar.gz - pushd curl-${curl_ver} > /dev/null - [ -e "/usr/local/lib/libnghttp2.so" ] && with_nghttp2='--with-nghttp2=/usr/local' - ./configure --prefix=${curl_install_dir} ${php5_with_ssl} ${with_nghttp2} - make -j ${THREAD} && make install - popd > /dev/null - rm -rf curl-${curl_ver} - fi - - if [ ! -e "${freetype_install_dir}/lib/libfreetype.la" ]; then - tar xzf freetype-${freetype_ver}.tar.gz - pushd freetype-${freetype_ver} > /dev/null - ./configure --prefix=${freetype_install_dir} --enable-freetype-config - make -j ${THREAD} && make install - ln -sf ${freetype_install_dir}/include/freetype2/* /usr/include/ - [ -d /usr/lib/pkgconfig ] && /bin/cp ${freetype_install_dir}/lib/pkgconfig/freetype2.pc /usr/lib/pkgconfig/ - popd > /dev/null - rm -rf freetype-${freetype_ver} - fi - - if [ ! -e "/usr/local/bin/libmcrypt-config" -a ! -e "/usr/bin/libmcrypt-config" ]; then - tar xzf libmcrypt-${libmcrypt_ver}.tar.gz - pushd libmcrypt-${libmcrypt_ver} > /dev/null - ./configure - make -j ${THREAD} && make install - ldconfig - pushd libltdl > /dev/null - ./configure --enable-ltdl-install - make -j ${THREAD} && make install - popd > /dev/null - popd > /dev/null - rm -rf libmcrypt-${libmcrypt_ver} - fi - - if [ ! -e "/usr/local/include/mhash.h" -a ! -e "/usr/include/mhash.h" ]; then - tar xzf mhash-${mhash_ver}.tar.gz - pushd mhash-${mhash_ver} > /dev/null - ./configure - make -j ${THREAD} && make install - popd > /dev/null - rm -rf mhash-${mhash_ver} - fi - - [ -z "`grep /usr/local/lib /etc/ld.so.conf.d/*.conf`" ] && echo '/usr/local/lib' > /etc/ld.so.conf.d/local.conf + pushd ${oneinstack_dir}/src + + tar xzf libiconv-$libiconv_version.tar.gz + patch -d libiconv-$libiconv_version -p0 < libiconv-glibc-2.16.patch + pushd libiconv-$libiconv_version + ./configure --prefix=/usr/local + make -j ${THREAD} && make install + popd + rm -rf libiconv-$libiconv_version + + tar xzf curl-$curl_version.tar.gz + pushd curl-$curl_version + ./configure --prefix=/usr/local + make -j ${THREAD} && make install + popd + rm -rf curl-$curl_version + + tar xzf libmcrypt-$libmcrypt_version.tar.gz + pushd libmcrypt-$libmcrypt_version + ./configure + make -j ${THREAD} && make install ldconfig - - if [ "${PM}" == 'yum' ]; then - [ ! -e "/usr/bin/libmcrypt-config" ] && ln -s /usr/local/bin/libmcrypt-config /usr/bin/libmcrypt-config - [ ! -e "/lib64/libpcre.so.1" ] && ln -s /lib64/libpcre.so.0.0.1 /lib64/libpcre.so.1 - [ ! -e "/usr/lib/libc-client.so" ] && ln -s /usr/lib64/libc-client.so /usr/lib/libc-client.so - fi - - if [ ! -e "/usr/local/bin/mcrypt" -a ! -e "/usr/bin/mcrypt" ]; then - tar xzf mcrypt-${mcrypt_ver}.tar.gz - pushd mcrypt-${mcrypt_ver} > /dev/null - ldconfig - ./configure - make -j ${THREAD} && make install - popd > /dev/null - rm -rf mcrypt-${mcrypt_ver} - fi - - id -g ${run_group} >/dev/null 2>&1 - [ $? -ne 0 ] && groupadd ${run_group} - id -u ${run_user} >/dev/null 2>&1 - [ $? -ne 0 ] && useradd -g ${run_group} -M -s /sbin/nologin ${run_user} - tar xzf php-${php55_ver}.tar.gz - patch -d php-${php55_ver} -p0 < fpm-race-condition.patch - pushd php-${php55_ver} > /dev/null - [ ! -d "${php_install_dir}" ] && mkdir -p ${php_install_dir} - { [ ${RHEL_ver:-0} -ge 9 >/dev/null 2>&1 ] || [ ${Debian_ver:-0} -ge 10 >/dev/null 2>&1 ] || [ ${Ubuntu_ver:-0} -ge 19 >/dev/null 2>&1 ]; } || intl_modules_options='--enable-intl' - [[ "${Platform}" =~ ^hce$ ]] && unset intl_modules_options - [ "${phpcache_option}" == '1' ] && phpcache_arg='--enable-opcache' || phpcache_arg='--disable-opcache' - if [ "${apache_mode_option}" == '2' ]; then - ./configure --prefix=${php_install_dir} --with-config-file-path=${php_install_dir}/etc \ - --with-config-file-scan-dir=${php_install_dir}/etc/php.d \ - --with-apxs2=${apache_install_dir}/bin/apxs ${phpcache_arg} --disable-fileinfo \ + pushd libltdl + ./configure --enable-ltdl-install + make -j ${THREAD} && make install + popd;popd + rm -rf libmcrypt-$libmcrypt_version + + tar xzf mhash-$mhash_version.tar.gz + pushd mhash-$mhash_version + ./configure + make -j ${THREAD} && make install + popd + rm -rf mhash-$mhash_version + + echo '/usr/local/lib' > /etc/ld.so.conf.d/local.conf + ldconfig + [ "$OS" == 'CentOS' ] && { ln -s /usr/local/bin/libmcrypt-config /usr/bin/libmcrypt-config; [ "$OS_BIT" == '64' ] && ln -s /lib64/libpcre.so.0.0.1 /lib64/libpcre.so.1 || ln -s /lib/libpcre.so.0.0.1 /lib/libpcre.so.1; } + + tar xzf mcrypt-$mcrypt_version.tar.gz + pushd mcrypt-$mcrypt_version + ldconfig + ./configure + make -j ${THREAD} && make install + popd + rm -rf mcrypt-$mcrypt_version + + id -u $run_user >/dev/null 2>&1 + [ $? -ne 0 ] && useradd -M -s /sbin/nologin $run_user + tar xzf php-$php55_version.tar.gz + patch -d php-$php55_version -p0 < fpm-race-condition.patch + pushd php-$php55_version + [ ! -d "$php_install_dir" ] && mkdir -p $php_install_dir + [ "$PHP_cache" == '1' ] && PHP_cache_tmp='--enable-opcache' || PHP_cache_tmp='--disable-opcache' + if [[ $Apache_version =~ ^[1-2]$ ]] || [ -e "$apache_install_dir/bin/apxs" ]; then + ./configure --prefix=$php_install_dir --with-config-file-path=$php_install_dir/etc \ + --with-config-file-scan-dir=$php_install_dir/etc/php.d \ + --with-apxs2=$apache_install_dir/bin/apxs $PHP_cache_tmp --disable-fileinfo \ --with-mysql=mysqlnd --with-mysqli=mysqlnd --with-pdo-mysql=mysqlnd \ - --with-iconv-dir=/usr/local --with-freetype-dir=${freetype_install_dir} --with-jpeg-dir --with-png-dir --with-zlib \ + --with-iconv-dir=/usr/local --with-freetype-dir --with-jpeg-dir --with-png-dir --with-zlib \ --with-libxml-dir=/usr --enable-xml --disable-rpath --enable-bcmath --enable-shmop --enable-exif \ - --enable-sysvsem --enable-inline-optimization ${php5_with_curl} --enable-mbregex \ - --enable-mbstring --with-mcrypt --with-gd --enable-gd-native-ttf ${php5_with_openssl} \ - --with-mhash --enable-pcntl --enable-sockets --with-xmlrpc --enable-ftp --with-xsl ${intl_modules_options} \ - --with-gettext --enable-zip --enable-soap --disable-debug ${php_modules_options} + --enable-sysvsem --enable-inline-optimization --with-curl=/usr/local --enable-mbregex \ + --enable-mbstring --with-mcrypt --with-gd --enable-gd-native-ttf --with-openssl \ + --with-mhash --enable-pcntl --enable-sockets --with-xmlrpc --enable-ftp --enable-intl --with-xsl \ + --with-gettext --enable-zip --enable-soap --disable-debug $php_modules_options else - ./configure --prefix=${php_install_dir} --with-config-file-path=${php_install_dir}/etc \ - --with-config-file-scan-dir=${php_install_dir}/etc/php.d \ - --with-fpm-user=${run_user} --with-fpm-group=${run_group} --enable-fpm ${phpcache_arg} --disable-fileinfo \ + ./configure --prefix=$php_install_dir --with-config-file-path=$php_install_dir/etc \ + --with-config-file-scan-dir=$php_install_dir/etc/php.d \ + --with-fpm-user=$run_user --with-fpm-group=$run_user --enable-fpm $PHP_cache_tmp --disable-fileinfo \ --with-mysql=mysqlnd --with-mysqli=mysqlnd --with-pdo-mysql=mysqlnd \ - --with-iconv-dir=/usr/local --with-freetype-dir=${freetype_install_dir} --with-jpeg-dir --with-png-dir --with-zlib \ + --with-iconv-dir=/usr/local --with-freetype-dir --with-jpeg-dir --with-png-dir --with-zlib \ --with-libxml-dir=/usr --enable-xml --disable-rpath --enable-bcmath --enable-shmop --enable-exif \ - --enable-sysvsem --enable-inline-optimization ${php5_with_curl} --enable-mbregex \ - --enable-mbstring --with-mcrypt --with-gd --enable-gd-native-ttf ${php5_with_openssl} \ - --with-mhash --enable-pcntl --enable-sockets --with-xmlrpc --enable-ftp --with-xsl ${intl_modules_options} \ - --with-gettext --enable-zip --enable-soap --disable-debug ${php_modules_options} + --enable-sysvsem --enable-inline-optimization --with-curl=/usr/local --enable-mbregex \ + --enable-mbstring --with-mcrypt --with-gd --enable-gd-native-ttf --with-openssl \ + --with-mhash --enable-pcntl --enable-sockets --with-xmlrpc --enable-ftp --enable-intl --with-xsl \ + --with-gettext --enable-zip --enable-soap --disable-debug $php_modules_options fi make ZEND_EXTRA_LIBS='-liconv' -j ${THREAD} make install - - if [ -e "${php_install_dir}/bin/phpize" ]; then - [ ! -e "${php_install_dir}/etc/php.d" ] && mkdir -p ${php_install_dir}/etc/php.d + + if [ -e "$php_install_dir/bin/phpize" ]; then echo "${CSUCCESS}PHP installed successfully! ${CEND}" else - rm -rf ${php_install_dir} + rm -rf $php_install_dir echo "${CFAILURE}PHP install failed, Please Contact the author! ${CEND}" - kill -9 $$; exit 1; + kill -9 $$ fi - - [ -z "`grep ^'export PATH=' /etc/profile`" ] && echo "export PATH=${php_install_dir}/bin:\$PATH" >> /etc/profile - [ -n "`grep ^'export PATH=' /etc/profile`" -a -z "`grep ${php_install_dir} /etc/profile`" ] && sed -i "s@^export PATH=\(.*\)@export PATH=${php_install_dir}/bin:\1@" /etc/profile + + [ -z "`grep ^'export PATH=' /etc/profile`" ] && echo "export PATH=$php_install_dir/bin:\$PATH" >> /etc/profile + [ -n "`grep ^'export PATH=' /etc/profile`" -a -z "`grep $php_install_dir /etc/profile`" ] && sed -i "s@^export PATH=\(.*\)@export PATH=$php_install_dir/bin:\1@" /etc/profile . /etc/profile - + # wget -c http://pear.php.net/go-pear.phar - # ${php_install_dir}/bin/php go-pear.phar - - /bin/cp php.ini-production ${php_install_dir}/etc/php.ini - - sed -i "s@^memory_limit.*@memory_limit = ${Memory_limit}M@" ${php_install_dir}/etc/php.ini - sed -i 's@^output_buffering =@output_buffering = On\noutput_buffering =@' ${php_install_dir}/etc/php.ini - #sed -i 's@^;cgi.fix_pathinfo.*@cgi.fix_pathinfo=0@' ${php_install_dir}/etc/php.ini - sed -i 's@^short_open_tag = Off@short_open_tag = On@' ${php_install_dir}/etc/php.ini - sed -i 's@^expose_php = On@expose_php = Off@' ${php_install_dir}/etc/php.ini - sed -i 's@^request_order.*@request_order = "CGP"@' ${php_install_dir}/etc/php.ini - sed -i "s@^;date.timezone.*@date.timezone = ${timezone}@" ${php_install_dir}/etc/php.ini - sed -i 's@^post_max_size.*@post_max_size = 100M@' ${php_install_dir}/etc/php.ini - sed -i 's@^upload_max_filesize.*@upload_max_filesize = 50M@' ${php_install_dir}/etc/php.ini - sed -i 's@^max_execution_time.*@max_execution_time = 5@' ${php_install_dir}/etc/php.ini - sed -i 's@^disable_functions.*@disable_functions = passthru,exec,system,chroot,chgrp,chown,shell_exec,proc_open,proc_get_status,ini_alter,ini_restore,dl,readlink,symlink,popepassthru,stream_socket_server,fsocket,popen@' ${php_install_dir}/etc/php.ini - [ -e /usr/sbin/sendmail ] && sed -i 's@^;sendmail_path.*@sendmail_path = /usr/sbin/sendmail -t -i@' ${php_install_dir}/etc/php.ini - - [ "${phpcache_option}" == '1' ] && cat > ${php_install_dir}/etc/php.d/02-opcache.ini << EOF + # $php_install_dir/bin/php go-pear.phar + + [ ! -e "$php_install_dir/etc/php.d" ] && mkdir -p $php_install_dir/etc/php.d + /bin/cp php.ini-production $php_install_dir/etc/php.ini + + sed -i "s@^memory_limit.*@memory_limit = ${Memory_limit}M@" $php_install_dir/etc/php.ini + sed -i 's@^output_buffering =@output_buffering = On\noutput_buffering =@' $php_install_dir/etc/php.ini + sed -i 's@^;cgi.fix_pathinfo.*@cgi.fix_pathinfo=0@' $php_install_dir/etc/php.ini + sed -i 's@^short_open_tag = Off@short_open_tag = On@' $php_install_dir/etc/php.ini + sed -i 's@^expose_php = On@expose_php = Off@' $php_install_dir/etc/php.ini + sed -i 's@^request_order.*@request_order = "CGP"@' $php_install_dir/etc/php.ini + sed -i 's@^;date.timezone.*@date.timezone = Asia/Shanghai@' $php_install_dir/etc/php.ini + sed -i 's@^post_max_size.*@post_max_size = 100M@' $php_install_dir/etc/php.ini + sed -i 's@^upload_max_filesize.*@upload_max_filesize = 50M@' $php_install_dir/etc/php.ini + sed -i 's@^max_execution_time.*@max_execution_time = 5@' $php_install_dir/etc/php.ini + sed -i 's@^disable_functions.*@disable_functions = passthru,exec,system,chroot,chgrp,chown,shell_exec,proc_open,proc_get_status,ini_alter,ini_restore,dl,openlog,syslog,readlink,symlink,popepassthru,stream_socket_server,fsocket,popen@' $php_install_dir/etc/php.ini + [ -e /usr/sbin/sendmail ] && sed -i 's@^;sendmail_path.*@sendmail_path = /usr/sbin/sendmail -t -i@' $php_install_dir/etc/php.ini + + [ "$PHP_cache" == '1' ] && cat > $php_install_dir/etc/php.d/ext-opcache.ini << EOF [opcache] zend_extension=opcache.so opcache.enable=1 -opcache.memory_consumption=${Memory_limit} +opcache.memory_consumption=$Memory_limit opcache.interned_strings_buffer=8 opcache.max_accelerated_files=4000 opcache.revalidate_freq=60 -;opcache.save_comments=0 +opcache.save_comments=0 opcache.fast_shutdown=1 opcache.enable_cli=1 ;opcache.optimization_level=0 EOF - if [ "${apache_mode_option}" != '2' ]; then + if [[ ! $Apache_version =~ ^[1-2]$ ]] && [ ! -e "$apache_install_dir/bin/apxs" ]; then # php-fpm Init Script - /bin/cp ${current_dir}/init.d/php-fpm.service /lib/systemd/system/ - sed -i "s@/usr/local/php@${php_install_dir}@g" /lib/systemd/system/php-fpm.service - systemctl enable php-fpm + /bin/cp sapi/fpm/init.d.php-fpm /etc/init.d/php-fpm + chmod +x /etc/init.d/php-fpm + [ "$OS" == 'CentOS' ] && { chkconfig --add php-fpm; chkconfig php-fpm on; } + [[ $OS =~ ^Ubuntu$|^Debian$ ]] && update-rc.d php-fpm defaults - cat > ${php_install_dir}/etc/php-fpm.conf < $php_install_dir/etc/php-fpm.conf < /dev/null - [ -e "${php_install_dir}/bin/phpize" ] && rm -rf php-${php55_ver} - popd > /dev/null + popd + [ -e "$php_install_dir/bin/phpize" ] && rm -rf php-$php55_version + popd } diff --git a/include/php-5.6.sh b/include/php-5.6.sh index 28f9bf67..d18ae94f 100644 --- a/include/php-5.6.sh +++ b/include/php-5.6.sh @@ -1,176 +1,148 @@ #!/bin/bash # Author: yeho -# BLOG: https://linuxeye.com +# BLOG: https://blog.linuxeye.com +# +# Notes: OneinStack for CentOS/RadHat 5+ Debian 6+ and Ubuntu 12+ +# +# Project home page: +# https://oneinstack.com +# https://github.com/lj2007331/oneinstack Install_PHP56() { - pushd ${current_dir}/src > /dev/null - if [ ! -e "/usr/local/lib/libiconv.la" ]; then - tar xzf libiconv-${libiconv_ver}.tar.gz - pushd libiconv-${libiconv_ver} > /dev/null - ./configure - make -j ${THREAD} && make install - popd > /dev/null - rm -rf libiconv-${libiconv_ver} - fi - - if [ ! -e "${curl_install_dir}/lib/libcurl.la" ]; then - tar xzf curl-${curl_ver}.tar.gz - pushd curl-${curl_ver} > /dev/null - [ -e "/usr/local/lib/libnghttp2.so" ] && with_nghttp2='--with-nghttp2=/usr/local' - ./configure --prefix=${curl_install_dir} ${php5_with_ssl} ${with_nghttp2} - make -j ${THREAD} && make install - popd > /dev/null - rm -rf curl-${curl_ver} - fi - - if [ ! -e "${freetype_install_dir}/lib/libfreetype.la" ]; then - tar xzf freetype-${freetype_ver}.tar.gz - pushd freetype-${freetype_ver} > /dev/null - ./configure --prefix=${freetype_install_dir} --enable-freetype-config - make -j ${THREAD} && make install - ln -sf ${freetype_install_dir}/include/freetype2/* /usr/include/ - [ -d /usr/lib/pkgconfig ] && /bin/cp ${freetype_install_dir}/lib/pkgconfig/freetype2.pc /usr/lib/pkgconfig/ - popd > /dev/null - rm -rf freetype-${freetype_ver} - fi - - if [ ! -e "/usr/local/bin/libmcrypt-config" -a ! -e "/usr/bin/libmcrypt-config" ]; then - tar xzf libmcrypt-${libmcrypt_ver}.tar.gz - pushd libmcrypt-${libmcrypt_ver} > /dev/null - ./configure - make -j ${THREAD} && make install - ldconfig - pushd libltdl > /dev/null - ./configure --enable-ltdl-install - make -j ${THREAD} && make install - popd > /dev/null - popd > /dev/null - rm -rf libmcrypt-${libmcrypt_ver} - fi - - if [ ! -e "/usr/local/include/mhash.h" -a ! -e "/usr/include/mhash.h" ]; then - tar xzf mhash-${mhash_ver}.tar.gz - pushd mhash-${mhash_ver} > /dev/null - ./configure - make -j ${THREAD} && make install - popd > /dev/null - rm -rf mhash-${mhash_ver} - fi - - [ -z "`grep /usr/local/lib /etc/ld.so.conf.d/*.conf`" ] && echo '/usr/local/lib' > /etc/ld.so.conf.d/local.conf + pushd ${oneinstack_dir}/src + + tar xzf libiconv-$libiconv_version.tar.gz + patch -d libiconv-$libiconv_version -p0 < libiconv-glibc-2.16.patch + pushd libiconv-$libiconv_version + ./configure --prefix=/usr/local + make -j ${THREAD} && make install + popd + rm -rf libiconv-$libiconv_version + + tar xzf curl-$curl_version.tar.gz + pushd curl-$curl_version + ./configure --prefix=/usr/local + make -j ${THREAD} && make install + popd + rm -rf curl-$curl_version + + tar xzf libmcrypt-$libmcrypt_version.tar.gz + pushd libmcrypt-$libmcrypt_version + ./configure + make -j ${THREAD} && make install ldconfig - - if [ "${PM}" == 'yum' ]; then - [ ! -e "/usr/bin/libmcrypt-config" ] && ln -s /usr/local/bin/libmcrypt-config /usr/bin/libmcrypt-config - [ ! -e "/lib64/libpcre.so.1" ] && ln -s /lib64/libpcre.so.0.0.1 /lib64/libpcre.so.1 - [ ! -e "/usr/lib/libc-client.so" ] && ln -s /usr/lib64/libc-client.so /usr/lib/libc-client.so - fi - - if [ ! -e "/usr/local/bin/mcrypt" -a ! -e "/usr/bin/mcrypt" ]; then - tar xzf mcrypt-${mcrypt_ver}.tar.gz - pushd mcrypt-${mcrypt_ver} > /dev/null - ldconfig - ./configure - make -j ${THREAD} && make install - popd > /dev/null - rm -rf mcrypt-${mcrypt_ver} - fi - - id -g ${run_group} >/dev/null 2>&1 - [ $? -ne 0 ] && groupadd ${run_group} - id -u ${run_user} >/dev/null 2>&1 - [ $? -ne 0 ] && useradd -g ${run_group} -M -s /sbin/nologin ${run_user} - - tar xzf php-${php56_ver}.tar.gz - pushd php-${php56_ver} > /dev/null + pushd libltdl + ./configure --enable-ltdl-install + make -j ${THREAD} && make install + popd;popd + rm -rf libmcrypt-$libmcrypt_version + + tar xzf mhash-$mhash_version.tar.gz + pushd mhash-$mhash_version + ./configure + make -j ${THREAD} && make install + popd + rm -rf mhash-$mhash_version + + echo '/usr/local/lib' > /etc/ld.so.conf.d/local.conf + ldconfig + [ "$OS" == 'CentOS' ] && { ln -s /usr/local/bin/libmcrypt-config /usr/bin/libmcrypt-config; [ "$OS_BIT" == '64' ] && ln -s /lib64/libpcre.so.0.0.1 /lib64/libpcre.so.1 || ln -s /lib/libpcre.so.0.0.1 /lib/libpcre.so.1; } + + tar xzf mcrypt-$mcrypt_version.tar.gz + pushd mcrypt-$mcrypt_version + ldconfig + ./configure + make -j ${THREAD} && make install + popd + rm -rf mcrypt-$mcrypt_version + + id -u $run_user >/dev/null 2>&1 + [ $? -ne 0 ] && useradd -M -s /sbin/nologin $run_user + + tar xzf php-$php56_version.tar.gz + pushd php-$php56_version make clean - [ ! -d "${php_install_dir}" ] && mkdir -p ${php_install_dir} - { [ ${RHEL_ver:-0} -ge 9 >/dev/null 2>&1 ] || [ ${Debian_ver:-0} -ge 10 >/dev/null 2>&1 ] || [ ${Ubuntu_ver:-0} -ge 19 >/dev/null 2>&1 ]; } || intl_modules_options='--enable-intl' - [[ "${Platform}" =~ ^hce$ ]] && unset intl_modules_options - [ "${phpcache_option}" == '1' ] && phpcache_arg='--enable-opcache' || phpcache_arg='--disable-opcache' - if [ "${apache_mode_option}" == '2' ]; then - ./configure --prefix=${php_install_dir} --with-config-file-path=${php_install_dir}/etc \ - --with-config-file-scan-dir=${php_install_dir}/etc/php.d \ - --with-apxs2=${apache_install_dir}/bin/apxs ${phpcache_arg} --disable-fileinfo \ + [ ! -d "$php_install_dir" ] && mkdir -p $php_install_dir + [ "$PHP_cache" == '1' ] && PHP_cache_tmp='--enable-opcache' || PHP_cache_tmp='--disable-opcache' + if [[ $Apache_version =~ ^[1-2]$ ]] || [ -e "$apache_install_dir/bin/apxs" ]; then + ./configure --prefix=$php_install_dir --with-config-file-path=$php_install_dir/etc \ + --with-config-file-scan-dir=$php_install_dir/etc/php.d \ + --with-apxs2=$apache_install_dir/bin/apxs $PHP_cache_tmp --disable-fileinfo \ --with-mysql=mysqlnd --with-mysqli=mysqlnd --with-pdo-mysql=mysqlnd \ - --with-iconv-dir=/usr/local --with-freetype-dir=${freetype_install_dir} --with-jpeg-dir --with-png-dir --with-zlib \ + --with-iconv-dir=/usr/local --with-freetype-dir --with-jpeg-dir --with-png-dir --with-zlib \ --with-libxml-dir=/usr --enable-xml --disable-rpath --enable-bcmath --enable-shmop --enable-exif \ - --enable-sysvsem --enable-inline-optimization ${php5_with_curl} --enable-mbregex \ - --enable-mbstring --with-mcrypt --with-gd --enable-gd-native-ttf ${php5_with_openssl} \ - --with-mhash --enable-pcntl --enable-sockets --with-xmlrpc --enable-ftp --with-xsl ${intl_modules_options} \ - --with-gettext --enable-zip --enable-soap --disable-debug ${php_modules_options} + --enable-sysvsem --enable-inline-optimization --with-curl=/usr/local --enable-mbregex \ + --enable-mbstring --with-mcrypt --with-gd --enable-gd-native-ttf --with-openssl \ + --with-mhash --enable-pcntl --enable-sockets --with-xmlrpc --enable-ftp --enable-intl --with-xsl \ + --with-gettext --enable-zip --enable-soap --disable-debug $php_modules_options else - ./configure --prefix=${php_install_dir} --with-config-file-path=${php_install_dir}/etc \ - --with-config-file-scan-dir=${php_install_dir}/etc/php.d \ - --with-fpm-user=${run_user} --with-fpm-group=${run_group} --enable-fpm ${phpcache_arg} --disable-fileinfo \ + ./configure --prefix=$php_install_dir --with-config-file-path=$php_install_dir/etc \ + --with-config-file-scan-dir=$php_install_dir/etc/php.d \ + --with-fpm-user=$run_user --with-fpm-group=$run_user --enable-fpm $PHP_cache_tmp --disable-fileinfo \ --with-mysql=mysqlnd --with-mysqli=mysqlnd --with-pdo-mysql=mysqlnd \ - --with-iconv-dir=/usr/local --with-freetype-dir=${freetype_install_dir} --with-jpeg-dir --with-png-dir --with-zlib \ + --with-iconv-dir=/usr/local --with-freetype-dir --with-jpeg-dir --with-png-dir --with-zlib \ --with-libxml-dir=/usr --enable-xml --disable-rpath --enable-bcmath --enable-shmop --enable-exif \ - --enable-sysvsem --enable-inline-optimization ${php5_with_curl} --enable-mbregex \ - --enable-mbstring --with-mcrypt --with-gd --enable-gd-native-ttf ${php5_with_openssl} \ - --with-mhash --enable-pcntl --enable-sockets --with-xmlrpc --enable-ftp --with-xsl ${intl_modules_options} \ - --with-gettext --enable-zip --enable-soap --disable-debug ${php_modules_options} + --enable-sysvsem --enable-inline-optimization --with-curl=/usr/local --enable-mbregex \ + --enable-mbstring --with-mcrypt --with-gd --enable-gd-native-ttf --with-openssl \ + --with-mhash --enable-pcntl --enable-sockets --with-xmlrpc --enable-ftp --enable-intl --with-xsl \ + --with-gettext --enable-zip --enable-soap --disable-debug $php_modules_options fi make ZEND_EXTRA_LIBS='-liconv' -j ${THREAD} make install - - if [ -e "${php_install_dir}/bin/phpize" ]; then - [ ! -e "${php_install_dir}/etc/php.d" ] && mkdir -p ${php_install_dir}/etc/php.d + + if [ -e "$php_install_dir/bin/phpize" ]; then echo "${CSUCCESS}PHP installed successfully! ${CEND}" else - rm -rf ${php_install_dir} + rm -rf $php_install_dir echo "${CFAILURE}PHP install failed, Please Contact the author! ${CEND}" - kill -9 $$; exit 1; + kill -9 $$ fi - [ -z "`grep ^'export PATH=' /etc/profile`" ] && echo "export PATH=${php_install_dir}/bin:\$PATH" >> /etc/profile - [ -n "`grep ^'export PATH=' /etc/profile`" -a -z "`grep ${php_install_dir} /etc/profile`" ] && sed -i "s@^export PATH=\(.*\)@export PATH=${php_install_dir}/bin:\1@" /etc/profile + [ -z "`grep ^'export PATH=' /etc/profile`" ] && echo "export PATH=$php_install_dir/bin:\$PATH" >> /etc/profile + [ -n "`grep ^'export PATH=' /etc/profile`" -a -z "`grep $php_install_dir /etc/profile`" ] && sed -i "s@^export PATH=\(.*\)@export PATH=$php_install_dir/bin:\1@" /etc/profile . /etc/profile - + # wget -c http://pear.php.net/go-pear.phar - # ${php_install_dir}/bin/php go-pear.phar - - /bin/cp php.ini-production ${php_install_dir}/etc/php.ini - - sed -i "s@^memory_limit.*@memory_limit = ${Memory_limit}M@" ${php_install_dir}/etc/php.ini - sed -i 's@^output_buffering =@output_buffering = On\noutput_buffering =@' ${php_install_dir}/etc/php.ini - #sed -i 's@^;cgi.fix_pathinfo.*@cgi.fix_pathinfo=0@' ${php_install_dir}/etc/php.ini - sed -i 's@^short_open_tag = Off@short_open_tag = On@' ${php_install_dir}/etc/php.ini - sed -i 's@^expose_php = On@expose_php = Off@' ${php_install_dir}/etc/php.ini - sed -i 's@^request_order.*@request_order = "CGP"@' ${php_install_dir}/etc/php.ini - sed -i "s@^;date.timezone.*@date.timezone = ${timezone}@" ${php_install_dir}/etc/php.ini - sed -i 's@^post_max_size.*@post_max_size = 100M@' ${php_install_dir}/etc/php.ini - sed -i 's@^upload_max_filesize.*@upload_max_filesize = 50M@' ${php_install_dir}/etc/php.ini - sed -i 's@^max_execution_time.*@max_execution_time = 5@' ${php_install_dir}/etc/php.ini - sed -i 's@^disable_functions.*@disable_functions = passthru,exec,system,chroot,chgrp,chown,shell_exec,proc_open,proc_get_status,ini_alter,ini_restore,dl,readlink,symlink,popepassthru,stream_socket_server,fsocket,popen@' ${php_install_dir}/etc/php.ini - [ -e /usr/sbin/sendmail ] && sed -i 's@^;sendmail_path.*@sendmail_path = /usr/sbin/sendmail -t -i@' ${php_install_dir}/etc/php.ini - if [ "${with_old_openssl_flag}" = 'y' ]; then - sed -i "s@^;curl.cainfo.*@curl.cainfo = \"${openssl_install_dir}/cert.pem\"@" ${php_install_dir}/etc/php.ini - sed -i "s@^;openssl.cafile.*@openssl.cafile = \"${openssl_install_dir}/cert.pem\"@" ${php_install_dir}/etc/php.ini - sed -i "s@^;openssl.capath.*@openssl.capath = \"${openssl_install_dir}/cert.pem\"@" ${php_install_dir}/etc/php.ini - fi - - [ "${phpcache_option}" == '1' ] && cat > ${php_install_dir}/etc/php.d/02-opcache.ini << EOF + # $php_install_dir/bin/php go-pear.phar + + [ ! -e "$php_install_dir/etc/php.d" ] && mkdir -p $php_install_dir/etc/php.d + /bin/cp php.ini-production $php_install_dir/etc/php.ini + + sed -i "s@^memory_limit.*@memory_limit = ${Memory_limit}M@" $php_install_dir/etc/php.ini + sed -i 's@^output_buffering =@output_buffering = On\noutput_buffering =@' $php_install_dir/etc/php.ini + sed -i 's@^;cgi.fix_pathinfo.*@cgi.fix_pathinfo=0@' $php_install_dir/etc/php.ini + sed -i 's@^short_open_tag = Off@short_open_tag = On@' $php_install_dir/etc/php.ini + sed -i 's@^expose_php = On@expose_php = Off@' $php_install_dir/etc/php.ini + sed -i 's@^request_order.*@request_order = "CGP"@' $php_install_dir/etc/php.ini + sed -i 's@^;date.timezone.*@date.timezone = Asia/Shanghai@' $php_install_dir/etc/php.ini + sed -i 's@^post_max_size.*@post_max_size = 100M@' $php_install_dir/etc/php.ini + sed -i 's@^upload_max_filesize.*@upload_max_filesize = 50M@' $php_install_dir/etc/php.ini + sed -i 's@^max_execution_time.*@max_execution_time = 5@' $php_install_dir/etc/php.ini + sed -i 's@^disable_functions.*@disable_functions = passthru,exec,system,chroot,chgrp,chown,shell_exec,proc_open,proc_get_status,ini_alter,ini_restore,dl,openlog,syslog,readlink,symlink,popepassthru,stream_socket_server,fsocket,popen@' $php_install_dir/etc/php.ini + [ -e /usr/sbin/sendmail ] && sed -i 's@^;sendmail_path.*@sendmail_path = /usr/sbin/sendmail -t -i@' $php_install_dir/etc/php.ini + + [ "$PHP_cache" == '1' ] && cat > $php_install_dir/etc/php.d/ext-opcache.ini << EOF [opcache] zend_extension=opcache.so opcache.enable=1 -opcache.memory_consumption=${Memory_limit} +opcache.memory_consumption=$Memory_limit opcache.interned_strings_buffer=8 opcache.max_accelerated_files=4000 opcache.revalidate_freq=60 -;opcache.save_comments=0 +opcache.save_comments=0 opcache.fast_shutdown=1 opcache.enable_cli=1 ;opcache.optimization_level=0 EOF - if [ "${apache_mode_option}" != '2' ]; then + if [[ ! $Apache_version =~ ^[1-2]$ ]] && [ ! -e "$apache_install_dir/bin/apxs" ]; then # php-fpm Init Script - /bin/cp ${current_dir}/init.d/php-fpm.service /lib/systemd/system/ - sed -i "s@/usr/local/php@${php_install_dir}@g" /lib/systemd/system/php-fpm.service - systemctl enable php-fpm + /bin/cp sapi/fpm/init.d.php-fpm /etc/init.d/php-fpm + chmod +x /etc/init.d/php-fpm + [ "$OS" == 'CentOS' ] && { chkconfig --add php-fpm; chkconfig php-fpm on; } + [[ $OS =~ ^Ubuntu$|^Debian$ ]] && update-rc.d php-fpm defaults - cat > ${php_install_dir}/etc/php-fpm.conf < $php_install_dir/etc/php-fpm.conf < /dev/null - [ -e "${php_install_dir}/bin/phpize" ] && rm -rf php-${php56_ver} - popd > /dev/null + popd + [ -e "$php_install_dir/bin/phpize" ] && rm -rf php-$php56_version + popd } diff --git a/include/php-7.0.sh b/include/php-7.0.sh index 65d3f2b9..6971555a 100644 --- a/include/php-7.0.sh +++ b/include/php-7.0.sh @@ -1,181 +1,154 @@ #!/bin/bash # Author: yeho -# BLOG: https://linuxeye.com +# BLOG: https://blog.linuxeye.com +# +# Notes: OneinStack for CentOS/RadHat 5+ Debian 6+ and Ubuntu 12+ +# +# Project home page: +# https://oneinstack.com +# https://github.com/lj2007331/oneinstack Install_PHP70() { - pushd ${current_dir}/src > /dev/null - if [ ! -e "/usr/local/lib/libiconv.la" ]; then - tar xzf libiconv-${libiconv_ver}.tar.gz - pushd libiconv-${libiconv_ver} > /dev/null - ./configure - make -j ${THREAD} && make install - popd > /dev/null - rm -rf libiconv-${libiconv_ver} - fi - - if [ ! -e "${curl_install_dir}/lib/libcurl.la" ]; then - tar xzf curl-${curl_ver}.tar.gz - pushd curl-${curl_ver} > /dev/null - [ -e "/usr/local/lib/libnghttp2.so" ] && with_nghttp2='--with-nghttp2=/usr/local' - ./configure --prefix=${curl_install_dir} ${php70_with_ssl} ${with_nghttp2} - make -j ${THREAD} && make install - popd > /dev/null - rm -rf curl-${curl_ver} - fi - - if [ ! -e "${freetype_install_dir}/lib/libfreetype.la" ]; then - tar xzf freetype-${freetype_ver}.tar.gz - pushd freetype-${freetype_ver} > /dev/null - ./configure --prefix=${freetype_install_dir} --enable-freetype-config - make -j ${THREAD} && make install - ln -sf ${freetype_install_dir}/include/freetype2/* /usr/include/ - [ -d /usr/lib/pkgconfig ] && /bin/cp ${freetype_install_dir}/lib/pkgconfig/freetype2.pc /usr/lib/pkgconfig/ - popd > /dev/null - rm -rf freetype-${freetype_ver} - fi - - if [ ! -e "/usr/local/bin/libmcrypt-config" -a ! -e "/usr/bin/libmcrypt-config" ]; then - tar xzf libmcrypt-${libmcrypt_ver}.tar.gz - pushd libmcrypt-${libmcrypt_ver} > /dev/null - ./configure - make -j ${THREAD} && make install - ldconfig - pushd libltdl > /dev/null - ./configure --enable-ltdl-install - make -j ${THREAD} && make install - popd > /dev/null - popd > /dev/null - rm -rf libmcrypt-${libmcrypt_ver} - fi - - if [ ! -e "/usr/local/include/mhash.h" -a ! -e "/usr/include/mhash.h" ]; then - tar xzf mhash-${mhash_ver}.tar.gz - pushd mhash-${mhash_ver} > /dev/null - ./configure - make -j ${THREAD} && make install - popd > /dev/null - rm -rf mhash-${mhash_ver} - fi - - [ -z "`grep /usr/local/lib /etc/ld.so.conf.d/*.conf`" ] && echo '/usr/local/lib' > /etc/ld.so.conf.d/local.conf + pushd ${oneinstack_dir}/src + + tar xzf libiconv-$libiconv_version.tar.gz + patch -d libiconv-$libiconv_version -p0 < libiconv-glibc-2.16.patch + pushd libiconv-$libiconv_version + ./configure --prefix=/usr/local + make -j ${THREAD} && make install + popd + rm -rf libiconv-$libiconv_version + + tar xzf curl-$curl_version.tar.gz + pushd curl-$curl_version + ./configure --prefix=/usr/local + make -j ${THREAD} && make install + popd + rm -rf curl-$curl_version + + tar xzf libmcrypt-$libmcrypt_version.tar.gz + pushd libmcrypt-$libmcrypt_version + ./configure + make -j ${THREAD} && make install ldconfig - - if [ "${PM}" == 'yum' ]; then - [ ! -e "/usr/bin/libmcrypt-config" ] && ln -s /usr/local/bin/libmcrypt-config /usr/bin/libmcrypt-config - [ ! -e "/lib64/libpcre.so.1" ] && ln -s /lib64/libpcre.so.0.0.1 /lib64/libpcre.so.1 - [ ! -e "/usr/lib/libc-client.so" ] && ln -s /usr/lib64/libc-client.so /usr/lib/libc-client.so - fi - - if [ ! -e "/usr/local/bin/mcrypt" -a ! -e "/usr/bin/mcrypt" ]; then - tar xzf mcrypt-${mcrypt_ver}.tar.gz - pushd mcrypt-${mcrypt_ver} > /dev/null - ldconfig - ./configure - make -j ${THREAD} && make install - popd > /dev/null - rm -rf mcrypt-${mcrypt_ver} - fi - - id -g ${run_group} >/dev/null 2>&1 - [ $? -ne 0 ] && groupadd ${run_group} - id -u ${run_user} >/dev/null 2>&1 - [ $? -ne 0 ] && useradd -g ${run_group} -M -s /sbin/nologin ${run_user} - - tar xzf php-${php70_ver}.tar.gz - pushd php-${php70_ver} + pushd libltdl + ./configure --enable-ltdl-install + make -j ${THREAD} && make install + popd;popd + rm -rf libmcrypt-$libmcrypt_version + + tar xzf mhash-$mhash_version.tar.gz + pushd mhash-$mhash_version + ./configure + make -j ${THREAD} && make install + popd + rm -rf mhash-$mhash_version + + echo '/usr/local/lib' > /etc/ld.so.conf.d/local.conf + ldconfig + [ "$OS" == 'CentOS' ] && { ln -s /usr/local/bin/libmcrypt-config /usr/bin/libmcrypt-config; [ "$OS_BIT" == '64' ] && ln -s /lib64/libpcre.so.0.0.1 /lib64/libpcre.so.1 || ln -s /lib/libpcre.so.0.0.1 /lib/libpcre.so.1; } + + tar xzf mcrypt-$mcrypt_version.tar.gz + pushd mcrypt-$mcrypt_version + ldconfig + ./configure + make -j ${THREAD} && make install + popd + rm -rf mcrypt-$mcrypt_version + + id -u $run_user >/dev/null 2>&1 + [ $? -ne 0 ] && useradd -M -s /sbin/nologin $run_user + + tar xzf php-$php70_version.tar.gz + pushd php-$php70_version make clean - [ ! -d "${php_install_dir}" ] && mkdir -p ${php_install_dir} - { [ ${RHEL_ver:-0} -ge 9 >/dev/null 2>&1 ] || [ ${Debian_ver:-0} -ge 10 >/dev/null 2>&1 ] || [ ${Ubuntu_ver:-0} -ge 19 >/dev/null 2>&1 ]; } || intl_modules_options='--enable-intl' - [[ "${Platform}" =~ ^hce$ ]] && unset intl_modules_options - [ "${phpcache_option}" == '1' ] && phpcache_arg='--enable-opcache' || phpcache_arg='--disable-opcache' - if [ "${apache_mode_option}" == '2' ]; then - ./configure --prefix=${php_install_dir} --with-config-file-path=${php_install_dir}/etc \ - --with-config-file-scan-dir=${php_install_dir}/etc/php.d \ - --with-apxs2=${apache_install_dir}/bin/apxs ${phpcache_arg} --disable-fileinfo \ + ./buildconf + [ ! -d "$php_install_dir" ] && mkdir -p $php_install_dir + [ "$PHP_cache" == '1' ] && PHP_cache_tmp='--enable-opcache' || PHP_cache_tmp='--disable-opcache' + if [[ $Apache_version =~ ^[1-2]$ ]] || [ -e "$apache_install_dir/bin/apxs" ]; then + ./configure --prefix=$php_install_dir --with-config-file-path=$php_install_dir/etc \ + --with-config-file-scan-dir=$php_install_dir/etc/php.d \ + --with-apxs2=$apache_install_dir/bin/apxs $PHP_cache_tmp --disable-fileinfo \ --enable-mysqlnd --with-mysqli=mysqlnd --with-pdo-mysql=mysqlnd \ - --with-iconv-dir=/usr/local --with-freetype-dir=${freetype_install_dir} --with-jpeg-dir --with-png-dir --with-zlib \ + --with-iconv-dir=/usr/local --with-freetype-dir --with-jpeg-dir --with-png-dir --with-zlib \ --with-libxml-dir=/usr --enable-xml --disable-rpath --enable-bcmath --enable-shmop --enable-exif \ - --enable-sysvsem --enable-inline-optimization ${php70_with_curl} --enable-mbregex \ - --enable-mbstring --with-mcrypt --with-gd --enable-gd-native-ttf ${php70_with_openssl} \ - --with-mhash --enable-pcntl --enable-sockets --with-xmlrpc --enable-ftp --with-xsl ${intl_modules_options} \ - --with-gettext --enable-zip --enable-soap --disable-debug ${php_modules_options} + --enable-sysvsem --enable-inline-optimization --with-curl=/usr/local --enable-mbregex \ + --enable-mbstring --with-mcrypt --with-gd --enable-gd-native-ttf --with-openssl \ + --with-mhash --enable-pcntl --enable-sockets --with-xmlrpc --enable-ftp --enable-intl --with-xsl \ + --with-gettext --enable-zip --enable-soap --disable-debug $php_modules_options else - ./configure --prefix=${php_install_dir} --with-config-file-path=${php_install_dir}/etc \ - --with-config-file-scan-dir=${php_install_dir}/etc/php.d \ - --with-fpm-user=${run_user} --with-fpm-group=${run_group} --enable-fpm ${phpcache_arg} --disable-fileinfo \ + ./configure --prefix=$php_install_dir --with-config-file-path=$php_install_dir/etc \ + --with-config-file-scan-dir=$php_install_dir/etc/php.d \ + --with-fpm-user=$run_user --with-fpm-group=$run_user --enable-fpm $PHP_cache_tmp --disable-fileinfo \ --enable-mysqlnd --with-mysqli=mysqlnd --with-pdo-mysql=mysqlnd \ - --with-iconv-dir=/usr/local --with-freetype-dir=${freetype_install_dir} --with-jpeg-dir --with-png-dir --with-zlib \ + --with-iconv-dir=/usr/local --with-freetype-dir --with-jpeg-dir --with-png-dir --with-zlib \ --with-libxml-dir=/usr --enable-xml --disable-rpath --enable-bcmath --enable-shmop --enable-exif \ - --enable-sysvsem --enable-inline-optimization ${php70_with_curl} --enable-mbregex \ - --enable-mbstring --with-mcrypt --with-gd --enable-gd-native-ttf ${php70_with_openssl} \ - --with-mhash --enable-pcntl --enable-sockets --with-xmlrpc --enable-ftp --with-xsl ${intl_modules_options} \ - --with-gettext --enable-zip --enable-soap --disable-debug ${php_modules_options} + --enable-sysvsem --enable-inline-optimization --with-curl=/usr/local --enable-mbregex \ + --enable-mbstring --with-mcrypt --with-gd --enable-gd-native-ttf --with-openssl \ + --with-mhash --enable-pcntl --enable-sockets --with-xmlrpc --enable-ftp --enable-intl --with-xsl \ + --with-gettext --enable-zip --enable-soap --disable-debug $php_modules_options fi make ZEND_EXTRA_LIBS='-liconv' -j ${THREAD} make install - - if [ -e "${php_install_dir}/bin/phpize" ]; then - [ ! -e "${php_install_dir}/etc/php.d" ] && mkdir -p ${php_install_dir}/etc/php.d + + if [ -e "$php_install_dir/bin/phpize" ]; then echo "${CSUCCESS}PHP installed successfully! ${CEND}" else - rm -rf ${php_install_dir} + rm -rf $php_install_dir echo "${CFAILURE}PHP install failed, Please Contact the author! ${CEND}" - kill -9 $$; exit 1; + kill -9 $$ fi - - [ -z "`grep ^'export PATH=' /etc/profile`" ] && echo "export PATH=${php_install_dir}/bin:\$PATH" >> /etc/profile - [ -n "`grep ^'export PATH=' /etc/profile`" -a -z "`grep ${php_install_dir} /etc/profile`" ] && sed -i "s@^export PATH=\(.*\)@export PATH=${php_install_dir}/bin:\1@" /etc/profile + + [ -z "`grep ^'export PATH=' /etc/profile`" ] && echo "export PATH=$php_install_dir/bin:\$PATH" >> /etc/profile + [ -n "`grep ^'export PATH=' /etc/profile`" -a -z "`grep $php_install_dir /etc/profile`" ] && sed -i "s@^export PATH=\(.*\)@export PATH=$php_install_dir/bin:\1@" /etc/profile . /etc/profile - + # wget -c http://pear.php.net/go-pear.phar - # ${php_install_dir}/bin/php go-pear.phar - - /bin/cp php.ini-production ${php_install_dir}/etc/php.ini - - sed -i "s@^memory_limit.*@memory_limit = ${Memory_limit}M@" ${php_install_dir}/etc/php.ini - sed -i 's@^output_buffering =@output_buffering = On\noutput_buffering =@' ${php_install_dir}/etc/php.ini - #sed -i 's@^;cgi.fix_pathinfo.*@cgi.fix_pathinfo=0@' ${php_install_dir}/etc/php.ini - sed -i 's@^short_open_tag = Off@short_open_tag = On@' ${php_install_dir}/etc/php.ini - sed -i 's@^expose_php = On@expose_php = Off@' ${php_install_dir}/etc/php.ini - sed -i 's@^request_order.*@request_order = "CGP"@' ${php_install_dir}/etc/php.ini - sed -i "s@^;date.timezone.*@date.timezone = ${timezone}@" ${php_install_dir}/etc/php.ini - sed -i 's@^post_max_size.*@post_max_size = 100M@' ${php_install_dir}/etc/php.ini - sed -i 's@^upload_max_filesize.*@upload_max_filesize = 50M@' ${php_install_dir}/etc/php.ini - sed -i 's@^max_execution_time.*@max_execution_time = 600@' ${php_install_dir}/etc/php.ini - sed -i 's@^;realpath_cache_size.*@realpath_cache_size = 2M@' ${php_install_dir}/etc/php.ini - sed -i 's@^disable_functions.*@disable_functions = passthru,exec,system,chroot,chgrp,chown,shell_exec,proc_open,proc_get_status,ini_alter,ini_restore,dl,readlink,symlink,popepassthru,stream_socket_server,fsocket,popen@' ${php_install_dir}/etc/php.ini - [ -e /usr/sbin/sendmail ] && sed -i 's@^;sendmail_path.*@sendmail_path = /usr/sbin/sendmail -t -i@' ${php_install_dir}/etc/php.ini - if [ "${with_old_openssl_flag}" = 'y' ]; then - sed -i "s@^;curl.cainfo.*@curl.cainfo = \"${openssl_install_dir}/cert.pem\"@" ${php_install_dir}/etc/php.ini - sed -i "s@^;openssl.cafile.*@openssl.cafile = \"${openssl_install_dir}/cert.pem\"@" ${php_install_dir}/etc/php.ini - sed -i "s@^;openssl.capath.*@openssl.capath = \"${openssl_install_dir}/cert.pem\"@" ${php_install_dir}/etc/php.ini - fi - - [ "${phpcache_option}" == '1' ] && cat > ${php_install_dir}/etc/php.d/02-opcache.ini << EOF + # $php_install_dir/bin/php go-pear.phar + + [ ! -e "$php_install_dir/etc/php.d" ] && mkdir -p $php_install_dir/etc/php.d + /bin/cp php.ini-production $php_install_dir/etc/php.ini + + sed -i "s@^memory_limit.*@memory_limit = ${Memory_limit}M@" $php_install_dir/etc/php.ini + sed -i 's@^output_buffering =@output_buffering = On\noutput_buffering =@' $php_install_dir/etc/php.ini + sed -i 's@^;cgi.fix_pathinfo.*@cgi.fix_pathinfo=0@' $php_install_dir/etc/php.ini + sed -i 's@^short_open_tag = Off@short_open_tag = On@' $php_install_dir/etc/php.ini + sed -i 's@^expose_php = On@expose_php = Off@' $php_install_dir/etc/php.ini + sed -i 's@^request_order.*@request_order = "CGP"@' $php_install_dir/etc/php.ini + sed -i 's@^;date.timezone.*@date.timezone = Asia/Shanghai@' $php_install_dir/etc/php.ini + sed -i 's@^post_max_size.*@post_max_size = 100M@' $php_install_dir/etc/php.ini + sed -i 's@^upload_max_filesize.*@upload_max_filesize = 50M@' $php_install_dir/etc/php.ini + sed -i 's@^max_execution_time.*@max_execution_time = 600@' $php_install_dir/etc/php.ini + sed -i 's@^;realpath_cache_size.*@realpath_cache_size = 2M@' $php_install_dir/etc/php.ini + sed -i 's@^disable_functions.*@disable_functions = passthru,exec,system,chroot,chgrp,chown,shell_exec,proc_open,proc_get_status,ini_alter,ini_restore,dl,openlog,syslog,readlink,symlink,popepassthru,stream_socket_server,fsocket,popen@' $php_install_dir/etc/php.ini + [ -e /usr/sbin/sendmail ] && sed -i 's@^;sendmail_path.*@sendmail_path = /usr/sbin/sendmail -t -i@' $php_install_dir/etc/php.ini + + [ "$PHP_cache" == '1' ] && cat > $php_install_dir/etc/php.d/ext-opcache.ini << EOF [opcache] zend_extension=opcache.so opcache.enable=1 opcache.enable_cli=1 -opcache.memory_consumption=${Memory_limit} +opcache.memory_consumption=$Memory_limit opcache.interned_strings_buffer=8 opcache.max_accelerated_files=100000 opcache.max_wasted_percentage=5 opcache.use_cwd=1 opcache.validate_timestamps=1 opcache.revalidate_freq=60 -;opcache.save_comments=0 +opcache.save_comments=0 opcache.fast_shutdown=1 opcache.consistency_checks=0 ;opcache.optimization_level=0 EOF - if [ "${apache_mode_option}" != '2' ]; then + if [[ ! $Apache_version =~ ^[1-2]$ ]] && [ ! -e "$apache_install_dir/bin/apxs" ]; then # php-fpm Init Script - /bin/cp ${current_dir}/init.d/php-fpm.service /lib/systemd/system/ - sed -i "s@/usr/local/php@${php_install_dir}@g" /lib/systemd/system/php-fpm.service - systemctl enable php-fpm + /bin/cp sapi/fpm/init.d.php-fpm /etc/init.d/php-fpm + chmod +x /etc/init.d/php-fpm + [ "$OS" == 'CentOS' ] && { chkconfig --add php-fpm; chkconfig php-fpm on; } + [[ $OS =~ ^Ubuntu$|^Debian$ ]] && update-rc.d php-fpm defaults - cat > ${php_install_dir}/etc/php-fpm.conf < $php_install_dir/etc/php-fpm.conf < /dev/null - [ -e "${php_install_dir}/bin/phpize" ] && rm -rf php-${php70_ver} - popd > /dev/null + popd + [ -e "$php_install_dir/bin/phpize" ] && rm -rf php-$php70_version + popd } diff --git a/include/php-7.1.sh b/include/php-7.1.sh index b8657702..18f17a4c 100644 --- a/include/php-7.1.sh +++ b/include/php-7.1.sh @@ -1,185 +1,154 @@ #!/bin/bash # Author: yeho -# BLOG: https://linuxeye.com +# BLOG: https://blog.linuxeye.com +# +# Notes: OneinStack for CentOS/RadHat 5+ Debian 6+ and Ubuntu 12+ +# +# Project home page: +# https://oneinstack.com +# https://github.com/lj2007331/oneinstack Install_PHP71() { - pushd ${current_dir}/src > /dev/null - if [ ! -e "/usr/local/lib/libiconv.la" ]; then - tar xzf libiconv-${libiconv_ver}.tar.gz - pushd libiconv-${libiconv_ver} > /dev/null - ./configure - make -j ${THREAD} && make install - popd > /dev/null - rm -rf libiconv-${libiconv_ver} - fi - - if [ ! -e "${curl_install_dir}/lib/libcurl.la" ]; then - tar xzf curl-${curl_ver}.tar.gz - pushd curl-${curl_ver} > /dev/null - [ -e "/usr/local/lib/libnghttp2.so" ] && with_nghttp2='--with-nghttp2=/usr/local' - ./configure --prefix=${curl_install_dir} ${php71_with_ssl} ${with_nghttp2} - make -j ${THREAD} && make install - popd > /dev/null - rm -rf curl-${curl_ver} - fi - - if [ ! -e "${freetype_install_dir}/lib/libfreetype.la" ]; then - tar xzf freetype-${freetype_ver}.tar.gz - pushd freetype-${freetype_ver} > /dev/null - ./configure --prefix=${freetype_install_dir} --enable-freetype-config - make -j ${THREAD} && make install - ln -sf ${freetype_install_dir}/include/freetype2/* /usr/include/ - [ -d /usr/lib/pkgconfig ] && /bin/cp ${freetype_install_dir}/lib/pkgconfig/freetype2.pc /usr/lib/pkgconfig/ - popd > /dev/null - rm -rf freetype-${freetype_ver} - fi - - if [ ! -e "/usr/local/bin/libmcrypt-config" -a ! -e "/usr/bin/libmcrypt-config" ]; then - tar xzf libmcrypt-${libmcrypt_ver}.tar.gz - pushd libmcrypt-${libmcrypt_ver} > /dev/null - ./configure - make -j ${THREAD} && make install - ldconfig - pushd libltdl > /dev/null - ./configure --enable-ltdl-install - make -j ${THREAD} && make install - popd > /dev/null - popd > /dev/null - rm -rf libmcrypt-${libmcrypt_ver} - fi - - if [ ! -e "/usr/local/include/mhash.h" -a ! -e "/usr/include/mhash.h" ]; then - tar xzf mhash-${mhash_ver}.tar.gz - pushd mhash-${mhash_ver} > /dev/null - ./configure - make -j ${THREAD} && make install - popd > /dev/null - rm -rf mhash-${mhash_ver} - fi - - [ -z "`grep /usr/local/lib /etc/ld.so.conf.d/*.conf`" ] && echo '/usr/local/lib' > /etc/ld.so.conf.d/local.conf + pushd ${oneinstack_dir}/src + + tar xzf libiconv-$libiconv_version.tar.gz + patch -d libiconv-$libiconv_version -p0 < libiconv-glibc-2.16.patch + pushd libiconv-$libiconv_version + ./configure --prefix=/usr/local + make -j ${THREAD} && make install + popd + rm -rf libiconv-$libiconv_version + + tar xzf curl-$curl_version.tar.gz + pushd curl-$curl_version + ./configure --prefix=/usr/local + make -j ${THREAD} && make install + popd + rm -rf curl-$curl_version + + tar xzf libmcrypt-$libmcrypt_version.tar.gz + pushd libmcrypt-$libmcrypt_version + ./configure + make -j ${THREAD} && make install ldconfig - - if [ "${PM}" == 'yum' ]; then - [ ! -e "/usr/bin/libmcrypt-config" ] && ln -s /usr/local/bin/libmcrypt-config /usr/bin/libmcrypt-config - [ ! -e "/lib64/libpcre.so.1" ] && ln -s /lib64/libpcre.so.0.0.1 /lib64/libpcre.so.1 - [ ! -e "/usr/lib/libc-client.so" ] && ln -s /usr/lib64/libc-client.so /usr/lib/libc-client.so - fi - - if [ ! -e "/usr/local/bin/mcrypt" -a ! -e "/usr/bin/mcrypt" ]; then - tar xzf mcrypt-${mcrypt_ver}.tar.gz - pushd mcrypt-${mcrypt_ver} > /dev/null - ldconfig - ./configure - make -j ${THREAD} && make install - popd > /dev/null - rm -rf mcrypt-${mcrypt_ver} - fi - - id -g ${run_group} >/dev/null 2>&1 - [ $? -ne 0 ] && groupadd ${run_group} - id -u ${run_user} >/dev/null 2>&1 - [ $? -ne 0 ] && useradd -g ${run_group} -M -s /sbin/nologin ${run_user} - - tar xzf php-${php71_ver}.tar.gz - pushd php-${php71_ver} > /dev/null - if [ -e ext/openssl/openssl.c ] && ! grep -Eqi '^#ifdef RSA_SSLV23_PADDING' ext/openssl/openssl.c; then - sed -i '/OPENSSL_SSLV23_PADDING/i#ifdef RSA_SSLV23_PADDING' ext/openssl/openssl.c - sed -i '/OPENSSL_SSLV23_PADDING/a#endif' ext/openssl/openssl.c - fi + pushd libltdl + ./configure --enable-ltdl-install + make -j ${THREAD} && make install + popd;popd + rm -rf libmcrypt-$libmcrypt_version + + tar xzf mhash-$mhash_version.tar.gz + pushd mhash-$mhash_version + ./configure + make -j ${THREAD} && make install + popd + rm -rf mhash-$mhash_version + + echo '/usr/local/lib' > /etc/ld.so.conf.d/local.conf + ldconfig + [ "$OS" == 'CentOS' ] && { ln -s /usr/local/bin/libmcrypt-config /usr/bin/libmcrypt-config; [ "$OS_BIT" == '64' ] && ln -s /lib64/libpcre.so.0.0.1 /lib64/libpcre.so.1 || ln -s /lib/libpcre.so.0.0.1 /lib/libpcre.so.1; } + + tar xzf mcrypt-$mcrypt_version.tar.gz + pushd mcrypt-$mcrypt_version + ldconfig + ./configure + make -j ${THREAD} && make install + popd + rm -rf mcrypt-$mcrypt_version + + id -u $run_user >/dev/null 2>&1 + [ $? -ne 0 ] && useradd -M -s /sbin/nologin $run_user + + tar xzf php-$php71_version.tar.gz + pushd php-$php71_version make clean - [ ! -d "${php_install_dir}" ] && mkdir -p ${php_install_dir} - [ "${phpcache_option}" == '1' ] && phpcache_arg='--enable-opcache' || phpcache_arg='--disable-opcache' - [ ${RHEL_ver:-0} -ge 9 >/dev/null 2>&1 ] || intl_modules_options='--enable-intl' - [[ "${Platform}" =~ ^hce$ ]] && unset intl_modules_options - if [ "${apache_mode_option}" == '2' ]; then - ./configure --prefix=${php_install_dir} --with-config-file-path=${php_install_dir}/etc \ - --with-config-file-scan-dir=${php_install_dir}/etc/php.d \ - --with-apxs2=${apache_install_dir}/bin/apxs ${phpcache_arg} --disable-fileinfo \ + ./buildconf + [ ! -d "$php_install_dir" ] && mkdir -p $php_install_dir + [ "$PHP_cache" == '1' ] && PHP_cache_tmp='--enable-opcache' || PHP_cache_tmp='--disable-opcache' + if [[ $Apache_version =~ ^[1-2]$ ]] || [ -e "$apache_install_dir/bin/apxs" ]; then + ./configure --prefix=$php_install_dir --with-config-file-path=$php_install_dir/etc \ + --with-config-file-scan-dir=$php_install_dir/etc/php.d \ + --with-apxs2=$apache_install_dir/bin/apxs $PHP_cache_tmp --disable-fileinfo \ --enable-mysqlnd --with-mysqli=mysqlnd --with-pdo-mysql=mysqlnd \ - --with-iconv-dir=/usr/local --with-freetype-dir=${freetype_install_dir} --with-jpeg-dir --with-png-dir --with-zlib \ + --with-iconv-dir=/usr/local --with-freetype-dir --with-jpeg-dir --with-png-dir --with-zlib \ --with-libxml-dir=/usr --enable-xml --disable-rpath --enable-bcmath --enable-shmop --enable-exif \ - --enable-sysvsem --enable-inline-optimization ${php71_with_curl} --enable-mbregex \ - --enable-mbstring --with-mcrypt --with-gd --enable-gd-native-ttf ${php71_with_openssl} \ - --with-mhash --enable-pcntl --enable-sockets --with-xmlrpc --enable-ftp --with-xsl ${intl_modules_options} \ - --with-gettext --enable-zip --enable-soap --disable-debug ${php_modules_options} + --enable-sysvsem --enable-inline-optimization --with-curl=/usr/local --enable-mbregex \ + --enable-mbstring --with-mcrypt --with-gd --enable-gd-native-ttf --with-openssl \ + --with-mhash --enable-pcntl --enable-sockets --with-xmlrpc --enable-ftp --enable-intl --with-xsl \ + --with-gettext --enable-zip --enable-soap --disable-debug $php_modules_options else - ./configure --prefix=${php_install_dir} --with-config-file-path=${php_install_dir}/etc \ - --with-config-file-scan-dir=${php_install_dir}/etc/php.d \ - --with-fpm-user=${run_user} --with-fpm-group=${run_group} --enable-fpm ${phpcache_arg} --disable-fileinfo \ + ./configure --prefix=$php_install_dir --with-config-file-path=$php_install_dir/etc \ + --with-config-file-scan-dir=$php_install_dir/etc/php.d \ + --with-fpm-user=$run_user --with-fpm-group=$run_user --enable-fpm $PHP_cache_tmp --disable-fileinfo \ --enable-mysqlnd --with-mysqli=mysqlnd --with-pdo-mysql=mysqlnd \ - --with-iconv-dir=/usr/local --with-freetype-dir=${freetype_install_dir} --with-jpeg-dir --with-png-dir --with-zlib \ + --with-iconv-dir=/usr/local --with-freetype-dir --with-jpeg-dir --with-png-dir --with-zlib \ --with-libxml-dir=/usr --enable-xml --disable-rpath --enable-bcmath --enable-shmop --enable-exif \ - --enable-sysvsem --enable-inline-optimization ${php71_with_curl} --enable-mbregex \ - --enable-mbstring --with-mcrypt --with-gd --enable-gd-native-ttf ${php71_with_openssl} \ - --with-mhash --enable-pcntl --enable-sockets --with-xmlrpc --enable-ftp --with-xsl ${intl_modules_options} \ - --with-gettext --enable-zip --enable-soap --disable-debug ${php_modules_options} + --enable-sysvsem --enable-inline-optimization --with-curl=/usr/local --enable-mbregex \ + --enable-mbstring --with-mcrypt --with-gd --enable-gd-native-ttf --with-openssl \ + --with-mhash --enable-pcntl --enable-sockets --with-xmlrpc --enable-ftp --enable-intl --with-xsl \ + --with-gettext --enable-zip --enable-soap --disable-debug $php_modules_options fi make ZEND_EXTRA_LIBS='-liconv' -j ${THREAD} make install - - if [ -e "${php_install_dir}/bin/phpize" ]; then - [ ! -e "${php_install_dir}/etc/php.d" ] && mkdir -p ${php_install_dir}/etc/php.d + + if [ -e "$php_install_dir/bin/phpize" ]; then echo "${CSUCCESS}PHP installed successfully! ${CEND}" else - rm -rf ${php_install_dir} + rm -rf $php_install_dir echo "${CFAILURE}PHP install failed, Please Contact the author! ${CEND}" - kill -9 $$; exit 1; + kill -9 $$ fi - - [ -z "`grep ^'export PATH=' /etc/profile`" ] && echo "export PATH=${php_install_dir}/bin:\$PATH" >> /etc/profile - [ -n "`grep ^'export PATH=' /etc/profile`" -a -z "`grep ${php_install_dir} /etc/profile`" ] && sed -i "s@^export PATH=\(.*\)@export PATH=${php_install_dir}/bin:\1@" /etc/profile + + [ -z "`grep ^'export PATH=' /etc/profile`" ] && echo "export PATH=$php_install_dir/bin:\$PATH" >> /etc/profile + [ -n "`grep ^'export PATH=' /etc/profile`" -a -z "`grep $php_install_dir /etc/profile`" ] && sed -i "s@^export PATH=\(.*\)@export PATH=$php_install_dir/bin:\1@" /etc/profile . /etc/profile - + # wget -c http://pear.php.net/go-pear.phar - # ${php_install_dir}/bin/php go-pear.phar - - /bin/cp php.ini-production ${php_install_dir}/etc/php.ini - - sed -i "s@^memory_limit.*@memory_limit = ${Memory_limit}M@" ${php_install_dir}/etc/php.ini - sed -i 's@^output_buffering =@output_buffering = On\noutput_buffering =@' ${php_install_dir}/etc/php.ini - #sed -i 's@^;cgi.fix_pathinfo.*@cgi.fix_pathinfo=0@' ${php_install_dir}/etc/php.ini - sed -i 's@^short_open_tag = Off@short_open_tag = On@' ${php_install_dir}/etc/php.ini - sed -i 's@^expose_php = On@expose_php = Off@' ${php_install_dir}/etc/php.ini - sed -i 's@^request_order.*@request_order = "CGP"@' ${php_install_dir}/etc/php.ini - sed -i "s@^;date.timezone.*@date.timezone = ${timezone}@" ${php_install_dir}/etc/php.ini - sed -i 's@^post_max_size.*@post_max_size = 100M@' ${php_install_dir}/etc/php.ini - sed -i 's@^upload_max_filesize.*@upload_max_filesize = 50M@' ${php_install_dir}/etc/php.ini - sed -i 's@^max_execution_time.*@max_execution_time = 600@' ${php_install_dir}/etc/php.ini - sed -i 's@^;realpath_cache_size.*@realpath_cache_size = 2M@' ${php_install_dir}/etc/php.ini - sed -i 's@^disable_functions.*@disable_functions = passthru,exec,system,chroot,chgrp,chown,shell_exec,proc_open,proc_get_status,ini_alter,ini_restore,dl,readlink,symlink,popepassthru,stream_socket_server,fsocket,popen@' ${php_install_dir}/etc/php.ini - [ -e /usr/sbin/sendmail ] && sed -i 's@^;sendmail_path.*@sendmail_path = /usr/sbin/sendmail -t -i@' ${php_install_dir}/etc/php.ini - if [ "${with_old_openssl_flag}" = 'y' ]; then - sed -i "s@^;curl.cainfo.*@curl.cainfo = \"${openssl_install_dir}/cert.pem\"@" ${php_install_dir}/etc/php.ini - sed -i "s@^;openssl.cafile.*@openssl.cafile = \"${openssl_install_dir}/cert.pem\"@" ${php_install_dir}/etc/php.ini - sed -i "s@^;openssl.capath.*@openssl.capath = \"${openssl_install_dir}/cert.pem\"@" ${php_install_dir}/etc/php.ini - fi - - [ "${phpcache_option}" == '1' ] && cat > ${php_install_dir}/etc/php.d/02-opcache.ini << EOF + # $php_install_dir/bin/php go-pear.phar + + [ ! -e "$php_install_dir/etc/php.d" ] && mkdir -p $php_install_dir/etc/php.d + /bin/cp php.ini-production $php_install_dir/etc/php.ini + + sed -i "s@^memory_limit.*@memory_limit = ${Memory_limit}M@" $php_install_dir/etc/php.ini + sed -i 's@^output_buffering =@output_buffering = On\noutput_buffering =@' $php_install_dir/etc/php.ini + sed -i 's@^;cgi.fix_pathinfo.*@cgi.fix_pathinfo=0@' $php_install_dir/etc/php.ini + sed -i 's@^short_open_tag = Off@short_open_tag = On@' $php_install_dir/etc/php.ini + sed -i 's@^expose_php = On@expose_php = Off@' $php_install_dir/etc/php.ini + sed -i 's@^request_order.*@request_order = "CGP"@' $php_install_dir/etc/php.ini + sed -i 's@^;date.timezone.*@date.timezone = Asia/Shanghai@' $php_install_dir/etc/php.ini + sed -i 's@^post_max_size.*@post_max_size = 100M@' $php_install_dir/etc/php.ini + sed -i 's@^upload_max_filesize.*@upload_max_filesize = 50M@' $php_install_dir/etc/php.ini + sed -i 's@^max_execution_time.*@max_execution_time = 600@' $php_install_dir/etc/php.ini + sed -i 's@^;realpath_cache_size.*@realpath_cache_size = 2M@' $php_install_dir/etc/php.ini + sed -i 's@^disable_functions.*@disable_functions = passthru,exec,system,chroot,chgrp,chown,shell_exec,proc_open,proc_get_status,ini_alter,ini_restore,dl,openlog,syslog,readlink,symlink,popepassthru,stream_socket_server,fsocket,popen@' $php_install_dir/etc/php.ini + [ -e /usr/sbin/sendmail ] && sed -i 's@^;sendmail_path.*@sendmail_path = /usr/sbin/sendmail -t -i@' $php_install_dir/etc/php.ini + + [ "$PHP_cache" == '1' ] && cat > $php_install_dir/etc/php.d/ext-opcache.ini << EOF [opcache] zend_extension=opcache.so opcache.enable=1 opcache.enable_cli=1 -opcache.memory_consumption=${Memory_limit} +opcache.memory_consumption=$Memory_limit opcache.interned_strings_buffer=8 opcache.max_accelerated_files=100000 opcache.max_wasted_percentage=5 opcache.use_cwd=1 opcache.validate_timestamps=1 opcache.revalidate_freq=60 -;opcache.save_comments=0 +opcache.save_comments=0 opcache.fast_shutdown=1 opcache.consistency_checks=0 ;opcache.optimization_level=0 EOF - if [ "${apache_mode_option}" != '2' ]; then + if [[ ! $Apache_version =~ ^[1-2]$ ]] && [ ! -e "$apache_install_dir/bin/apxs" ]; then # php-fpm Init Script - /bin/cp ${current_dir}/init.d/php-fpm.service /lib/systemd/system/ - sed -i "s@/usr/local/php@${php_install_dir}@g" /lib/systemd/system/php-fpm.service - systemctl enable php-fpm + /bin/cp sapi/fpm/init.d.php-fpm /etc/init.d/php-fpm + chmod +x /etc/init.d/php-fpm + [ "$OS" == 'CentOS' ] && { chkconfig --add php-fpm; chkconfig php-fpm on; } + [[ $OS =~ ^Ubuntu$|^Debian$ ]] && update-rc.d php-fpm defaults - cat > ${php_install_dir}/etc/php-fpm.conf < $php_install_dir/etc/php-fpm.conf < /dev/null - [ -e "${php_install_dir}/bin/phpize" ] && rm -rf php-${php71_ver} - popd > /dev/null + popd + [ -e "$php_install_dir/bin/phpize" ] && rm -rf php-$php71_version + popd } diff --git a/include/php-7.2.sh b/include/php-7.2.sh deleted file mode 100644 index 14e3aa7f..00000000 --- a/include/php-7.2.sh +++ /dev/null @@ -1,266 +0,0 @@ -#!/bin/bash -# Author: yeho -# BLOG: https://linuxeye.com - -Install_PHP72() { - pushd ${current_dir}/src > /dev/null - if [ ! -e "/usr/local/lib/libiconv.la" ]; then - tar xzf libiconv-${libiconv_ver}.tar.gz - pushd libiconv-${libiconv_ver} > /dev/null - ./configure - make -j ${THREAD} && make install - popd > /dev/null - rm -rf libiconv-${libiconv_ver} - fi - - if [ ! -e "${curl_install_dir}/lib/libcurl.la" ]; then - tar xzf curl-${curl_ver}.tar.gz - pushd curl-${curl_ver} > /dev/null - [ -e "/usr/local/lib/libnghttp2.so" ] && with_nghttp2='--with-nghttp2=/usr/local' - ./configure --prefix=${curl_install_dir} ${php72_with_ssl} ${with_nghttp2} - make -j ${THREAD} && make install - popd > /dev/null - rm -rf curl-${curl_ver} - fi - - if [ ! -e "${freetype_install_dir}/lib/libfreetype.la" ]; then - tar xzf freetype-${freetype_ver}.tar.gz - pushd freetype-${freetype_ver} > /dev/null - ./configure --prefix=${freetype_install_dir} --enable-freetype-config - make -j ${THREAD} && make install - ln -sf ${freetype_install_dir}/include/freetype2/* /usr/include/ - [ -d /usr/lib/pkgconfig ] && /bin/cp ${freetype_install_dir}/lib/pkgconfig/freetype2.pc /usr/lib/pkgconfig/ - popd > /dev/null - rm -rf freetype-${freetype_ver} - fi - - if [ ! -e "/usr/local/lib/pkgconfig/libargon2.pc" ]; then - tar xzf argon2-${argon2_ver}.tar.gz - pushd argon2-${argon2_ver} > /dev/null - make -j ${THREAD} && make install - [ ! -d /usr/local/lib/pkgconfig ] && mkdir -p /usr/local/lib/pkgconfig - /bin/cp libargon2.pc /usr/local/lib/pkgconfig/ - popd > /dev/null - rm -rf argon2-${argon2_ver} - fi - - if [ ! -e "/usr/local/lib/libsodium.la" ]; then - tar xzf libsodium-${libsodium_ver}.tar.gz - pushd libsodium-${libsodium_ver} > /dev/null - ./configure --disable-dependency-tracking --enable-minimal - make -j ${THREAD} && make install - popd > /dev/null - rm -rf libsodium-${libsodium_ver} - fi - - if [ ! -e "/usr/local/include/mhash.h" -a ! -e "/usr/include/mhash.h" ]; then - tar xzf mhash-${mhash_ver}.tar.gz - pushd mhash-${mhash_ver} > /dev/null - ./configure - make -j ${THREAD} && make install - popd > /dev/null - rm -rf mhash-${mhash_ver} - fi - - [ -z "`grep /usr/local/lib /etc/ld.so.conf.d/*.conf`" ] && echo '/usr/local/lib' > /etc/ld.so.conf.d/local.conf - ldconfig - - if [ "${PM}" == 'yum' ]; then - [ ! -e "/lib64/libpcre.so.1" ] && ln -s /lib64/libpcre.so.0.0.1 /lib64/libpcre.so.1 - [ ! -e "/usr/lib/libc-client.so" ] && ln -s /usr/lib64/libc-client.so /usr/lib/libc-client.so - fi - - id -g ${run_group} >/dev/null 2>&1 - [ $? -ne 0 ] && groupadd ${run_group} - id -u ${run_user} >/dev/null 2>&1 - [ $? -ne 0 ] && useradd -g ${run_group} -M -s /sbin/nologin ${run_user} - - tar xzf php-${php72_ver}.tar.gz - pushd php-${php72_ver} > /dev/null - if [ -e ext/openssl/openssl.c ] && ! grep -Eqi '^#ifdef RSA_SSLV23_PADDING' ext/openssl/openssl.c; then - sed -i '/OPENSSL_SSLV23_PADDING/i#ifdef RSA_SSLV23_PADDING' ext/openssl/openssl.c - sed -i '/OPENSSL_SSLV23_PADDING/a#endif' ext/openssl/openssl.c - fi - make clean - [ ! -d "${php_install_dir}" ] && mkdir -p ${php_install_dir} - [ "${phpcache_option}" == '1' ] && phpcache_arg='--enable-opcache' || phpcache_arg='--disable-opcache' - [ ${RHEL_ver:-0} -ge 9 >/dev/null 2>&1 ] || intl_modules_options='--enable-intl' - [[ "${Platform}" =~ ^hce$ ]] && unset intl_modules_options - if [ "${apache_mode_option}" == '2' ]; then - ./configure --prefix=${php_install_dir} --with-config-file-path=${php_install_dir}/etc \ - --with-config-file-scan-dir=${php_install_dir}/etc/php.d \ - --with-apxs2=${apache_install_dir}/bin/apxs ${phpcache_arg} --disable-fileinfo \ - --enable-mysqlnd --with-mysqli=mysqlnd --with-pdo-mysql=mysqlnd --with-iconv-dir=/usr/local \ - --with-freetype-dir=${freetype_install_dir} --with-jpeg-dir --with-png-dir --with-zlib \ - --with-libxml-dir=/usr --enable-xml --disable-rpath --enable-bcmath --enable-shmop --enable-exif \ - --enable-sysvsem --enable-inline-optimization ${php72_with_curl} --enable-mbregex \ - --enable-mbstring --with-password-argon2 --with-sodium=/usr/local --with-gd ${php72_with_openssl} \ - --with-mhash --enable-pcntl --enable-sockets --with-xmlrpc --enable-ftp --with-xsl ${intl_modules_options} \ - --with-gettext --enable-zip --enable-soap --disable-debug ${php_modules_options} - else - ./configure --prefix=${php_install_dir} --with-config-file-path=${php_install_dir}/etc \ - --with-config-file-scan-dir=${php_install_dir}/etc/php.d \ - --with-fpm-user=${run_user} --with-fpm-group=${run_group} --enable-fpm ${phpcache_arg} --disable-fileinfo \ - --enable-mysqlnd --with-mysqli=mysqlnd --with-pdo-mysql=mysqlnd --with-iconv-dir=/usr/local \ - --with-freetype-dir=${freetype_install_dir} --with-jpeg-dir --with-png-dir --with-zlib \ - --with-libxml-dir=/usr --enable-xml --disable-rpath --enable-bcmath --enable-shmop --enable-exif \ - --enable-sysvsem --enable-inline-optimization ${php72_with_curl} --enable-mbregex \ - --enable-mbstring --with-password-argon2 --with-sodium=/usr/local --with-gd ${php72_with_openssl} \ - --with-mhash --enable-pcntl --enable-sockets --with-xmlrpc --enable-ftp --with-xsl ${intl_modules_options} \ - --with-gettext --enable-zip --enable-soap --disable-debug ${php_modules_options} - fi - make ZEND_EXTRA_LIBS='-liconv' -j ${THREAD} - make install - - if [ -e "${php_install_dir}/bin/phpize" ]; then - [ ! -e "${php_install_dir}/etc/php.d" ] && mkdir -p ${php_install_dir}/etc/php.d - echo "${CSUCCESS}PHP installed successfully! ${CEND}" - else - rm -rf ${php_install_dir} - echo "${CFAILURE}PHP install failed, Please Contact the author! ${CEND}" - kill -9 $$; exit 1; - fi - - [ -z "`grep ^'export PATH=' /etc/profile`" ] && echo "export PATH=${php_install_dir}/bin:\$PATH" >> /etc/profile - [ -n "`grep ^'export PATH=' /etc/profile`" -a -z "`grep ${php_install_dir} /etc/profile`" ] && sed -i "s@^export PATH=\(.*\)@export PATH=${php_install_dir}/bin:\1@" /etc/profile - . /etc/profile - - # wget -c http://pear.php.net/go-pear.phar - # ${php_install_dir}/bin/php go-pear.phar - - /bin/cp php.ini-production ${php_install_dir}/etc/php.ini - - sed -i "s@^memory_limit.*@memory_limit = ${Memory_limit}M@" ${php_install_dir}/etc/php.ini - sed -i 's@^output_buffering =@output_buffering = On\noutput_buffering =@' ${php_install_dir}/etc/php.ini - #sed -i 's@^;cgi.fix_pathinfo.*@cgi.fix_pathinfo=0@' ${php_install_dir}/etc/php.ini - sed -i 's@^short_open_tag = Off@short_open_tag = On@' ${php_install_dir}/etc/php.ini - sed -i 's@^expose_php = On@expose_php = Off@' ${php_install_dir}/etc/php.ini - sed -i 's@^request_order.*@request_order = "CGP"@' ${php_install_dir}/etc/php.ini - sed -i "s@^;date.timezone.*@date.timezone = ${timezone}@" ${php_install_dir}/etc/php.ini - sed -i 's@^post_max_size.*@post_max_size = 100M@' ${php_install_dir}/etc/php.ini - sed -i 's@^upload_max_filesize.*@upload_max_filesize = 50M@' ${php_install_dir}/etc/php.ini - sed -i 's@^max_execution_time.*@max_execution_time = 600@' ${php_install_dir}/etc/php.ini - sed -i 's@^;realpath_cache_size.*@realpath_cache_size = 2M@' ${php_install_dir}/etc/php.ini - sed -i 's@^disable_functions.*@disable_functions = passthru,exec,system,chroot,chgrp,chown,shell_exec,proc_open,proc_get_status,ini_alter,ini_restore,dl,readlink,symlink,popepassthru,stream_socket_server,fsocket,popen@' ${php_install_dir}/etc/php.ini - [ -e /usr/sbin/sendmail ] && sed -i 's@^;sendmail_path.*@sendmail_path = /usr/sbin/sendmail -t -i@' ${php_install_dir}/etc/php.ini - if [ "${with_old_openssl_flag}" = 'y' ]; then - sed -i "s@^;curl.cainfo.*@curl.cainfo = \"${openssl_install_dir}/cert.pem\"@" ${php_install_dir}/etc/php.ini - sed -i "s@^;openssl.cafile.*@openssl.cafile = \"${openssl_install_dir}/cert.pem\"@" ${php_install_dir}/etc/php.ini - sed -i "s@^;openssl.capath.*@openssl.capath = \"${openssl_install_dir}/cert.pem\"@" ${php_install_dir}/etc/php.ini - fi - - [ "${phpcache_option}" == '1' ] && cat > ${php_install_dir}/etc/php.d/02-opcache.ini << EOF -[opcache] -zend_extension=opcache.so -opcache.enable=1 -opcache.enable_cli=1 -opcache.memory_consumption=${Memory_limit} -opcache.interned_strings_buffer=8 -opcache.max_accelerated_files=100000 -opcache.max_wasted_percentage=5 -opcache.use_cwd=1 -opcache.validate_timestamps=1 -opcache.revalidate_freq=60 -;opcache.save_comments=0 -opcache.consistency_checks=0 -;opcache.optimization_level=0 -EOF - - if [ "${apache_mode_option}" != '2' ]; then - # php-fpm Init Script - /bin/cp ${current_dir}/init.d/php-fpm.service /lib/systemd/system/ - sed -i "s@/usr/local/php@${php_install_dir}@g" /lib/systemd/system/php-fpm.service - systemctl enable php-fpm - - cat > ${php_install_dir}/etc/php-fpm.conf < /dev/null - [ -e "${php_install_dir}/bin/phpize" ] && rm -rf php-${php72_ver} - popd > /dev/null -} diff --git a/include/php-7.3.sh b/include/php-7.3.sh deleted file mode 100644 index 00338045..00000000 --- a/include/php-7.3.sh +++ /dev/null @@ -1,265 +0,0 @@ -#!/bin/bash -# Author: yeho -# BLOG: https://linuxeye.com - -Install_PHP73() { - pushd ${current_dir}/src > /dev/null - if [ ! -e "/usr/local/lib/libiconv.la" ]; then - tar xzf libiconv-${libiconv_ver}.tar.gz - pushd libiconv-${libiconv_ver} > /dev/null - ./configure - make -j ${THREAD} && make install - popd > /dev/null - rm -rf libiconv-${libiconv_ver} - fi - - if [ ! -e "${curl_install_dir}/lib/libcurl.la" ]; then - tar xzf curl-${curl_ver}.tar.gz - pushd curl-${curl_ver} > /dev/null - [ -e "/usr/local/lib/libnghttp2.so" ] && with_nghttp2='--with-nghttp2=/usr/local' - ./configure --prefix=${curl_install_dir} ${php73_with_ssl} ${with_nghttp2} - make -j ${THREAD} && make install - popd > /dev/null - rm -rf curl-${curl_ver} - fi - - if [ ! -e "${freetype_install_dir}/lib/libfreetype.la" ]; then - tar xzf freetype-${freetype_ver}.tar.gz - pushd freetype-${freetype_ver} > /dev/null - ./configure --prefix=${freetype_install_dir} --enable-freetype-config - make -j ${THREAD} && make install - ln -sf ${freetype_install_dir}/include/freetype2/* /usr/include/ - [ -d /usr/lib/pkgconfig ] && /bin/cp ${freetype_install_dir}/lib/pkgconfig/freetype2.pc /usr/lib/pkgconfig/ - popd > /dev/null - rm -rf freetype-${freetype_ver} - fi - - if [ ! -e "/usr/local/lib/pkgconfig/libargon2.pc" ]; then - tar xzf argon2-${argon2_ver}.tar.gz - pushd argon2-${argon2_ver} > /dev/null - make -j ${THREAD} && make install - [ ! -d /usr/local/lib/pkgconfig ] && mkdir -p /usr/local/lib/pkgconfig - /bin/cp libargon2.pc /usr/local/lib/pkgconfig/ - popd > /dev/null - rm -rf argon2-${argon2_ver} - fi - - if [ ! -e "/usr/local/lib/libsodium.la" ]; then - tar xzf libsodium-${libsodium_ver}.tar.gz - pushd libsodium-${libsodium_ver} > /dev/null - ./configure --disable-dependency-tracking --enable-minimal - make -j ${THREAD} && make install - popd > /dev/null - rm -rf libsodium-${libsodium_ver} - fi - - if [ ! -e "/usr/local/include/mhash.h" -a ! -e "/usr/include/mhash.h" ]; then - tar xzf mhash-${mhash_ver}.tar.gz - pushd mhash-${mhash_ver} > /dev/null - ./configure - make -j ${THREAD} && make install - popd > /dev/null - rm -rf mhash-${mhash_ver} - fi - - [ -z "`grep /usr/local/lib /etc/ld.so.conf.d/*.conf`" ] && echo '/usr/local/lib' > /etc/ld.so.conf.d/local.conf - ldconfig - - if [ "${PM}" == 'yum' ]; then - [ ! -e "/lib64/libpcre.so.1" ] && ln -s /lib64/libpcre.so.0.0.1 /lib64/libpcre.so.1 - [ ! -e "/usr/lib/libc-client.so" ] && ln -s /usr/lib64/libc-client.so /usr/lib/libc-client.so - fi - - id -g ${run_group} >/dev/null 2>&1 - [ $? -ne 0 ] && groupadd ${run_group} - id -u ${run_user} >/dev/null 2>&1 - [ $? -ne 0 ] && useradd -g ${run_group} -M -s /sbin/nologin ${run_user} - - tar xzf php-${php73_ver}.tar.gz - pushd php-${php73_ver} > /dev/null - if [ -e ext/openssl/openssl.c ] && ! grep -Eqi '^#ifdef RSA_SSLV23_PADDING' ext/openssl/openssl.c; then - sed -i '/OPENSSL_SSLV23_PADDING/i#ifdef RSA_SSLV23_PADDING' ext/openssl/openssl.c - sed -i '/OPENSSL_SSLV23_PADDING/a#endif' ext/openssl/openssl.c - fi - make clean - [ ! -d "${php_install_dir}" ] && mkdir -p ${php_install_dir} - [ "${phpcache_option}" == '1' ] && phpcache_arg='--enable-opcache' || phpcache_arg='--disable-opcache' - [ ${RHEL_ver:-0} -ge 9 >/dev/null 2>&1 ] || intl_modules_options='--enable-intl' - if [ "${apache_mode_option}" == '2' ]; then - ./configure --prefix=${php_install_dir} --with-config-file-path=${php_install_dir}/etc \ - --with-config-file-scan-dir=${php_install_dir}/etc/php.d \ - --with-apxs2=${apache_install_dir}/bin/apxs ${phpcache_arg} --disable-fileinfo \ - --enable-mysqlnd --with-mysqli=mysqlnd --with-pdo-mysql=mysqlnd --with-iconv-dir=/usr/local \ - --with-freetype-dir=${freetype_install_dir} --with-jpeg-dir --with-png-dir --with-zlib \ - --with-libxml-dir=/usr --enable-xml --disable-rpath --enable-bcmath --enable-shmop --enable-exif \ - --enable-sysvsem --enable-inline-optimization ${php73_with_curl} --enable-mbregex \ - --enable-mbstring --with-password-argon2 --with-sodium=/usr/local --with-gd ${php73_with_openssl} \ - --with-mhash --enable-pcntl --enable-sockets --with-xmlrpc --enable-ftp --with-xsl ${intl_modules_options} \ - --with-gettext --enable-zip --without-libzip --enable-soap --disable-debug ${php_modules_options} - else - ./configure --prefix=${php_install_dir} --with-config-file-path=${php_install_dir}/etc \ - --with-config-file-scan-dir=${php_install_dir}/etc/php.d \ - --with-fpm-user=${run_user} --with-fpm-group=${run_group} --enable-fpm ${phpcache_arg} --disable-fileinfo \ - --enable-mysqlnd --with-mysqli=mysqlnd --with-pdo-mysql=mysqlnd --with-iconv-dir=/usr/local \ - --with-freetype-dir=${freetype_install_dir} --with-jpeg-dir --with-png-dir --with-zlib \ - --with-libxml-dir=/usr --enable-xml --disable-rpath --enable-bcmath --enable-shmop --enable-exif \ - --enable-sysvsem --enable-inline-optimization ${php73_with_curl} --enable-mbregex \ - --enable-mbstring --with-password-argon2 --with-sodium=/usr/local --with-gd ${php73_with_openssl} \ - --with-mhash --enable-pcntl --enable-sockets --with-xmlrpc --enable-ftp --with-xsl ${intl_modules_options} \ - --with-gettext --enable-zip --without-libzip --enable-soap --disable-debug ${php_modules_options} - fi - make ZEND_EXTRA_LIBS='-liconv' -j ${THREAD} - make install - - if [ -e "${php_install_dir}/bin/phpize" ]; then - [ ! -e "${php_install_dir}/etc/php.d" ] && mkdir -p ${php_install_dir}/etc/php.d - echo "${CSUCCESS}PHP installed successfully! ${CEND}" - else - rm -rf ${php_install_dir} - echo "${CFAILURE}PHP install failed, Please Contact the author! ${CEND}" - kill -9 $$; exit 1; - fi - - [ -z "`grep ^'export PATH=' /etc/profile`" ] && echo "export PATH=${php_install_dir}/bin:\$PATH" >> /etc/profile - [ -n "`grep ^'export PATH=' /etc/profile`" -a -z "`grep ${php_install_dir} /etc/profile`" ] && sed -i "s@^export PATH=\(.*\)@export PATH=${php_install_dir}/bin:\1@" /etc/profile - . /etc/profile - - # wget -c http://pear.php.net/go-pear.phar - # ${php_install_dir}/bin/php go-pear.phar - - /bin/cp php.ini-production ${php_install_dir}/etc/php.ini - - sed -i "s@^memory_limit.*@memory_limit = ${Memory_limit}M@" ${php_install_dir}/etc/php.ini - sed -i 's@^output_buffering =@output_buffering = On\noutput_buffering =@' ${php_install_dir}/etc/php.ini - #sed -i 's@^;cgi.fix_pathinfo.*@cgi.fix_pathinfo=0@' ${php_install_dir}/etc/php.ini - sed -i 's@^short_open_tag = Off@short_open_tag = On@' ${php_install_dir}/etc/php.ini - sed -i 's@^expose_php = On@expose_php = Off@' ${php_install_dir}/etc/php.ini - sed -i 's@^request_order.*@request_order = "CGP"@' ${php_install_dir}/etc/php.ini - sed -i "s@^;date.timezone.*@date.timezone = ${timezone}@" ${php_install_dir}/etc/php.ini - sed -i 's@^post_max_size.*@post_max_size = 100M@' ${php_install_dir}/etc/php.ini - sed -i 's@^upload_max_filesize.*@upload_max_filesize = 50M@' ${php_install_dir}/etc/php.ini - sed -i 's@^max_execution_time.*@max_execution_time = 600@' ${php_install_dir}/etc/php.ini - sed -i 's@^;realpath_cache_size.*@realpath_cache_size = 2M@' ${php_install_dir}/etc/php.ini - sed -i 's@^disable_functions.*@disable_functions = passthru,exec,system,chroot,chgrp,chown,shell_exec,proc_open,proc_get_status,ini_alter,ini_restore,dl,readlink,symlink,popepassthru,stream_socket_server,fsocket,popen@' ${php_install_dir}/etc/php.ini - [ -e /usr/sbin/sendmail ] && sed -i 's@^;sendmail_path.*@sendmail_path = /usr/sbin/sendmail -t -i@' ${php_install_dir}/etc/php.ini - if [ "${with_old_openssl_flag}" = 'y' ]; then - sed -i "s@^;curl.cainfo.*@curl.cainfo = \"${openssl_install_dir}/cert.pem\"@" ${php_install_dir}/etc/php.ini - sed -i "s@^;openssl.cafile.*@openssl.cafile = \"${openssl_install_dir}/cert.pem\"@" ${php_install_dir}/etc/php.ini - sed -i "s@^;openssl.capath.*@openssl.capath = \"${openssl_install_dir}/cert.pem\"@" ${php_install_dir}/etc/php.ini - fi - - [ "${phpcache_option}" == '1' ] && cat > ${php_install_dir}/etc/php.d/02-opcache.ini << EOF -[opcache] -zend_extension=opcache.so -opcache.enable=1 -opcache.enable_cli=1 -opcache.memory_consumption=${Memory_limit} -opcache.interned_strings_buffer=8 -opcache.max_accelerated_files=100000 -opcache.max_wasted_percentage=5 -opcache.use_cwd=1 -opcache.validate_timestamps=1 -opcache.revalidate_freq=60 -;opcache.save_comments=0 -opcache.consistency_checks=0 -;opcache.optimization_level=0 -EOF - - if [ "${apache_mode_option}" != '2' ]; then - # php-fpm Init Script - /bin/cp ${current_dir}/init.d/php-fpm.service /lib/systemd/system/ - sed -i "s@/usr/local/php@${php_install_dir}@g" /lib/systemd/system/php-fpm.service - systemctl enable php-fpm - - cat > ${php_install_dir}/etc/php-fpm.conf < /dev/null - [ -e "${php_install_dir}/bin/phpize" ] && rm -rf php-${php73_ver} - popd > /dev/null -} diff --git a/include/php-7.4.sh b/include/php-7.4.sh deleted file mode 100644 index 113d9c2e..00000000 --- a/include/php-7.4.sh +++ /dev/null @@ -1,274 +0,0 @@ -#!/bin/bash -# Author: yeho -# BLOG: https://linuxeye.com - -Install_PHP74() { - pushd ${current_dir}/src > /dev/null - if [ ! -e "/usr/local/lib/libiconv.la" ]; then - tar xzf libiconv-${libiconv_ver}.tar.gz - pushd libiconv-${libiconv_ver} > /dev/null - ./configure - make -j ${THREAD} && make install - popd > /dev/null - rm -rf libiconv-${libiconv_ver} - fi - - if [ ! -e "${curl_install_dir}/lib/libcurl.la" ]; then - tar xzf curl-${curl_ver}.tar.gz - pushd curl-${curl_ver} > /dev/null - [ -e "/usr/local/lib/libnghttp2.so" ] && with_nghttp2='--with-nghttp2=/usr/local' - ./configure --prefix=${curl_install_dir} ${php74_with_ssl} ${with_nghttp2} - make -j ${THREAD} && make install - popd > /dev/null - rm -rf curl-${curl_ver} - fi - - if [ ! -e "${freetype_install_dir}/lib/libfreetype.la" ]; then - tar xzf freetype-${freetype_ver}.tar.gz - pushd freetype-${freetype_ver} > /dev/null - ./configure --prefix=${freetype_install_dir} --enable-freetype-config - make -j ${THREAD} && make install - ln -sf ${freetype_install_dir}/include/freetype2/* /usr/include/ - [ -d /usr/lib/pkgconfig ] && /bin/cp ${freetype_install_dir}/lib/pkgconfig/freetype2.pc /usr/lib/pkgconfig/ - popd > /dev/null - rm -rf freetype-${freetype_ver} - fi - - if [ ! -e "/usr/local/lib/pkgconfig/libargon2.pc" ]; then - tar xzf argon2-${argon2_ver}.tar.gz - pushd argon2-${argon2_ver} > /dev/null - make -j ${THREAD} && make install - [ ! -d /usr/local/lib/pkgconfig ] && mkdir -p /usr/local/lib/pkgconfig - /bin/cp libargon2.pc /usr/local/lib/pkgconfig/ - popd > /dev/null - rm -rf argon2-${argon2_ver} - fi - - if [ ! -e "/usr/local/lib/libsodium.la" ]; then - tar xzf libsodium-${libsodium_ver}.tar.gz - pushd libsodium-${libsodium_ver} > /dev/null - ./configure --disable-dependency-tracking --enable-minimal - make -j ${THREAD} && make install - popd > /dev/null - rm -rf libsodium-${libsodium_ver} - fi - - if [ ! -e "/usr/local/lib/libzip.la" ]; then - tar xzf libzip-${libzip_ver}.tar.gz - pushd libzip-${libzip_ver} > /dev/null - ./configure - make -j ${THREAD} && make install - popd > /dev/null - rm -rf libzip-${libzip_ver} - fi - - if [ ! -e "/usr/local/include/mhash.h" -a ! -e "/usr/include/mhash.h" ]; then - tar xzf mhash-${mhash_ver}.tar.gz - pushd mhash-${mhash_ver} > /dev/null - ./configure - make -j ${THREAD} && make install - popd > /dev/null - rm -rf mhash-${mhash_ver} - fi - - [ -z "`grep /usr/local/lib /etc/ld.so.conf.d/*.conf`" ] && echo '/usr/local/lib' > /etc/ld.so.conf.d/local.conf - ldconfig - - if [ "${PM}" == 'yum' ]; then - [ ! -e "/lib64/libpcre.so.1" ] && ln -s /lib64/libpcre.so.0.0.1 /lib64/libpcre.so.1 - [ ! -e "/usr/lib/libc-client.so" ] && ln -s /usr/lib64/libc-client.so /usr/lib/libc-client.so - fi - - id -g ${run_group} >/dev/null 2>&1 - [ $? -ne 0 ] && groupadd ${run_group} - id -u ${run_user} >/dev/null 2>&1 - [ $? -ne 0 ] && useradd -g ${run_group} -M -s /sbin/nologin ${run_user} - - tar xzf php-${php74_ver}.tar.gz - pushd php-${php74_ver} > /dev/null - if [ -e ext/openssl/openssl.c ] && ! grep -Eqi '^#ifdef RSA_SSLV23_PADDING' ext/openssl/openssl.c; then - sed -i '/OPENSSL_SSLV23_PADDING/i#ifdef RSA_SSLV23_PADDING' ext/openssl/openssl.c - sed -i '/OPENSSL_SSLV23_PADDING/a#endif' ext/openssl/openssl.c - fi - make clean - export PKG_CONFIG_PATH=/usr/local/lib/pkgconfig/:$PKG_CONFIG_PATH - [ ! -d "${php_install_dir}" ] && mkdir -p ${php_install_dir} - [ "${phpcache_option}" == '1' ] && phpcache_arg='--enable-opcache' || phpcache_arg='--disable-opcache' - if [ "${apache_mode_option}" == '2' ]; then - ./configure --prefix=${php_install_dir} --with-config-file-path=${php_install_dir}/etc \ - --with-config-file-scan-dir=${php_install_dir}/etc/php.d \ - --with-apxs2=${apache_install_dir}/bin/apxs ${phpcache_arg} --disable-fileinfo \ - --enable-mysqlnd --with-mysqli=mysqlnd --with-pdo-mysql=mysqlnd \ - --with-iconv-dir=/usr/local --with-freetype --with-jpeg --with-zlib \ - --enable-xml --disable-rpath --enable-bcmath --enable-shmop --enable-exif \ - --enable-sysvsem --enable-inline-optimization ${php74_with_curl} --enable-mbregex \ - --enable-mbstring --with-password-argon2 --with-sodium=/usr/local --enable-gd ${php74_with_openssl} \ - --with-mhash --enable-pcntl --enable-sockets --with-xmlrpc --enable-ftp --enable-intl --with-xsl \ - --with-gettext --with-zip=/usr/local --enable-soap --disable-debug ${php_modules_options} - else - ./configure --prefix=${php_install_dir} --with-config-file-path=${php_install_dir}/etc \ - --with-config-file-scan-dir=${php_install_dir}/etc/php.d \ - --with-fpm-user=${run_user} --with-fpm-group=${run_group} --enable-fpm ${phpcache_arg} --disable-fileinfo \ - --enable-mysqlnd --with-mysqli=mysqlnd --with-pdo-mysql=mysqlnd \ - --with-iconv-dir=/usr/local --with-freetype --with-jpeg --with-zlib \ - --enable-xml --disable-rpath --enable-bcmath --enable-shmop --enable-exif \ - --enable-sysvsem --enable-inline-optimization ${php74_with_curl} --enable-mbregex \ - --enable-mbstring --with-password-argon2 --with-sodium=/usr/local --enable-gd ${php74_with_openssl} \ - --with-mhash --enable-pcntl --enable-sockets --with-xmlrpc --enable-ftp --enable-intl --with-xsl \ - --with-gettext --with-zip=/usr/local --enable-soap --disable-debug ${php_modules_options} - fi - make ZEND_EXTRA_LIBS='-liconv' -j ${THREAD} - make install - - if [ -e "${php_install_dir}/bin/phpize" ]; then - [ ! -e "${php_install_dir}/etc/php.d" ] && mkdir -p ${php_install_dir}/etc/php.d - echo "${CSUCCESS}PHP installed successfully! ${CEND}" - else - rm -rf ${php_install_dir} - echo "${CFAILURE}PHP install failed, Please Contact the author! ${CEND}" - kill -9 $$; exit 1; - fi - - [ -z "`grep ^'export PATH=' /etc/profile`" ] && echo "export PATH=${php_install_dir}/bin:\$PATH" >> /etc/profile - [ -n "`grep ^'export PATH=' /etc/profile`" -a -z "`grep ${php_install_dir} /etc/profile`" ] && sed -i "s@^export PATH=\(.*\)@export PATH=${php_install_dir}/bin:\1@" /etc/profile - . /etc/profile - - # wget -c http://pear.php.net/go-pear.phar - # ${php_install_dir}/bin/php go-pear.phar - - /bin/cp php.ini-production ${php_install_dir}/etc/php.ini - - sed -i "s@^memory_limit.*@memory_limit = ${Memory_limit}M@" ${php_install_dir}/etc/php.ini - sed -i 's@^output_buffering =@output_buffering = On\noutput_buffering =@' ${php_install_dir}/etc/php.ini - #sed -i 's@^;cgi.fix_pathinfo.*@cgi.fix_pathinfo=0@' ${php_install_dir}/etc/php.ini - sed -i 's@^short_open_tag = Off@short_open_tag = On@' ${php_install_dir}/etc/php.ini - sed -i 's@^expose_php = On@expose_php = Off@' ${php_install_dir}/etc/php.ini - sed -i 's@^request_order.*@request_order = "CGP"@' ${php_install_dir}/etc/php.ini - sed -i "s@^;date.timezone.*@date.timezone = ${timezone}@" ${php_install_dir}/etc/php.ini - sed -i 's@^post_max_size.*@post_max_size = 100M@' ${php_install_dir}/etc/php.ini - sed -i 's@^upload_max_filesize.*@upload_max_filesize = 50M@' ${php_install_dir}/etc/php.ini - sed -i 's@^max_execution_time.*@max_execution_time = 600@' ${php_install_dir}/etc/php.ini - sed -i 's@^;realpath_cache_size.*@realpath_cache_size = 2M@' ${php_install_dir}/etc/php.ini - sed -i 's@^disable_functions.*@disable_functions = passthru,exec,system,chroot,chgrp,chown,shell_exec,proc_open,proc_get_status,ini_alter,ini_restore,dl,readlink,symlink,popepassthru,stream_socket_server,fsocket,popen@' ${php_install_dir}/etc/php.ini - [ -e /usr/sbin/sendmail ] && sed -i 's@^;sendmail_path.*@sendmail_path = /usr/sbin/sendmail -t -i@' ${php_install_dir}/etc/php.ini - if [ "${with_old_openssl_flag}" = 'y' ]; then - sed -i "s@^;curl.cainfo.*@curl.cainfo = \"${openssl_install_dir}/cert.pem\"@" ${php_install_dir}/etc/php.ini - sed -i "s@^;openssl.cafile.*@openssl.cafile = \"${openssl_install_dir}/cert.pem\"@" ${php_install_dir}/etc/php.ini - sed -i "s@^;openssl.capath.*@openssl.capath = \"${openssl_install_dir}/cert.pem\"@" ${php_install_dir}/etc/php.ini - fi - - [ "${phpcache_option}" == '1' ] && cat > ${php_install_dir}/etc/php.d/02-opcache.ini << EOF -[opcache] -zend_extension=opcache.so -opcache.enable=1 -opcache.enable_cli=1 -opcache.memory_consumption=${Memory_limit} -opcache.interned_strings_buffer=8 -opcache.max_accelerated_files=100000 -opcache.max_wasted_percentage=5 -opcache.use_cwd=1 -opcache.validate_timestamps=1 -opcache.revalidate_freq=60 -;opcache.save_comments=0 -opcache.consistency_checks=0 -;opcache.optimization_level=0 -EOF - - if [ "${apache_mode_option}" != '2' ]; then - # php-fpm Init Script - /bin/cp ${current_dir}/init.d/php-fpm.service /lib/systemd/system/ - sed -i "s@/usr/local/php@${php_install_dir}@g" /lib/systemd/system/php-fpm.service - systemctl enable php-fpm - - cat > ${php_install_dir}/etc/php-fpm.conf < /dev/null - [ -e "${php_install_dir}/bin/phpize" ] && rm -rf php-${php74_ver} - popd > /dev/null -} diff --git a/include/php-8.0.sh b/include/php-8.0.sh deleted file mode 100644 index 31020b25..00000000 --- a/include/php-8.0.sh +++ /dev/null @@ -1,274 +0,0 @@ -#!/bin/bash -# Author: yeho -# BLOG: https://linuxeye.com - -Install_PHP80() { - pushd ${current_dir}/src > /dev/null - if [ ! -e "/usr/local/lib/libiconv.la" ]; then - tar xzf libiconv-${libiconv_ver}.tar.gz - pushd libiconv-${libiconv_ver} > /dev/null - ./configure - make -j ${THREAD} && make install - popd > /dev/null - rm -rf libiconv-${libiconv_ver} - fi - - if [ ! -e "${curl_install_dir}/lib/libcurl.la" ]; then - tar xzf curl-${curl_ver}.tar.gz - pushd curl-${curl_ver} > /dev/null - [ -e "/usr/local/lib/libnghttp2.so" ] && with_nghttp2='--with-nghttp2=/usr/local' - ./configure --prefix=${curl_install_dir} ${php80_with_ssl} ${with_nghttp2} - make -j ${THREAD} && make install - popd > /dev/null - rm -rf curl-${curl_ver} - fi - - if [ ! -e "${freetype_install_dir}/lib/libfreetype.la" ]; then - tar xzf freetype-${freetype_ver}.tar.gz - pushd freetype-${freetype_ver} > /dev/null - ./configure --prefix=${freetype_install_dir} --enable-freetype-config - make -j ${THREAD} && make install - ln -sf ${freetype_install_dir}/include/freetype2/* /usr/include/ - [ -d /usr/lib/pkgconfig ] && /bin/cp ${freetype_install_dir}/lib/pkgconfig/freetype2.pc /usr/lib/pkgconfig/ - popd > /dev/null - rm -rf freetype-${freetype_ver} - fi - - if [ ! -e "/usr/local/lib/pkgconfig/libargon2.pc" ]; then - tar xzf argon2-${argon2_ver}.tar.gz - pushd argon2-${argon2_ver} > /dev/null - make -j ${THREAD} && make install - [ ! -d /usr/local/lib/pkgconfig ] && mkdir -p /usr/local/lib/pkgconfig - /bin/cp libargon2.pc /usr/local/lib/pkgconfig/ - popd > /dev/null - rm -rf argon2-${argon2_ver} - fi - - if [ ! -e "/usr/local/lib/libsodium.la" ]; then - tar xzf libsodium-${libsodium_ver}.tar.gz - pushd libsodium-${libsodium_ver} > /dev/null - ./configure --disable-dependency-tracking --enable-minimal - make -j ${THREAD} && make install - popd > /dev/null - rm -rf libsodium-${libsodium_ver} - fi - - if [ ! -e "/usr/local/lib/libzip.la" ]; then - tar xzf libzip-${libzip_ver}.tar.gz - pushd libzip-${libzip_ver} > /dev/null - ./configure - make -j ${THREAD} && make install - popd > /dev/null - rm -rf libzip-${libzip_ver} - fi - - if [ ! -e "/usr/local/include/mhash.h" -a ! -e "/usr/include/mhash.h" ]; then - tar xzf mhash-${mhash_ver}.tar.gz - pushd mhash-${mhash_ver} > /dev/null - ./configure - make -j ${THREAD} && make install - popd > /dev/null - rm -rf mhash-${mhash_ver} - fi - - [ -z "`grep /usr/local/lib /etc/ld.so.conf.d/*.conf`" ] && echo '/usr/local/lib' > /etc/ld.so.conf.d/local.conf - ldconfig - - if [ "${PM}" == 'yum' ]; then - [ ! -e "/lib64/libpcre.so.1" ] && ln -s /lib64/libpcre.so.0.0.1 /lib64/libpcre.so.1 - [ ! -e "/usr/lib/libc-client.so" ] && ln -s /usr/lib64/libc-client.so /usr/lib/libc-client.so - fi - - id -g ${run_group} >/dev/null 2>&1 - [ $? -ne 0 ] && groupadd ${run_group} - id -u ${run_user} >/dev/null 2>&1 - [ $? -ne 0 ] && useradd -g ${run_group} -M -s /sbin/nologin ${run_user} - - tar xzf php-${php80_ver}.tar.gz - pushd php-${php80_ver} > /dev/null - if [ -e ext/openssl/openssl.c ] && ! grep -Eqi '^#ifdef RSA_SSLV23_PADDING' ext/openssl/openssl.c; then - sed -i '/OPENSSL_SSLV23_PADDING/i#ifdef RSA_SSLV23_PADDING' ext/openssl/openssl.c - sed -i '/OPENSSL_SSLV23_PADDING/a#endif' ext/openssl/openssl.c - fi - make clean - export PKG_CONFIG_PATH=/usr/local/lib/pkgconfig/:$PKG_CONFIG_PATH - [ ! -d "${php_install_dir}" ] && mkdir -p ${php_install_dir} - [ "${phpcache_option}" == '1' ] && phpcache_arg='--enable-opcache' || phpcache_arg='--disable-opcache' - if [ "${apache_mode_option}" == '2' ]; then - ./configure --prefix=${php_install_dir} --with-config-file-path=${php_install_dir}/etc \ - --with-config-file-scan-dir=${php_install_dir}/etc/php.d \ - --with-apxs2=${apache_install_dir}/bin/apxs ${phpcache_arg} --disable-fileinfo \ - --enable-mysqlnd --with-mysqli=mysqlnd --with-pdo-mysql=mysqlnd \ - --with-iconv=/usr/local --with-freetype --with-jpeg --with-zlib \ - --enable-xml --disable-rpath --enable-bcmath --enable-shmop --enable-exif \ - --enable-sysvsem ${php80_with_curl} --enable-mbregex \ - --enable-mbstring --with-password-argon2 --with-sodium=/usr/local --enable-gd ${php80_with_openssl} \ - --with-mhash --enable-pcntl --enable-sockets --enable-ftp --enable-intl --with-xsl \ - --with-gettext --with-zip=/usr/local --enable-soap --disable-debug ${php_modules_options} - else - ./configure --prefix=${php_install_dir} --with-config-file-path=${php_install_dir}/etc \ - --with-config-file-scan-dir=${php_install_dir}/etc/php.d \ - --with-fpm-user=${run_user} --with-fpm-group=${run_group} --enable-fpm ${phpcache_arg} --disable-fileinfo \ - --enable-mysqlnd --with-mysqli=mysqlnd --with-pdo-mysql=mysqlnd \ - --with-iconv=/usr/local --with-freetype --with-jpeg --with-zlib \ - --enable-xml --disable-rpath --enable-bcmath --enable-shmop --enable-exif \ - --enable-sysvsem ${php80_with_curl} --enable-mbregex \ - --enable-mbstring --with-password-argon2 --with-sodium=/usr/local --enable-gd ${php80_with_openssl} \ - --with-mhash --enable-pcntl --enable-sockets --enable-ftp --enable-intl --with-xsl \ - --with-gettext --with-zip=/usr/local --enable-soap --disable-debug ${php_modules_options} - fi - make ZEND_EXTRA_LIBS='-liconv' -j ${THREAD} - make install - - if [ -e "${php_install_dir}/bin/phpize" ]; then - [ ! -e "${php_install_dir}/etc/php.d" ] && mkdir -p ${php_install_dir}/etc/php.d - echo "${CSUCCESS}PHP installed successfully! ${CEND}" - else - rm -rf ${php_install_dir} - echo "${CFAILURE}PHP install failed, Please Contact the author! ${CEND}" - kill -9 $$; exit 1; - fi - - [ -z "`grep ^'export PATH=' /etc/profile`" ] && echo "export PATH=${php_install_dir}/bin:\$PATH" >> /etc/profile - [ -n "`grep ^'export PATH=' /etc/profile`" -a -z "`grep ${php_install_dir} /etc/profile`" ] && sed -i "s@^export PATH=\(.*\)@export PATH=${php_install_dir}/bin:\1@" /etc/profile - . /etc/profile - - # wget -c http://pear.php.net/go-pear.phar - # ${php_install_dir}/bin/php go-pear.phar - - /bin/cp php.ini-production ${php_install_dir}/etc/php.ini - - sed -i "s@^memory_limit.*@memory_limit = ${Memory_limit}M@" ${php_install_dir}/etc/php.ini - sed -i 's@^output_buffering =@output_buffering = On\noutput_buffering =@' ${php_install_dir}/etc/php.ini - #sed -i 's@^;cgi.fix_pathinfo.*@cgi.fix_pathinfo=0@' ${php_install_dir}/etc/php.ini - sed -i 's@^short_open_tag = Off@short_open_tag = On@' ${php_install_dir}/etc/php.ini - sed -i 's@^expose_php = On@expose_php = Off@' ${php_install_dir}/etc/php.ini - sed -i 's@^request_order.*@request_order = "CGP"@' ${php_install_dir}/etc/php.ini - sed -i "s@^;date.timezone.*@date.timezone = ${timezone}@" ${php_install_dir}/etc/php.ini - sed -i 's@^post_max_size.*@post_max_size = 100M@' ${php_install_dir}/etc/php.ini - sed -i 's@^upload_max_filesize.*@upload_max_filesize = 50M@' ${php_install_dir}/etc/php.ini - sed -i 's@^max_execution_time.*@max_execution_time = 600@' ${php_install_dir}/etc/php.ini - sed -i 's@^;realpath_cache_size.*@realpath_cache_size = 2M@' ${php_install_dir}/etc/php.ini - sed -i 's@^disable_functions.*@disable_functions = passthru,exec,system,chroot,chgrp,chown,shell_exec,proc_open,proc_get_status,ini_alter,ini_restore,dl,readlink,symlink,popepassthru,stream_socket_server,fsocket,popen@' ${php_install_dir}/etc/php.ini - [ -e /usr/sbin/sendmail ] && sed -i 's@^;sendmail_path.*@sendmail_path = /usr/sbin/sendmail -t -i@' ${php_install_dir}/etc/php.ini - if [ "${with_old_openssl_flag}" = 'y' ]; then - sed -i "s@^;curl.cainfo.*@curl.cainfo = \"${openssl_install_dir}/cert.pem\"@" ${php_install_dir}/etc/php.ini - sed -i "s@^;openssl.cafile.*@openssl.cafile = \"${openssl_install_dir}/cert.pem\"@" ${php_install_dir}/etc/php.ini - sed -i "s@^;openssl.capath.*@openssl.capath = \"${openssl_install_dir}/cert.pem\"@" ${php_install_dir}/etc/php.ini - fi - - [ "${phpcache_option}" == '1' ] && cat > ${php_install_dir}/etc/php.d/02-opcache.ini << EOF -[opcache] -zend_extension=opcache.so -opcache.enable=1 -opcache.enable_cli=1 -opcache.memory_consumption=${Memory_limit} -opcache.interned_strings_buffer=8 -opcache.max_accelerated_files=100000 -opcache.max_wasted_percentage=5 -opcache.use_cwd=1 -opcache.validate_timestamps=1 -opcache.revalidate_freq=60 -;opcache.save_comments=0 -opcache.consistency_checks=0 -;opcache.optimization_level=0 -EOF - - if [ "${apache_mode_option}" != '2' ]; then - # php-fpm Init Script - /bin/cp ${current_dir}/init.d/php-fpm.service /lib/systemd/system/ - sed -i "s@/usr/local/php@${php_install_dir}@g" /lib/systemd/system/php-fpm.service - systemctl enable php-fpm - - cat > ${php_install_dir}/etc/php-fpm.conf < /dev/null - [ -e "${php_install_dir}/bin/phpize" ] && rm -rf php-${php80_ver} - popd > /dev/null -} diff --git a/include/php-8.1.sh b/include/php-8.1.sh deleted file mode 100644 index 1109985b..00000000 --- a/include/php-8.1.sh +++ /dev/null @@ -1,270 +0,0 @@ -#!/bin/bash -# Author: yeho -# BLOG: https://linuxeye.com - -Install_PHP81() { - pushd ${current_dir}/src > /dev/null - if [ ! -e "/usr/local/lib/libiconv.la" ]; then - tar xzf libiconv-${libiconv_ver}.tar.gz - pushd libiconv-${libiconv_ver} > /dev/null - ./configure - make -j ${THREAD} && make install - popd > /dev/null - rm -rf libiconv-${libiconv_ver} - fi - - if [ ! -e "${curl_install_dir}/lib/libcurl.la" ]; then - tar xzf curl-${curl_ver}.tar.gz - pushd curl-${curl_ver} > /dev/null - [ -e "/usr/local/lib/libnghttp2.so" ] && with_nghttp2='--with-nghttp2=/usr/local' - ./configure --prefix=${curl_install_dir} ${php81_with_ssl} ${with_nghttp2} - make -j ${THREAD} && make install - popd > /dev/null - rm -rf curl-${curl_ver} - fi - - if [ ! -e "${freetype_install_dir}/lib/libfreetype.la" ]; then - tar xzf freetype-${freetype_ver}.tar.gz - pushd freetype-${freetype_ver} > /dev/null - ./configure --prefix=${freetype_install_dir} --enable-freetype-config - make -j ${THREAD} && make install - ln -sf ${freetype_install_dir}/include/freetype2/* /usr/include/ - [ -d /usr/lib/pkgconfig ] && /bin/cp ${freetype_install_dir}/lib/pkgconfig/freetype2.pc /usr/lib/pkgconfig/ - popd > /dev/null - rm -rf freetype-${freetype_ver} - fi - - if [ ! -e "/usr/local/lib/pkgconfig/libargon2.pc" ]; then - tar xzf argon2-${argon2_ver}.tar.gz - pushd argon2-${argon2_ver} > /dev/null - make -j ${THREAD} && make install - [ ! -d /usr/local/lib/pkgconfig ] && mkdir -p /usr/local/lib/pkgconfig - /bin/cp libargon2.pc /usr/local/lib/pkgconfig/ - popd > /dev/null - rm -rf argon2-${argon2_ver} - fi - - if [ ! -e "/usr/local/lib/libsodium.la" ]; then - tar xzf libsodium-${libsodium_ver}.tar.gz - pushd libsodium-${libsodium_ver} > /dev/null - ./configure --disable-dependency-tracking --enable-minimal - make -j ${THREAD} && make install - popd > /dev/null - rm -rf libsodium-${libsodium_ver} - fi - - if [ ! -e "/usr/local/lib/libzip.la" ]; then - tar xzf libzip-${libzip_ver}.tar.gz - pushd libzip-${libzip_ver} > /dev/null - ./configure - make -j ${THREAD} && make install - popd > /dev/null - rm -rf libzip-${libzip_ver} - fi - - if [ ! -e "/usr/local/include/mhash.h" -a ! -e "/usr/include/mhash.h" ]; then - tar xzf mhash-${mhash_ver}.tar.gz - pushd mhash-${mhash_ver} > /dev/null - ./configure - make -j ${THREAD} && make install - popd > /dev/null - rm -rf mhash-${mhash_ver} - fi - - [ -z "`grep /usr/local/lib /etc/ld.so.conf.d/*.conf`" ] && echo '/usr/local/lib' > /etc/ld.so.conf.d/local.conf - ldconfig - - if [ "${PM}" == 'yum' ]; then - [ ! -e "/lib64/libpcre.so.1" ] && ln -s /lib64/libpcre.so.0.0.1 /lib64/libpcre.so.1 - [ ! -e "/usr/lib/libc-client.so" ] && ln -s /usr/lib64/libc-client.so /usr/lib/libc-client.so - fi - - id -g ${run_group} >/dev/null 2>&1 - [ $? -ne 0 ] && groupadd ${run_group} - id -u ${run_user} >/dev/null 2>&1 - [ $? -ne 0 ] && useradd -g ${run_group} -M -s /sbin/nologin ${run_user} - - tar xzf php-${php81_ver}.tar.gz - pushd php-${php81_ver} > /dev/null - make clean - export PKG_CONFIG_PATH=/usr/local/lib/pkgconfig/:$PKG_CONFIG_PATH - [ ! -d "${php_install_dir}" ] && mkdir -p ${php_install_dir} - [ "${phpcache_option}" == '1' ] && phpcache_arg='--enable-opcache' || phpcache_arg='--disable-opcache' - if [ "${apache_mode_option}" == '2' ]; then - ./configure --prefix=${php_install_dir} --with-config-file-path=${php_install_dir}/etc \ - --with-config-file-scan-dir=${php_install_dir}/etc/php.d \ - --with-apxs2=${apache_install_dir}/bin/apxs ${phpcache_arg} --disable-fileinfo \ - --enable-mysqlnd --with-mysqli=mysqlnd --with-pdo-mysql=mysqlnd \ - --with-iconv=/usr/local --with-freetype --with-jpeg --with-zlib \ - --enable-xml --disable-rpath --enable-bcmath --enable-shmop --enable-exif \ - --enable-sysvsem ${php81_with_curl} --enable-mbregex \ - --enable-mbstring --with-password-argon2 --with-sodium=/usr/local --enable-gd ${php81_with_openssl} \ - --with-mhash --enable-pcntl --enable-sockets --enable-ftp --enable-intl --with-xsl \ - --with-gettext --with-zip=/usr/local --enable-soap --disable-debug ${php_modules_options} - else - ./configure --prefix=${php_install_dir} --with-config-file-path=${php_install_dir}/etc \ - --with-config-file-scan-dir=${php_install_dir}/etc/php.d \ - --with-fpm-user=${run_user} --with-fpm-group=${run_group} --enable-fpm ${phpcache_arg} --disable-fileinfo \ - --enable-mysqlnd --with-mysqli=mysqlnd --with-pdo-mysql=mysqlnd \ - --with-iconv=/usr/local --with-freetype --with-jpeg --with-zlib \ - --enable-xml --disable-rpath --enable-bcmath --enable-shmop --enable-exif \ - --enable-sysvsem ${php81_with_curl} --enable-mbregex \ - --enable-mbstring --with-password-argon2 --with-sodium=/usr/local --enable-gd ${php81_with_openssl} \ - --with-mhash --enable-pcntl --enable-sockets --enable-ftp --enable-intl --with-xsl \ - --with-gettext --with-zip=/usr/local --enable-soap --disable-debug ${php_modules_options} - fi - make ZEND_EXTRA_LIBS='-liconv' -j ${THREAD} - make install - - if [ -e "${php_install_dir}/bin/phpize" ]; then - [ ! -e "${php_install_dir}/etc/php.d" ] && mkdir -p ${php_install_dir}/etc/php.d - echo "${CSUCCESS}PHP installed successfully! ${CEND}" - else - rm -rf ${php_install_dir} - echo "${CFAILURE}PHP install failed, Please Contact the author! ${CEND}" - kill -9 $$; exit 1; - fi - - [ -z "`grep ^'export PATH=' /etc/profile`" ] && echo "export PATH=${php_install_dir}/bin:\$PATH" >> /etc/profile - [ -n "`grep ^'export PATH=' /etc/profile`" -a -z "`grep ${php_install_dir} /etc/profile`" ] && sed -i "s@^export PATH=\(.*\)@export PATH=${php_install_dir}/bin:\1@" /etc/profile - . /etc/profile - - # wget -c http://pear.php.net/go-pear.phar - # ${php_install_dir}/bin/php go-pear.phar - - /bin/cp php.ini-production ${php_install_dir}/etc/php.ini - - sed -i "s@^memory_limit.*@memory_limit = ${Memory_limit}M@" ${php_install_dir}/etc/php.ini - sed -i 's@^output_buffering =@output_buffering = On\noutput_buffering =@' ${php_install_dir}/etc/php.ini - #sed -i 's@^;cgi.fix_pathinfo.*@cgi.fix_pathinfo=0@' ${php_install_dir}/etc/php.ini - sed -i 's@^short_open_tag = Off@short_open_tag = On@' ${php_install_dir}/etc/php.ini - sed -i 's@^expose_php = On@expose_php = Off@' ${php_install_dir}/etc/php.ini - sed -i 's@^request_order.*@request_order = "CGP"@' ${php_install_dir}/etc/php.ini - sed -i "s@^;date.timezone.*@date.timezone = ${timezone}@" ${php_install_dir}/etc/php.ini - sed -i 's@^post_max_size.*@post_max_size = 100M@' ${php_install_dir}/etc/php.ini - sed -i 's@^upload_max_filesize.*@upload_max_filesize = 50M@' ${php_install_dir}/etc/php.ini - sed -i 's@^max_execution_time.*@max_execution_time = 600@' ${php_install_dir}/etc/php.ini - sed -i 's@^;realpath_cache_size.*@realpath_cache_size = 2M@' ${php_install_dir}/etc/php.ini - sed -i 's@^disable_functions.*@disable_functions = passthru,exec,system,chroot,chgrp,chown,shell_exec,proc_open,proc_get_status,ini_alter,ini_restore,dl,readlink,symlink,popepassthru,stream_socket_server,fsocket,popen@' ${php_install_dir}/etc/php.ini - [ -e /usr/sbin/sendmail ] && sed -i 's@^;sendmail_path.*@sendmail_path = /usr/sbin/sendmail -t -i@' ${php_install_dir}/etc/php.ini - if [ "${with_old_openssl_flag}" = 'y' ]; then - sed -i "s@^;curl.cainfo.*@curl.cainfo = \"${openssl_install_dir}/cert.pem\"@" ${php_install_dir}/etc/php.ini - sed -i "s@^;openssl.cafile.*@openssl.cafile = \"${openssl_install_dir}/cert.pem\"@" ${php_install_dir}/etc/php.ini - sed -i "s@^;openssl.capath.*@openssl.capath = \"${openssl_install_dir}/cert.pem\"@" ${php_install_dir}/etc/php.ini - fi - - [ "${phpcache_option}" == '1' ] && cat > ${php_install_dir}/etc/php.d/02-opcache.ini << EOF -[opcache] -zend_extension=opcache.so -opcache.enable=1 -opcache.enable_cli=1 -opcache.memory_consumption=${Memory_limit} -opcache.interned_strings_buffer=8 -opcache.max_accelerated_files=100000 -opcache.max_wasted_percentage=5 -opcache.use_cwd=1 -opcache.validate_timestamps=1 -opcache.revalidate_freq=60 -;opcache.save_comments=0 -opcache.consistency_checks=0 -;opcache.optimization_level=0 -EOF - - if [ "${apache_mode_option}" != '2' ]; then - # php-fpm Init Script - /bin/cp ${current_dir}/init.d/php-fpm.service /lib/systemd/system/ - sed -i "s@/usr/local/php@${php_install_dir}@g" /lib/systemd/system/php-fpm.service - systemctl enable php-fpm - - cat > ${php_install_dir}/etc/php-fpm.conf < /dev/null - [ -e "${php_install_dir}/bin/phpize" ] && rm -rf php-${php81_ver} - popd > /dev/null -} diff --git a/include/php-8.2.sh b/include/php-8.2.sh deleted file mode 100644 index c4e4c446..00000000 --- a/include/php-8.2.sh +++ /dev/null @@ -1,270 +0,0 @@ -#!/bin/bash -# Author: yeho -# BLOG: https://linuxeye.com - -Install_PHP82() { - pushd ${current_dir}/src > /dev/null - if [ ! -e "/usr/local/lib/libiconv.la" ]; then - tar xzf libiconv-${libiconv_ver}.tar.gz - pushd libiconv-${libiconv_ver} > /dev/null - ./configure - make -j ${THREAD} && make install - popd > /dev/null - rm -rf libiconv-${libiconv_ver} - fi - - if [ ! -e "${curl_install_dir}/lib/libcurl.la" ]; then - tar xzf curl-${curl_ver}.tar.gz - pushd curl-${curl_ver} > /dev/null - [ -e "/usr/local/lib/libnghttp2.so" ] && with_nghttp2='--with-nghttp2=/usr/local' - ./configure --prefix=${curl_install_dir} ${php82_with_ssl} ${with_nghttp2} - make -j ${THREAD} && make install - popd > /dev/null - rm -rf curl-${curl_ver} - fi - - if [ ! -e "${freetype_install_dir}/lib/libfreetype.la" ]; then - tar xzf freetype-${freetype_ver}.tar.gz - pushd freetype-${freetype_ver} > /dev/null - ./configure --prefix=${freetype_install_dir} --enable-freetype-config - make -j ${THREAD} && make install - ln -sf ${freetype_install_dir}/include/freetype2/* /usr/include/ - [ -d /usr/lib/pkgconfig ] && /bin/cp ${freetype_install_dir}/lib/pkgconfig/freetype2.pc /usr/lib/pkgconfig/ - popd > /dev/null - rm -rf freetype-${freetype_ver} - fi - - if [ ! -e "/usr/local/lib/pkgconfig/libargon2.pc" ]; then - tar xzf argon2-${argon2_ver}.tar.gz - pushd argon2-${argon2_ver} > /dev/null - make -j ${THREAD} && make install - [ ! -d /usr/local/lib/pkgconfig ] && mkdir -p /usr/local/lib/pkgconfig - /bin/cp libargon2.pc /usr/local/lib/pkgconfig/ - popd > /dev/null - rm -rf argon2-${argon2_ver} - fi - - if [ ! -e "/usr/local/lib/libsodium.la" ]; then - tar xzf libsodium-${libsodium_ver}.tar.gz - pushd libsodium-${libsodium_ver} > /dev/null - ./configure --disable-dependency-tracking --enable-minimal - make -j ${THREAD} && make install - popd > /dev/null - rm -rf libsodium-${libsodium_ver} - fi - - if [ ! -e "/usr/local/lib/libzip.la" ]; then - tar xzf libzip-${libzip_ver}.tar.gz - pushd libzip-${libzip_ver} > /dev/null - ./configure - make -j ${THREAD} && make install - popd > /dev/null - rm -rf libzip-${libzip_ver} - fi - - if [ ! -e "/usr/local/include/mhash.h" -a ! -e "/usr/include/mhash.h" ]; then - tar xzf mhash-${mhash_ver}.tar.gz - pushd mhash-${mhash_ver} > /dev/null - ./configure - make -j ${THREAD} && make install - popd > /dev/null - rm -rf mhash-${mhash_ver} - fi - - [ -z "`grep /usr/local/lib /etc/ld.so.conf.d/*.conf`" ] && echo '/usr/local/lib' > /etc/ld.so.conf.d/local.conf - ldconfig - - if [ "${PM}" == 'yum' ]; then - [ ! -e "/lib64/libpcre.so.1" ] && ln -s /lib64/libpcre.so.0.0.1 /lib64/libpcre.so.1 - [ ! -e "/usr/lib/libc-client.so" ] && ln -s /usr/lib64/libc-client.so /usr/lib/libc-client.so - fi - - id -g ${run_group} >/dev/null 2>&1 - [ $? -ne 0 ] && groupadd ${run_group} - id -u ${run_user} >/dev/null 2>&1 - [ $? -ne 0 ] && useradd -g ${run_group} -M -s /sbin/nologin ${run_user} - - tar xzf php-${php82_ver}.tar.gz - pushd php-${php82_ver} > /dev/null - make clean - export PKG_CONFIG_PATH=/usr/local/lib/pkgconfig/:$PKG_CONFIG_PATH - [ ! -d "${php_install_dir}" ] && mkdir -p ${php_install_dir} - [ "${phpcache_option}" == '1' ] && phpcache_arg='--enable-opcache' || phpcache_arg='--disable-opcache' - if [ "${apache_mode_option}" == '2' ]; then - ./configure --prefix=${php_install_dir} --with-config-file-path=${php_install_dir}/etc \ - --with-config-file-scan-dir=${php_install_dir}/etc/php.d \ - --with-apxs2=${apache_install_dir}/bin/apxs ${phpcache_arg} --disable-fileinfo \ - --enable-mysqlnd --with-mysqli=mysqlnd --with-pdo-mysql=mysqlnd \ - --with-iconv=/usr/local --with-freetype --with-jpeg --with-zlib \ - --enable-xml --disable-rpath --enable-bcmath --enable-shmop --enable-exif \ - --enable-sysvsem ${php82_with_curl} --enable-mbregex \ - --enable-mbstring --with-password-argon2 --with-sodium=/usr/local --enable-gd ${php82_with_openssl} \ - --with-mhash --enable-pcntl --enable-sockets --enable-ftp --enable-intl --with-xsl \ - --with-gettext --with-zip=/usr/local --enable-soap --disable-debug ${php_modules_options} - else - ./configure --prefix=${php_install_dir} --with-config-file-path=${php_install_dir}/etc \ - --with-config-file-scan-dir=${php_install_dir}/etc/php.d \ - --with-fpm-user=${run_user} --with-fpm-group=${run_group} --enable-fpm ${phpcache_arg} --disable-fileinfo \ - --enable-mysqlnd --with-mysqli=mysqlnd --with-pdo-mysql=mysqlnd \ - --with-iconv=/usr/local --with-freetype --with-jpeg --with-zlib \ - --enable-xml --disable-rpath --enable-bcmath --enable-shmop --enable-exif \ - --enable-sysvsem ${php82_with_curl} --enable-mbregex \ - --enable-mbstring --with-password-argon2 --with-sodium=/usr/local --enable-gd ${php82_with_openssl} \ - --with-mhash --enable-pcntl --enable-sockets --enable-ftp --enable-intl --with-xsl \ - --with-gettext --with-zip=/usr/local --enable-soap --disable-debug ${php_modules_options} - fi - make ZEND_EXTRA_LIBS='-liconv' -j ${THREAD} - make install - - if [ -e "${php_install_dir}/bin/phpize" ]; then - [ ! -e "${php_install_dir}/etc/php.d" ] && mkdir -p ${php_install_dir}/etc/php.d - echo "${CSUCCESS}PHP installed successfully! ${CEND}" - else - rm -rf ${php_install_dir} - echo "${CFAILURE}PHP install failed, Please Contact the author! ${CEND}" - kill -9 $$; exit 1; - fi - - [ -z "`grep ^'export PATH=' /etc/profile`" ] && echo "export PATH=${php_install_dir}/bin:\$PATH" >> /etc/profile - [ -n "`grep ^'export PATH=' /etc/profile`" -a -z "`grep ${php_install_dir} /etc/profile`" ] && sed -i "s@^export PATH=\(.*\)@export PATH=${php_install_dir}/bin:\1@" /etc/profile - . /etc/profile - - # wget -c http://pear.php.net/go-pear.phar - # ${php_install_dir}/bin/php go-pear.phar - - /bin/cp php.ini-production ${php_install_dir}/etc/php.ini - - sed -i "s@^memory_limit.*@memory_limit = ${Memory_limit}M@" ${php_install_dir}/etc/php.ini - sed -i 's@^output_buffering =@output_buffering = On\noutput_buffering =@' ${php_install_dir}/etc/php.ini - #sed -i 's@^;cgi.fix_pathinfo.*@cgi.fix_pathinfo=0@' ${php_install_dir}/etc/php.ini - sed -i 's@^short_open_tag = Off@short_open_tag = On@' ${php_install_dir}/etc/php.ini - sed -i 's@^expose_php = On@expose_php = Off@' ${php_install_dir}/etc/php.ini - sed -i 's@^request_order.*@request_order = "CGP"@' ${php_install_dir}/etc/php.ini - sed -i "s@^;date.timezone.*@date.timezone = ${timezone}@" ${php_install_dir}/etc/php.ini - sed -i 's@^post_max_size.*@post_max_size = 100M@' ${php_install_dir}/etc/php.ini - sed -i 's@^upload_max_filesize.*@upload_max_filesize = 50M@' ${php_install_dir}/etc/php.ini - sed -i 's@^max_execution_time.*@max_execution_time = 600@' ${php_install_dir}/etc/php.ini - sed -i 's@^;realpath_cache_size.*@realpath_cache_size = 2M@' ${php_install_dir}/etc/php.ini - sed -i 's@^disable_functions.*@disable_functions = passthru,exec,system,chroot,chgrp,chown,shell_exec,proc_open,proc_get_status,ini_alter,ini_restore,dl,readlink,symlink,popepassthru,stream_socket_server,fsocket,popen@' ${php_install_dir}/etc/php.ini - [ -e /usr/sbin/sendmail ] && sed -i 's@^;sendmail_path.*@sendmail_path = /usr/sbin/sendmail -t -i@' ${php_install_dir}/etc/php.ini - if [ "${with_old_openssl_flag}" = 'y' ]; then - sed -i "s@^;curl.cainfo.*@curl.cainfo = \"${openssl_install_dir}/cert.pem\"@" ${php_install_dir}/etc/php.ini - sed -i "s@^;openssl.cafile.*@openssl.cafile = \"${openssl_install_dir}/cert.pem\"@" ${php_install_dir}/etc/php.ini - sed -i "s@^;openssl.capath.*@openssl.capath = \"${openssl_install_dir}/cert.pem\"@" ${php_install_dir}/etc/php.ini - fi - - [ "${phpcache_option}" == '1' ] && cat > ${php_install_dir}/etc/php.d/02-opcache.ini << EOF -[opcache] -zend_extension=opcache.so -opcache.enable=1 -opcache.enable_cli=1 -opcache.memory_consumption=${Memory_limit} -opcache.interned_strings_buffer=8 -opcache.max_accelerated_files=100000 -opcache.max_wasted_percentage=5 -opcache.use_cwd=1 -opcache.validate_timestamps=1 -opcache.revalidate_freq=60 -;opcache.save_comments=0 -opcache.consistency_checks=0 -;opcache.optimization_level=0 -EOF - - if [ "${apache_mode_option}" != '2' ]; then - # php-fpm Init Script - /bin/cp ${current_dir}/init.d/php-fpm.service /lib/systemd/system/ - sed -i "s@/usr/local/php@${php_install_dir}@g" /lib/systemd/system/php-fpm.service - systemctl enable php-fpm - - cat > ${php_install_dir}/etc/php-fpm.conf < /dev/null - [ -e "${php_install_dir}/bin/phpize" ] && rm -rf php-${php82_ver} - popd > /dev/null -} diff --git a/include/php-8.3.sh b/include/php-8.3.sh deleted file mode 100644 index 9d47a077..00000000 --- a/include/php-8.3.sh +++ /dev/null @@ -1,279 +0,0 @@ -#!/bin/bash -# Author: yeho -# BLOG: https://linuxeye.com - -Install_PHP83() { - pushd ${current_dir}/src > /dev/null - if [ ! -e "/usr/local/lib/libiconv.la" ]; then - tar xzf libiconv-${libiconv_ver}.tar.gz - pushd libiconv-${libiconv_ver} > /dev/null - ./configure - make -j ${THREAD} && make install - popd > /dev/null - rm -rf libiconv-${libiconv_ver} - fi - - if [ ! -e "${curl_install_dir}/lib/libcurl.la" ]; then - tar xzf curl-${curl_ver}.tar.gz - pushd curl-${curl_ver} > /dev/null - [ -e "/usr/local/lib/libnghttp2.so" ] && with_nghttp2='--with-nghttp2=/usr/local' - ./configure --prefix=${curl_install_dir} ${php83_with_ssl} ${with_nghttp2} - make -j ${THREAD} && make install - popd > /dev/null - rm -rf curl-${curl_ver} - fi - - if [ ! -e "${freetype_install_dir}/lib/libfreetype.la" ]; then - tar xzf freetype-${freetype_ver}.tar.gz - pushd freetype-${freetype_ver} > /dev/null - ./configure --prefix=${freetype_install_dir} --enable-freetype-config - make -j ${THREAD} && make install - ln -sf ${freetype_install_dir}/include/freetype2/* /usr/include/ - [ -d /usr/lib/pkgconfig ] && /bin/cp ${freetype_install_dir}/lib/pkgconfig/freetype2.pc /usr/lib/pkgconfig/ - popd > /dev/null - rm -rf freetype-${freetype_ver} - fi - - if [ ! -e "/usr/local/lib/pkgconfig/libargon2.pc" ]; then - tar xzf argon2-${argon2_ver}.tar.gz - pushd argon2-${argon2_ver} > /dev/null - make -j ${THREAD} && make install - [ ! -d /usr/local/lib/pkgconfig ] && mkdir -p /usr/local/lib/pkgconfig - /bin/cp libargon2.pc /usr/local/lib/pkgconfig/ - popd > /dev/null - rm -rf argon2-${argon2_ver} - fi - - if [ ! -e "/usr/local/lib/libsodium.la" ]; then - tar xzf libsodium-${libsodium_ver}.tar.gz - pushd libsodium-${libsodium_ver} > /dev/null - ./configure --disable-dependency-tracking --enable-minimal - make -j ${THREAD} && make install - popd > /dev/null - rm -rf libsodium-${libsodium_ver} - fi - - if [ ! -e "/usr/local/lib/libzip.la" ]; then - tar xzf libzip-${libzip_ver}.tar.gz - pushd libzip-${libzip_ver} > /dev/null - ./configure - make -j ${THREAD} && make install - popd > /dev/null - rm -rf libzip-${libzip_ver} - fi - - if [ ! -e "/usr/local/include/mhash.h" -a ! -e "/usr/include/mhash.h" ]; then - tar xzf mhash-${mhash_ver}.tar.gz - pushd mhash-${mhash_ver} > /dev/null - ./configure - make -j ${THREAD} && make install - popd > /dev/null - rm -rf mhash-${mhash_ver} - fi - - if [ ! -e "/usr/local/include/bfd.h" -a "${RHEL_ver}" == "8" ]; then - tar xzf binutils-${binutils_ver}.tar.gz - pushd binutils-${binutils_ver} - ./configure - make -j ${THREAD} && make install - popd > /dev/null - rm -rf binutils-${binutils_ver} - fi - - [ -z "`grep /usr/local/lib /etc/ld.so.conf.d/*.conf`" ] && echo '/usr/local/lib' > /etc/ld.so.conf.d/local.conf - ldconfig - - if [ "${PM}" == 'yum' ]; then - [ ! -e "/lib64/libpcre.so.1" ] && ln -s /lib64/libpcre.so.0.0.1 /lib64/libpcre.so.1 - [ ! -e "/usr/lib/libc-client.so" ] && ln -s /usr/lib64/libc-client.so /usr/lib/libc-client.so - fi - - id -g ${run_group} >/dev/null 2>&1 - [ $? -ne 0 ] && groupadd ${run_group} - id -u ${run_user} >/dev/null 2>&1 - [ $? -ne 0 ] && useradd -g ${run_group} -M -s /sbin/nologin ${run_user} - - tar xzf php-${php83_ver}.tar.gz - pushd php-${php83_ver} > /dev/null - make clean - export PKG_CONFIG_PATH=/usr/local/lib/pkgconfig/:$PKG_CONFIG_PATH - [ ! -d "${php_install_dir}" ] && mkdir -p ${php_install_dir} - [ "${phpcache_option}" == '1' ] && phpcache_arg='--enable-opcache' || phpcache_arg='--disable-opcache' - if [ "${apache_mode_option}" == '2' ]; then - ./configure --prefix=${php_install_dir} --with-config-file-path=${php_install_dir}/etc \ - --with-config-file-scan-dir=${php_install_dir}/etc/php.d \ - --with-apxs2=${apache_install_dir}/bin/apxs ${phpcache_arg} --disable-fileinfo \ - --enable-mysqlnd --with-mysqli=mysqlnd --with-pdo-mysql=mysqlnd \ - --with-iconv=/usr/local --with-freetype --with-jpeg --with-zlib \ - --enable-xml --disable-rpath --enable-bcmath --enable-shmop --enable-exif \ - --enable-sysvsem ${php83_with_curl} --enable-mbregex \ - --enable-mbstring --with-password-argon2 --with-sodium=/usr/local --enable-gd ${php83_with_openssl} \ - --with-mhash --enable-pcntl --enable-sockets --enable-ftp --enable-intl --with-xsl \ - --with-gettext --with-zip=/usr/local --enable-soap --disable-debug ${php_modules_options} - else - ./configure --prefix=${php_install_dir} --with-config-file-path=${php_install_dir}/etc \ - --with-config-file-scan-dir=${php_install_dir}/etc/php.d \ - --with-fpm-user=${run_user} --with-fpm-group=${run_group} --enable-fpm ${phpcache_arg} --disable-fileinfo \ - --enable-mysqlnd --with-mysqli=mysqlnd --with-pdo-mysql=mysqlnd \ - --with-iconv=/usr/local --with-freetype --with-jpeg --with-zlib \ - --enable-xml --disable-rpath --enable-bcmath --enable-shmop --enable-exif \ - --enable-sysvsem ${php83_with_curl} --enable-mbregex \ - --enable-mbstring --with-password-argon2 --with-sodium=/usr/local --enable-gd ${php83_with_openssl} \ - --with-mhash --enable-pcntl --enable-sockets --enable-ftp --enable-intl --with-xsl \ - --with-gettext --with-zip=/usr/local --enable-soap --disable-debug ${php_modules_options} - fi - make ZEND_EXTRA_LIBS='-liconv' -j ${THREAD} - make install - - if [ -e "${php_install_dir}/bin/phpize" ]; then - [ ! -e "${php_install_dir}/etc/php.d" ] && mkdir -p ${php_install_dir}/etc/php.d - echo "${CSUCCESS}PHP installed successfully! ${CEND}" - else - rm -rf ${php_install_dir} - echo "${CFAILURE}PHP install failed, Please Contact the author! ${CEND}" - kill -9 $$; exit 1; - fi - - [ -z "`grep ^'export PATH=' /etc/profile`" ] && echo "export PATH=${php_install_dir}/bin:\$PATH" >> /etc/profile - [ -n "`grep ^'export PATH=' /etc/profile`" -a -z "`grep ${php_install_dir} /etc/profile`" ] && sed -i "s@^export PATH=\(.*\)@export PATH=${php_install_dir}/bin:\1@" /etc/profile - . /etc/profile - - # wget -c http://pear.php.net/go-pear.phar - # ${php_install_dir}/bin/php go-pear.phar - - /bin/cp php.ini-production ${php_install_dir}/etc/php.ini - - sed -i "s@^memory_limit.*@memory_limit = ${Memory_limit}M@" ${php_install_dir}/etc/php.ini - sed -i 's@^output_buffering =@output_buffering = On\noutput_buffering =@' ${php_install_dir}/etc/php.ini - #sed -i 's@^;cgi.fix_pathinfo.*@cgi.fix_pathinfo=0@' ${php_install_dir}/etc/php.ini - sed -i 's@^short_open_tag = Off@short_open_tag = On@' ${php_install_dir}/etc/php.ini - sed -i 's@^expose_php = On@expose_php = Off@' ${php_install_dir}/etc/php.ini - sed -i 's@^request_order.*@request_order = "CGP"@' ${php_install_dir}/etc/php.ini - sed -i "s@^;date.timezone.*@date.timezone = ${timezone}@" ${php_install_dir}/etc/php.ini - sed -i 's@^post_max_size.*@post_max_size = 100M@' ${php_install_dir}/etc/php.ini - sed -i 's@^upload_max_filesize.*@upload_max_filesize = 50M@' ${php_install_dir}/etc/php.ini - sed -i 's@^max_execution_time.*@max_execution_time = 600@' ${php_install_dir}/etc/php.ini - sed -i 's@^;realpath_cache_size.*@realpath_cache_size = 2M@' ${php_install_dir}/etc/php.ini - sed -i 's@^disable_functions.*@disable_functions = passthru,exec,system,chroot,chgrp,chown,shell_exec,proc_open,proc_get_status,ini_alter,ini_restore,dl,readlink,symlink,popepassthru,stream_socket_server,fsocket,popen@' ${php_install_dir}/etc/php.ini - [ -e /usr/sbin/sendmail ] && sed -i 's@^;sendmail_path.*@sendmail_path = /usr/sbin/sendmail -t -i@' ${php_install_dir}/etc/php.ini - if [ "${with_old_openssl_flag}" = 'y' ]; then - sed -i "s@^;curl.cainfo.*@curl.cainfo = \"${openssl_install_dir}/cert.pem\"@" ${php_install_dir}/etc/php.ini - sed -i "s@^;openssl.cafile.*@openssl.cafile = \"${openssl_install_dir}/cert.pem\"@" ${php_install_dir}/etc/php.ini - sed -i "s@^;openssl.capath.*@openssl.capath = \"${openssl_install_dir}/cert.pem\"@" ${php_install_dir}/etc/php.ini - fi - - [ "${phpcache_option}" == '1' ] && cat > ${php_install_dir}/etc/php.d/02-opcache.ini << EOF -[opcache] -zend_extension=opcache.so -opcache.enable=1 -opcache.enable_cli=1 -opcache.memory_consumption=${Memory_limit} -opcache.interned_strings_buffer=8 -opcache.max_accelerated_files=100000 -opcache.max_wasted_percentage=5 -opcache.use_cwd=1 -opcache.validate_timestamps=1 -opcache.revalidate_freq=60 -;opcache.save_comments=0 -opcache.consistency_checks=0 -;opcache.optimization_level=0 -EOF - - if [ "${apache_mode_option}" != '2' ]; then - # php-fpm Init Script - /bin/cp ${current_dir}/init.d/php-fpm.service /lib/systemd/system/ - sed -i "s@/usr/local/php@${php_install_dir}@g" /lib/systemd/system/php-fpm.service - systemctl enable php-fpm - - cat > ${php_install_dir}/etc/php-fpm.conf < /dev/null - [ -e "${php_install_dir}/bin/phpize" ] && rm -rf php-${php83_ver} - popd > /dev/null -} diff --git a/include/php-8.4.sh b/include/php-8.4.sh deleted file mode 100644 index 0b6c707c..00000000 --- a/include/php-8.4.sh +++ /dev/null @@ -1,279 +0,0 @@ -#!/bin/bash -# Author: yeho -# BLOG: https://linuxeye.com - -Install_PHP84() { - pushd ${current_dir}/src > /dev/null - if [ ! -e "/usr/local/lib/libiconv.la" ]; then - tar xzf libiconv-${libiconv_ver}.tar.gz - pushd libiconv-${libiconv_ver} > /dev/null - ./configure - make -j ${THREAD} && make install - popd > /dev/null - rm -rf libiconv-${libiconv_ver} - fi - - if [ ! -e "${curl_install_dir}/lib/libcurl.la" ]; then - tar xzf curl-${curl_ver}.tar.gz - pushd curl-${curl_ver} > /dev/null - [ -e "/usr/local/lib/libnghttp2.so" ] && with_nghttp2='--with-nghttp2=/usr/local' - ./configure --prefix=${curl_install_dir} ${php84_with_ssl} ${with_nghttp2} - make -j ${THREAD} && make install - popd > /dev/null - rm -rf curl-${curl_ver} - fi - - if [ ! -e "${freetype_install_dir}/lib/libfreetype.la" ]; then - tar xzf freetype-${freetype_ver}.tar.gz - pushd freetype-${freetype_ver} > /dev/null - ./configure --prefix=${freetype_install_dir} --enable-freetype-config - make -j ${THREAD} && make install - ln -sf ${freetype_install_dir}/include/freetype2/* /usr/include/ - [ -d /usr/lib/pkgconfig ] && /bin/cp ${freetype_install_dir}/lib/pkgconfig/freetype2.pc /usr/lib/pkgconfig/ - popd > /dev/null - rm -rf freetype-${freetype_ver} - fi - - if [ ! -e "/usr/local/lib/pkgconfig/libargon2.pc" ]; then - tar xzf argon2-${argon2_ver}.tar.gz - pushd argon2-${argon2_ver} > /dev/null - make -j ${THREAD} && make install - [ ! -d /usr/local/lib/pkgconfig ] && mkdir -p /usr/local/lib/pkgconfig - /bin/cp libargon2.pc /usr/local/lib/pkgconfig/ - popd > /dev/null - rm -rf argon2-${argon2_ver} - fi - - if [ ! -e "/usr/local/lib/libsodium.la" ]; then - tar xzf libsodium-${libsodium_ver}.tar.gz - pushd libsodium-${libsodium_ver} > /dev/null - ./configure --disable-dependency-tracking --enable-minimal - make -j ${THREAD} && make install - popd > /dev/null - rm -rf libsodium-${libsodium_ver} - fi - - if [ ! -e "/usr/local/lib/libzip.la" ]; then - tar xzf libzip-${libzip_ver}.tar.gz - pushd libzip-${libzip_ver} > /dev/null - ./configure - make -j ${THREAD} && make install - popd > /dev/null - rm -rf libzip-${libzip_ver} - fi - - if [ ! -e "/usr/local/include/mhash.h" -a ! -e "/usr/include/mhash.h" ]; then - tar xzf mhash-${mhash_ver}.tar.gz - pushd mhash-${mhash_ver} > /dev/null - ./configure - make -j ${THREAD} && make install - popd > /dev/null - rm -rf mhash-${mhash_ver} - fi - - if [ ! -e "/usr/local/include/bfd.h" -a "${RHEL_ver}" == "8" ]; then - tar xzf binutils-${binutils_ver}.tar.gz - pushd binutils-${binutils_ver} - ./configure - make -j ${THREAD} && make install - popd > /dev/null - rm -rf binutils-${binutils_ver} - fi - - [ -z "`grep /usr/local/lib /etc/ld.so.conf.d/*.conf`" ] && echo '/usr/local/lib' > /etc/ld.so.conf.d/local.conf - ldconfig - - if [ "${PM}" == 'yum' ]; then - [ ! -e "/lib64/libpcre.so.1" ] && ln -s /lib64/libpcre.so.0.0.1 /lib64/libpcre.so.1 - [ ! -e "/usr/lib/libc-client.so" ] && ln -s /usr/lib64/libc-client.so /usr/lib/libc-client.so - fi - - id -g ${run_group} >/dev/null 2>&1 - [ $? -ne 0 ] && groupadd ${run_group} - id -u ${run_user} >/dev/null 2>&1 - [ $? -ne 0 ] && useradd -g ${run_group} -M -s /sbin/nologin ${run_user} - - tar xzf php-${php84_ver}.tar.gz - pushd php-${php84_ver} > /dev/null - make clean - export PKG_CONFIG_PATH=/usr/local/lib/pkgconfig/:$PKG_CONFIG_PATH - [ ! -d "${php_install_dir}" ] && mkdir -p ${php_install_dir} - [ "${phpcache_option}" == '1' ] && phpcache_arg='--enable-opcache' || phpcache_arg='--disable-opcache' - if [ "${apache_mode_option}" == '2' ]; then - ./configure --prefix=${php_install_dir} --with-config-file-path=${php_install_dir}/etc \ - --with-config-file-scan-dir=${php_install_dir}/etc/php.d \ - --with-apxs2=${apache_install_dir}/bin/apxs ${phpcache_arg} --disable-fileinfo \ - --enable-mysqlnd --with-mysqli=mysqlnd --with-pdo-mysql=mysqlnd \ - --with-iconv=/usr/local --with-freetype --with-jpeg --with-zlib \ - --enable-xml --disable-rpath --enable-bcmath --enable-shmop --enable-exif \ - --enable-sysvsem ${php84_with_curl} --enable-mbregex \ - --enable-mbstring --with-password-argon2 --with-sodium=/usr/local --enable-gd ${php84_with_openssl} \ - --with-mhash --enable-pcntl --enable-sockets --enable-ftp --enable-intl --with-xsl \ - --with-gettext --with-zip=/usr/local --enable-soap --disable-debug ${php_modules_options} - else - ./configure --prefix=${php_install_dir} --with-config-file-path=${php_install_dir}/etc \ - --with-config-file-scan-dir=${php_install_dir}/etc/php.d \ - --with-fpm-user=${run_user} --with-fpm-group=${run_group} --enable-fpm ${phpcache_arg} --disable-fileinfo \ - --enable-mysqlnd --with-mysqli=mysqlnd --with-pdo-mysql=mysqlnd \ - --with-iconv=/usr/local --with-freetype --with-jpeg --with-zlib \ - --enable-xml --disable-rpath --enable-bcmath --enable-shmop --enable-exif \ - --enable-sysvsem ${php84_with_curl} --enable-mbregex \ - --enable-mbstring --with-password-argon2 --with-sodium=/usr/local --enable-gd ${php84_with_openssl} \ - --with-mhash --enable-pcntl --enable-sockets --enable-ftp --enable-intl --with-xsl \ - --with-gettext --with-zip=/usr/local --enable-soap --disable-debug ${php_modules_options} - fi - make ZEND_EXTRA_LIBS='-liconv' -j ${THREAD} - make install - - if [ -e "${php_install_dir}/bin/phpize" ]; then - [ ! -e "${php_install_dir}/etc/php.d" ] && mkdir -p ${php_install_dir}/etc/php.d - echo "${CSUCCESS}PHP installed successfully! ${CEND}" - else - rm -rf ${php_install_dir} - echo "${CFAILURE}PHP install failed, Please Contact the author! ${CEND}" - kill -9 $$; exit 1; - fi - - [ -z "`grep ^'export PATH=' /etc/profile`" ] && echo "export PATH=${php_install_dir}/bin:\$PATH" >> /etc/profile - [ -n "`grep ^'export PATH=' /etc/profile`" -a -z "`grep ${php_install_dir} /etc/profile`" ] && sed -i "s@^export PATH=\(.*\)@export PATH=${php_install_dir}/bin:\1@" /etc/profile - . /etc/profile - - # wget -c http://pear.php.net/go-pear.phar - # ${php_install_dir}/bin/php go-pear.phar - - /bin/cp php.ini-production ${php_install_dir}/etc/php.ini - - sed -i "s@^memory_limit.*@memory_limit = ${Memory_limit}M@" ${php_install_dir}/etc/php.ini - sed -i 's@^output_buffering =@output_buffering = On\noutput_buffering =@' ${php_install_dir}/etc/php.ini - #sed -i 's@^;cgi.fix_pathinfo.*@cgi.fix_pathinfo=0@' ${php_install_dir}/etc/php.ini - sed -i 's@^short_open_tag = Off@short_open_tag = On@' ${php_install_dir}/etc/php.ini - sed -i 's@^expose_php = On@expose_php = Off@' ${php_install_dir}/etc/php.ini - sed -i 's@^request_order.*@request_order = "CGP"@' ${php_install_dir}/etc/php.ini - sed -i "s@^;date.timezone.*@date.timezone = ${timezone}@" ${php_install_dir}/etc/php.ini - sed -i 's@^post_max_size.*@post_max_size = 100M@' ${php_install_dir}/etc/php.ini - sed -i 's@^upload_max_filesize.*@upload_max_filesize = 50M@' ${php_install_dir}/etc/php.ini - sed -i 's@^max_execution_time.*@max_execution_time = 600@' ${php_install_dir}/etc/php.ini - sed -i 's@^;realpath_cache_size.*@realpath_cache_size = 2M@' ${php_install_dir}/etc/php.ini - sed -i 's@^disable_functions.*@disable_functions = passthru,exec,system,chroot,chgrp,chown,shell_exec,proc_open,proc_get_status,ini_alter,ini_restore,dl,readlink,symlink,popepassthru,stream_socket_server,fsocket,popen@' ${php_install_dir}/etc/php.ini - [ -e /usr/sbin/sendmail ] && sed -i 's@^;sendmail_path.*@sendmail_path = /usr/sbin/sendmail -t -i@' ${php_install_dir}/etc/php.ini - if [ "${with_old_openssl_flag}" = 'y' ]; then - sed -i "s@^;curl.cainfo.*@curl.cainfo = \"${openssl_install_dir}/cert.pem\"@" ${php_install_dir}/etc/php.ini - sed -i "s@^;openssl.cafile.*@openssl.cafile = \"${openssl_install_dir}/cert.pem\"@" ${php_install_dir}/etc/php.ini - sed -i "s@^;openssl.capath.*@openssl.capath = \"${openssl_install_dir}/cert.pem\"@" ${php_install_dir}/etc/php.ini - fi - - [ "${phpcache_option}" == '1' ] && cat > ${php_install_dir}/etc/php.d/02-opcache.ini << EOF -[opcache] -zend_extension=opcache.so -opcache.enable=1 -opcache.enable_cli=1 -opcache.memory_consumption=${Memory_limit} -opcache.interned_strings_buffer=8 -opcache.max_accelerated_files=100000 -opcache.max_wasted_percentage=5 -opcache.use_cwd=1 -opcache.validate_timestamps=1 -opcache.revalidate_freq=60 -;opcache.save_comments=0 -opcache.consistency_checks=0 -;opcache.optimization_level=0 -EOF - - if [ "${apache_mode_option}" != '2' ]; then - # php-fpm Init Script - /bin/cp ${current_dir}/init.d/php-fpm.service /lib/systemd/system/ - sed -i "s@/usr/local/php@${php_install_dir}@g" /lib/systemd/system/php-fpm.service - systemctl enable php-fpm - - cat > ${php_install_dir}/etc/php-fpm.conf < /dev/null - [ -e "${php_install_dir}/bin/phpize" ] && rm -rf php-${php84_ver} - popd > /dev/null -} diff --git a/include/php-8.5.sh b/include/php-8.5.sh deleted file mode 100644 index 08135e2f..00000000 --- a/include/php-8.5.sh +++ /dev/null @@ -1,277 +0,0 @@ -#!/bin/bash -# Author: yeho -# BLOG: https://linuxeye.com - -Install_PHP85() { - pushd ${current_dir}/src > /dev/null - if [ ! -e "/usr/local/lib/libiconv.la" ]; then - tar xzf libiconv-${libiconv_ver}.tar.gz - pushd libiconv-${libiconv_ver} > /dev/null - ./configure - make -j ${THREAD} && make install - popd > /dev/null - rm -rf libiconv-${libiconv_ver} - fi - - if [ ! -e "${curl_install_dir}/lib/libcurl.la" ]; then - tar xzf curl-${curl_ver}.tar.gz - pushd curl-${curl_ver} > /dev/null - [ -e "/usr/local/lib/libnghttp2.so" ] && with_nghttp2='--with-nghttp2=/usr/local' - ./configure --prefix=${curl_install_dir} ${php85_with_ssl} ${with_nghttp2} - make -j ${THREAD} && make install - popd > /dev/null - rm -rf curl-${curl_ver} - fi - - if [ ! -e "${freetype_install_dir}/lib/libfreetype.la" ]; then - tar xzf freetype-${freetype_ver}.tar.gz - pushd freetype-${freetype_ver} > /dev/null - ./configure --prefix=${freetype_install_dir} --enable-freetype-config - make -j ${THREAD} && make install - ln -sf ${freetype_install_dir}/include/freetype2/* /usr/include/ - [ -d /usr/lib/pkgconfig ] && /bin/cp ${freetype_install_dir}/lib/pkgconfig/freetype2.pc /usr/lib/pkgconfig/ - popd > /dev/null - rm -rf freetype-${freetype_ver} - fi - - if [ ! -e "/usr/local/lib/pkgconfig/libargon2.pc" ]; then - tar xzf argon2-${argon2_ver}.tar.gz - pushd argon2-${argon2_ver} > /dev/null - make -j ${THREAD} && make install - [ ! -d /usr/local/lib/pkgconfig ] && mkdir -p /usr/local/lib/pkgconfig - /bin/cp libargon2.pc /usr/local/lib/pkgconfig/ - popd > /dev/null - rm -rf argon2-${argon2_ver} - fi - - if [ ! -e "/usr/local/lib/libsodium.la" ]; then - tar xzf libsodium-${libsodium_ver}.tar.gz - pushd libsodium-${libsodium_ver} > /dev/null - ./configure --disable-dependency-tracking --enable-minimal - make -j ${THREAD} && make install - popd > /dev/null - rm -rf libsodium-${libsodium_ver} - fi - - if [ ! -e "/usr/local/lib/libzip.la" ]; then - tar xzf libzip-${libzip_ver}.tar.gz - pushd libzip-${libzip_ver} > /dev/null - ./configure - make -j ${THREAD} && make install - popd > /dev/null - rm -rf libzip-${libzip_ver} - fi - - if [ ! -e "/usr/local/include/mhash.h" -a ! -e "/usr/include/mhash.h" ]; then - tar xzf mhash-${mhash_ver}.tar.gz - pushd mhash-${mhash_ver} > /dev/null - ./configure - make -j ${THREAD} && make install - popd > /dev/null - rm -rf mhash-${mhash_ver} - fi - - if [ ! -e "/usr/local/include/bfd.h" -a "${RHEL_ver}" == "8" ]; then - tar xzf binutils-${binutils_ver}.tar.gz - pushd binutils-${binutils_ver} - ./configure - make -j ${THREAD} && make install - popd > /dev/null - rm -rf binutils-${binutils_ver} - fi - - [ -z "`grep /usr/local/lib /etc/ld.so.conf.d/*.conf`" ] && echo '/usr/local/lib' > /etc/ld.so.conf.d/local.conf - ldconfig - - if [ "${PM}" == 'yum' ]; then - [ ! -e "/lib64/libpcre.so.1" ] && ln -s /lib64/libpcre.so.0.0.1 /lib64/libpcre.so.1 - [ ! -e "/usr/lib/libc-client.so" ] && ln -s /usr/lib64/libc-client.so /usr/lib/libc-client.so - fi - - id -g ${run_group} >/dev/null 2>&1 - [ $? -ne 0 ] && groupadd ${run_group} - id -u ${run_user} >/dev/null 2>&1 - [ $? -ne 0 ] && useradd -g ${run_group} -M -s /sbin/nologin ${run_user} - - tar xzf php-${php85_ver}.tar.gz - pushd php-${php85_ver} > /dev/null - make clean - export PKG_CONFIG_PATH=/usr/local/lib/pkgconfig/:$PKG_CONFIG_PATH - [ ! -d "${php_install_dir}" ] && mkdir -p ${php_install_dir} - if [ "${apache_mode_option}" == '2' ]; then - ./configure --prefix=${php_install_dir} --with-config-file-path=${php_install_dir}/etc \ - --with-config-file-scan-dir=${php_install_dir}/etc/php.d \ - --with-apxs2=${apache_install_dir}/bin/apxs --disable-fileinfo \ - --enable-mysqlnd --with-mysqli=mysqlnd --with-pdo-mysql=mysqlnd \ - --with-iconv=/usr/local --with-freetype --with-jpeg --with-zlib \ - --enable-xml --disable-rpath --enable-bcmath --enable-shmop --enable-exif \ - --enable-sysvsem ${php85_with_curl} --enable-mbregex \ - --enable-mbstring --with-password-argon2 --with-sodium=/usr/local --enable-gd ${php85_with_openssl} \ - --with-mhash --enable-pcntl --enable-sockets --enable-ftp --enable-intl --with-xsl \ - --with-gettext --with-zip=/usr/local --enable-soap --disable-debug ${php_modules_options} - else - ./configure --prefix=${php_install_dir} --with-config-file-path=${php_install_dir}/etc \ - --with-config-file-scan-dir=${php_install_dir}/etc/php.d \ - --with-fpm-user=${run_user} --with-fpm-group=${run_group} --enable-fpm --disable-fileinfo \ - --enable-mysqlnd --with-mysqli=mysqlnd --with-pdo-mysql=mysqlnd \ - --with-iconv=/usr/local --with-freetype --with-jpeg --with-zlib \ - --enable-xml --disable-rpath --enable-bcmath --enable-shmop --enable-exif \ - --enable-sysvsem ${php85_with_curl} --enable-mbregex \ - --enable-mbstring --with-password-argon2 --with-sodium=/usr/local --enable-gd ${php85_with_openssl} \ - --with-mhash --enable-pcntl --enable-sockets --enable-ftp --enable-intl --with-xsl \ - --with-gettext --with-zip=/usr/local --enable-soap --disable-debug ${php_modules_options} - fi - make ZEND_EXTRA_LIBS='-liconv' -j ${THREAD} - make install - - if [ -e "${php_install_dir}/bin/phpize" ]; then - [ ! -e "${php_install_dir}/etc/php.d" ] && mkdir -p ${php_install_dir}/etc/php.d - echo "${CSUCCESS}PHP installed successfully! ${CEND}" - else - rm -rf ${php_install_dir} - echo "${CFAILURE}PHP install failed, Please Contact the author! ${CEND}" - kill -9 $$; exit 1; - fi - - [ -z "`grep ^'export PATH=' /etc/profile`" ] && echo "export PATH=${php_install_dir}/bin:\$PATH" >> /etc/profile - [ -n "`grep ^'export PATH=' /etc/profile`" -a -z "`grep ${php_install_dir} /etc/profile`" ] && sed -i "s@^export PATH=\(.*\)@export PATH=${php_install_dir}/bin:\1@" /etc/profile - . /etc/profile - - # wget -c http://pear.php.net/go-pear.phar - # ${php_install_dir}/bin/php go-pear.phar - - /bin/cp php.ini-production ${php_install_dir}/etc/php.ini - - sed -i "s@^memory_limit.*@memory_limit = ${Memory_limit}M@" ${php_install_dir}/etc/php.ini - sed -i 's@^output_buffering =@output_buffering = On\noutput_buffering =@' ${php_install_dir}/etc/php.ini - #sed -i 's@^;cgi.fix_pathinfo.*@cgi.fix_pathinfo=0@' ${php_install_dir}/etc/php.ini - sed -i 's@^short_open_tag = Off@short_open_tag = On@' ${php_install_dir}/etc/php.ini - sed -i 's@^expose_php = On@expose_php = Off@' ${php_install_dir}/etc/php.ini - sed -i 's@^request_order.*@request_order = "CGP"@' ${php_install_dir}/etc/php.ini - sed -i "s@^;date.timezone.*@date.timezone = ${timezone}@" ${php_install_dir}/etc/php.ini - sed -i 's@^post_max_size.*@post_max_size = 100M@' ${php_install_dir}/etc/php.ini - sed -i 's@^upload_max_filesize.*@upload_max_filesize = 50M@' ${php_install_dir}/etc/php.ini - sed -i 's@^max_execution_time.*@max_execution_time = 600@' ${php_install_dir}/etc/php.ini - sed -i 's@^;realpath_cache_size.*@realpath_cache_size = 2M@' ${php_install_dir}/etc/php.ini - sed -i 's@^disable_functions.*@disable_functions = passthru,exec,system,chroot,chgrp,chown,shell_exec,proc_open,proc_get_status,ini_alter,ini_restore,dl,readlink,symlink,popepassthru,stream_socket_server,fsocket,popen@' ${php_install_dir}/etc/php.ini - [ -e /usr/sbin/sendmail ] && sed -i 's@^;sendmail_path.*@sendmail_path = /usr/sbin/sendmail -t -i@' ${php_install_dir}/etc/php.ini - if [ "${with_old_openssl_flag}" = 'y' ]; then - sed -i "s@^;curl.cainfo.*@curl.cainfo = \"${openssl_install_dir}/cert.pem\"@" ${php_install_dir}/etc/php.ini - sed -i "s@^;openssl.cafile.*@openssl.cafile = \"${openssl_install_dir}/cert.pem\"@" ${php_install_dir}/etc/php.ini - sed -i "s@^;openssl.capath.*@openssl.capath = \"${openssl_install_dir}/cert.pem\"@" ${php_install_dir}/etc/php.ini - fi - - cat > ${php_install_dir}/etc/php.d/02-opcache.ini << EOF -[opcache] -opcache.enable=1 -opcache.enable_cli=1 -opcache.memory_consumption=${Memory_limit} -opcache.interned_strings_buffer=8 -opcache.max_accelerated_files=100000 -opcache.max_wasted_percentage=5 -opcache.use_cwd=1 -opcache.validate_timestamps=1 -opcache.revalidate_freq=60 -;opcache.save_comments=0 -opcache.consistency_checks=0 -;opcache.optimization_level=0 -EOF - - if [ "${apache_mode_option}" != '2' ]; then - # php-fpm Init Script - /bin/cp ${current_dir}/init.d/php-fpm.service /lib/systemd/system/ - sed -i "s@/usr/local/php@${php_install_dir}@g" /lib/systemd/system/php-fpm.service - systemctl enable php-fpm - - cat > ${php_install_dir}/etc/php-fpm.conf < /dev/null - [ -e "${php_install_dir}/bin/phpize" ] && rm -rf php-${php85_ver} - popd > /dev/null -} diff --git a/include/phpmyadmin.sh b/include/phpmyadmin.sh index f7d19423..8b1219f5 100644 --- a/include/phpmyadmin.sh +++ b/include/phpmyadmin.sh @@ -1,26 +1,22 @@ #!/bin/bash # Author: yeho -# BLOG: https://linuxeye.com +# BLOG: https://blog.linuxeye.com +# +# Notes: OneinStack for CentOS/RadHat 5+ Debian 6+ and Ubuntu 12+ +# +# Project home page: +# https://oneinstack.com +# https://github.com/lj2007331/oneinstack Install_phpMyAdmin() { - if [ -e "${php_install_dir}/bin/phpize" ]; then - pushd ${current_dir}/src > /dev/null - PHP_detail_ver=`${php_install_dir}/bin/php-config --version` - PHP_main_ver=${PHP_detail_ver%.*} - if [[ "${PHP_main_ver}" =~ ^5.[3-6]$|^7.[0-1]$ ]]; then - tar xzf phpMyAdmin-4.4.15.10-all-languages.tar.gz - /bin/mv phpMyAdmin-4.4.15.10-all-languages ${wwwroot_dir}/default/phpMyAdmin - else - tar xzf phpMyAdmin-${phpmyadmin_ver}-all-languages.tar.gz - /bin/mv phpMyAdmin-${phpmyadmin_ver}-all-languages ${wwwroot_dir}/default/phpMyAdmin - fi - /bin/cp ${wwwroot_dir}/default/phpMyAdmin/{config.sample.inc.php,config.inc.php} - mkdir ${wwwroot_dir}/default/phpMyAdmin/{upload,save} - sed -i "s@UploadDir.*@UploadDir'\] = 'upload';@" ${wwwroot_dir}/default/phpMyAdmin/config.inc.php - sed -i "s@SaveDir.*@SaveDir'\] = 'save';@" ${wwwroot_dir}/default/phpMyAdmin/config.inc.php - sed -i "s@host'\].*@host'\] = '127.0.0.1';@" ${wwwroot_dir}/default/phpMyAdmin/config.inc.php - sed -i "s@blowfish_secret.*;@blowfish_secret\'\] = \'$(cat /dev/urandom | head -1 | base64 | head -c 32)\';@" ${wwwroot_dir}/default/phpMyAdmin/config.inc.php - chown -R ${run_user}:${run_group} ${wwwroot_dir}/default/phpMyAdmin - popd > /dev/null - fi + pushd ${oneinstack_dir}/src + tar xzf phpMyAdmin-${phpMyAdmin_version}-all-languages.tar.gz + /bin/mv phpMyAdmin-${phpMyAdmin_version}-all-languages ${wwwroot_dir}/default/phpMyAdmin + /bin/cp ${wwwroot_dir}/default/phpMyAdmin/{config.sample.inc.php,config.inc.php} + mkdir ${wwwroot_dir}/default/phpMyAdmin/{upload,save} + sed -i "s@UploadDir.*@UploadDir'\] = 'upload';@" ${wwwroot_dir}/default/phpMyAdmin/config.inc.php + sed -i "s@SaveDir.*@SaveDir'\] = 'save';@" ${wwwroot_dir}/default/phpMyAdmin/config.inc.php + sed -i "s@blowfish_secret.*;@blowfish_secret\'\] = \'$(cat /dev/urandom | head -1 | base64 | head -c 45)\';@" ${wwwroot_dir}/default/phpMyAdmin/config.inc.php + chown -R ${run_user}.$run_user ${wwwroot_dir}/default/phpMyAdmin + popd } diff --git a/include/postgresql.sh b/include/postgresql.sh deleted file mode 100644 index 93427587..00000000 --- a/include/postgresql.sh +++ /dev/null @@ -1,45 +0,0 @@ -#!/bin/bash -# Author: yeho -# BLOG: https://linuxeye.com - -Install_PostgreSQL() { - pushd ${current_dir}/src > /dev/null - id -u postgres >/dev/null 2>&1 - [ $? -ne 0 ] && useradd -d ${pgsql_install_dir} -s /bin/bash postgres - mkdir -p ${pgsql_data_dir};chown postgres.postgres -R ${pgsql_data_dir} - tar xzf postgresql-${pgsql_ver}.tar.gz - pushd postgresql-${pgsql_ver} - ./configure --prefix=$pgsql_install_dir - make -j ${THREAD} - make install - chmod 755 ${pgsql_install_dir} - chown -R postgres.postgres ${pgsql_install_dir} - /bin/cp ${current_dir}/init.d/postgresql.service /lib/systemd/system/ - sed -i "s@=/usr/local/pgsql@=${pgsql_install_dir}@g" /lib/systemd/system/postgresql.service - sed -i "s@PGDATA=.*@PGDATA=${pgsql_data_dir}@" /lib/systemd/system/postgresql.service - systemctl enable postgresql - popd - su - postgres -c "${pgsql_install_dir}/bin/initdb -D ${pgsql_data_dir}" - systemctl start postgresql - sleep 5 - su - postgres -c "${pgsql_install_dir}/bin/psql -c \"alter user postgres with password '$dbpostgrespwd';\"" - sed -i 's@^host.*@#&@g' ${pgsql_data_dir}/pg_hba.conf - sed -i 's@^local.*@#&@g' ${pgsql_data_dir}/pg_hba.conf - echo 'local all all md5' >> ${pgsql_data_dir}/pg_hba.conf - echo 'host all all 0.0.0.0/0 md5' >> ${pgsql_data_dir}/pg_hba.conf - sed -i "s@^#listen_addresses.*@listen_addresses = '*'@" ${pgsql_data_dir}/postgresql.conf - systemctl reload postgresql - - if [ -e "${pgsql_install_dir}/bin/psql" ]; then - sed -i "s+^dbpostgrespwd.*+dbpostgrespwd='$dbpostgrespwd'+" ../options.conf - echo "${CSUCCESS}PostgreSQL installed successfully! ${CEND}" - else - rm -rf ${pgsql_install_dir} ${pgsql_data_dir} - echo "${CFAILURE}PostgreSQL install failed, Please contact the author! ${CEND}" && grep -Ew 'NAME|ID|ID_LIKE|VERSION_ID|PRETTY_NAME' /etc/os-release - kill -9 $$; exit 1; - fi - popd - [ -z "$(grep ^'export PATH=' /etc/profile)" ] && echo "export PATH=${pgsql_install_dir}/bin:\$PATH" >> /etc/profile - [ -n "$(grep ^'export PATH=' /etc/profile)" -a -z "$(grep ${pgsql_install_dir} /etc/profile)" ] && sed -i "s@^export PATH=\(.*\)@export PATH=${pgsql_install_dir}/bin:\1@" /etc/profile - . /etc/profile -} diff --git a/include/pureftpd.sh b/include/pureftpd.sh index be82d617..6777f89c 100644 --- a/include/pureftpd.sh +++ b/include/pureftpd.sh @@ -1,59 +1,61 @@ #!/bin/bash # Author: yeho -# BLOG: https://linuxeye.com +# BLOG: https://blog.linuxeye.com +# +# Notes: OneinStack for CentOS/RadHat 5+ Debian 6+ and Ubuntu 12+ +# +# Project home page: +# https://oneinstack.com +# https://github.com/lj2007331/oneinstack Install_PureFTPd() { - pushd ${current_dir}/src > /dev/null - id -g ${run_group} >/dev/null 2>&1 - [ $? -ne 0 ] && groupadd ${run_group} + pushd ${oneinstack_dir}/src + id -u ${run_user} >/dev/null 2>&1 - [ $? -ne 0 ] && useradd -g ${run_group} -M -s /sbin/nologin ${run_user} + [ $? -ne 0 ] && useradd -M -s /sbin/nologin ${run_user} - tar xzf pure-ftpd-${pureftpd_ver}.tar.gz - pushd pure-ftpd-${pureftpd_ver} > /dev/null + tar xzf pure-ftpd-${pureftpd_version}.tar.gz + pushd pure-ftpd-${pureftpd_version} [ ! -d "${pureftpd_install_dir}" ] && mkdir -p ${pureftpd_install_dir} - ./configure --prefix=${pureftpd_install_dir} CFLAGS=-O2 --with-puredb --with-quotas --with-cookie --with-virtualhosts --with-virtualchroot --with-diraliases --with-sysquotas --with-ratios --with-altlog --with-paranoidmsg --with-shadow --with-welcomemsg --with-throttling --with-uploadscript --with-language=english --with-tls + ./configure --prefix=${pureftpd_install_dir} CFLAGS=-O2 --with-puredb --with-quotas --with-cookie --with-virtualhosts --with-virtualchroot --with-diraliases --with-sysquotas --with-ratios --with-altlog --with-paranoidmsg --with-shadow --with-welcomemsg --with-throttling --with-uploadscript --with-language=english --with-rfc2640 make -j ${THREAD} && make install - popd > /dev/null if [ -e "${pureftpd_install_dir}/sbin/pure-ftpwho" ]; then - /bin/cp ../init.d/pureftpd.service /lib/systemd/system/ - sed -i "s@/usr/local/pureftpd@${pureftpd_install_dir}@g" /lib/systemd/system/pureftpd.service - systemctl enable pureftpd - [ ! -e "${pureftpd_install_dir}/etc" ] && mkdir ${pureftpd_install_dir}/etc + popd + /bin/cp ../init.d/Pureftpd-init /etc/init.d/pureftpd /bin/cp ../config/pure-ftpd.conf ${pureftpd_install_dir}/etc + sed -i "s@/usr/local/pureftpd@${pureftpd_install_dir}@g" /etc/init.d/pureftpd + chmod +x /etc/init.d/pureftpd + [ "${OS}" == "CentOS" ] && { chkconfig --add pureftpd; chkconfig pureftpd on; } + [[ "${OS}" =~ ^Ubuntu$|^Debian$ ]] && { sed -i 's@^. /etc/rc.d/init.d/functions@. /lib/lsb/init-functions@' /etc/init.d/pureftpd; update-rc.d pureftpd defaults; } + [ "${Debian_version}" == '7' ] && sed -i 's@/var/lock/subsys/@/var/lock/@g' /etc/init.d/pureftpd + sed -i "s@^PureDB.*@PureDB ${pureftpd_install_dir}/etc/pureftpd.pdb@" ${pureftpd_install_dir}/etc/pure-ftpd.conf sed -i "s@^LimitRecursion.*@LimitRecursion 65535 8@" ${pureftpd_install_dir}/etc/pure-ftpd.conf - IPADDR=${IPADDR:-127.0.0.1} - [ ! -d /etc/ssl/private ] && mkdir -p /etc/ssl/private - openssl dhparam -out /etc/ssl/private/pure-ftpd-dhparams.pem 2048 - openssl req -x509 -days 7300 -sha256 -nodes -subj "/C=CN/ST=Shanghai/L=Shanghai/O=LinuxEye/CN=${IPADDR}" -newkey rsa:2048 -keyout /etc/ssl/private/pure-ftpd.pem -out /etc/ssl/private/pure-ftpd.pem - chmod 600 /etc/ssl/private/pure-ftpd*.pem - sed -i "s@^# TLS.*@&\nCertFile /etc/ssl/private/pure-ftpd.pem@" ${pureftpd_install_dir}/etc/pure-ftpd.conf - sed -i "s@^# TLS.*@&\nTLSCipherSuite HIGH:MEDIUM:+TLSv1:\!SSLv2:\!SSLv3@" ${pureftpd_install_dir}/etc/pure-ftpd.conf - sed -i "s@^# TLS.*@TLS 1@" ${pureftpd_install_dir}/etc/pure-ftpd.conf ulimit -s unlimited - systemctl start pureftpd + service pureftpd start - # Firewall Ftp - if [ "${PM}" == 'yum' ]; then - if [ "`firewall-cmd --state`" == "running" ]; then - firewall-cmd --permanent --zone=public --add-port={21/tcp,20000-30000/tcp} - firewall-cmd --reload + # iptables Ftp + if [ "${OS}" == "CentOS" ]; then + if [ -z "$(grep '20000:30000' /etc/sysconfig/iptables)" ]; then + iptables -I INPUT 5 -p tcp -m state --state NEW -m tcp --dport 21 -j ACCEPT + iptables -I INPUT 6 -p tcp -m state --state NEW -m tcp --dport 20000:30000 -j ACCEPT + service iptables save fi - elif [ "${PM}" == 'apt-get' ]; then - if ufw status | grep -wq active; then - ufw allow 21/tcp - ufw allow 20000:30000/tcp + elif [[ "${OS}" =~ ^Ubuntu$|^Debian$ ]]; then + if [ -z "$(grep '20000:30000' /etc/iptables.up.rules)" ]; then + iptables -I INPUT 5 -p tcp -m state --state NEW -m tcp --dport 21 -j ACCEPT + iptables -I INPUT 6 -p tcp -m state --state NEW -m tcp --dport 20000:30000 -j ACCEPT + iptables-save > /etc/iptables.up.rules fi fi echo "${CSUCCESS}Pure-Ftp installed successfully! ${CEND}" - rm -rf pure-ftpd-${pureftpd_ver} + rm -rf pure-ftpd-${pureftpd_version} else rm -rf ${pureftpd_install_dir} - echo "${CFAILURE}Pure-Ftpd install failed, Please contact the author! ${CEND}" && grep -Ew 'NAME|ID|ID_LIKE|VERSION_ID|PRETTY_NAME' /etc/os-release - kill -9 $$; exit 1; + echo "${CFAILURE}Pure-Ftpd install failed, Please contact the author! ${CEND}" + kill -9 $$ fi - popd > /dev/null + popd } diff --git a/include/python.sh b/include/python.sh new file mode 100755 index 00000000..4f8006c7 --- /dev/null +++ b/include/python.sh @@ -0,0 +1,87 @@ +#!/bin/bash +# Author: yeho +# BLOG: https://blog.linuxeye.com +# +# Notes: OneinStack for CentOS/RadHat 5+ Debian 6+ and Ubuntu 12+ +# +# Project home page: +# https://oneinstack.com +# https://github.com/lj2007331/oneinstack + +Install_Python() { + pushd ${oneinstack_dir}/src + if [ "${CentOS_RHEL_version}" == '7' ]; then + [ ! -e /etc/yum.repos.d/epel.repo ] && cat > /etc/yum.repos.d/epel.repo << EOF +[epel] +name=Extra Packages for Enterprise Linux 7 - \$basearch +#baseurl=http://download.fedoraproject.org/pub/epel/7/\$basearch +mirrorlist=https://mirrors.fedoraproject.org/metalink?repo=epel-7&arch=\$basearch +failovermethod=priority +enabled=1 +gpgcheck=0 +EOF + elif [ "${CentOS_RHEL_version}" == '6' ]; then + [ ! -e /etc/yum.repos.d/epel.repo ] && cat > /etc/yum.repos.d/epel.repo << EOF +[epel] +name=Extra Packages for Enterprise Linux 6 - \$basearch +#baseurl=http://download.fedoraproject.org/pub/epel/6/\$basearch +mirrorlist=https://mirrors.fedoraproject.org/metalink?repo=epel-6&arch=\$basearch +failovermethod=priority +enabled=1 +gpgcheck=0 +EOF + fi + + if [ "${OS}" == "CentOS" ]; then + pkgList="gcc dialog augeas-libs openssl openssl-devel libffi-devel redhat-rpm-config ca-certificates" + for Package in ${pkgList}; do + yum -y install ${Package} + done + elif [[ "${OS}" =~ ^Ubuntu$|^Debian$ ]]; then + pkgList="gcc dialog libaugeas0 augeas-lenses libssl-dev libffi-dev ca-certificates" + for Package in ${pkgList}; do + apt-get -y install $Package + done + fi + + # Install Python + if [ ! -e "${python_install_dir}/bin/python" -a ! -e "${python_install_dir}/bin/python3" ] ;then + src_url=http://mirrors.linuxeye.com/oneinstack/src/Python-${python_version}.tgz && Download_src + tar xzf Python-${python_version}.tgz + pushd Python-${python_version} + ./configure --prefix=${python_install_dir} + make && make install + [ ! -e "${python_install_dir}/bin/python" -a -e "${python_install_dir}/bin/python3" ] && ln -s ${python_install_dir}/bin/python{3,} + popd + rm -rf Python-${python_version} + fi + + if [ ! -e "${python_install_dir}/bin/easy_install" ] ;then + src_url=http://mirrors.linuxeye.com/oneinstack/src/setuptools-${setuptools_version}.zip && Download_src + unzip -q setuptools-${setuptools_version}.zip + pushd setuptools-${setuptools_version} + ${python_install_dir}/bin/python setup.py install + popd + rm -rf setuptools-${setuptools_version} + fi + + if [ ! -e "${python_install_dir}/bin/pip" ] ;then + src_url=http://mirrors.linuxeye.com/oneinstack/src/pip-${pip_version}.tar.gz && Download_src + tar xzf pip-${pip_version}.tar.gz + pushd pip-${pip_version} + ${python_install_dir}/bin/python setup.py install + popd + rm -rf pip-${pip_version} + fi + + if [ ! -e "/root/.pip/pip.conf" ] ;then + # get the IP information + PUBLIC_IPADDR=$(../include/get_public_ipaddr.py) + IPADDR_COUNTRY=$(../include/get_ipaddr_state.py $PUBLIC_IPADDR | awk '{print $1}') + if [ "$IPADDR_COUNTRY"x != "CN"x ]; then + [ ! -d "/root/.pip" ] && mkdir /root/.pip + echo -e "[global]\nindex-url = https://pypi.tuna.tsinghua.edu.cn/simple" > /root/.pip/pip.conf + fi + fi + popd +} diff --git a/include/redis.sh b/include/redis.sh index af4ddbb0..10f59ab3 100644 --- a/include/redis.sh +++ b/include/redis.sh @@ -1,18 +1,28 @@ #!/bin/bash # Author: yeho -# BLOG: https://linuxeye.com +# BLOG: https://blog.linuxeye.com +# +# Notes: OneinStack for CentOS/RadHat 5+ Debian 6+ and Ubuntu 12+ +# +# Project home page: +# https://oneinstack.com +# https://github.com/lj2007331/oneinstack -Install_redis_server() { - pushd ${current_dir}/src > /dev/null - tar xzf redis-${redis_ver}.tar.gz - pushd redis-${redis_ver} > /dev/null +Install_redis-server() { + pushd ${oneinstack_dir}/src + tar xzf redis-${redis_version}.tar.gz + pushd redis-${redis_version} + if [ "$OS_BIT" == '32' ]; then + sed -i '1i\CFLAGS= -march=i686' src/Makefile + sed -i 's@^OPT=.*@OPT=-O2 -march=i686@' src/.make-settings + fi make -j ${THREAD} if [ -f "src/redis-server" ]; then mkdir -p ${redis_install_dir}/{bin,etc,var} /bin/cp src/{redis-benchmark,redis-check-aof,redis-check-rdb,redis-cli,redis-sentinel,redis-server} ${redis_install_dir}/bin/ /bin/cp redis.conf ${redis_install_dir}/etc/ ln -s ${redis_install_dir}/bin/* /usr/local/bin/ - sed -i 's@pidfile.*@pidfile /var/run/redis/redis.pid@' ${redis_install_dir}/etc/redis.conf + sed -i 's@pidfile.*@pidfile /var/run/redis.pid@' ${redis_install_dir}/etc/redis.conf sed -i "s@logfile.*@logfile ${redis_install_dir}/var/redis.log@" ${redis_install_dir}/etc/redis.conf sed -i "s@^dir.*@dir ${redis_install_dir}/var@" ${redis_install_dir}/etc/redis.conf sed -i 's@daemonize no@daemonize yes@' ${redis_install_dir}/etc/redis.conf @@ -20,63 +30,53 @@ Install_redis_server() { redis_maxmemory=`expr $Mem / 8`000000 [ -z "`grep ^maxmemory ${redis_install_dir}/etc/redis.conf`" ] && sed -i "s@maxmemory @maxmemory \nmaxmemory `expr $Mem / 8`000000@" ${redis_install_dir}/etc/redis.conf echo "${CSUCCESS}Redis-server installed successfully! ${CEND}" - popd > /dev/null - rm -rf redis-${redis_ver} + popd + rm -rf redis-${redis_version} id -u redis >/dev/null 2>&1 [ $? -ne 0 ] && useradd -M -s /sbin/nologin redis chown -R redis:redis ${redis_install_dir}/{var,etc} - - /bin/cp ../init.d/redis-server.service /lib/systemd/system/ - sed -i "s@/usr/local/redis@${redis_install_dir}@g" /lib/systemd/system/redis-server.service - systemctl enable redis-server + /bin/cp ../init.d/Redis-server-init /etc/init.d/redis-server + if [ "$OS" == 'CentOS' ]; then + cc start-stop-daemon.c -o /sbin/start-stop-daemon + chkconfig --add redis-server + chkconfig redis-server on + elif [[ $OS =~ ^Ubuntu$|^Debian$ ]]; then + update-rc.d redis-server defaults + fi + sed -i "s@/usr/local/redis@${redis_install_dir}@g" /etc/init.d/redis-server #[ -z "`grep 'vm.overcommit_memory' /etc/sysctl.conf`" ] && echo 'vm.overcommit_memory = 1' >> /etc/sysctl.conf #sysctl -p - systemctl start redis-server + service redis-server start else rm -rf ${redis_install_dir} - echo "${CFAILURE}Redis-server install failed, Please contact the author! ${CEND}" && grep -Ew 'NAME|ID|ID_LIKE|VERSION_ID|PRETTY_NAME' /etc/os-release - kill -9 $$; exit 1; + echo "${CFAILURE}Redis-server install failed, Please contact the author! ${CEND}" + kill -9 $$ fi - popd > /dev/null + popd } -Install_pecl_redis() { +Install_php-redis() { + pushd ${oneinstack_dir}/src if [ -e "${php_install_dir}/bin/phpize" ]; then - pushd ${current_dir}/src > /dev/null phpExtensionDir=`${php_install_dir}/bin/php-config --extension-dir` - if [ "$(${php_install_dir}/bin/php-config --version | awk -F. '{print $1}')" == '5' ]; then - tar xzf redis-4.3.0.tgz - pushd redis-4.3.0 > /dev/null - elif [[ "$(${php_install_dir}/bin/php-config --version | awk -F. '{print $1$2}')" =~ ^7[0-1]$ ]]; then - tar xzf redis-5.3.7.tgz - pushd redis-5.3.7 > /dev/null - elif [[ "$(${php_install_dir}/bin/php-config --version | awk -F. '{print $1$2}')" =~ ^7[2-3]$ ]]; then - tar xzf redis-6.0.2.tgz - pushd redis-6.0.2 > /dev/null + if [ "`${php_install_dir}/bin/php -r 'echo PHP_VERSION;' | awk -F. '{print $1}'`" == '7' ]; then + tar xzf redis-${redis_pecl_for_php7_version}.tgz + pushd redis-${redis_pecl_for_php7_version} else - tar xzf redis-${pecl_redis_ver}.tgz - pushd redis-${pecl_redis_ver} > /dev/null + tar xzf redis-$redis_pecl_version.tgz + pushd redis-$redis_pecl_version fi ${php_install_dir}/bin/phpize ./configure --with-php-config=${php_install_dir}/bin/php-config make -j ${THREAD} && make install - popd > /dev/null if [ -f "${phpExtensionDir}/redis.so" ]; then - echo 'extension=redis.so' > ${php_install_dir}/etc/php.d/05-redis.ini + echo 'extension=redis.so' > ${php_install_dir}/etc/php.d/ext-redis.ini echo "${CSUCCESS}PHP Redis module installed successfully! ${CEND}" - rm -rf redis-${pecl_redis_ver} redis-4.3.0 redis-5.3.7 redis-6.0.2 + popd + rm -rf redis-${redis_pecl_for_php7_version} redis-$redis_pecl_version else - echo "${CFAILURE}PHP Redis module install failed, Please contact the author! ${CEND}" && grep -Ew 'NAME|ID|ID_LIKE|VERSION_ID|PRETTY_NAME' /etc/os-release + echo "${CFAILURE}PHP Redis module install failed, Please contact the author! ${CEND}" fi - popd > /dev/null - fi -} - -Uninstall_pecl_redis() { - if [ -e "${php_install_dir}/etc/php.d/05-redis.ini" ]; then - rm -f ${php_install_dir}/etc/php.d/05-redis.ini - echo; echo "${CMSG}PHP redis module uninstall completed${CEND}" - else - echo; echo "${CWARNING}PHP redis module does not exist! ${CEND}" fi + popd } diff --git a/include/sourceguardian.sh b/include/sourceguardian.sh deleted file mode 100644 index b5f36286..00000000 --- a/include/sourceguardian.sh +++ /dev/null @@ -1,43 +0,0 @@ -#!/bin/bash -# Author: yeho -# BLOG: https://linuxeye.com - -Install_SourceGuardian() { - if [ -e "${php_install_dir}/bin/phpize" ]; then - pushd ${current_dir}/src > /dev/null - PHP_detail_ver=`${php_install_dir}/bin/php-config --version` - PHP_main_ver=${PHP_detail_ver%.*} - phpExtensionDir=`${php_install_dir}/bin/php-config --extension-dir` - [ ! -e sourceguardian ] && mkdir sourceguardian - [ -e "loaders.linux-${ARCH}.tar.gz" ] && tar xzf loaders.linux-${ARCH}.tar.gz -C sourceguardian - - if [ -e "sourceguardian/ixed.${PHP_main_ver}.lin" ]; then - [ ! -d "${phpExtensionDir}" ] && mkdir -p ${phpExtensionDir} - if [ -z "`echo ${phpExtensionDir} | grep 'non-zts'`" ]; then - /bin/mv sourceguardian/ixed.${PHP_main_ver}ts.lin ${phpExtensionDir} - extension="ixed.${PHP_main_ver}ts.lin" - else - /bin/mv sourceguardian/ixed.${PHP_main_ver}.lin ${phpExtensionDir} - extension="ixed.${PHP_main_ver}.lin" - fi - - if [ -f "${phpExtensionDir}/ixed.${PHP_main_ver}.lin" ]; then - echo "extension=${extension}" > ${php_install_dir}/etc/php.d/02-sourceguardian.ini - echo "${CSUCCESS}PHP SourceGuardian module installed successfully! ${CEND}" - rm -rf sourceguardian - fi - else - echo; echo "${CWARNING}Your php ${PHP_detail_ver} or platform ${TARGET_ARCH} does not support SourceGuardian! ${CEND}"; - fi - popd > /dev/null - fi -} - -Uninstall_SourceGuardian() { - if [ -e "${php_install_dir}/etc/php.d/02-sourceguardian.ini" ]; then - rm -f ${php_install_dir}/etc/php.d/02-sourceguardian.ini - echo; echo "${CMSG}PHP SourceGuardian module uninstall completed${CEND}" - else - echo; echo "${CWARNING}PHP SourceGuardian module does not exist! ${CEND}" - fi -} diff --git a/include/tengine.sh b/include/tengine.sh index b0a98fcb..c55cf6e7 100644 --- a/include/tengine.sh +++ b/include/tengine.sh @@ -1,52 +1,61 @@ #!/bin/bash # Author: yeho -# BLOG: https://linuxeye.com +# BLOG: https://blog.linuxeye.com +# +# Notes: OneinStack for CentOS/RadHat 5+ Debian 6+ and Ubuntu 12+ +# +# Project home page: +# https://oneinstack.com +# https://github.com/lj2007331/oneinstack Install_Tengine() { - pushd ${current_dir}/src > /dev/null - id -g ${run_group} >/dev/null 2>&1 - [ $? -ne 0 ] && groupadd ${run_group} - id -u ${run_user} >/dev/null 2>&1 - [ $? -ne 0 ] && useradd -g ${run_group} -M -s /sbin/nologin ${run_user} - - tar xzf pcre-${pcre_ver}.tar.gz - tar xzf tengine-${tengine_ver}.tar.gz - tar xzf openssl-${openssl_ver}.tar.gz - pushd tengine-${tengine_ver} > /dev/null + pushd ${oneinstack_dir}/src + + id -u $run_user >/dev/null 2>&1 + [ $? -ne 0 ] && useradd -M -s /sbin/nologin $run_user + + tar xzf pcre-$pcre_version.tar.gz + tar xzf tengine-$tengine_version.tar.gz + tar xzf openssl-$openssl_version.tar.gz + pushd tengine-$tengine_version # Modify Tengine version #sed -i 's@TENGINE "/" TENGINE_VERSION@"Tengine/unknown"@' src/core/nginx.h - - [ ! -d "${tengine_install_dir}" ] && mkdir -p ${tengine_install_dir} - ./configure --prefix=${tengine_install_dir} --user=${run_user} --group=${run_group} --with-http_v2_module --with-http_ssl_module --with-stream --with-stream_ssl_preread_module --with-stream_ssl_module --with-http_gzip_static_module --with-http_realip_module --with-http_flv_module --with-http_mp4_module --with-openssl=../openssl-${openssl_ver} --with-pcre=../pcre-${pcre_ver} --with-pcre-jit --with-jemalloc ${nginx_modules_options} - make && make install - if [ -e "${tengine_install_dir}/conf/nginx.conf" ]; then - popd > /dev/null - rm -rf pcre-${pcre_ver} openssl-${openssl_ver} tengine-${tengine_ver} + + # close debug + sed -i 's@CFLAGS="$CFLAGS -g"@#CFLAGS="$CFLAGS -g"@' auto/cc/gcc + + [ ! -d "$tengine_install_dir" ] && mkdir -p $tengine_install_dir + ./configure --prefix=$tengine_install_dir --user=$run_user --group=$run_user --with-http_v2_module --with-http_ssl_module --with-http_gzip_static_module --with-http_realip_module --with-http_flv_module --with-http_mp4_module --with-http_concat_module=shared --with-http_sysguard_module=shared --with-openssl=../openssl-$openssl_version --with-pcre=../pcre-$pcre_version --with-pcre-jit --with-jemalloc $nginx_modules_options + make -j ${THREAD} && make install + if [ -e "$tengine_install_dir/conf/nginx.conf" ]; then + popd + rm -rf tengine-$tengine_version echo "${CSUCCESS}Tengine installed successfully! ${CEND}" else - rm -rf ${tengine_install_dir} + rm -rf $tengine_install_dir echo "${CFAILURE}Tengine install failed, Please Contact the author! ${CEND}" - kill -9 $$; exit 1; + kill -9 $$ fi - [ -z "`grep ^'export PATH=' /etc/profile`" ] && echo "export PATH=${tengine_install_dir}/sbin:\$PATH" >> /etc/profile - [ -n "`grep ^'export PATH=' /etc/profile`" -a -z "`grep ${tengine_install_dir} /etc/profile`" ] && sed -i "s@^export PATH=\(.*\)@export PATH=${tengine_install_dir}/sbin:\1@" /etc/profile + [ -z "`grep ^'export PATH=' /etc/profile`" ] && echo "export PATH=$tengine_install_dir/sbin:\$PATH" >> /etc/profile + [ -n "`grep ^'export PATH=' /etc/profile`" -a -z "`grep $tengine_install_dir /etc/profile`" ] && sed -i "s@^export PATH=\(.*\)@export PATH=$tengine_install_dir/sbin:\1@" /etc/profile . /etc/profile - - /bin/cp ../init.d/nginx.service /lib/systemd/system/ - sed -i "s@/usr/local/nginx@${tengine_install_dir}@g" /lib/systemd/system/nginx.service - systemctl enable nginx - - mv ${tengine_install_dir}/conf/nginx.conf{,_bk} - if [ "${apache_flag}" == 'y' ] || [ -e "${apache_install_dir}/bin/httpd" ]; then - /bin/cp ../config/nginx_apache.conf ${tengine_install_dir}/conf/nginx.conf - elif { [[ ${tomcat_option} =~ ^[1-4]$ ]] || [ -e "${tomcat_install_dir}/conf/server.xml" ]; } && { [[ ! ${php_option} =~ ^[1-9]$|^1[0-5]$ ]] && [ ! -e "${php_install_dir}/bin/php" ]; }; then - /bin/cp ../config/nginx_tomcat.conf ${tengine_install_dir}/conf/nginx.conf + + [ "$OS" == 'CentOS' ] && { /bin/cp ../init.d/Nginx-init-CentOS /etc/init.d/nginx; chkconfig --add nginx; chkconfig nginx on; } + [[ $OS =~ ^Ubuntu$|^Debian$ ]] && { /bin/cp ../init.d/Nginx-init-Ubuntu /etc/init.d/nginx; update-rc.d nginx defaults; } + + sed -i "s@/usr/local/nginx@$tengine_install_dir@g" /etc/init.d/nginx + + mv $tengine_install_dir/conf/nginx.conf{,_bk} + if [[ $Apache_version =~ ^[1-2]$ ]]; then + /bin/cp ../config/nginx_apache.conf $tengine_install_dir/conf/nginx.conf + elif [[ $Tomcat_version =~ ^[1-2]$ ]] && [ ! -e "$php_install_dir/bin/php" ]; then + /bin/cp ../config/nginx_tomcat.conf $tengine_install_dir/conf/nginx.conf else - /bin/cp ../config/nginx.conf ${tengine_install_dir}/conf/nginx.conf - [[ "${php_option}" =~ ^[1-9]$|^1[0-5]$ ]] && [ -z "`grep '/php-fpm_status' ${tengine_install_dir}/conf/nginx.conf`" ] && sed -i "s@index index.html index.php;@index index.html index.php;\n location ~ /php-fpm_status {\n #fastcgi_pass remote_php_ip:9000;\n fastcgi_pass unix:/dev/shm/php-cgi.sock;\n fastcgi_index index.php;\n include fastcgi.conf;\n allow 127.0.0.1;\n deny all;\n }@" ${tengine_install_dir}/conf/nginx.conf + /bin/cp ../config/nginx.conf $tengine_install_dir/conf/nginx.conf + [ "$PHP_yn" == 'y' ] && [ -z "`grep '/php-fpm_status' $tengine_install_dir/conf/nginx.conf`" ] && sed -i "s@index index.html index.php;@index index.html index.php;\n location ~ /php-fpm_status {\n #fastcgi_pass remote_php_ip:9000;\n fastcgi_pass unix:/dev/shm/php-cgi.sock;\n fastcgi_index index.php;\n include fastcgi.conf;\n allow 127.0.0.1;\n deny all;\n }@" $tengine_install_dir/conf/nginx.conf fi - cat > ${tengine_install_dir}/conf/proxy.conf << EOF + cat > $tengine_install_dir/conf/proxy.conf << EOF proxy_connect_timeout 300s; proxy_send_timeout 900; proxy_read_timeout 900; @@ -61,15 +70,18 @@ proxy_set_header Cookie \$http_cookie; proxy_set_header Host \$host; proxy_set_header X-Real-IP \$remote_addr; proxy_set_header X-Forwarded-For \$proxy_add_x_forwarded_for; -proxy_set_header X-Forwarded-Proto \$scheme; EOF - sed -i "s@/data/wwwroot/default@${wwwroot_dir}/default@" ${tengine_install_dir}/conf/nginx.conf - sed -i "s@/data/wwwlogs@${wwwlogs_dir}@g" ${tengine_install_dir}/conf/nginx.conf - sed -i "s@^user www www@user ${run_user} ${run_group}@" ${tengine_install_dir}/conf/nginx.conf - + sed -i "s@/data/wwwroot/default@$wwwroot_dir/default@" $tengine_install_dir/conf/nginx.conf + sed -i "s@/data/wwwlogs@$wwwlogs_dir@g" $tengine_install_dir/conf/nginx.conf + sed -i "s@^user www www@user $run_user $run_user@" $tengine_install_dir/conf/nginx.conf + uname -r | awk -F'.' '{if ($1$2>=39)S=0;else S=1}{exit S}' && [ -z "`grep 'reuse_port on;' $tengine_install_dir/conf/nginx.conf`" ] && sed -i "s@worker_connections 51200;@worker_connections 51200;\n reuse_port on;@" $tengine_install_dir/conf/nginx.conf + + # worker_cpu_affinity + sed -i "s@^worker_processes.*@worker_processes auto;\nworker_cpu_affinity auto;\ndso {\n\tload ngx_http_concat_module.so;\n\tload ngx_http_sysguard_module.so;\n}@" $tengine_install_dir/conf/nginx.conf + # logrotate nginx log cat > /etc/logrotate.d/nginx << EOF -${wwwlogs_dir}/*nginx.log { +$wwwlogs_dir/*nginx.log { daily rotate 5 missingok @@ -82,7 +94,7 @@ ${wwwlogs_dir}/*nginx.log { endscript } EOF - popd > /dev/null + popd ldconfig - systemctl start nginx + service nginx start } diff --git a/include/tomcat-10.sh b/include/tomcat-10.sh deleted file mode 100644 index cd1310ae..00000000 --- a/include/tomcat-10.sh +++ /dev/null @@ -1,101 +0,0 @@ -#!/bin/bash -# Author: yeho -# BLOG: https://linuxeye.com - -Install_Tomcat10() { - pushd ${current_dir}/src > /dev/null - . /etc/profile - id -g ${run_group} >/dev/null 2>&1 - [ $? -ne 0 ] && groupadd ${run_group} - id -u ${run_user} >/dev/null 2>&1 - [ $? -ne 0 ] && useradd -g ${run_group} -M -s /bin/bash ${run_user} || { [ -z "$(grep ^${run_user} /etc/passwd | grep '/bin/bash')" ] && usermod -g ${run_group} -s /bin/bash ${run_user}; } - - tar xzf apache-tomcat-${tomcat10_ver}.tar.gz - [ ! -d "${tomcat_install_dir}" ] && mkdir -p ${tomcat_install_dir} - /bin/cp -R apache-tomcat-${tomcat10_ver}/* ${tomcat_install_dir} - rm -rf ${tomcat_install_dir}/webapps/{docs,examples,host-manager,manager,ROOT/*} - - if [ ! -e "${tomcat_install_dir}/conf/server.xml" ]; then - rm -rf ${tomcat_install_dir} - echo "${CFAILURE}Tomcat install failed, Please contact the author! ${CEND}" && grep -Ew 'NAME|ID|ID_LIKE|VERSION_ID|PRETTY_NAME' /etc/os-release - kill -9 $$; exit 1; - fi - - if [ -e "${tomcat_install_dir}/bin/catalina.sh" ]; then - [ ${Mem} -le 768 ] && let Xms_Mem="${Mem}/3" || Xms_Mem=256 - let XmxMem="${Mem}/2" - cat > ${tomcat_install_dir}/bin/setenv.sh << EOF -JAVA_OPTS='-Djava.security.egd=file:/dev/./urandom -server -Xms${Xms_Mem}m -Xmx${XmxMem}m -Dfile.encoding=UTF-8' -# -Djava.rmi.server.hostname=$IPADDR -# -Dcom.sun.management.jmxremote.password.file=\$CATALINA_BASE/conf/jmxremote.password -# -Dcom.sun.management.jmxremote.access.file=\$CATALINA_BASE/conf/jmxremote.access -# -Dcom.sun.management.jmxremote.ssl=false" -EOF - chmod +x ${tomcat_install_dir}/bin/*.sh - /bin/mv ${tomcat_install_dir}/conf/server.xml{,_bk} - /bin/cp ${current_dir}/config/server.xml ${tomcat_install_dir}/conf - sed -i "s@/usr/local/tomcat@${tomcat_install_dir}@g" ${tomcat_install_dir}/conf/server.xml - sed -i '/Http11AprProtocol/d' ${tomcat_install_dir}/conf/server.xml - - if [ ! -e "${nginx_install_dir}/sbin/nginx" -a ! -e "${tengine_install_dir}/sbin/nginx" -a ! -e "${openresty_install_dir}/nginx/sbin/nginx" -a ! -e "${apache_install_dir}/bin/httpd" ]; then - if [ "${PM}" == 'yum' ]; then - if [ "`firewall-cmd --state`" == "running" ]; then - firewall-cmd --permanent --zone=public --add-port=8080/tcp - firewall-cmd --reload - fi - elif [ "${PM}" == 'apt-get' ]; then - if ufw status | grep -wq active; then - ufw allow 8080/tcp - fi - fi - fi - - [ ! -d "${tomcat_install_dir}/conf/vhost" ] && mkdir ${tomcat_install_dir}/conf/vhost - cat > ${tomcat_install_dir}/conf/vhost/localhost.xml << EOF - - - - - -EOF - # logrotate tomcat catalina.out - cat > /etc/logrotate.d/tomcat << EOF -${tomcat_install_dir}/logs/catalina.out { - daily - rotate 5 - missingok - dateext - compress - notifempty - copytruncate -} -EOF - [ -z "$(grep ' /dev/null - echo "${CFAILURE}Tomcat install failed, Please contact the author! ${CEND}" && grep -Ew 'NAME|ID|ID_LIKE|VERSION_ID|PRETTY_NAME' /etc/os-release - fi - service tomcat start - popd > /dev/null -} diff --git a/include/tomcat-9.sh b/include/tomcat-6.sh similarity index 54% rename from include/tomcat-9.sh rename to include/tomcat-6.sh index c45240c9..b81ee4bb 100644 --- a/include/tomcat-9.sh +++ b/include/tomcat-6.sh @@ -1,49 +1,65 @@ #!/bin/bash # Author: yeho -# BLOG: https://linuxeye.com +# BLOG: https://blog.linuxeye.com +# +# Notes: OneinStack for CentOS/RadHat 5+ Debian 6+ and Ubuntu 12+ +# +# Project home page: +# https://oneinstack.com +# https://github.com/lj2007331/oneinstack -Install_Tomcat9() { - pushd ${current_dir}/src > /dev/null +Install_Tomcat6() { + pushd ${oneinstack_dir}/src . /etc/profile - id -g ${run_group} >/dev/null 2>&1 - [ $? -ne 0 ] && groupadd ${run_group} + id -u ${run_user} >/dev/null 2>&1 - [ $? -ne 0 ] && useradd -g ${run_group} -M -s /bin/bash ${run_user} || { [ -z "$(grep ^${run_user} /etc/passwd | grep '/bin/bash')" ] && usermod -g ${run_group} -s /bin/bash ${run_user}; } + [ $? -ne 0 ] && useradd -M -s /bin/bash ${run_user} || { [ -z "$(grep ^${run_user} /etc/passwd | grep '/bin/bash')" ] && usermod -s /bin/bash ${run_user}; } # install apr - if [ ! -e "${apr_install_dir}/bin/apr-1-config" ]; then - tar xzf apr-${apr_ver}.tar.gz - pushd apr-${apr_ver} > /dev/null - ./configure --prefix=${apr_install_dir} + if [ ! -e "/usr/local/apr/bin/apr-1-config" ]; then + tar xzf apr-${apr_version}.tar.gz + pushd apr-${apr_version} + ./configure make -j ${THREAD} && make install - popd > /dev/null - rm -rf apr-${apr_ver} + popd + rm -rf apr-${apr_version} fi - tar xzf apache-tomcat-${tomcat9_ver}.tar.gz + tar xzf apache-tomcat-${tomcat6_version}.tar.gz [ ! -d "${tomcat_install_dir}" ] && mkdir -p ${tomcat_install_dir} - /bin/cp -R apache-tomcat-${tomcat9_ver}/* ${tomcat_install_dir} + /bin/cp -R apache-tomcat-${tomcat6_version}/* ${tomcat_install_dir} rm -rf ${tomcat_install_dir}/webapps/{docs,examples,host-manager,manager,ROOT/*} if [ ! -e "${tomcat_install_dir}/conf/server.xml" ]; then rm -rf ${tomcat_install_dir} - echo "${CFAILURE}Tomcat install failed, Please contact the author! ${CEND}" && grep -Ew 'NAME|ID|ID_LIKE|VERSION_ID|PRETTY_NAME' /etc/os-release - kill -9 $$; exit 1; + echo "${CFAILURE}Tomcat install failed, Please contact the author! ${CEND}" + kill -9 $$ fi - pushd ${tomcat_install_dir}/bin > /dev/null + /bin/cp catalina-jmx-remote.jar ${tomcat_install_dir}/lib + [ ! -d "${tomcat_install_dir}/lib/catalina" ] && mkdir ${tomcat_install_dir}/lib/catalina + pushd ${tomcat_install_dir}/lib/catalina + jar xf ../catalina.jar + sed -i 's@^server.info=.*@server.info=Tomcat@' org/apache/catalina/util/ServerInfo.properties + sed -i 's@^server.number=.*@server.number=6@' org/apache/catalina/util/ServerInfo.properties + sed -i "s@^server.built=.*@server.built=$(date)@" org/apache/catalina/util/ServerInfo.properties + jar cf ../catalina.jar ./* + popd + rm -rf ${tomcat_install_dir}/lib/catalina + + pushd ${tomcat_install_dir}/bin tar xzf tomcat-native.tar.gz - pushd tomcat-native-*-src/native > /dev/null - ./configure --prefix=${apr_install_dir} --with-apr=${apr_install_dir} - make -j ${THREAD} && make install - popd > /dev/null + pushd tomcat-native-*-src/native + ./configure --with-apr=/usr/local/apr --with-ssl=${openssl_install_dir} + make -j ${THREAD} && make install + popd rm -rf tomcat-native-* - if [ -e "${apr_install_dir}/lib/libtcnative-1.la" ]; then + if [ -e "/usr/local/apr/lib/libtcnative-1.la" ]; then [ ${Mem} -le 768 ] && let Xms_Mem="${Mem}/3" || Xms_Mem=256 let XmxMem="${Mem}/2" cat > ${tomcat_install_dir}/bin/setenv.sh << EOF JAVA_OPTS='-Djava.security.egd=file:/dev/./urandom -server -Xms${Xms_Mem}m -Xmx${XmxMem}m -Dfile.encoding=UTF-8' -CATALINA_OPTS="-Djava.library.path=${apr_install_dir}/lib" +CATALINA_OPTS="-Djava.library.path=/usr/local/apr/lib" # -Djava.rmi.server.hostname=$IPADDR # -Dcom.sun.management.jmxremote.password.file=\$CATALINA_BASE/conf/jmxremote.password # -Dcom.sun.management.jmxremote.access.file=\$CATALINA_BASE/conf/jmxremote.access @@ -51,19 +67,21 @@ CATALINA_OPTS="-Djava.library.path=${apr_install_dir}/lib" EOF chmod +x ./*.sh /bin/mv ${tomcat_install_dir}/conf/server.xml{,_bk} - popd # goto ${current_dir}/src - /bin/cp ${current_dir}/config/server.xml ${tomcat_install_dir}/conf - sed -i "s@/usr/local/tomcat@${tomcat_install_dir}@g" ${tomcat_install_dir}/conf/server.xml + popd # goto ${oneinstack_dir}/src - if [ ! -e "${nginx_install_dir}/sbin/nginx" -a ! -e "${tengine_install_dir}/sbin/nginx" -a ! -e "${openresty_install_dir}/nginx/sbin/nginx" -a ! -e "${apache_install_dir}/bin/httpd" ]; then - if [ "${PM}" == 'yum' ]; then - if [ "`firewall-cmd --state`" == "running" ]; then - firewall-cmd --permanent --zone=public --add-port=8080/tcp - firewall-cmd --reload - fi - elif [ "${PM}" == 'apt-get' ]; then - if ufw status | grep -wq active; then - ufw allow 8080/tcp + /bin/cp ${oneinstack_dir}/config/server.xml ${tomcat_install_dir}/conf + sed -i "s@/usr/local/tomcat@${tomcat_install_dir}@g" ${tomcat_install_dir}/conf/server.xml + sed -i /ThreadLocalLeakPreventionListener/d ${tomcat_install_dir}/conf/server.xml + if [ ! -e "${nginx_install_dir}/sbin/nginx" -a ! -e "${tengine_install_dir}/sbin/nginx" -a ! -e "${apache_install_dir}/conf/httpd.conf" ]; then + if [ "${OS}" == "CentOS" ]; then + if [ -z "$(grep -w '8080' /etc/sysconfig/iptables)" ]; then + iptables -I INPUT 5 -p tcp -m state --state NEW -m tcp --dport 8080 -j ACCEPT + service iptables save + fi + elif [[ "${OS}" =~ ^Ubuntu$|^Debian$ ]]; then + if [ -z "$(grep -w '8080' /etc/iptables.up.rules)" ]; then + iptables -I INPUT 5 -p tcp -m state --state NEW -m tcp --dport 8080 -j ACCEPT + iptables-save > /etc/iptables.up.rules fi fi fi @@ -74,8 +92,6 @@ EOF - EOF # logrotate tomcat catalina.out @@ -101,19 +117,19 @@ EOF monitorRole $(cat /dev/urandom | head -1 | md5sum | head -c 8) # controlRole R&D EOF - chown -R ${run_user}:${run_group} ${tomcat_install_dir} - /bin/cp ${current_dir}/init.d/Tomcat-init /etc/init.d/tomcat + chown -R ${run_user}.${run_user} ${tomcat_install_dir} + /bin/cp ${oneinstack_dir}/init.d/Tomcat-init /etc/init.d/tomcat sed -i "s@JAVA_HOME=.*@JAVA_HOME=${JAVA_HOME}@" /etc/init.d/tomcat sed -i "s@^CATALINA_HOME=.*@CATALINA_HOME=${tomcat_install_dir}@" /etc/init.d/tomcat sed -i "s@^TOMCAT_USER=.*@TOMCAT_USER=${run_user}@" /etc/init.d/tomcat - [ "${PM}" == 'yum' ] && { chkconfig --add tomcat; chkconfig tomcat on; } - [ "${PM}" == 'apt-get' ] && update-rc.d tomcat defaults + [ "${OS}" == "CentOS" ] && { chkconfig --add tomcat; chkconfig tomcat on; } + [[ "${OS}" =~ ^Ubuntu$|^Debian$ ]] && update-rc.d tomcat defaults echo "${CSUCCESS}Tomcat installed successfully! ${CEND}" - rm -rf apache-tomcat-${tomcat9_ver} + rm -rf apache-tomcat-${tomcat6_version} else - popd > /dev/null - echo "${CFAILURE}Tomcat install failed, Please contact the author! ${CEND}" && grep -Ew 'NAME|ID|ID_LIKE|VERSION_ID|PRETTY_NAME' /etc/os-release + popd + echo "${CFAILURE}Tomcat install failed, Please contact the author! ${CEND}" fi service tomcat start - popd > /dev/null + popd } diff --git a/include/tomcat-7.sh b/include/tomcat-7.sh index d4a21b58..097a5fb8 100644 --- a/include/tomcat-7.sh +++ b/include/tomcat-7.sh @@ -1,51 +1,65 @@ #!/bin/bash # Author: yeho -# BLOG: https://linuxeye.com +# BLOG: https://blog.linuxeye.com +# +# Notes: OneinStack for CentOS/RadHat 5+ Debian 6+ and Ubuntu 12+ +# +# Project home page: +# https://oneinstack.com +# https://github.com/lj2007331/oneinstack Install_Tomcat7() { - pushd ${current_dir}/src > /dev/null + pushd ${oneinstack_dir}/src . /etc/profile - id -g ${run_group} >/dev/null 2>&1 - [ $? -ne 0 ] && groupadd ${run_group} + id -u ${run_user} >/dev/null 2>&1 - [ $? -ne 0 ] && useradd -g ${run_group} -M -s /bin/bash ${run_user} || { [ -z "$(grep ^${run_user} /etc/passwd | grep '/bin/bash')" ] && usermod -g ${run_group} -s /bin/bash ${run_user}; } + [ $? -ne 0 ] && useradd -M -s /bin/bash ${run_user} || { [ -z "$(grep ^${run_user} /etc/passwd | grep '/bin/bash')" ] && usermod -s /bin/bash ${run_user}; } # install apr - if [ ! -e "${apr_install_dir}/bin/apr-1-config" ]; then - tar xzf apr-${apr_ver}.tar.gz - pushd apr-${apr_ver} > /dev/null - ./configure --prefix=${apr_install_dir} + if [ ! -e "/usr/local/apr/bin/apr-1-config" ]; then + tar xzf apr-${apr_version}.tar.gz + pushd apr-${apr_version} + ./configure make -j ${THREAD} && make install - popd > /dev/null - rm -rf apr-${apr_ver} + popd + rm -rf apr-${apr_version} fi - tar xzf apache-tomcat-${tomcat7_ver}.tar.gz + tar xzf apache-tomcat-${tomcat7_version}.tar.gz [ ! -d "${tomcat_install_dir}" ] && mkdir -p ${tomcat_install_dir} - /bin/cp -R apache-tomcat-${tomcat7_ver}/* ${tomcat_install_dir} + /bin/cp -R apache-tomcat-${tomcat7_version}/* ${tomcat_install_dir} rm -rf ${tomcat_install_dir}/webapps/{docs,examples,host-manager,manager,ROOT/*} if [ ! -e "${tomcat_install_dir}/conf/server.xml" ]; then rm -rf ${tomcat_install_dir} - echo "${CFAILURE}Tomcat install failed, Please contact the author! ${CEND}" && grep -Ew 'NAME|ID|ID_LIKE|VERSION_ID|PRETTY_NAME' /etc/os-release - kill -9 $$; exit 1; + echo "${CFAILURE}Tomcat install failed, Please contact the author! ${CEND}" + kill -9 $$ fi /bin/cp catalina-jmx-remote.jar ${tomcat_install_dir}/lib + [ ! -d "${tomcat_install_dir}/lib/catalina" ] && mkdir ${tomcat_install_dir}/lib/catalina + pushd ${tomcat_install_dir}/lib/catalina + jar xf ../catalina.jar + sed -i 's@^server.info=.*@server.info=Tomcat@' org/apache/catalina/util/ServerInfo.properties + sed -i 's@^server.number=.*@server.number=7@' org/apache/catalina/util/ServerInfo.properties + sed -i "s@^server.built=.*@server.built=$(date)@" org/apache/catalina/util/ServerInfo.properties + jar cf ../catalina.jar ./* + popd + rm -rf ${tomcat_install_dir}/lib/catalina - pushd ${tomcat_install_dir}/bin > /dev/null + pushd ${tomcat_install_dir}/bin tar xzf tomcat-native.tar.gz - pushd tomcat-native-*-src/native > /dev/null - ./configure --prefix=${apr_install_dir} --with-apr=${apr_install_dir} - make -j ${THREAD} && make install - popd > /dev/null + pushd tomcat-native-*-src/native + ./configure --with-apr=/usr/local/apr --with-ssl=${openssl_install_dir} + make -j ${THREAD} && make install + popd rm -rf tomcat-native-* - if [ -e "${apr_install_dir}/lib/libtcnative-1.la" ]; then + if [ -e "/usr/local/apr/lib/libtcnative-1.la" ]; then [ ${Mem} -le 768 ] && let Xms_Mem="${Mem}/3" || Xms_Mem=256 let XmxMem="${Mem}/2" cat > ${tomcat_install_dir}/bin/setenv.sh << EOF JAVA_OPTS='-Djava.security.egd=file:/dev/./urandom -server -Xms${Xms_Mem}m -Xmx${XmxMem}m -Dfile.encoding=UTF-8' -CATALINA_OPTS="-Djava.library.path=${apr_install_dir}/lib" +CATALINA_OPTS="-Djava.library.path=/usr/local/apr/lib" # -Djava.rmi.server.hostname=$IPADDR # -Dcom.sun.management.jmxremote.password.file=\$CATALINA_BASE/conf/jmxremote.password # -Dcom.sun.management.jmxremote.access.file=\$CATALINA_BASE/conf/jmxremote.access @@ -53,19 +67,21 @@ CATALINA_OPTS="-Djava.library.path=${apr_install_dir}/lib" EOF chmod +x ./*.sh /bin/mv ${tomcat_install_dir}/conf/server.xml{,_bk} - popd # goto ${current_dir}/src - /bin/cp ${current_dir}/config/server.xml ${tomcat_install_dir}/conf + popd # goto ${oneinstack_dir}/src + + /bin/cp ${oneinstack_dir}/config/server.xml ${tomcat_install_dir}/conf sed -i "s@/usr/local/tomcat@${tomcat_install_dir}@g" ${tomcat_install_dir}/conf/server.xml - if [ ! -e "${nginx_install_dir}/sbin/nginx" -a ! -e "${tengine_install_dir}/sbin/nginx" -a ! -e "${openresty_install_dir}/nginx/sbin/nginx" -a ! -e "${apache_install_dir}/bin/httpd" ]; then - if [ "${PM}" == 'yum' ]; then - if [ "`firewall-cmd --state`" == "running" ]; then - firewall-cmd --permanent --zone=public --add-port=8080/tcp - firewall-cmd --reload - fi - elif [ "${PM}" == 'apt-get' ]; then - if ufw status | grep -wq active; then - ufw allow 8080/tcp + if [ ! -e "${nginx_install_dir}/sbin/nginx" -a ! -e "${tengine_install_dir}/sbin/nginx" -a ! -e "${apache_install_dir}/conf/httpd.conf" ]; then + if [ "${OS}" == "CentOS" ]; then + if [ -z "$(grep -w '8080' /etc/sysconfig/iptables)" ]; then + iptables -I INPUT 5 -p tcp -m state --state NEW -m tcp --dport 8080 -j ACCEPT + service iptables save + fi + elif [[ "${OS}" =~ ^Ubuntu$|^Debian$ ]]; then + if [ -z "$(grep -w '8080' /etc/iptables.up.rules)" ]; then + iptables -I INPUT 5 -p tcp -m state --state NEW -m tcp --dport 8080 -j ACCEPT + iptables-save > /etc/iptables.up.rules fi fi fi @@ -76,8 +92,6 @@ EOF - EOF # logrotate tomcat catalina.out @@ -103,19 +117,19 @@ EOF monitorRole $(cat /dev/urandom | head -1 | md5sum | head -c 8) # controlRole R&D EOF - chown -R ${run_user}:${run_group} ${tomcat_install_dir} - /bin/cp ${current_dir}/init.d/Tomcat-init /etc/init.d/tomcat + chown -R ${run_user}.${run_user} ${tomcat_install_dir} + /bin/cp ${oneinstack_dir}/init.d/Tomcat-init /etc/init.d/tomcat sed -i "s@JAVA_HOME=.*@JAVA_HOME=${JAVA_HOME}@" /etc/init.d/tomcat sed -i "s@^CATALINA_HOME=.*@CATALINA_HOME=${tomcat_install_dir}@" /etc/init.d/tomcat sed -i "s@^TOMCAT_USER=.*@TOMCAT_USER=${run_user}@" /etc/init.d/tomcat - [ "${PM}" == 'yum' ] && { chkconfig --add tomcat; chkconfig tomcat on; } - [ "${PM}" == 'apt-get' ] && update-rc.d tomcat defaults + [ "${OS}" == "CentOS" ] && { chkconfig --add tomcat; chkconfig tomcat on; } + [[ "${OS}" =~ ^Ubuntu$|^Debian$ ]] && update-rc.d tomcat defaults echo "${CSUCCESS}Tomcat installed successfully! ${CEND}" - rm -rf apache-tomcat-${tomcat7_ver} + rm -rf apache-tomcat-${tomcat7_version} else - popd > /dev/null - echo "${CFAILURE}Tomcat install failed, Please contact the author! ${CEND}" && grep -Ew 'NAME|ID|ID_LIKE|VERSION_ID|PRETTY_NAME' /etc/os-release + popd + echo "${CFAILURE}Tomcat install failed, Please contact the author! ${CEND}" fi service tomcat start - popd > /dev/null + popd } diff --git a/include/tomcat-8.sh b/include/tomcat-8.sh index 1990bb84..22cf7a4b 100644 --- a/include/tomcat-8.sh +++ b/include/tomcat-8.sh @@ -1,49 +1,65 @@ #!/bin/bash # Author: yeho -# BLOG: https://linuxeye.com +# BLOG: https://blog.linuxeye.com +# +# Notes: OneinStack for CentOS/RadHat 5+ Debian 6+ and Ubuntu 12+ +# +# Project home page: +# https://oneinstack.com +# https://github.com/lj2007331/oneinstack Install_Tomcat8() { - pushd ${current_dir}/src > /dev/null + pushd ${oneinstack_dir}/src . /etc/profile - id -g ${run_group} >/dev/null 2>&1 - [ $? -ne 0 ] && groupadd ${run_group} + id -u ${run_user} >/dev/null 2>&1 - [ $? -ne 0 ] && useradd -g ${run_group} -M -s /bin/bash ${run_user} || { [ -z "$(grep ^${run_user} /etc/passwd | grep '/bin/bash')" ] && usermod -g ${run_group} -s /bin/bash ${run_user}; } + [ $? -ne 0 ] && useradd -M -s /bin/bash ${run_user} || { [ -z "$(grep ^${run_user} /etc/passwd | grep '/bin/bash')" ] && usermod -s /bin/bash ${run_user}; } # install apr - if [ ! -e "${apr_install_dir}/bin/apr-1-config" ]; then - tar xzf apr-${apr_ver}.tar.gz - pushd apr-${apr_ver} > /dev/null - ./configure --prefix=${apr_install_dir} + if [ ! -e "/usr/local/apr/bin/apr-1-config" ]; then + tar xzf apr-${apr_version}.tar.gz + pushd apr-${apr_version} + ./configure make -j ${THREAD} && make install - popd > /dev/null - rm -rf apr-${apr_ver} + popd + rm -rf apr-${apr_version} fi - tar xzf apache-tomcat-${tomcat8_ver}.tar.gz + tar xzf apache-tomcat-${tomcat8_version}.tar.gz [ ! -d "${tomcat_install_dir}" ] && mkdir -p ${tomcat_install_dir} - /bin/cp -R apache-tomcat-${tomcat8_ver}/* ${tomcat_install_dir} + /bin/cp -R apache-tomcat-${tomcat8_version}/* ${tomcat_install_dir} rm -rf ${tomcat_install_dir}/webapps/{docs,examples,host-manager,manager,ROOT/*} if [ ! -e "${tomcat_install_dir}/conf/server.xml" ]; then rm -rf ${tomcat_install_dir} - echo "${CFAILURE}Tomcat install failed, Please contact the author! ${CEND}" && grep -Ew 'NAME|ID|ID_LIKE|VERSION_ID|PRETTY_NAME' /etc/os-release - kill -9 $$; exit 1; + echo "${CFAILURE}Tomcat install failed, Please contact the author! ${CEND}" + kill -9 $$ fi - pushd ${tomcat_install_dir}/bin > /dev/null + /bin/cp catalina-jmx-remote.jar ${tomcat_install_dir}/lib + [ ! -d "${tomcat_install_dir}/lib/catalina" ] && mkdir ${tomcat_install_dir}/lib/catalina + pushd ${tomcat_install_dir}/lib/catalina + jar xf ../catalina.jar + sed -i 's@^server.info=.*@server.info=Tomcat@' org/apache/catalina/util/ServerInfo.properties + sed -i 's@^server.number=.*@server.number=8@' org/apache/catalina/util/ServerInfo.properties + sed -i "s@^server.built=.*@server.built=$(date)@" org/apache/catalina/util/ServerInfo.properties + jar cf ../catalina.jar ./* + popd + rm -rf ${tomcat_install_dir}/lib/catalina + + pushd ${tomcat_install_dir}/bin tar xzf tomcat-native.tar.gz - pushd tomcat-native-*-src/native > /dev/null - ./configure --prefix=${apr_install_dir} --with-apr=${apr_install_dir} - make -j ${THREAD} && make install - popd > /dev/null + pushd tomcat-native-*-src/native + ./configure --with-apr=/usr/local/apr --with-ssl=${openssl_install_dir} + make -j ${THREAD} && make install + popd rm -rf tomcat-native-* - if [ -e "${apr_install_dir}/lib/libtcnative-1.la" ]; then + if [ -e "/usr/local/apr/lib/libtcnative-1.la" ]; then [ ${Mem} -le 768 ] && let Xms_Mem="${Mem}/3" || Xms_Mem=256 let XmxMem="${Mem}/2" cat > ${tomcat_install_dir}/bin/setenv.sh << EOF JAVA_OPTS='-Djava.security.egd=file:/dev/./urandom -server -Xms${Xms_Mem}m -Xmx${XmxMem}m -Dfile.encoding=UTF-8' -CATALINA_OPTS="-Djava.library.path=${apr_install_dir}/lib" +CATALINA_OPTS="-Djava.library.path=/usr/local/apr/lib" # -Djava.rmi.server.hostname=$IPADDR # -Dcom.sun.management.jmxremote.password.file=\$CATALINA_BASE/conf/jmxremote.password # -Dcom.sun.management.jmxremote.access.file=\$CATALINA_BASE/conf/jmxremote.access @@ -51,19 +67,21 @@ CATALINA_OPTS="-Djava.library.path=${apr_install_dir}/lib" EOF chmod +x ./*.sh /bin/mv ${tomcat_install_dir}/conf/server.xml{,_bk} - popd # goto ${current_dir}/src - /bin/cp ${current_dir}/config/server.xml ${tomcat_install_dir}/conf + popd # goto ${oneinstack_dir}/src + + /bin/cp ${oneinstack_dir}/config/server.xml ${tomcat_install_dir}/conf sed -i "s@/usr/local/tomcat@${tomcat_install_dir}@g" ${tomcat_install_dir}/conf/server.xml - if [ ! -e "${nginx_install_dir}/sbin/nginx" -a ! -e "${tengine_install_dir}/sbin/nginx" -a ! -e "${openresty_install_dir}/nginx/sbin/nginx" -a ! -e "${apache_install_dir}/bin/httpd" ]; then - if [ "${PM}" == 'yum' ]; then - if [ "`firewall-cmd --state`" == "running" ]; then - firewall-cmd --permanent --zone=public --add-port=8080/tcp - firewall-cmd --reload - fi - elif [ "${PM}" == 'apt-get' ]; then - if ufw status | grep -wq active; then - ufw allow 8080/tcp + if [ ! -e "${nginx_install_dir}/sbin/nginx" -a ! -e "${tengine_install_dir}/sbin/nginx" -a ! -e "${apache_install_dir}/conf/httpd.conf" ]; then + if [ "${OS}" == "CentOS" ]; then + if [ -z "$(grep -w '8080' /etc/sysconfig/iptables)" ]; then + iptables -I INPUT 5 -p tcp -m state --state NEW -m tcp --dport 8080 -j ACCEPT + service iptables save + fi + elif [[ "${OS}" =~ ^Ubuntu$|^Debian$ ]]; then + if [ -z "$(grep -w '8080' /etc/iptables.up.rules)" ]; then + iptables -I INPUT 5 -p tcp -m state --state NEW -m tcp --dport 8080 -j ACCEPT + iptables-save > /etc/iptables.up.rules fi fi fi @@ -74,8 +92,6 @@ EOF - EOF # logrotate tomcat catalina.out @@ -101,19 +117,19 @@ EOF monitorRole $(cat /dev/urandom | head -1 | md5sum | head -c 8) # controlRole R&D EOF - chown -R ${run_user}:${run_group} ${tomcat_install_dir} - /bin/cp ${current_dir}/init.d/Tomcat-init /etc/init.d/tomcat + chown -R ${run_user}.${run_user} ${tomcat_install_dir} + /bin/cp ${oneinstack_dir}/init.d/Tomcat-init /etc/init.d/tomcat sed -i "s@JAVA_HOME=.*@JAVA_HOME=${JAVA_HOME}@" /etc/init.d/tomcat sed -i "s@^CATALINA_HOME=.*@CATALINA_HOME=${tomcat_install_dir}@" /etc/init.d/tomcat sed -i "s@^TOMCAT_USER=.*@TOMCAT_USER=${run_user}@" /etc/init.d/tomcat - [ "${PM}" == 'yum' ] && { chkconfig --add tomcat; chkconfig tomcat on; } - [ "${PM}" == 'apt-get' ] && update-rc.d tomcat defaults + [ "${OS}" == "CentOS" ] && { chkconfig --add tomcat; chkconfig tomcat on; } + [[ "${OS}" =~ ^Ubuntu$|^Debian$ ]] && update-rc.d tomcat defaults echo "${CSUCCESS}Tomcat installed successfully! ${CEND}" - rm -rf apache-tomcat-${tomcat8_ver} + rm -rf apache-tomcat-${tomcat8_version} else - popd > /dev/null - echo "${CFAILURE}Tomcat install failed, Please contact the author! ${CEND}" && grep -Ew 'NAME|ID|ID_LIKE|VERSION_ID|PRETTY_NAME' /etc/os-release + popd + echo "${CFAILURE}Tomcat install failed, Please contact the author! ${CEND}" fi service tomcat start - popd > /dev/null + popd } diff --git a/include/upgrade_db.sh b/include/upgrade_db.sh index ebb81574..192200f2 100644 --- a/include/upgrade_db.sh +++ b/include/upgrade_db.sh @@ -1,172 +1,180 @@ #!/bin/bash # Author: yeho -# BLOG: https://linuxeye.com +# BLOG: https://blog.linuxeye.com +# +# Notes: OneinStack for CentOS/RadHat 5+ Debian 6+ and Ubuntu 12+ +# +# Project home page: +# https://oneinstack.com +# https://github.com/lj2007331/oneinstack Upgrade_DB() { - pushd ${current_dir}/src > /dev/null - [ ! -e "${db_install_dir}/bin/mysql" ] && echo "${CWARNING}MySQL/MariaDB/Percona is not installed on your system! ${CEND}" && exit 1 - [ "${armplatform}" == 'y' ] && echo "${CWARNING}The arm architecture operating system does not support upgrading MySQL/MariaDB/Percona! ${CEND}" && exit 1 + pushd ${oneinstack_dir}/src > /dev/null + [ ! -e "$db_install_dir/bin/mysql" ] && echo "${CWARNING}MySQL/MariaDB/Percona is not installed on your system! ${CEND}" && exit 1 + OLD_DB_version_tmp=`$db_install_dir/bin/mysql -V | awk '{print $5}' | awk -F, '{print $1}'` + DB_tmp=`echo $OLD_DB_version_tmp | awk -F'-' '{print $2}'` + if [ "$DB_tmp" == 'MariaDB' ]; then + [ "$IPADDR_COUNTRY"x == "CN"x ] && DOWN_ADDR=https://mirrors.tuna.tsinghua.edu.cn/mariadb || DOWN_ADDR=https://downloads.mariadb.org/f + DB=MariaDB + OLD_DB_version=`echo $OLD_DB_version_tmp | awk -F'-' '{print $1}'` + elif [ -n "$DB_tmp" -a "$DB_tmp" != 'MariaDB' ]; then + DB=Percona + OLD_DB_version=$OLD_DB_version_tmp + else + [ "$IPADDR_COUNTRY"x == "CN"x ] && DOWN_ADDR=https://mirrors.tuna.tsinghua.edu.cn/mysql/downloads || DOWN_ADDR=http://cdn.mysql.com/Downloads + DB=MySQL + OLD_DB_version=$OLD_DB_version_tmp + fi - # check db passwd + #backup while :; do - ${db_install_dir}/bin/mysql -uroot -p${dbrootpwd} -e "quit" > /dev/null 2>&1 + $db_install_dir/bin/mysql -uroot -p${dbrootpwd} -e "quit" >/dev/null 2>&1 if [ $? -eq 0 ]; then break else echo - read -e -p "Please input the root password of database: " NEW_dbrootpwd - ${db_install_dir}/bin/mysql -uroot -p${NEW_dbrootpwd} -e "quit" >/dev/null 2>&1 + read -p "Please input the root password of database: " NEW_dbrootpwd + $db_install_dir/bin/mysql -uroot -p${NEW_dbrootpwd} -e "quit" >/dev/null 2>&1 if [ $? -eq 0 ]; then - dbrootpwd=${NEW_dbrootpwd} + dbrootpwd=$NEW_dbrootpwd sed -i "s+^dbrootpwd.*+dbrootpwd='$dbrootpwd'+" ../options.conf break else - echo "${CFAILURE}${DB} root password incorrect,Please enter again! ${CEND}" + echo "${CFAILURE}$DB root password incorrect,Please enter again! ${CEND}" fi fi done - OLD_db_ver_tmp=`${db_install_dir}/bin/mysql -uroot -p${dbrootpwd} -e 'select version()\G;' | grep version | awk '{print $2}'` - if [ -n "`${db_install_dir}/bin/mysql -V | grep -o MariaDB`" ]; then - [ "${OUTIP_STATE}"x == "China"x ] && DOWN_ADDR=https://mirrors.tuna.tsinghua.edu.cn/mariadb || DOWN_ADDR=https://archive.mariadb.org - DB=MariaDB - OLD_db_ver=`echo ${OLD_db_ver_tmp} | awk -F'-' '{print $1}'` - elif [ -n "`${db_install_dir}/bin/mysql -V | grep -o Percona`" ]; then - DB=Percona - OLD_db_ver=${OLD_db_ver_tmp} - else - #[ "${OUTIP_STATE}"x == "China"x ] && DOWN_ADDR=http://mirrors.ustc.edu.cn/mysql-ftp/Downloads || DOWN_ADDR=http://cdn.mysql.com/Downloads - DOWN_ADDR=http://cdn.mysql.com/Downloads - DB=MySQL - OLD_db_ver=${OLD_db_ver_tmp%%-log} - fi - - #backup echo - echo "${CSUCCESS}Starting ${DB} backup${CEND}......" - ${db_install_dir}/bin/mysqldump -uroot -p${dbrootpwd} --opt --all-databases > DB_all_backup_$(date +"%Y%m%d").sql - [ -f "DB_all_backup_$(date +"%Y%m%d").sql" ] && echo "${DB} backup success, Backup file: ${MSG}`pwd`/DB_all_backup_$(date +"%Y%m%d").sql${CEND}" - + echo "${CSUCCESS}Starting $DB backup${CEND}......" + $db_install_dir/bin/mysqldump -uroot -p${dbrootpwd} --opt --all-databases > DB_all_backup_$(date +"%Y%m%d").sql + [ -f "DB_all_backup_$(date +"%Y%m%d").sql" ] && echo "$DB backup success, Backup file: ${MSG}`pwd`/DB_all_backup_$(date +"%Y%m%d").sql${CEND}" + #upgrade echo - echo "Current ${DB} Version: ${CMSG}${OLD_db_ver}${CEND}" + echo "Current $DB Version: ${CMSG}$OLD_DB_version${CEND}" while :; do echo - [ "${db_flag}" != 'y' ] && read -e -p "Please input upgrade ${DB} Version(example: ${OLD_db_ver}): " NEW_db_ver - if [ `echo ${NEW_db_ver} | awk -F. '{print $1"."$2}'` == `echo ${OLD_db_ver} | awk -F. '{print $1"."$2}'` ]; then - if [ "${DB}" == 'MariaDB' ]; then - DB_filename=mariadb-${NEW_db_ver}-linux-systemd-x86_64 - DB_URL=${DOWN_ADDR}/mariadb-${NEW_db_ver}/bintar-linux-systemd-x86_64/${DB_filename}.tar.gz - elif [ "${DB}" == 'Percona' ]; then - if [[ "`echo ${NEW_db_ver} | awk -F. '{print $1"."$2}'`" =~ ^5.[5-6]$ ]]; then - perconaVerStr1=$(echo ${NEW_db_ver} | sed "s@-@-rel@") - else - perconaVerStr1=${NEW_db_ver} - fi - if [[ "`echo ${NEW_db_ver} | awk -F. '{print $1"."$2}'`" =~ ^8.4$|^8.0$|^5.7$ ]]; then - DB_filename=Percona-Server-${perconaVerStr1}-Linux.x86_64.glibc2.35 - else - DB_filename=Percona-Server-${perconaVerStr1}-Linux.x86_64.${sslLibVer} - fi - DB_URL=https://www.percona.com/downloads/Percona-Server-`echo ${NEW_db_ver} | awk -F. '{print $1"."$2}'`/Percona-Server-${NEW_db_ver}/binary/tarball/${DB_filename}.tar.gz - elif [ "${DB}" == 'MySQL' ]; then - if [ `echo ${OLD_db_ver} | awk -F. '{print $1"."$2}'` =~ ^8.4$|^8.0$ ]; then - DB_filename=mysql-${NEW_db_ver}-linux-glibc2.28-x86_64 - DB_URL=${DOWN_ADDR}/MySQL-`echo ${NEW_db_ver} | awk -F. '{print $1"."$2}'`/${DB_filename}.tar.xz + read -p "Please input upgrade $DB Version(example: $OLD_DB_version): " NEW_DB_version + if [ `echo $NEW_DB_version | awk -F. '{print $1"."$2}'` == `echo $OLD_DB_version | awk -F. '{print $1"."$2}'` ]; then + if [ "$DB" == 'MariaDB' ]; then + DB_name=mariadb-${NEW_DB_version}-${GLIBC_FLAG}-${SYS_BIT_b} + DB_URL=$DOWN_ADDR/mariadb-${NEW_DB_version}/bintar-${GLIBC_FLAG}-$SYS_BIT_a/$DB_name.tar.gz + elif [ "$DB" == 'Percona' ]; then + DB_name=percona-server-$NEW_DB_version + DB_URL=http://www.percona.com/redir/downloads/Percona-Server-`echo $NEW_DB_version | awk -F. '{print $1"."$2}'`/LATEST/source/tarball/$DB_name.tar.gz + elif [ "$DB" == 'MySQL' ]; then + DB_URL=$DOWN_ADDR/MySQL-`echo $NEW_DB_version | awk -F. '{print $1"."$2}'`/$DB_name.tar.gz + fi + [ ! -e "$DB_name.tar.gz" ] && wget --no-check-certificate -c $DB_URL > /dev/null 2>&1 + if [ -e "$DB_name.tar.gz" ]; then + echo "Download [${CMSG}$DB_name.tar.gz${CEND}] successfully! " else - DB_filename=mysql-${NEW_db_ver}-linux-glibc2.12-x86_64 - DB_URL=${DOWN_ADDR}/MySQL-`echo ${NEW_db_ver} | awk -F. '{print $1"."$2}'`/${DB_filename}.tar.gz + echo "${CWARNING}$DB version does not exist! ${CEND}" fi - fi - [ ! -e "`ls ${DB_filename}.tar.?z 2>/dev/null`" ] && wget --no-check-certificate -c ${DB_URL} > /dev/null 2>&1 - if [ -e "`ls ${DB_filename}.tar.?z 2>/dev/null`" ]; then - echo "Download [${CMSG}`ls ${DB_filename}.tar.?z 2>/dev/null`${CEND}] successfully! " - else - echo "${CWARNING}${DB} version does not exist! ${CEND}" - fi - break + break else - echo "${CWARNING}input error! ${CEND}Please only input '${CMSG}${OLD_db_ver%.*}.xx${CEND}'" - [ "${db_flag}" == 'y' ] && exit + echo "${CWARNING}input error! ${CEND}Please only input '${CMSG}${OLD_DB_version%.*}.xx${CEND}'" fi done - if [ -e "`ls ${DB_filename}.tar.?z 2>/dev/null`" ]; then - echo "[${CMSG}`ls ${DB_filename}.tar.?z 2>/dev/null`${CEND}] found" - if [ "${db_flag}" != 'y' ]; then - echo "Press Ctrl+c to cancel or Press any key to continue..." - char=`get_char` - fi - if [ "${DB}" == 'MariaDB' ]; then - tar xzf ${DB_filename}.tar.gz + if [ -e "$DB_name.tar.gz" ]; then + echo "[${CMSG}$DB_name.tar.gz${CEND}] found" + echo "Press Ctrl+c to cancel or Press any key to continue..." + char=`get_char` + if [ "$DB" == 'MariaDB' ]; then service mysqld stop mv ${mariadb_install_dir}{,_old_`date +"%Y%m%d_%H%M%S"`} mv ${mariadb_data_dir}{,_old_`date +"%Y%m%d_%H%M%S"`} - [ ! -d "${mariadb_install_dir}" ] && mkdir -p ${mariadb_install_dir} - mkdir -p ${mariadb_data_dir};chown mysql:mysql -R ${mariadb_data_dir} - mv ${DB_filename}/* ${mariadb_install_dir}/ - sed -i 's@executing mysqld_safe@executing mysqld_safe\nexport LD_PRELOAD=/usr/local/lib/libjemalloc.so@' ${mariadb_install_dir}/bin/mysqld_safe - ${mariadb_install_dir}/scripts/mysql_install_db --user=mysql --basedir=${mariadb_install_dir} --datadir=${mariadb_data_dir} - chown mysql:mysql -R ${mariadb_data_dir} + mkdir -p $mariadb_data_dir;chown mysql.mysql -R $mariadb_data_dir + tar xzf $DB_name.tar.gz + [ ! -d "$mariadb_install_dir" ] && mkdir -p $mariadb_install_dir + mv mariadb-${NEW_DB_version}-*-${SYS_BIT_b}/* $mariadb_install_dir + sed -i 's@executing mysqld_safe@executing mysqld_safe\nexport LD_PRELOAD=/usr/local/lib/libjemalloc.so@' $mariadb_install_dir/bin/mysqld_safe + $mariadb_install_dir/scripts/mysql_install_db --user=mysql --basedir=$mariadb_install_dir --datadir=$mariadb_data_dir + chown mysql.mysql -R $mariadb_data_dir service mysqld start - ${mariadb_install_dir}/bin/mysql < DB_all_backup_$(date +"%Y%m%d").sql + $mariadb_install_dir/bin/mysql < DB_all_backup_$(date +"%Y%m%d").sql service mysqld restart - ${mariadb_install_dir}/bin/mysql -uroot -p${dbrootpwd} -e "drop database test;" >/dev/null 2>&1 - ${mariadb_install_dir}/bin/mysql -uroot -p${dbrootpwd} -e "reset master;" >/dev/null 2>&1 - ${mariadb_install_dir}/bin/mysql_upgrade -uroot -p${dbrootpwd} >/dev/null 2>&1 - [ $? -eq 0 ] && echo "You have ${CMSG}successfully${CEND} upgrade from ${CMSG}${OLD_db_ver}${CEND} to ${CMSG}${NEW_db_ver}${CEND}" - elif [ "${DB}" == 'Percona' ]; then - tar xzf ${DB_filename}.tar.gz + $mariadb_install_dir/bin/mysql -uroot -p${dbrootpwd} -e "drop database test;" >/dev/null 2>&1 + $mariadb_install_dir/bin/mysql -uroot -p${dbrootpwd} -e "reset master;" >/dev/null 2>&1 + [ $? -eq 0 ] && echo "You have ${CMSG}successfully${CEND} upgrade from ${CMSG}$OLD_DB_version${CEND} to ${CMSG}$NEW_DB_version${CEND}" + elif [ "$DB" == 'Percona' ]; then + tar zxf $DB_name.tar.gz + pushd $DB_name + make clean + if [ "`echo $NEW_DB_version | awk -F. '{print $1"."$2}'`" == '5.5' ]; then + cmake . -DCMAKE_INSTALL_PREFIX=$percona_install_dir \ + -DMYSQL_DATADIR=$percona_data_dir \ + -DSYSCONFDIR=/etc \ + -DWITH_INNOBASE_STORAGE_ENGINE=1 \ + -DWITH_PARTITION_STORAGE_ENGINE=1 \ + -DWITH_FEDERATED_STORAGE_ENGINE=1 \ + -DWITH_BLACKHOLE_STORAGE_ENGINE=1 \ + -DWITH_MYISAM_STORAGE_ENGINE=1 \ + -DWITH_ARCHIVE_STORAGE_ENGINE=1 \ + -DWITH_READLINE=1 \ + -DENABLE_DTRACE=0 \ + -DENABLED_LOCAL_INFILE=1 \ + -DDEFAULT_CHARSET=utf8mb4 \ + -DDEFAULT_COLLATION=utf8mb4_general_ci \ + -DCMAKE_EXE_LINKER_FLAGS='-ljemalloc' + else + cmake . -DCMAKE_INSTALL_PREFIX=$percona_install_dir \ + -DMYSQL_DATADIR=$percona_data_dir \ + -DSYSCONFDIR=/etc \ + -DWITH_INNOBASE_STORAGE_ENGINE=1 \ + -DWITH_PARTITION_STORAGE_ENGINE=1 \ + -DWITH_FEDERATED_STORAGE_ENGINE=1 \ + -DWITH_BLACKHOLE_STORAGE_ENGINE=1 \ + -DWITH_MYISAM_STORAGE_ENGINE=1 \ + -DWITH_ARCHIVE_STORAGE_ENGINE=1 \ + -DENABLED_LOCAL_INFILE=1 \ + -DENABLE_DTRACE=0 \ + -DDEFAULT_CHARSET=utf8mb4 \ + -DDEFAULT_COLLATION=utf8mb4_general_ci \ + -DCMAKE_EXE_LINKER_FLAGS='-ljemalloc' + fi + make -j ${THREAD} service mysqld stop mv ${percona_install_dir}{,_old_`date +"%Y%m%d_%H%M%S"`} mv ${percona_data_dir}{,_old_`date +"%Y%m%d_%H%M%S"`} - [ ! -d "${percona_install_dir}" ] && mkdir -p ${percona_install_dir} - mkdir -p ${percona_data_dir};chown mysql:mysql -R ${percona_data_dir} - mv ${DB_filename}/* ${percona_install_dir}/ - sed -i 's@executing mysqld_safe@executing mysqld_safe\nexport LD_PRELOAD=/usr/local/lib/libjemalloc.so@' ${percona_install_dir}/bin/mysqld_safe - sed -i "s@/usr/local/${DB_filename}@${percona_install_dir}@g" ${percona_install_dir}/bin/mysqld_safe - if [[ "`echo ${NEW_db_ver} | awk -F. '{print $1"."$2}'`" =~ ^5.[5-6]$ ]]; then - ${percona_install_dir}/scripts/mysql_install_db --user=mysql --basedir=${percona_install_dir} --datadir=${percona_data_dir} + [ ! -d "$percona_install_dir" ] && mkdir -p $percona_install_dir + mkdir -p $percona_data_dir;chown mysql.mysql -R $percona_data_dir + make install + popd + if [ "`echo $NEW_DB_version | awk -F. '{print $1"."$2}'`" == '5.7' ]; then + $percona_install_dir/bin/mysqld --initialize-insecure --user=mysql --basedir=$percona_install_dir --datadir=$percona_data_dir else - ${percona_install_dir}/bin/mysqld --initialize-insecure --user=mysql --basedir=${percona_install_dir} --datadir=${percona_data_dir} + $percona_install_dir/scripts/mysql_install_db --user=mysql --basedir=$percona_install_dir --datadir=$percona_data_dir fi - chown mysql:mysql -R ${percona_data_dir} + chown mysql.mysql -R $percona_data_dir service mysqld start - ${percona_install_dir}/bin/mysql < DB_all_backup_$(date +"%Y%m%d").sql + $percona_install_dir/bin/mysql < DB_all_backup_$(date +"%Y%m%d").sql service mysqld restart - ${percona_install_dir}/bin/mysql -uroot -p${dbrootpwd} -e "drop database test;" >/dev/null 2>&1 - ${percona_install_dir}/bin/mysql -uroot -p${dbrootpwd} -e "reset master;" >/dev/null 2>&1 - ${percona_install_dir}/bin/mysql_upgrade -uroot -p${dbrootpwd} >/dev/null 2>&1 - [ $? -eq 0 ] && echo "You have ${CMSG}successfully${CEND} upgrade from ${CMSG}${OLD_db_ver}${CEND} to ${CMSG}${NEW_db_ver}${CEND}" - elif [ "${DB}" == 'MySQL' ]; then - if [ `echo ${OLD_db_ver} | awk -F. '{print $1"."$2}'` == '8.0' ]; then - tar xJf ${DB_filename}.tar.xz - else - tar xzf ${DB_filename}.tar.gz - fi + $percona_install_dir/bin/mysql -uroot -p${dbrootpwd} -e "drop database test;" >/dev/null 2>&1 + $percona_install_dir/bin/mysql -uroot -p${dbrootpwd} -e "reset master;" >/dev/null 2>&1 + [ $? -eq 0 ] && echo "You have ${CMSG}successfully${CEND} upgrade from ${CMSG}$OLD_DB_version${CEND} to ${CMSG}$NEW_DB_version${CEND}" + elif [ "$DB" == 'MySQL' ]; then + tar zxf $DB_name.tar.gz service mysqld stop mv ${mysql_install_dir}{,_old_`date +"%Y%m%d_%H%M%S"`} mv ${mysql_data_dir}{,_old_`date +"%Y%m%d_%H%M%S"`} - [ ! -d "${mysql_install_dir}" ] && mkdir -p ${mysql_install_dir} - mkdir -p ${mysql_data_dir};chown mysql:mysql -R ${mysql_data_dir} - mv ${DB_filename}/* ${mysql_install_dir}/ - sed -i 's@executing mysqld_safe@executing mysqld_safe\nexport LD_PRELOAD=/usr/local/lib/libjemalloc.so@' ${mysql_install_dir}/bin/mysqld_safe + [ ! -d "$mysql_install_dir" ] && mkdir -p $mysql_install_dir + mkdir -p $mysql_data_dir;chown mysql.mysql -R $mysql_data_dir + mv $DB_name/* $mysql_install_dir/ + sed -i 's@executing mysqld_safe@executing mysqld_safe\nexport LD_PRELOAD=/usr/local/lib/libjemalloc.so@' $mysql_install_dir/bin/mysqld_safe sed -i "s@/usr/local/mysql@${mysql_install_dir}@g" ${mysql_install_dir}/bin/mysqld_safe - if [[ "`echo ${NEW_db_ver} | awk -F. '{print $1"."$2}'`" =~ ^5.[5-6]$ ]]; then - ${mysql_install_dir}/scripts/mysql_install_db --user=mysql --basedir=${mysql_install_dir} --datadir=${mysql_data_dir} - else - ${mysql_install_dir}/bin/mysqld --initialize-insecure --user=mysql --basedir=${mysql_install_dir} --datadir=${mysql_data_dir} - fi + [ "`echo $NEW_DB_version | awk -F. '{print $1"."$2}'`" != '5.7' ] && $mysql_install_dir/scripts/mysql_install_db --user=mysql --basedir=$mysql_install_dir --datadir=$mysql_data_dir + [ "`echo $NEW_DB_version | awk -F. '{print $1"."$2}'`" == '5.7' ] && $mysql_install_dir/bin/mysqld --initialize-insecure --user=mysql --basedir=$mysql_install_dir --datadir=$mysql_data_dir - chown mysql:mysql -R ${mysql_data_dir} - [ -e "${mysql_install_dir}/my.cnf" ] && rm -rf ${mysql_install_dir}/my.cnf - sed -i '/myisam_repair_threads/d' /etc/my.cnf + chown mysql.mysql -R $mysql_data_dir + [ -e "$mysql_install_dir/my.cnf" ] && rm -rf $mysql_install_dir/my.cnf service mysqld start - ${mysql_install_dir}/bin/mysql < DB_all_backup_$(date +"%Y%m%d").sql + $mysql_install_dir/bin/mysql < DB_all_backup_$(date +"%Y%m%d").sql service mysqld restart - ${mysql_install_dir}/bin/mysql -uroot -p${dbrootpwd} -e "drop database test;" >/dev/null 2>&1 - ${mysql_install_dir}/bin/mysql -uroot -p${dbrootpwd} -e "reset master;" >/dev/null 2>&1 - ${mysql_install_dir}/bin/mysql_upgrade -uroot -p${dbrootpwd} >/dev/null 2>&1 - [ $? -eq 0 ] && echo "You have ${CMSG}successfully${CEND} upgrade from ${CMSG}${OLD_db_ver}${CEND} to ${CMSG}${NEW_db_ver}${CEND}" + $mysql_install_dir/bin/mysql -uroot -p${dbrootpwd} -e "drop database test;" >/dev/null 2>&1 + $mysql_install_dir/bin/mysql -uroot -p${dbrootpwd} -e "reset master;" >/dev/null 2>&1 + [ $? -eq 0 ] && echo "You have ${CMSG}successfully${CEND} upgrade from ${CMSG}$OLD_DB_version${CEND} to ${CMSG}$NEW_DB_version${CEND}" fi fi } diff --git a/include/upgrade_memcached.sh b/include/upgrade_memcached.sh index 9a4f0112..cae33d2c 100644 --- a/include/upgrade_memcached.sh +++ b/include/upgrade_memcached.sh @@ -1,40 +1,39 @@ #!/bin/bash # Author: yeho -# BLOG: https://linuxeye.com +# BLOG: https://blog.linuxeye.com +# +# Notes: OneinStack for CentOS/RadHat 5+ Debian 6+ and Ubuntu 12+ +# +# Project home page: +# https://oneinstack.com +# https://github.com/lj2007331/oneinstack Upgrade_Memcached() { - pushd ${current_dir}/src > /dev/null + pushd ${oneinstack_dir}/src > /dev/null [ ! -e "${memcached_install_dir}/bin/memcached" ] && echo "${CWARNING}Memcached is not installed on your system! ${CEND}" && exit 1 - OLD_memcached_ver=`${memcached_install_dir}/bin/memcached -V | awk '{print $2}'` - Latest_memcached_ver=`curl --connect-timeout 2 -m 3 -s https://github.com/memcached/memcached/wiki/ReleaseNotes | grep 'internal present.*ReleaseNotes' | grep -oE "[0-9]\.[0-9]\.[0-9]+" | head -1` - Latest_memcached_ver=${Latest_memcached_ver:-1.5.12} - echo "Current Memcached Version: ${CMSG}${OLD_memcached_ver}${CEND}" + OLD_Memcached_version=`$memcached_install_dir/bin/memcached -V | awk '{print $2}'` + echo "Current Memcached Version: ${CMSG}$OLD_Memcached_version${CEND}" while :; do echo - [ "${memcached_flag}" != 'y' ] && read -e -p "Please input upgrade Memcached Version(default: ${Latest_memcached_ver}): " NEW_memcached_ver - NEW_memcached_ver=${NEW_memcached_ver:-${Latest_memcached_ver}} - if [ "${NEW_memcached_ver}" != "${OLD_memcached_ver}" ]; then - [ "${OUTIP_STATE}"x == "China"x ] && DOWN_ADDR=${mirror_link}/src || DOWN_ADDR=http://www.memcached.org/files - [ ! -e "memcached-${NEW_memcached_ver}.tar.gz" ] && wget --no-check-certificate -c ${DOWN_ADDR}/memcached-${NEW_memcached_ver}.tar.gz > /dev/null 2>&1 - if [ -e "memcached-${NEW_memcached_ver}.tar.gz" ]; then - echo "Download [${CMSG}memcached-${NEW_memcached_ver}.tar.gz${CEND}] successfully! " + read -p "Please input upgrade Memcached Version(example: 1.4.39): " NEW_Memcached_version + if [ "${NEW_Memcached_version}" != "$OLD_Memcached_version" ]; then + [ ! -e "memcached-${NEW_Memcached_version}.tar.gz" ] && wget --no-check-certificate -c http://www.memcached.org/files/memcached-${NEW_Memcached_version}.tar.gz > /dev/null 2>&1 + if [ -e "memcached-${NEW_Memcached_version}.tar.gz" ]; then + echo "Download [${CMSG}memcached-${NEW_Memcached_version}.tar.gz${CEND}] successfully! " break else echo "${CWARNING}Memcached version does not exist! ${CEND}" fi else echo "${CWARNING}input error! Upgrade Memcached version is the same as the old version${CEND}" - exit fi done - if [ -e "memcached-${NEW_memcached_ver}.tar.gz" ]; then - echo "[${CMSG}memcached-${NEW_memcached_ver}.tar.gz${CEND}] found" - if [ "${memcached_flag}" != 'y' ]; then - echo "Press Ctrl+c to cancel or Press any key to continue..." - char=`get_char` - fi - tar xzf memcached-${NEW_memcached_ver}.tar.gz - pushd memcached-${NEW_memcached_ver} + if [ -e "memcached-${NEW_Memcached_version}.tar.gz" ]; then + echo "[${CMSG}memcached-${NEW_Memcached_version}.tar.gz${CEND}] found" + echo "Press Ctrl+c to cancel or Press any key to continue..." + char=`get_char` + tar xzf memcached-${NEW_Memcached_version}.tar.gz + pushd memcached-${NEW_Memcached_version} make clean ./configure --prefix=${memcached_install_dir} make -j ${THREAD} @@ -45,8 +44,8 @@ Upgrade_Memcached() { make install service memcached start popd > /dev/null - echo "You have ${CMSG}successfully${CEND} upgrade from ${CWARNING}${OLD_memcached_ver}${CEND} to ${CWARNING}${NEW_memcached_ver}${CEND}" - rm -rf memcached-${NEW_memcached_ver} + echo "You have ${CMSG}successfully${CEND} upgrade from ${CWARNING}$OLD_Memcached_version${CEND} to ${CWARNING}${NEW_Memcached_version}${CEND}" + rm -rf memcached-${NEW_Memcached_version} else echo "${CFAILURE}Upgrade Memcached failed! ${CEND}" fi diff --git a/include/upgrade_php.sh b/include/upgrade_php.sh index 6731f901..e02bf429 100644 --- a/include/upgrade_php.sh +++ b/include/upgrade_php.sh @@ -1,53 +1,46 @@ #!/bin/bash # Author: yeho -# BLOG: https://linuxeye.com +# BLOG: https://blog.linuxeye.com +# +# Notes: OneinStack for CentOS/RadHat 5+ Debian 6+ and Ubuntu 12+ +# +# Project home page: +# https://oneinstack.com +# https://github.com/lj2007331/oneinstack Upgrade_PHP() { - pushd ${current_dir}/src > /dev/null + pushd ${oneinstack_dir}/src > /dev/null [ ! -e "${php_install_dir}" ] && echo "${CWARNING}PHP is not installed on your system! ${CEND}" && exit 1 - OLD_php_ver=`${php_install_dir}/bin/php-config --version` - pythonCtl=python - command -v python3 > /dev/null 2>&1 && pythonCtl=python3 - Latest_php_ver=`curl --connect-timeout 2 -m 3 -s https://www.php.net/releases/active.php | ${pythonCtl} -mjson.tool | awk '/version/{print $2}' | sed 's/"//g' | grep "${OLD_php_ver%.*}"` - Latest_php_ver=${Latest_php_ver:-5.5.38} echo - echo "Current PHP Version: ${CMSG}$OLD_php_ver${CEND}" + OLD_PHP_version=`${php_install_dir}/bin/php -r 'echo PHP_VERSION;'` + echo "Current PHP Version: ${CMSG}$OLD_PHP_version${CEND}" while :; do echo - [ "${php_flag}" != 'y' ] && read -e -p "Please input upgrade PHP Version(Default: $Latest_php_ver): " NEW_php_ver - NEW_php_ver=${NEW_php_ver:-${Latest_php_ver}} - if [ "${NEW_php_ver%.*}" == "${OLD_php_ver%.*}" ]; then - [ ! -e "php-${NEW_php_ver}.tar.gz" ] && wget --no-check-certificate -c https://secure.php.net/distributions/php-${NEW_php_ver}.tar.gz > /dev/null 2>&1 - if [ -e "php-${NEW_php_ver}.tar.gz" ]; then - echo "Download [${CMSG}php-${NEW_php_ver}.tar.gz${CEND}] successfully! " + read -p "Please input upgrade PHP Version: " NEW_PHP_version + if [ "${NEW_PHP_version%.*}" == "${OLD_PHP_version%.*}" ]; then + [ ! -e "php-${NEW_PHP_version}.tar.gz" ] && wget --no-check-certificate -c http://www.php.net/distributions/php-${NEW_PHP_version}.tar.gz > /dev/null 2>&1 + if [ -e "php-${NEW_PHP_version}.tar.gz" ]; then + echo "Download [${CMSG}php-${NEW_PHP_version}.tar.gz${CEND}] successfully! " else echo "${CWARNING}PHP version does not exist! ${CEND}" fi break else - echo "${CWARNING}input error! ${CEND}Please only input '${CMSG}${OLD_php_ver%.*}.xx${CEND}'" - [ "${php_flag}" == 'y' ] && exit + echo "${CWARNING}input error! ${CEND}Please only input '${CMSG}${OLD_PHP_version%.*}.xx${CEND}'" fi done - if [ -e "php-${NEW_php_ver}.tar.gz" ]; then - echo "[${CMSG}php-${NEW_php_ver}.tar.gz${CEND}] found" - if [ "${php_flag}" != 'y' ]; then - echo "Press Ctrl+c to cancel or Press any key to continue..." - char=`get_char` - fi - tar xzf php-${NEW_php_ver}.tar.gz - src_url=${mirror_link}/src/fpm-race-condition.patch && Download_src - patch -d php-${NEW_php_ver} -p0 < fpm-race-condition.patch - pushd php-${NEW_php_ver} - if [[ "${OLD_php_ver%.*}" =~ ^7.[1-4]$|^8.[0-1]$ ]] && [ -e ext/openssl/openssl.c ] && ! grep -Eqi '^#ifdef RSA_SSLV23_PADDING' ext/openssl/openssl.c; then - sed -i '/OPENSSL_SSLV23_PADDING/i#ifdef RSA_SSLV23_PADDING' ext/openssl/openssl.c - sed -i '/OPENSSL_SSLV23_PADDING/a#endif' ext/openssl/openssl.c - fi + if [ -e "php-${NEW_PHP_version}.tar.gz" ]; then + echo "[${CMSG}php-${NEW_PHP_version}.tar.gz${CEND}] found" + echo "Press Ctrl+c to cancel or Press any key to continue..." + char=`get_char` + tar xzf php-${NEW_PHP_version}.tar.gz + src_url=http://mirrors.linuxeye.com/oneinstack/src/fpm-race-condition.patch && Download_src + patch -d php-${NEW_PHP_version} -p0 < fpm-race-condition.patch + pushd php-${NEW_PHP_version} make clean - export PKG_CONFIG_PATH=/usr/local/lib/pkgconfig/:$PKG_CONFIG_PATH ${php_install_dir}/bin/php -i |grep 'Configure Command' | awk -F'=>' '{print $2}' | bash - make ZEND_EXTRA_LIBS='-liconv' -j ${THREAD} - if [ -e "${apache_install_dir}/bin/httpd" ]; then + make ZEND_EXTRA_LIBS='-liconv' + if [ -e "${apache_install_dir}/bin/apachectl" ]; then echo "Stoping apache..." service httpd stop make install @@ -61,8 +54,8 @@ Upgrade_PHP() { service php-fpm start fi popd > /dev/null - echo "You have ${CMSG}successfully${CEND} upgrade from ${CWARNING}$OLD_php_ver${CEND} to ${CWARNING}${NEW_php_ver}${CEND}" - rm -rf php-${NEW_php_ver} + echo "You have ${CMSG}successfully${CEND} upgrade from ${CWARNING}$OLD_PHP_version${CEND} to ${CWARNING}${NEW_PHP_version}${CEND}" + rm -rf php-${NEW_PHP_version} fi popd > /dev/null } diff --git a/include/upgrade_phpmyadmin.sh b/include/upgrade_phpmyadmin.sh index b2d1ec02..d182c260 100644 --- a/include/upgrade_phpmyadmin.sh +++ b/include/upgrade_phpmyadmin.sh @@ -1,48 +1,48 @@ #!/bin/bash # Author: yeho -# BLOG: https://linuxeye.com +# BLOG: https://blog.linuxeye.com +# +# Notes: OneinStack for CentOS/RadHat 5+ Debian 6+ and Ubuntu 12+ +# +# Project home page: +# https://oneinstack.com +# https://github.com/lj2007331/oneinstack Upgrade_phpMyAdmin() { - pushd ${current_dir}/src > /dev/null + pushd ${oneinstack_dir}/src > /dev/null [ ! -e "${wwwroot_dir}/default/phpMyAdmin" ] && echo "${CWARNING}phpMyAdmin is not installed on your system! ${CEND}" && exit 1 - OLD_phpmyadmin_ver=`grep Version ${wwwroot_dir}/default/phpMyAdmin/README | awk '{print $2}'` - Latest_phpmyadmin_ver=`curl --connect-timeout 2 -m 3 -s https://www.phpmyadmin.net/files/ | awk -F'>|<' '/\/files\/[0-9]/{print $5}' | head -1` - Latest_phpmyadmin_ver=${Latest_phpmyadmin_ver:-5.0.4} - echo "Current phpMyAdmin Version: ${CMSG}${OLD_phpmyadmin_ver}${CEND}" + OLD_phpMyAdmin_version=`grep Version ${wwwroot_dir}/default/phpMyAdmin/README | awk '{print $2}'` + echo "Current phpMyAdmin Version: ${CMSG}${OLD_phpMyAdmin_version}${CEND}" + while :; do echo - [ "${phpmyadmin_flag}" != 'y' ] && read -e -p "Please input upgrade phpMyAdmin Version(default: ${Latest_phpmyadmin_ver}): " NEW_phpmyadmin_ver - NEW_phpmyadmin_ver=${NEW_phpmyadmin_ver:-${Latest_phpmyadmin_ver}} - if [ "${NEW_phpmyadmin_ver}" != "${OLD_phpmyadmin_ver}" ]; then - [ ! -e "phpMyAdmin-${NEW_phpmyadmin_ver}-all-languages.tar.gz" ] && wget --no-check-certificate -c https://files.phpmyadmin.net/phpMyAdmin/${NEW_phpmyadmin_ver}/phpMyAdmin-${NEW_phpmyadmin_ver}-all-languages.tar.gz > /dev/null 2>&1 - if [ -e "phpMyAdmin-${NEW_phpmyadmin_ver}-all-languages.tar.gz" ]; then - echo "Download [${CMSG}phpMyAdmin-${NEW_phpmyadmin_ver}-all-languages.tar.gz${CEND}] successfully! " + read -p "Please input upgrade phpMyAdmin Version(example: 4.4.15): " NEW_phpMyAdmin_version + if [ "${NEW_phpMyAdmin_version}" != "${OLD_phpMyAdmin_version}" ]; then + [ ! -e "phpMyAdmin-${NEW_phpMyAdmin_version}-all-languages.tar.gz" ] && wget --no-check-certificate -c https://files.phpmyadmin.net/phpMyAdmin/${NEW_phpMyAdmin_version}/phpMyAdmin-${NEW_phpMyAdmin_version}-all-languages.tar.gz > /dev/null 2>&1 + if [ -e "phpMyAdmin-${NEW_phpMyAdmin_version}-all-languages.tar.gz" ]; then + echo "Download [${CMSG}phpMyAdmin-${NEW_phpMyAdmin_version}-all-languages.tar.gz${CEND}] successfully! " break else echo "${CWARNING}phpMyAdmin version does not exist! ${CEND}" fi else echo "${CWARNING}input error! Upgrade phpMyAdmin version is the same as the old version${CEND}" - exit fi done - if [ -e "phpMyAdmin-${NEW_phpmyadmin_ver}-all-languages.tar.gz" ]; then - echo "[${CMSG}phpMyAdmin-${NEW_phpmyadmin_ver}-all-languages.tar.gz${CEND}] found" - if [ "${phpmyadmin_flag}" != 'y' ]; then - echo "Press Ctrl+c to cancel or Press any key to continue..." - char=`get_char` - fi - tar xzf phpMyAdmin-${NEW_phpmyadmin_ver}-all-languages.tar.gz + if [ -e "phpMyAdmin-${NEW_phpMyAdmin_version}-all-languages.tar.gz" ]; then + echo "[${CMSG}phpMyAdmin-${NEW_phpMyAdmin_version}-all-languages.tar.gz${CEND}] found" + echo "Press Ctrl+c to cancel or Press any key to continue..." + char=`get_char` + tar xzf phpMyAdmin-${NEW_phpMyAdmin_version}-all-languages.tar.gz rm -rf ${wwwroot_dir}/default/phpMyAdmin - /bin/mv phpMyAdmin-${NEW_phpmyadmin_ver}-all-languages ${wwwroot_dir}/default/phpMyAdmin + /bin/mv phpMyAdmin-${NEW_phpMyAdmin_version}-all-languages ${wwwroot_dir}/default/phpMyAdmin /bin/cp ${wwwroot_dir}/default/phpMyAdmin/{config.sample.inc.php,config.inc.php} mkdir ${wwwroot_dir}/default/phpMyAdmin/{upload,save} sed -i "s@UploadDir.*@UploadDir'\] = 'upload';@" ${wwwroot_dir}/default/phpMyAdmin/config.inc.php sed -i "s@SaveDir.*@SaveDir'\] = 'save';@" ${wwwroot_dir}/default/phpMyAdmin/config.inc.php - sed -i "s@host'\].*@host'\] = '127.0.0.1';@" ${wwwroot_dir}/default/phpMyAdmin/config.inc.php sed -i "s@blowfish_secret.*;@blowfish_secret\'\] = \'$(cat /dev/urandom | head -1 | base64 | head -c 45)\';@" ${wwwroot_dir}/default/phpMyAdmin/config.inc.php - chown -R ${run_user}:${run_group} ${wwwroot_dir}/default/phpMyAdmin - echo "You have ${CMSG}successfully${CEND} upgrade from ${CWARNING}$OLD_phpmyadmin_ver${CEND} to ${CWARNING}$NEW_phpmyadmin_ver${CEND}" + chown -R ${run_user}.$run_user ${wwwroot_dir}/default/phpMyAdmin + echo "You have ${CMSG}successfully${CEND} upgrade from ${CWARNING}$OLD_phpMyAdmin_version${CEND} to ${CWARNING}$NEW_phpMyAdmin_version${CEND}" fi popd > /dev/null } diff --git a/include/upgrade_redis.sh b/include/upgrade_redis.sh index 99717df5..444e0b66 100644 --- a/include/upgrade_redis.sh +++ b/include/upgrade_redis.sh @@ -1,40 +1,45 @@ #!/bin/bash # Author: yeho -# BLOG: https://linuxeye.com +# BLOG: https://blog.linuxeye.com +# +# Notes: OneinStack for CentOS/RadHat 5+ Debian 6+ and Ubuntu 12+ +# +# Project home page: +# https://oneinstack.com +# https://github.com/lj2007331/oneinstack Upgrade_Redis() { - pushd ${current_dir}/src > /dev/null + pushd ${oneinstack_dir}/src > /dev/null [ ! -d "$redis_install_dir" ] && echo "${CWARNING}Redis is not installed on your system! ${CEND}" && exit 1 - OLD_redis_ver=`$redis_install_dir/bin/redis-cli --version | awk '{print $2}'` - Latest_redis_ver=`curl --connect-timeout 2 -m 3 -s http://download.redis.io/redis-stable/00-RELEASENOTES | awk '/Released/{print $2}' | head -1` - Latest_redis_ver=${Latest_redis_ver:-6.0.4} - echo "Current Redis Version: ${CMSG}$OLD_redis_ver${CEND}" + OLD_Redis_version=`$redis_install_dir/bin/redis-cli --version | awk '{print $2}'` + echo "Current Redis Version: ${CMSG}$OLD_Redis_version${CEND}" while :; do echo - [ "${redis_flag}" != 'y' ] && read -e -p "Please input upgrade Redis Version(default: ${Latest_redis_ver}): " NEW_redis_ver - NEW_redis_ver=${NEW_redis_ver:-${Latest_redis_ver}} - if [ "$NEW_redis_ver" != "$OLD_redis_ver" ]; then - [ ! -e "redis-$NEW_redis_ver.tar.gz" ] && wget --no-check-certificate -c http://download.redis.io/releases/redis-$NEW_redis_ver.tar.gz > /dev/null 2>&1 - if [ -e "redis-$NEW_redis_ver.tar.gz" ]; then - echo "Download [${CMSG}redis-$NEW_redis_ver.tar.gz${CEND}] successfully! " + read -p "Please input upgrade Redis Version(example: 3.0.5): " NEW_Redis_version + if [ "$NEW_Redis_version" != "$OLD_Redis_version" ]; then + [ ! -e "redis-$NEW_Redis_version.tar.gz" ] && wget --no-check-certificate -c http://download.redis.io/releases/redis-$NEW_Redis_version.tar.gz > /dev/null 2>&1 + if [ -e "redis-$NEW_Redis_version.tar.gz" ]; then + echo "Download [${CMSG}redis-$NEW_Redis_version.tar.gz${CEND}] successfully! " break else echo "${CWARNING}Redis version does not exist! ${CEND}" fi else echo "${CWARNING}input error! Upgrade Redis version is the same as the old version${CEND}" - exit fi done - if [ -e "redis-$NEW_redis_ver.tar.gz" ]; then - echo "[${CMSG}redis-$NEW_redis_ver.tar.gz${CEND}] found" - if [ "${redis_flag}" != 'y' ]; then - echo "Press Ctrl+c to cancel or Press any key to continue..." - char=`get_char` - fi - tar xzf redis-$NEW_redis_ver.tar.gz - pushd redis-$NEW_redis_ver + if [ -e "redis-$NEW_Redis_version.tar.gz" ]; then + echo "[${CMSG}redis-$NEW_Redis_version.tar.gz${CEND}] found" + echo "Press Ctrl+c to cancel or Press any key to continue..." + char=`get_char` + tar xzf redis-$NEW_Redis_version.tar.gz + pushd redis-$NEW_Redis_version make clean + if [ "$OS_BIT" == '32' ]; then + sed -i '1i\CFLAGS= -march=i686' src/Makefile + sed -i 's@^OPT=.*@OPT=-O2 -march=i686@' src/.make-settings + fi + make -j ${THREAD} if [ -f "src/redis-server" ]; then @@ -43,8 +48,8 @@ Upgrade_Redis() { /bin/cp src/{redis-benchmark,redis-check-aof,redis-check-rdb,redis-cli,redis-sentinel,redis-server} $redis_install_dir/bin/ service redis-server start popd > /dev/null - echo "You have ${CMSG}successfully${CEND} upgrade from ${CWARNING}$OLD_redis_ver${CEND} to ${CWARNING}$NEW_redis_ver${CEND}" - rm -rf redis-$NEW_redis_ver + echo "You have ${CMSG}successfully${CEND} upgrade from ${CWARNING}$OLD_Redis_version${CEND} to ${CWARNING}$NEW_Redis_version${CEND}" + rm -rf redis-$NEW_Redis_version else echo "${CFAILURE}Upgrade Redis failed! ${CEND}" fi diff --git a/include/upgrade_script.sh b/include/upgrade_script.sh deleted file mode 100644 index 950fb4b9..00000000 --- a/include/upgrade_script.sh +++ /dev/null @@ -1,54 +0,0 @@ -#!/bin/bash -# Author: yeho -# BLOG: https://linuxeye.com - -Upgrade_Script() { - pushd ${current_dir} > /dev/null - latest_md5=$(curl --connect-timeout 3 -m 5 -s ${mirror_link}/md5sum.txt | grep lnmp.tar.gz | awk '{print $1}') - [ ! -e README.md ] && ois_flag=n - if [ "${script_md5}" != "${latest_md5}" ]; then - /bin/mv options.conf /tmp - sed -i '/current_dir=/d' /tmp/options.conf - [ -e /tmp/lnmp.tar.gz ] && rm -rf /tmp/lnmp.tar.gz - wget --no-check-certificate -qc ${mirror_link}/lnmp.tar.gz -O /tmp/lnmp.tar.gz - tar xzf /tmp/lnmp.tar.gz -C /tmp - /bin/cp -R /tmp/lnmp/* ${current_dir}/ - /bin/rm -rf /tmp/lnmp - IFS=$'\n' - for L in `grep -vE '^#|^$' /tmp/options.conf` - do - IFS=$IFS_old - Key="`echo ${L%%=*}`" - Value="`echo ${L#*=}`" - sed -i "s|^${Key}=.*|${Key}=${Value}|" ./options.conf - done - rm -rf /tmp/{lnmp.tar.gz,options.conf} - [ "${ois_flag}" == "n" ] && rm -f ss.sh LICENSE README.md - sed -i "s@^script_md5=.*@script_md5=${latest_md5}@" ./options.conf - if [ -e "${php_install_dir}/sbin/php-fpm" ]; then - [ -n "`grep ^cgi.fix_pathinfo=0 ${php_install_dir}/etc/php.ini`" ] && sed -i 's@^cgi.fix_pathinfo.*@;&@' ${php_install_dir}/etc/php.ini - [ -e "/usr/local/php53/etc/php.ini" ] && sed -i 's@^cgi.fix_pathinfo=0@;&@' /usr/local/php53/etc/php.ini 2>/dev/null - [ -e "/usr/local/php54/etc/php.ini" ] && sed -i 's@^cgi.fix_pathinfo=0@;&@' /usr/local/php54/etc/php.ini 2>/dev/null - [ -e "/usr/local/php55/etc/php.ini" ] && sed -i 's@^cgi.fix_pathinfo=0@;&@' /usr/local/php55/etc/php.ini 2>/dev/null - [ -e "/usr/local/php56/etc/php.ini" ] && sed -i 's@^cgi.fix_pathinfo=0@;&@' /usr/local/php56/etc/php.ini 2>/dev/null - [ -e "/usr/local/php70/etc/php.ini" ] && sed -i 's@^cgi.fix_pathinfo=0@;&@' /usr/local/php70/etc/php.ini 2>/dev/null - [ -e "/usr/local/php71/etc/php.ini" ] && sed -i 's@^cgi.fix_pathinfo=0@;&@' /usr/local/php71/etc/php.ini 2>/dev/null - [ -e "/usr/local/php72/etc/php.ini" ] && sed -i 's@^cgi.fix_pathinfo=0@;&@' /usr/local/php72/etc/php.ini 2>/dev/null - [ -e "/usr/local/php73/etc/php.ini" ] && sed -i 's@^cgi.fix_pathinfo=0@;&@' /usr/local/php73/etc/php.ini 2>/dev/null - [ -e "/usr/local/php74/etc/php.ini" ] && sed -i 's@^cgi.fix_pathinfo=0@;&@' /usr/local/php74/etc/php.ini 2>/dev/null - [ -e "/usr/local/php80/etc/php.ini" ] && sed -i 's@^cgi.fix_pathinfo=0@;&@' /usr/local/php80/etc/php.ini 2>/dev/null - [ -e "/usr/local/php81/etc/php.ini" ] && sed -i 's@^cgi.fix_pathinfo=0@;&@' /usr/local/php81/etc/php.ini 2>/dev/null - [ -e "/usr/local/php82/etc/php.ini" ] && sed -i 's@^cgi.fix_pathinfo=0@;&@' /usr/local/php82/etc/php.ini 2>/dev/null - [ -e "/usr/local/php83/etc/php.ini" ] && sed -i 's@^cgi.fix_pathinfo=0@;&@' /usr/local/php83/etc/php.ini 2>/dev/null - [ -e "/usr/local/php84/etc/php.ini" ] && sed -i 's@^cgi.fix_pathinfo=0@;&@' /usr/local/php84/etc/php.ini 2>/dev/null - fi - [ -e "/lib/systemd/system/php-fpm.service" ] && { sed -i 's@^PrivateTmp.*@#&@g' /lib/systemd/system/php-fpm.service; systemctl daemon-reload; } - echo - echo "${CSUCCESS}Congratulations! LNMP upgrade successful! ${CEND}" - echo - else - echo "${CWARNING}Your LNMP already has the latest version or does not need to be upgraded! ${CEND}" - fi - [ ! -e "${current_dir}/options.conf" ] && [ -e "/tmp/options.conf" ] && /bin/cp /tmp/options.conf ${current_dir}/options.conf - popd > /dev/null -} diff --git a/include/upgrade_web.sh b/include/upgrade_web.sh index f00641ea..3bfe7bf6 100644 --- a/include/upgrade_web.sh +++ b/include/upgrade_web.sh @@ -1,92 +1,61 @@ #!/bin/bash # Author: yeho -# BLOG: https://linuxeye.com +# BLOG: https://blog.linuxeye.com +# +# Notes: OneinStack for CentOS/RadHat 5+ Debian 6+ and Ubuntu 12+ +# +# Project home page: +# https://oneinstack.com +# https://github.com/lj2007331/oneinstack Upgrade_Nginx() { - pushd ${current_dir}/src > /dev/null - [ ! -e "${nginx_install_dir}/sbin/nginx" ] && echo "${CWARNING}Nginx is not installed on your system! ${CEND}" && exit 1 - OLD_nginx_ver_tmp=`${nginx_install_dir}/sbin/nginx -v 2>&1` - OLD_nginx_ver=${OLD_nginx_ver_tmp##*/} - Latest_nginx_ver=`curl --connect-timeout 2 -m 3 -s http://nginx.org/en/CHANGES-1.22 | awk '/Changes with nginx/{print$0}' | awk '{print $4}' | head -1` - [ -z "${Latest_nginx_ver}" ] && Latest_nginx_ver=`curl --connect-timeout 2 -m 3 -s http://nginx.org/en/CHANGES | awk '/Changes with nginx/{print$0}' | awk '{print $4}' | head -1` + pushd ${oneinstack_dir}/src > /dev/null + [ ! -e "$nginx_install_dir/sbin/nginx" ] && echo "${CWARNING}Nginx is not installed on your system! ${CEND}" && exit 1 + OLD_Nginx_version_tmp=`$nginx_install_dir/sbin/nginx -v 2>&1` + OLD_Nginx_version=${OLD_Nginx_version_tmp##*/} echo - echo "Current Nginx Version: ${CMSG}${OLD_nginx_ver}${CEND}" + echo "Current Nginx Version: ${CMSG}$OLD_Nginx_version${CEND}" while :; do echo - [ "${nginx_flag}" != 'y' ] && read -e -p "Please input upgrade Nginx Version(default: ${Latest_nginx_ver}): " NEW_nginx_ver - NEW_nginx_ver=${NEW_nginx_ver:-${Latest_nginx_ver}} - if [ "${NEW_nginx_ver}" != "${OLD_nginx_ver}" ]; then - [ ! -e "nginx-${NEW_nginx_ver}.tar.gz" ] && wget --no-check-certificate -c http://nginx.org/download/nginx-${NEW_nginx_ver}.tar.gz > /dev/null 2>&1 - if [ -e "nginx-${NEW_nginx_ver}.tar.gz" ]; then - src_url=${mirror_link}/src/openssl-${openssl_ver}.tar.gz && Download_src - src_url=${mirror_link}/src/pcre-${pcre_ver}.tar.gz && Download_src - src_url=${mirror_link}/src/ngx_devel_kit.tar.gz && Download_src - src_url=${mirror_link}/src/lua-nginx-module-${lua_nginx_module_ver}.tar.gz && Download_src - tar xzf openssl-${openssl_ver}.tar.gz - tar xzf pcre-${pcre_ver}.tar.gz - tar xzf ngx_devel_kit.tar.gz - tar xzf lua-nginx-module-${lua_nginx_module_ver}.tar.gz - echo "Download [${CMSG}nginx-${NEW_nginx_ver}.tar.gz${CEND}] successfully! " + read -p "Please input upgrade Nginx Version(example: 1.9.15): " NEW_Nginx_version + if [ "$NEW_Nginx_version" != "$OLD_Nginx_version" ]; then + [ ! -e "nginx-$NEW_Nginx_version.tar.gz" ] && wget --no-check-certificate -c http://nginx.org/download/nginx-$NEW_Nginx_version.tar.gz > /dev/null 2>&1 + if [ -e "nginx-$NEW_Nginx_version.tar.gz" ]; then + src_url=https://www.openssl.org/source/openssl-$openssl_version.tar.gz && Download_src + src_url=http://mirrors.linuxeye.com/oneinstack/src/pcre-$pcre_version.tar.gz && Download_src + tar xzf openssl-$openssl_version.tar.gz + tar xzf pcre-$pcre_version.tar.gz + echo "Download [${CMSG}nginx-$NEW_Nginx_version.tar.gz${CEND}] successfully! " break else echo "${CWARNING}Nginx version does not exist! ${CEND}" fi else echo "${CWARNING}input error! Upgrade Nginx version is the same as the old version${CEND}" - exit fi done - if [ -e "nginx-${NEW_nginx_ver}.tar.gz" ]; then - echo "[${CMSG}nginx-${NEW_nginx_ver}.tar.gz${CEND}] found" - if [ "${nginx_flag}" != 'y' ]; then - echo "Press Ctrl+c to cancel or Press any key to continue..." - char=`get_char` - fi - ${nginx_install_dir}/sbin/nginx -V &> $$ - nginx_configure_args_tmp=`cat $$ | grep 'configure arguments:' | awk -F: '{print $2}'` - rm -rf $$ - nginx_configure_args=`echo ${nginx_configure_args_tmp} | sed "s@lua-nginx-module-\w.\w\+.\w\+ @lua-nginx-module-${lua_nginx_module_ver} @" | sed "s@lua-nginx-module @lua-nginx-module-${lua_nginx_module_ver} @" | sed "s@--with-openssl=../openssl-\w.\w.\w\+ @--with-openssl=../openssl-${openssl_ver} @" | sed "s@--with-pcre=../pcre-\w.\w\+ @--with-pcre=../pcre-${pcre_ver} @"` - if [ -n "`echo $nginx_configure_args | grep lua-nginx-module`" ]; then - ${current_dir}/upgrade.sh --script > /dev/null - src_url=${mirror_link}/src/luajit2-${luajit2_ver}.tar.gz && Download_src - tar xzf luajit2-${luajit2_ver}.tar.gz - pushd luajit2-${luajit2_ver} - make && make install - popd > /dev/null - rm -rf luajit2-${luajit2_ver} - - src_url=${mirror_link}/src/lua-resty-core-${lua_resty_core_ver}.tar.gz && Download_src - tar xzf lua-resty-core-${lua_resty_core_ver}.tar.gz - pushd lua-resty-core-${lua_resty_core_ver} - make install - popd > /dev/null - rm -rf lua-resty-core-${lua_resty_core_ver} - - src_url=${mirror_link}/src/lua-resty-lrucache-${lua_resty_lrucache_ver}.tar.gz && Download_src - tar xzf lua-resty-lrucache-${lua_resty_lrucache_ver}.tar.gz - pushd lua-resty-lrucache-${lua_resty_lrucache_ver} - make install - popd > /dev/null - rm -rf lua-resty-lrucache-${lua_resty_lrucache_ver} - fi - - tar xzf nginx-${NEW_nginx_ver}.tar.gz - pushd nginx-${NEW_nginx_ver} + if [ -e "nginx-$NEW_Nginx_version.tar.gz" ]; then + echo "[${CMSG}nginx-$NEW_Nginx_version.tar.gz${CEND}] found" + echo "Press Ctrl+c to cancel or Press any key to continue..." + char=`get_char` + tar xzf nginx-$NEW_Nginx_version.tar.gz + pushd nginx-$NEW_Nginx_version make clean sed -i 's@CFLAGS="$CFLAGS -g"@#CFLAGS="$CFLAGS -g"@' auto/cc/gcc # close debug - export LUAJIT_LIB=/usr/local/lib - export LUAJIT_INC=/usr/local/include/luajit-2.1 - ./configure ${nginx_configure_args} + $nginx_install_dir/sbin/nginx -V &> $$ + nginx_configure_arguments=`cat $$ | grep 'configure arguments:' | awk -F: '{print $2}'` + rm -rf $$ + ./configure $nginx_configure_arguments make -j ${THREAD} if [ -f "objs/nginx" ]; then - /bin/mv ${nginx_install_dir}/sbin/nginx{,`date +%m%d`} - /bin/cp objs/nginx ${nginx_install_dir}/sbin/nginx + /bin/mv $nginx_install_dir/sbin/nginx{,`date +%m%d`} + /bin/cp objs/nginx $nginx_install_dir/sbin/nginx kill -USR2 `cat /var/run/nginx.pid` sleep 1 kill -QUIT `cat /var/run/nginx.pid.oldbin` popd > /dev/null - echo "You have ${CMSG}successfully${CEND} upgrade from ${CWARNING}${OLD_nginx_ver}${CEND} to ${CWARNING}${NEW_nginx_ver}${CEND}" - rm -rf nginx-${NEW_nginx_ver} + echo "You have ${CMSG}successfully${CEND} upgrade from ${CWARNING}$OLD_Nginx_version${CEND} to ${CWARNING}$NEW_Nginx_version${CEND}" + rm -rf nginx-$NEW_Nginx_version else echo "${CFAILURE}Upgrade Nginx failed! ${CEND}" fi @@ -95,63 +64,58 @@ Upgrade_Nginx() { } Upgrade_Tengine() { - pushd ${current_dir}/src > /dev/null - [ ! -e "${tengine_install_dir}/sbin/nginx" ] && echo "${CWARNING}Tengine is not installed on your system! ${CEND}" && exit 1 - OLD_tengine_ver_tmp=`${tengine_install_dir}/sbin/nginx -v 2>&1` - OLD_tengine_ver="`echo ${OLD_tengine_ver_tmp#*/} | awk '{print $1}'`" - Latest_tengine_ver=`curl --connect-timeout 2 -m 3 -s http://tengine.taobao.org/changelog.html | grep -v generator | grep -oE "[0-9]\.[0-9]\.[0-9]+" | head -1` + pushd ${oneinstack_dir}/src + [ ! -e "$tengine_install_dir/sbin/nginx" ] && echo "${CWARNING}Tengine is not installed on your system! ${CEND}" && exit 1 + OLD_Tengine_version_tmp=`$tengine_install_dir/sbin/nginx -v 2>&1` + OLD_Tengine_version="`echo ${OLD_Tengine_version_tmp#*/} | awk '{print $1}'`" echo - echo "Current Tengine Version: ${CMSG}${OLD_tengine_ver}${CEND}" + echo "Current Tengine Version: ${CMSG}$OLD_Tengine_version${CEND}" while :; do echo - [ "${tengine_flag}" != 'y' ] && read -e -p "Please input upgrade Tengine Version(default: ${Latest_tengine_ver}): " NEW_tengine_ver - NEW_tengine_ver=${NEW_tengine_ver:-${Latest_tengine_ver}} - if [ "${NEW_tengine_ver}" != "${OLD_tengine_ver}" ]; then - [ ! -e "tengine-${NEW_tengine_ver}.tar.gz" ] && wget --no-check-certificate -c http://tengine.taobao.org/download/tengine-${NEW_tengine_ver}.tar.gz > /dev/null 2>&1 - if [ -e "tengine-${NEW_tengine_ver}.tar.gz" ]; then - src_url=${mirror_link}/src/openssl-${openssl_ver}.tar.gz && Download_src - src_url=${mirror_link}/src/pcre-${pcre_ver}.tar.gz && Download_src - tar xzf openssl-${openssl_ver}.tar.gz - tar xzf pcre-${pcre_ver}.tar.gz - echo "Download [${CMSG}tengine-${NEW_tengine_ver}.tar.gz${CEND}] successfully! " + read -p "Please input upgrade Tengine Version(example: 2.1.15): " NEW_Tengine_version + if [ "$NEW_Tengine_version" != "$OLD_Tengine_version" ]; then + [ ! -e "tengine-$NEW_Tengine_version.tar.gz" ] && wget --no-check-certificate -c http://tengine.taobao.org/download/tengine-$NEW_Tengine_version.tar.gz > /dev/null 2>&1 + if [ -e "tengine-$NEW_Tengine_version.tar.gz" ]; then + src_url=https://www.openssl.org/source/openssl-$openssl_version.tar.gz && Download_src + src_url=http://mirrors.linuxeye.com/oneinstack/src/pcre-$pcre_version.tar.gz && Download_src + tar xzf openssl-$openssl_version.tar.gz + tar xzf pcre-$pcre_version.tar.gz + echo "Download [${CMSG}tengine-$NEW_Tengine_version.tar.gz${CEND}] successfully! " break else echo "${CWARNING}Tengine version does not exist! ${CEND}" fi else echo "${CWARNING}input error! Upgrade Tengine version is the same as the old version${CEND}" - exit fi done - if [ -e "tengine-${NEW_tengine_ver}.tar.gz" ]; then - echo "[${CMSG}tengine-${NEW_tengine_ver}.tar.gz${CEND}] found" - if [ "${tengine_flag}" != 'y' ]; then - echo "Press Ctrl+c to cancel or Press any key to continue..." - char=`get_char` - fi - tar xzf tengine-${NEW_tengine_ver}.tar.gz - pushd tengine-${NEW_tengine_ver} + if [ -e "tengine-$NEW_Tengine_version.tar.gz" ]; then + echo "[${CMSG}tengine-$NEW_Tengine_version.tar.gz${CEND}] found" + echo "Press Ctrl+c to cancel or Press any key to continue..." + char=`get_char` + tar xzf tengine-$NEW_Tengine_version.tar.gz + pushd tengine-$NEW_Tengine_version make clean - ${tengine_install_dir}/sbin/nginx -V &> $$ - tengine_configure_args_tmp=`cat $$ | grep 'configure arguments:' | awk -F: '{print $2}'` + sed -i 's@CFLAGS="$CFLAGS -g"@#CFLAGS="$CFLAGS -g"@' auto/cc/gcc # close debug + $tengine_install_dir/sbin/nginx -V &> $$ + tengine_configure_arguments=`cat $$ | grep 'configure arguments:' | awk -F: '{print $2}'` rm -rf $$ - tengine_configure_args=`echo ${tengine_configure_args_tmp} | sed "s@--with-openssl=../openssl-\w.\w.\w\+ @--with-openssl=../openssl-${openssl_ver} @" | sed "s@--with-pcre=../pcre-\w.\w\+ @--with-pcre=../pcre-${pcre_ver} @"` - export LUAJIT_LIB=/usr/local/lib - export LUAJIT_INC=/usr/local/include/luajit-2.1 - ./configure ${tengine_configure_args} - make + ./configure $tengine_configure_arguments + make -j ${THREAD} if [ -f "objs/nginx" ]; then - /bin/mv ${tengine_install_dir}/sbin/nginx{,`date +%m%d`} - /bin/mv ${tengine_install_dir}/modules{,`date +%m%d`} - /bin/cp objs/nginx ${tengine_install_dir}/sbin/nginx - chmod +x ${tengine_install_dir}/sbin/* + /bin/mv $tengine_install_dir/sbin/nginx{,`date +%m%d`} + /bin/mv $tengine_install_dir/sbin/dso_tool{,`date +%m%d`} + /bin/mv $tengine_install_dir/modules{,`date +%m%d`} + /bin/cp objs/nginx $tengine_install_dir/sbin/nginx + /bin/cp objs/dso_tool $tengine_install_dir/sbin/dso_tool + chmod +x $tengine_install_dir/sbin/* make install kill -USR2 `cat /var/run/nginx.pid` sleep 1 kill -QUIT `cat /var/run/nginx.pid.oldbin` popd > /dev/null - echo "You have ${CMSG}successfully${CEND} upgrade from ${CWARNING}$OLD_tengine_ver${CEND} to ${CWARNING}${NEW_tengine_ver}${CEND}" - rm -rf tengine-${NEW_tengine_ver} + echo "You have ${CMSG}successfully${CEND} upgrade from ${CWARNING}$OLD_Tengine_version${CEND} to ${CWARNING}$NEW_Tengine_version${CEND}" + rm -rf tengine-$NEW_Tengine_version else echo "${CFAILURE}Upgrade Tengine failed! ${CEND}" fi @@ -160,195 +124,55 @@ Upgrade_Tengine() { } Upgrade_OpenResty() { - pushd ${current_dir}/src > /dev/null - [ ! -e "${openresty_install_dir}/nginx/sbin/nginx" ] && echo "${CWARNING}OpenResty is not installed on your system! ${CEND}" && exit 1 - OLD_openresy_ver_tmp=`${openresty_install_dir}/nginx/sbin/nginx -v 2>&1` - OLD_openresy_ver="`echo ${OLD_openresy_ver_tmp#*/} | awk '{print $1}'`" - Latest_openresy_ver=`curl --connect-timeout 2 -m 3 -s https://openresty.org/en/download.html | awk '/download\/openresty-/{print $0}' | grep -oE "[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+" | head -1` + pushd ${oneinstack_dir}/src + [ ! -e "$openresty_install_dir/nginx/sbin/nginx" ] && echo "${CWARNING}OpenResty is not installed on your system! ${CEND}" && exit 1 + OLD_OpenResty_version_tmp=`$openresty_install_dir/nginx/sbin/nginx -v 2>&1` + OLD_OpenResty_version="`echo ${OLD_OpenResty_version_tmp#*/} | awk '{print $1}'`" echo - echo "Current OpenResty Version: ${CMSG}${OLD_openresy_ver}${CEND}" + echo "Current OpenResty Version: ${CMSG}$OLD_OpenResty_version${CEND}" while :; do echo - [ "${openresty_flag}" != 'y' ] && read -e -p "Please input upgrade OpenResty Version(default: ${Latest_openresy_ver}): " NEW_openresy_ver - NEW_openresy_ver=${NEW_openresy_ver:-${Latest_openresy_ver}} - if [ "${NEW_openresy_ver}" != "${OLD_openresy_ver}" ]; then - [ ! -e "openresty-${NEW_openresy_ver}.tar.gz" ] && wget --no-check-certificate -c https://openresty.org/download/openresty-${NEW_openresy_ver}.tar.gz > /dev/null 2>&1 - if [ -e "openresty-${NEW_openresy_ver}.tar.gz" ]; then - src_url=${mirror_link}/src/openssl-${openssl_ver}.tar.gz && Download_src - src_url=${mirror_link}/src/pcre-${pcre_ver}.tar.gz && Download_src - tar xzf openssl-${openssl_ver}.tar.gz - tar xzf pcre-${pcre_ver}.tar.gz - echo "Download [${CMSG}openresty-${NEW_openresy_ver}.tar.gz${CEND}] successfully! " + read -p "Please input upgrade OpenResty Version(example: 1.9.7.19): " NEW_OpenResty_version + if [ "$NEW_OpenResty_version" != "$OLD_OpenResty_version" ]; then + [ ! -e "openresty-$NEW_OpenResty_version.tar.gz" ] && wget --no-check-certificate -c https://openresty.org/download/openresty-$NEW_OpenResty_version.tar.gz > /dev/null 2>&1 + if [ -e "openresty-$NEW_OpenResty_version.tar.gz" ]; then + src_url=https://www.openssl.org/source/openssl-$openssl_version.tar.gz && Download_src + src_url=http://mirrors.linuxeye.com/oneinstack/src/pcre-$pcre_version.tar.gz && Download_src + tar xzf openssl-$openssl_version.tar.gz + tar xzf pcre-$pcre_version.tar.gz + echo "Download [${CMSG}openresty-$NEW_OpenResty_version.tar.gz${CEND}] successfully! " break else echo "${CWARNING}OpenResty version does not exist! ${CEND}" fi else echo "${CWARNING}input error! Upgrade OpenResty version is the same as the old version${CEND}" - exit fi done - if [ -e "openresty-${NEW_openresy_ver}.tar.gz" ]; then - echo "[${CMSG}openresty-${NEW_openresy_ver}.tar.gz${CEND}] found" - if [ "${openresty_flag}" != 'y' ]; then - echo "Press Ctrl+c to cancel or Press any key to continue..." - char=`get_char` - fi - tar xzf openresty-${NEW_openresy_ver}.tar.gz - pushd openresty-${NEW_openresy_ver} + if [ -e "openresty-$NEW_OpenResty_version.tar.gz" ]; then + echo "[${CMSG}openresty-$NEW_OpenResty_version.tar.gz${CEND}] found" + echo "Press Ctrl+c to cancel or Press any key to continue..." + char=`get_char` + tar xzf openresty-$NEW_OpenResty_version.tar.gz + pushd openresty-$NEW_OpenResty_version make clean - sed -i 's@CFLAGS="$CFLAGS -g"@#CFLAGS="$CFLAGS -g"@' bundle/nginx-${NEW_openresy_ver%.*}/auto/cc/gcc # close debug - ${openresty_install_dir}/nginx/sbin/nginx -V &> $$ - ./configure --prefix=${openresty_install_dir} --user=${run_user} --group=${run_user} --with-http_stub_status_module --with-http_sub_module --with-http_v2_module --with-http_ssl_module --with-http_gzip_static_module --with-http_realip_module --with-http_flv_module --with-http_mp4_module --with-openssl=../openssl-${openssl_ver} --with-pcre=../pcre-${pcre_ver} --with-pcre-jit --with-ld-opt='-ljemalloc -Wl,-u,pcre_version' ${nginx_modules_options} + openresty_version_tmp=${NEW_OpenResty_version%.*} + sed -i 's@CFLAGS="$CFLAGS -g"@#CFLAGS="$CFLAGS -g"@' bundle/nginx-$openresty_version_tmp/auto/cc/gcc # close debug + $openresty_install_dir/nginx/sbin/nginx -V &> $$ + ./configure --prefix=$openresty_install_dir --user=$run_user --group=$run_user --with-http_stub_status_module --with-http_v2_module --with-http_ssl_module --with-http_gzip_static_module --with-http_realip_module --with-http_flv_module --with-http_mp4_module --with-openssl=../openssl-$openssl_version --with-pcre=../pcre-$pcre_version --with-pcre-jit --with-ld-opt='-ljemalloc' $nginx_modules_options make -j ${THREAD} - if [ -f "build/nginx-${NEW_openresy_ver%.*}/objs/nginx" ]; then - /bin/mv ${openresty_install_dir}/nginx/sbin/nginx{,`date +%m%d`} + if [ -f "build/nginx-$openresty_version_tmp/objs/nginx" ]; then + /bin/mv $openresty_install_dir/nginx/sbin/nginx{,`date +%m%d`} make install kill -USR2 `cat /var/run/nginx.pid` sleep 1 kill -QUIT `cat /var/run/nginx.pid.oldbin` popd > /dev/null - echo "You have ${CMSG}successfully${CEND} upgrade from ${CWARNING}${OLD_openresy_ver}${CEND} to ${CWARNING}${NEW_openresy_ver}${CEND}" - rm -rf openresty-${NEW_openresy_ver} + echo "You have ${CMSG}successfully${CEND} upgrade from ${CWARNING}$OLD_OpenResty_version${CEND} to ${CWARNING}$NEW_OpenResty_version${CEND}" + rm -rf openresty-$NEW_OpenResty_version else echo "${CFAILURE}Upgrade OpenResty failed! ${CEND}" fi fi - popd > /dev/null -} - -Upgrade_Apache() { - pushd ${current_dir}/src > /dev/null - [ ! -e "${apache_install_dir}/bin/httpd" ] && echo "${CWARNING}Apache is not installed on your system! ${CEND}" && exit 1 - OLD_apache_ver="`${apache_install_dir}/bin/httpd -v | grep version | awk -F'/| ' '{print $4}'`" - Latest_apache_ver=`curl --connect-timeout 2 -m 3 -s http://httpd.apache.org/download.cgi | awk "/#apache24/{print $2}" | head -1 | grep -oE "2\.[24]\.[0-9]+"` - Latest_apache_ver=${Latest_apache_ver:-${apache22_ver}} - echo - echo "Current Apache Version: ${CMSG}${OLD_apache_ver}${CEND}" - while :; do echo - [ "${apache_flag}" != 'y' ] && read -e -p "Please input upgrade Apache Version(Default: ${Latest_apache_ver}): " NEW_apache_ver - NEW_apache_ver=${NEW_apache_ver:-${Latest_apache_ver}} - if [ `echo ${NEW_apache_ver} | awk -F. '{print $1$2}'` == "24" ]; then - if [ "${NEW_apache_ver}" != "${OLD_apache_ver}" ]; then - src_url=http://archive.apache.org/dist/apr/apr-${apr_ver}.tar.gz && Download_src - src_url=http://archive.apache.org/dist/apr/apr-util-${apr_util_ver}.tar.gz && Download_src - [ ! -e "httpd-${NEW_apache_ver}.tar.gz" ] && wget --no-check-certificate -c http://archive.apache.org/dist/httpd/httpd-${NEW_apache_ver}.tar.gz > /dev/null 2>&1 - if [ -e "httpd-${NEW_apache_ver}.tar.gz" ]; then - echo "Download [${CMSG}apache-${NEW_apache_ver}.tar.gz${CEND}] successfully! " - break - else - echo "${CWARNING}Apache version does not exist! ${CEND}" - fi - else - echo "${CWARNING}input error! Upgrade Apache version is the same as the old version${CEND}" - exit - fi - else - echo "${CWARNING}input error! ${CEND}Please only input '${CMSG}${OLD_apache_ver%.*}.xx${CEND}'" - [ "${apache_flag}" == 'y' ] && exit - fi - done - - if [ -e "httpd-${NEW_apache_ver}.tar.gz" ]; then - echo "[${CMSG}httpd-${NEW_apache_ver}.tar.gz${CEND}] found" - if [ "${apache_flag}" != 'y' ]; then - echo "Press Ctrl+c to cancel or Press any key to continue..." - char=`get_char` - fi - # install apr - if [ ! -e "${apr_install_dir}/bin/apr-1-config" ]; then - tar xzf apr-${apr_ver}.tar.gz - pushd apr-${apr_ver} > /dev/null - ./configure --prefix=${apr_install_dir} - make -j ${THREAD} && make install - popd > /dev/null - rm -rf apr-${apr_ver} - fi - # install apr-util - if [ ! -e "${apr_install_dir}/bin/apu-1-config" ]; then - tar xzf apr-util-${apr_util_ver}.tar.gz - pushd apr-util-${apr_util_ver} > /dev/null - ./configure --prefix=${apr_install_dir} --with-apr=${apr_install_dir} - make -j ${THREAD} && make install - popd > /dev/null - rm -rf apr-util-${apr_util_ver} - fi - tar xzf httpd-${NEW_apache_ver}.tar.gz - pushd httpd-${NEW_apache_ver} - make clean - LDFLAGS=-ldl ./configure --prefix=${apache_install_dir} --enable-mpms-shared=all --with-pcre --with-apr=${apr_install_dir} --with-apr-util=${apr_install_dir} --enable-headers --enable-mime-magic --enable-deflate --enable-proxy --enable-so --enable-dav --enable-rewrite --enable-remoteip --enable-expires --enable-static-support --enable-suexec --enable-mods-shared=most --enable-nonportable-atomics=yes --enable-ssl --with-ssl=${openssl_install_dir} --enable-http2 --with-nghttp2=/usr/local - make -j ${THREAD} - if [ -e 'httpd' ]; then - [[ -d ${apache_install_dir}_bak && -d ${apache_install_dir} ]] && rm -rf ${apache_install_dir}_bak - service httpd stop - /bin/cp -R ${apache_install_dir}{,_bak} - make install && unset LDFLAGS - service httpd start - popd > /dev/null - echo "You have ${CMSG}successfully${CEND} upgrade from ${CWARNING}${OLD_apache_ver}${CEND} to ${CWARNING}${NEW_apache_ver}${CEND}" - rm -rf httpd-${NEW_apache_ver} - else - echo "${CFAILURE}Upgrade Apache failed! ${CEND}" - fi - fi - popd > /dev/null -} - -Upgrade_Tomcat() { - pushd ${current_dir}/src > /dev/null - [ ! -e "${tomcat_install_dir}/conf/server.xml" ] && echo "${CWARNING}Tomcat is not installed on your system! ${CEND}" && exit 1 - OLD_tomcat_ver="`${tomcat_install_dir}/bin/version.sh | awk '/Server number/{print $3}' | awk -F. '{print $1"."$2"."$3}'`" - Tomcat_flag="`echo ${OLD_tomcat_ver} | awk -F. '{print $1}'`" - Latest_tomcat_ver=`curl --connect-timeout 2 -m 3 -s https://tomcat.apache.org/download-${Tomcat_flag}0.cgi | grep "README" | head -1 | grep -oE "[6-9]\.[0-9]\.[0-9]+"` - Latest_tomcat_ver=${Latest_tomcat_ver:-${tomcat10_ver}} - echo - echo "Current Tomcat Version: ${CMSG}${OLD_tomcat_ver}${CEND}" - while :; do echo - [ "${tomcat_flag}" != 'y' ] && read -e -p "Please input upgrade Tomcat Version(Default: ${Latest_tomcat_ver}): " NEW_tomcat_ver - NEW_tomcat_ver=${NEW_tomcat_ver:-${Latest_tomcat_ver}} - if [ "`echo ${NEW_tomcat_ver} | awk -F. '{print $1}'`" == "${Tomcat_flag}" ]; then - rm -f catalina-jmx-remote.jar - echo "Download tomcat-${NEW_tomcat_ver}..." - src_url=${mirror_link}/apache/tomcat/v${NEW_tomcat_ver}/apache-tomcat-${NEW_tomcat_ver}.tar.gz && Download_src - [ ! -e "apache-tomcat-${NEW_tomcat_ver}.tar.gz" ] && wget --no-check-certificate -c https://archive.apache.org/dist/tomcat-${OLD_tomcat_ver}/v${NEW_tomcat_ver}/bin/apache-tomcat-${NEW_tomcat_ver}.tar.gz > /dev/null 2>&1 - if [ -e "${tomcat_install_dir}/lib/catalina-jmx-remote.jar" ]; then - src_url=${mirror_link}/apache/tomcat/v${NEW_tomcat_ver}/catalina-jmx-remote.jar && Download_src - [ ! -e "catalina-jmx-remote.jar" ] && wget --no-check-certificate -c https://archive.apache.org/dist/tomcat-${OLD_tomcat_ver}/v${NEW_tomcat_ver}/bin/extras/catalina-jmx-remote.jar > /dev/null 2>&1 - fi - if [ -e "apache-tomcat-${NEW_tomcat_ver}.tar.gz" ]; then - echo "Download [${CMSG}apache-tomcat-${NEW_tomcat_ver}.tar.gz${CEND}] successfully! " - break - else - echo "${CWARNING}Tomcat version does not exist! ${CEND}" - fi - else - echo "${CWARNING}input error! ${CEND}Please only input '${CMSG}${Tomcat_flag}.xx${CEND}'" - fi - done - - if [ -e "apache-tomcat-${NEW_tomcat_ver}.tar.gz" ]; then - echo "[${CMSG}apache-tomcat-${NEW_tomcat_ver}.tar.gz${CEND}] found" - if [ "${tomcat_flag}" != 'y' ]; then - echo "Press Ctrl+c to cancel or Press any key to continue..." - char=`get_char` - fi - tar xzf apache-tomcat-${NEW_tomcat_ver}.tar.gz - /bin/mv apache-tomcat-${NEW_tomcat_ver}/conf/server.xml{,_bk} - /bin/cp ${tomcat_install_dir}/conf/{server.xml,jmxremote.access,jmxremote.password,tomcat-users.xml} apache-tomcat-${NEW_tomcat_ver}/conf/ - [ -e "${tomcat_install_dir}/lib/catalina-jmx-remote.jar" ] && /bin/cp catalina-jmx-remote.jar apache-tomcat-${NEW_tomcat_ver}/lib - /bin/cp ${tomcat_install_dir}/bin/setenv.sh apache-tomcat-${NEW_tomcat_ver}/bin/ - /bin/cp -R ${tomcat_install_dir}/conf/vhost apache-tomcat-${NEW_tomcat_ver}/conf/ - chmod +x apache-tomcat-${NEW_tomcat_ver}/bin/*.sh - [[ -d ${tomcat_install_dir}_bak && -d ${tomcat_install_dir} ]] && rm -rf ${tomcat_install_dir}._bak - service tomcat stop - /bin/mv ${tomcat_install_dir}{,_bak} - /bin/mv apache-tomcat-${NEW_tomcat_ver} ${tomcat_install_dir} && chown -R ${run_user}:${run_group} ${tomcat_install_dir} - if [ -e "${tomcat_install_dir}/conf/server.xml" ]; then - service tomcat start - echo "You have ${CMSG}successfully${CEND} upgrade from ${CWARNING}${OLD_tomcat_ver}${CEND} to ${CWARNING}${NEW_tomcat_ver}${CEND}" - else - echo "${CFAILURE}Upgrade Tomcat failed! ${CEND}" - fi - fi - popd > /dev/null + popd > /dev/null } diff --git a/include/xcache.sh b/include/xcache.sh new file mode 100644 index 00000000..7668f884 --- /dev/null +++ b/include/xcache.sh @@ -0,0 +1,69 @@ +#!/bin/bash +# Author: yeho +# BLOG: https://blog.linuxeye.com +# +# Notes: OneinStack for CentOS/RadHat 5+ Debian 6+ and Ubuntu 12+ +# +# Project home page: +# https://oneinstack.com +# https://github.com/lj2007331/oneinstack + +Install_XCache() { + pushd ${oneinstack_dir}/src + phpExtensionDir=$(${php_install_dir}/bin/php-config --extension-dir) + tar xzf xcache-${xcache_version}.tar.gz + pushd xcache-${xcache_version} + ${php_install_dir}/bin/phpize + ./configure --enable-xcache --enable-xcache-coverager --enable-xcache-optimizer --with-php-config=${php_install_dir}/bin/php-config + make -j ${THREAD} && make install + if [ -f "${phpExtensionDir}/xcache.so" ]; then + /bin/cp -R htdocs ${wwwroot_dir}/default/xcache + popd + chown -R ${run_user}.${run_user} ${wwwroot_dir}/default/xcache + touch /tmp/xcache;chown ${run_user}.${run_user} /tmp/xcache + let xcacheCount="${CPU}+1" + let xcacheSize="${Memory_limit}/2" + cat > ${php_install_dir}/etc/php.d/ext-xcache.ini << EOF +[xcache-common] +extension=xcache.so +[xcache.admin] +xcache.admin.enable_auth=On +xcache.admin.user=admin +xcache.admin.pass="${xcache_admin_md5_pass}" + +[xcache] +xcache.size=${xcacheSize}M +xcache.count=${xcacheCount} +xcache.slots=8K +xcache.ttl=3600 +xcache.gc_interval=300 +xcache.var_size=4M +xcache.var_count=${xcacheCount} +xcache.var_slots=8K +xcache.var_ttl=0 +xcache.var_maxttl=0 +xcache.var_gc_interval=300 +xcache.test=Off +xcache.readonly_protection=Off +xcache.shm_scheme=mmap +xcache.mmap_path=/tmp/xcache +xcache.coredump_directory= +xcache.cacher=On +xcache.stat=On +xcache.optimizer=Off + +[xcache.coverager] +; enabling this feature will impact performance +; enable only if xcache.coverager == On && xcache.coveragedump_directory == "non-empty-value" +; enable coverage data collecting and xcache_coverager_start/stop/get/clean() functions +xcache.coverager = Off +xcache.coverager_autostart = On +xcache.coveragedump_directory = "" +EOF + echo "${CSUCCESS}Xcache module installed successfully! ${CEND}" + rm -rf xcache-${xcache_version} + else + echo "${CFAILURE}Xcache module install failed, Please contact the author! ${CEND}" + fi + popd +} diff --git a/include/zendopcache.sh b/include/zendopcache.sh index 79e58107..4aa16d10 100644 --- a/include/zendopcache.sh +++ b/include/zendopcache.sh @@ -1,31 +1,35 @@ #!/bin/bash # Author: yeho -# BLOG: https://linuxeye.com +# BLOG: https://blog.linuxeye.com +# +# Notes: OneinStack for CentOS/RadHat 5+ Debian 6+ and Ubuntu 12+ +# +# Project home page: +# https://oneinstack.com +# https://github.com/lj2007331/oneinstack Install_ZendOPcache() { - if [ -e "${php_install_dir}/bin/phpize" ]; then - pushd ${current_dir}/src > /dev/null - phpExtensionDir=$(${php_install_dir}/bin/php-config --extension-dir) - PHP_detail_ver=$(${php_install_dir}/bin/php-config --version) - PHP_main_ver=${PHP_detail_ver%.*} - if [[ "${PHP_main_ver}" =~ ^5.[3-4]$ ]]; then - tar xzf zendopcache-${zendopcache_ver}.tgz - pushd zendopcache-${zendopcache_ver} > /dev/null - else - src_url=https://secure.php.net/distributions/php-${PHP_detail_ver}.tar.gz && Download_src - tar xzf php-${PHP_detail_ver}.tar.gz - pushd php-${PHP_detail_ver}/ext/opcache > /dev/null - fi + pushd ${oneinstack_dir}/src + phpExtensionDir=$(${php_install_dir}/bin/php-config --extension-dir) + PHP_detail_version=$(${php_install_dir}/bin/php -r 'echo PHP_VERSION;') + PHP_main_version=${PHP_detail_version%.*} + if [[ "${PHP_main_version}" =~ ^5.[3-4]$ ]]; then + tar xvf zendopcache-${zendopcache_version}.tgz + pushd zendopcache-${zendopcache_version} + else + tar xvf php-${PHP_detail_version}.tar.gz + pushd php-${PHP_detail_version}/ext/opcache + fi - ${php_install_dir}/bin/phpize - ./configure --with-php-config=${php_install_dir}/bin/php-config - make -j ${THREAD} && make install - popd > /dev/null - if [ -f "${phpExtensionDir}/opcache.so" ]; then - # write opcache configs - if [[ "${PHP_main_ver}" =~ ^5.[3-4]$ ]]; then - # For php 5.3 5.4 - cat > ${php_install_dir}/etc/php.d/02-opcache.ini << EOF + ${php_install_dir}/bin/phpize + ./configure --with-php-config=${php_install_dir}/bin/php-config + make -j ${THREAD} && make install + popd + if [ -f "${phpExtensionDir}/opcache.so" ]; then + # write opcache configs + if [[ "${PHP_main_version}" =~ ^5.[3-4]$ ]]; then + # For php 5.3 5.4 + cat > ${php_install_dir}/etc/php.d/ext-opcache.ini << EOF [opcache] zend_extension=${phpExtensionDir}/opcache.so opcache.enable=1 @@ -33,15 +37,14 @@ opcache.memory_consumption=${Memory_limit} opcache.interned_strings_buffer=8 opcache.max_accelerated_files=4000 opcache.revalidate_freq=60 -;opcache.save_comments=0 +opcache.save_comments=0 opcache.fast_shutdown=1 opcache.enable_cli=1 ;opcache.optimization_level=0 EOF - rm -rf zendopcache-${zendopcache_ver} - else - # For php 5.5+ - cat > ${php_install_dir}/etc/php.d/02-opcache.ini << EOF + else + # For php 5.5+ + cat > ${php_install_dir}/etc/php.d/ext-opcache.ini << EOF [opcache] zend_extension=opcache.so opcache.enable=1 @@ -53,27 +56,17 @@ opcache.max_wasted_percentage=5 opcache.use_cwd=1 opcache.validate_timestamps=1 opcache.revalidate_freq=60 -;opcache.save_comments=0 +opcache.save_comments=0 opcache.fast_shutdown=1 opcache.consistency_checks=0 ;opcache.optimization_level=0 EOF - fi - - echo "${CSUCCESS}PHP opcache module installed successfully! ${CEND}" - rm -rf php-${PHP_detail_ver} - else - echo "${CFAILURE}PHP opcache module install failed, Please contact the author! ${CEND}" && grep -Ew 'NAME|ID|ID_LIKE|VERSION_ID|PRETTY_NAME' /etc/os-release fi - popd > /dev/null - fi -} -Uninstall_ZendOPcache() { - if [ -e "${php_install_dir}/etc/php.d/02-opcache.ini" ]; then - rm -f ${php_install_dir}/etc/php.d/02-opcache.ini - echo; echo "${CMSG}PHP opcache module uninstall completed${CEND}" + echo "${CSUCCESS}PHP OPcache module installed successfully! ${CEND}" + rm -rf zendopcache-${zendopcache_version} php-${PHP_detail_version} else - echo; echo "${CWARNING}PHP opcache module does not exist! ${CEND}" + echo "${CFAILURE}PHP OPcache module install failed, Please contact the author! ${CEND}" fi + popd } diff --git a/init.d/Memcached-init-CentOS b/init.d/Memcached-init-CentOS new file mode 100755 index 00000000..fe90d14b --- /dev/null +++ b/init.d/Memcached-init-CentOS @@ -0,0 +1,77 @@ +#!/bin/sh +# +# chkconfig: - 55 45 +# description: The memcached daemon is a network memory cache service. +# processname: memcached +# config: /etc/sysconfig/memcached + +# Source function library. +. /etc/rc.d/init.d/functions + +PORT=11211 +USER=memcached +MAXCONN=1024 +CACHESIZE=256 +OPTIONS="-l 127.0.0.1" +DAEMON=/usr/local/memcached/bin/memcached + +if [ "$NETWORKING" = "no" ] +then + exit 0 +fi + +RETVAL=0 +prog="memcached" + +start () { + echo -n $"Starting $prog: " + # insure that /var/run/memcached has proper permissions + mkdir -p /var/run/memcached + if [ "$(stat -c %U /var/run/memcached)" != "$USER" ]; then + chown $USER /var/run/memcached + fi + daemon $DAEMON -d -p $PORT -u $USER -m $CACHESIZE -c $MAXCONN -P /var/run/memcached/memcached.pid $OPTIONS + RETVAL=$? + echo + [ $RETVAL -eq 0 ] && touch /var/lock/subsys/memcached +} +stop () { + echo -n $"Stopping $prog: " + killproc memcached + RETVAL=$? + echo + if [ $RETVAL -eq 0 ] ; then + rm -f /var/lock/subsys/memcached + rm -f /var/run/memcached/memcached.pid + fi +} + +restart () { + stop + start +} + + +# See how we were called. +case "$1" in + start) + start + ;; + stop) + stop + ;; + status) + status memcached + ;; + restart|reload) + restart + ;; + condrestart) + [ -f /var/lock/subsys/memcached ] && restart || : + ;; + *) + echo $"Usage: $0 {start|stop|status|restart|reload|condrestart}" + exit 1 +esac + +exit $? diff --git a/init.d/Memcached-init-Ubuntu b/init.d/Memcached-init-Ubuntu new file mode 100755 index 00000000..69bdbec5 --- /dev/null +++ b/init.d/Memcached-init-Ubuntu @@ -0,0 +1,101 @@ +#! /bin/bash +### BEGIN INIT INFO +# Provides: memcached +# Required-Start: $syslog +# Required-Stop: $syslog +# Should-Start: $local_fs +# Should-Stop: $local_fs +# Default-Start: 2 3 4 5 +# Default-Stop: 0 1 6 +# Short-Description: memcached - Memory caching daemon +# Description: memcached - Memory caching daemon +### END INIT INFO +# +# memcached: MemCached Daemon +# +# chkconfig: - 90 25 +# description: MemCached Daemon +# + +PORT=11211 +USER=memcached +MAXCONN=1024 +OPTIONS="-l 127.0.0.1" +DAEMON=/usr/local/memcached/bin/memcached + +RETVAL=0 +prog="/usr/local/memcached/bin/memcached" + +start_instance() { + echo -n $"Starting $prog ($1): " + start-stop-daemon --start --quiet --pidfile /var/run/memcached/memcached.$1.pid --exec $DAEMON -- -d -p $PORT -u $USER -m $2 -c $MAXCONN -P /var/run/memcached/memcached.$1.pid $OPTIONS + RETVAL=$? + echo + [ $RETVAL -eq 0 ] && touch /var/lock/memcached.$1 + let PORT="$PORT+1" +} + +stop_instance() { + echo -n $"Stopping $prog ($1): " + start-stop-daemon --stop --quiet --oknodo --pidfile /var/run/memcached/memcached.$1.pid --exec $DAEMON + RETVAL=$? + echo + if [ $RETVAL -eq 0 ] ; then + rm -f /var/lock/memcached.$1 + rm -f /var/run/memcached/memcached.$1.pid + fi +} +start () { + # insure that /var/run/memcached has proper permissions + mkdir -p /var/run/memcached + if [ "$(stat -c %U /var/run/memcached)" != "$USER" ]; then + chown $USER /var/run/memcached + fi + + start_instance default 256; + #start_instance block 16; + #start_instance content 128; + #start_instance filter 128; + #start_instance form 32; + #start_instance menu 16; + #start_instance page 8; + #start_instance update 8; + #start_instance views 8; +} +stop () { + stop_instance default; + #stop_instance block; + #stop_instance content; + #stop_instance filter; + #stop_instance form; + #stop_instance menu; + #stop_instance page; + #stop_instance update; + #stop_instance views; +} + +restart () { + stop + start +} + +# See how we were called. +case "$1" in + start) + start + ;; + stop) + stop + ;; + status) + status memcached + ;; + restart|reload|force-reload) + restart + ;; + *) + echo $"Usage: $0 {start|stop|status|restart|reload|force-reload}" + exit 1 +esac + +exit $? diff --git a/init.d/Nginx-init-CentOS b/init.d/Nginx-init-CentOS new file mode 100755 index 00000000..1ed372fc --- /dev/null +++ b/init.d/Nginx-init-CentOS @@ -0,0 +1,131 @@ +#!/bin/bash +# +# nginx - this script starts and stops the nginx daemon +# +# chkconfig: - 85 15 +# description: NGINX is an HTTP(S) server, HTTP(S) reverse \ +# proxy and IMAP/POP3 proxy server +# processname: nginx +# config: /etc/nginx/nginx.conf +# config: /etc/sysconfig/nginx +# pidfile: /var/run/nginx.pid + +# Source function library. +. /etc/rc.d/init.d/functions + +# Source networking configuration. +. /etc/sysconfig/network + +# Check that networking is up. +[ "$NETWORKING" = "no" ] && exit 0 + +nginx="/usr/local/nginx/sbin/nginx" +prog=$(basename $nginx) + +NGINX_CONF_FILE="/usr/local/nginx/conf/nginx.conf" + +[ -f /etc/sysconfig/nginx ] && . /etc/sysconfig/nginx + +lockfile=/var/lock/subsys/nginx + +make_dirs() { + # make required directories + user=`$nginx -V 2>&1 | grep "configure arguments:.*--user=" | sed 's/[^*]*--user=\([^ ]*\).*/\1/g' -` + if [ -n "$user" ]; then + if [ -z "`grep $user /etc/passwd`" ]; then + useradd -M -s /bin/nologin $user + fi + options=`$nginx -V 2>&1 | grep 'configure arguments:'` + for opt in $options; do + if [ `echo $opt | grep '.*-temp-path'` ]; then + value=`echo $opt | cut -d "=" -f 2` + if [ ! -d "$value" ]; then + # echo "creating" $value + mkdir -p $value && chown -R $user $value + fi + fi + done + fi +} + +start() { + [ -x $nginx ] || exit 5 + [ -f $NGINX_CONF_FILE ] || exit 6 + make_dirs + echo -n $"Starting $prog: " + daemon $nginx -c $NGINX_CONF_FILE + retval=$? + echo + [ $retval -eq 0 ] && touch $lockfile + return $retval +} + +stop() { + echo -n $"Stopping $prog: " + killproc $prog -QUIT + retval=$? + echo + [ $retval -eq 0 ] && rm -f $lockfile + return $retval +} + +restart() { + configtest || return $? + stop + sleep 1 + start +} + +reload() { + configtest || return $? + echo -n $"Reloading $prog: " + killproc $nginx -HUP + RETVAL=$? + echo +} + +force_reload() { + restart +} + +configtest() { + $nginx -t -c $NGINX_CONF_FILE +} + +rh_status() { + status $prog +} + +rh_status_q() { + rh_status >/dev/null 2>&1 +} + +case "$1" in + start) + rh_status_q && exit 0 + $1 + ;; + stop) + rh_status_q || exit 0 + $1 + ;; + restart|configtest) + $1 + ;; + reload) + rh_status_q || exit 7 + $1 + ;; + force-reload) + force_reload + ;; + status) + rh_status + ;; + condrestart|try-restart) + rh_status_q || exit 0 + ;; + *) + echo $"Usage: $0 {start|stop|status|restart|reload|configtest}" + exit 2 +esac diff --git a/init.d/Nginx-init-Ubuntu b/init.d/Nginx-init-Ubuntu new file mode 100755 index 00000000..15a3cd90 --- /dev/null +++ b/init.d/Nginx-init-Ubuntu @@ -0,0 +1,62 @@ +#! /bin/sh + +### BEGIN INIT INFO +# Provides: nginx +# Required-Start: $all +# Required-Stop: $all +# Default-Start: 2 3 4 5 +# Default-Stop: 0 1 6 +# Short-Description: starts the nginx web server +# Description: starts nginx using start-stop-daemon +### END INIT INFO + +PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin +DAEMON=/usr/local/nginx/sbin/nginx +DAEMON_OPTS='-c /usr/local/nginx/conf/nginx.conf' +NAME=nginx +DESC=nginx + +test -x $DAEMON || exit 0 + +# Include nginx defaults if available +if [ -f /etc/default/nginx ] ; then + . /etc/default/nginx +fi + +set -e + +case "$1" in + start) + echo -n "Starting $DESC: " + start-stop-daemon --start --quiet --pidfile /var/run/nginx.pid --exec $DAEMON -- $DAEMON_OPTS + echo "$NAME." + ;; + stop) + echo -n "Stopping $DESC: " + start-stop-daemon --stop --quiet --pidfile /var/run/nginx.pid --exec $DAEMON + echo "$NAME." + ;; + restart|force-reload) + echo -n "Restarting $DESC: " + start-stop-daemon --stop --quiet --pidfile /var/run/nginx.pid --exec $DAEMON + sleep 1 + start-stop-daemon --start --quiet --pidfile /var/run/nginx.pid --exec $DAEMON -- $DAEMON_OPTS + echo "$NAME." + ;; + reload) + echo -n "Reloading $DESC configuration: " + start-stop-daemon --stop --signal HUP --quiet --pidfile /var/run/nginx.pid \ + --exec $DAEMON + echo "$NAME." + ;; + configtest) + $DAEMON -t $DAEMON_OPTS + ;; + *) + N=/etc/init.d/$NAME + echo "Usage: $N {start|stop|restart|configtest|force-reload}" >&2 + exit 1 + ;; +esac + +exit 0 diff --git a/init.d/Pureftpd-init b/init.d/Pureftpd-init new file mode 100755 index 00000000..6a3fc64a --- /dev/null +++ b/init.d/Pureftpd-init @@ -0,0 +1,65 @@ +#!/bin/bash +### BEGIN INIT INFO +# Provides: pureftpd +# Required-Start: $local_fs $remote_fs $network $syslog +# Required-Stop: $local_fs $remote_fs $network $syslog +# Default-Start: 2 3 4 5 +# Default-Stop: 0 1 6 +# Short-Description: Startup script for the pure-ftpd FTP Server +# Description: pureftpd daemon +### END INIT INFO +# Startup script for the pure-ftpd FTP Server $Revision: 1.3 $ +# +# chkconfig: 2345 85 15 +# Default-Start: 2 3 4 5 +# Default-Stop: 0 1 6 +# description: Pure-FTPd is an FTP server daemon based upon Troll-FTPd +# processname: pure-ftpd +# pidfile: /var/run/pure-ftpd.pid +# config: /usr/local/pureftpd/etc/pure-ftpd.conf + +# Source function library. +. /etc/rc.d/init.d/functions + +RETVAL=0 + +# Path to the pure-ftp binaries. +prog=pure-ftpd +fullpath=/usr/local/pureftpd/sbin/$prog +pure_config=/usr/local/pureftpd/etc/pure-ftpd.conf + +start() { + echo -n $"Starting $prog: " + $fullpath $pure_config + RETVAL=$? + [ $RETVAL = 0 ] && touch /var/lock/subsys/$prog + echo +} +stop() { + echo -n $"Stopping $prog: " + kill $(cat /var/run/pure-ftpd.pid) + RETVAL=$? + [ $RETVAL = 0 ] && rm -f /var/lock/subsys/$prog + echo +} + +# See how we were called. +case "$1" in + start) + start + ;; + stop) + stop + ;; + restart) + stop + start + ;; + status) + status $prog + ;; + *) + echo $"Usage: $prog {start|stop|restart|status}" + RETVAL=1 +esac +exit $RETVAL diff --git a/init.d/Redis-server-init b/init.d/Redis-server-init new file mode 100755 index 00000000..9b3fbcac --- /dev/null +++ b/init.d/Redis-server-init @@ -0,0 +1,71 @@ +#! /bin/sh +### BEGIN INIT INFO +# Provides: redis-server +# Required-Start: $syslog +# Required-Stop: $syslog +# Should-Start: $local_fs +# Should-Stop: $local_fs +# Default-Start: 2 3 4 5 +# Default-Stop: 0 1 6 +# Short-Description: redis-server - Persistent key-value db +# Description: redis-server - Persistent key-value db +### END INIT INFO + +PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin +DAEMON=/usr/local/redis/bin/redis-server +DAEMON_ARGS=/usr/local/redis/etc/redis.conf +NAME=redis-server +DESC=redis-server +PIDFILE=/var/run/redis.pid + +test -x $DAEMON || exit 0 +test -x $DAEMONBOOTSTRAP || exit 0 + +set -e + +case "$1" in + start) + echo -n "Starting $DESC: " + touch $PIDFILE + chown redis:redis $PIDFILE + if start-stop-daemon --start --quiet --pidfile $PIDFILE --chuid redis:redis --exec $DAEMON -- $DAEMON_ARGS + then + echo "[OK]" + else + echo "failed" + fi + ;; + stop) + echo -n "Stopping $DESC: " + if start-stop-daemon --stop --retry 10 --quiet --oknodo --pidfile $PIDFILE --exec $DAEMON + then + echo "[OK]" + else + echo "failed" + fi + rm -f $PIDFILE + ;; + status) + if [ ! -r $PIDFILE ] ; then + echo "redis-server is stopped" + exit 0 + fi + + PID=`cat $PIDFILE` + if ps -p $PID | grep -q $PID; then + echo "redis-server (pid $PID) is running..." + else + echo "redis-server dead but pid file exists" + fi + ;; + restart|force-reload) + ${0} stop + ${0} start + ;; + *) + echo "Usage: /etc/init.d/$NAME {start|stop|restart|status|force-reload}" >&2 + exit 1 + ;; +esac + +exit 0 diff --git a/init.d/SS-libev-init b/init.d/SS-libev-init new file mode 100755 index 00000000..322fc028 --- /dev/null +++ b/init.d/SS-libev-init @@ -0,0 +1,124 @@ +#!/bin/bash +# +# Script to run SS in daemon mode at boot time. +# ScriptAuthor: icyboy +# Revision 1.0 - 14th Sep 2013 +#==================================================================== +# Run level information: +# chkconfig: 2345 99 99 +# Description: lightweight secured scoks5 proxy +# processname: ss-server +# Author: Max Lv ; +# Run "/sbin/chkconfig --add shadowsocks" to add the Run levels. +#==================================================================== + +#==================================================================== +# Paths and variables and system checks. + +# Source function library +. /etc/rc.d/init.d/functions + +# Check that networking is up. +# +[ ${NETWORKING} ="yes" ] || exit 0 + +# Daemon +NAME=ss-server +DAEMON=/usr/local/bin/ss-server + +# Path to the configuration file. +# +CONF=/etc/shadowsocks/config.json + +#USER="nobody" +#GROUP="nobody" + +# Take care of pidfile permissions +mkdir /var/run/$NAME 2>/dev/null || true +#chown "$USER:$GROUP" /var/run/$NAME + +# Check the configuration file exists. +# +if [ ! -f $CONF ]; then + echo "The configuration file cannot be found!" + exit 0 +fi + +# Path to the lock file. +# +LOCK_FILE=/var/lock/subsys/shadowsocks + +# Path to the pid file. +# +PID=/var/run/$NAME/pid + + +#==================================================================== + +#==================================================================== +# Run controls: + +RETVAL=0 + +# Start SS as daemon. +# +start() { + if [ -f $LOCK_FILE ]; then + echo "$NAME is already running!" + exit 0 + else + echo -n $"Starting ${NAME}: " + #daemon --check $DAEMON --user $USER "$DAEMON -f $PID -c $CONF > /dev/null" + daemon $DAEMON -u -c $CONF -f $PID + fi + + RETVAL=$? + [ $RETVAL -eq 0 ] && success + echo + [ $RETVAL -eq 0 ] && touch $LOCK_FILE + return $RETVAL +} + + +# Stop SS. +# +stop() { + echo -n $"Shutting down ${NAME}: " + killproc -p ${PID} + RETVAL=$? + [ $RETVAL -eq 0 ] + rm -f $LOCK_FILE + rm -f ${PID} + echo + return $RETVAL +} + +# See how we were called. +case "$1" in + start) + start + ;; + stop) + stop + ;; + restart) + stop + start + ;; + condrestart) + if [ -f $LOCK_FILE ]; then + stop + start + RETVAL=$? + fi + ;; + status) + status $DAEMON + RETVAL=$? + ;; + *) + echo $"Usage: $0 {start|stop|restart|condrestart|status}" + RETVAL=1 +esac + +exit $RETVAL diff --git a/init.d/SS-python-init b/init.d/SS-python-init new file mode 100755 index 00000000..4473b863 --- /dev/null +++ b/init.d/SS-python-init @@ -0,0 +1,99 @@ +#!/bin/bash +# Author: yeho +# BLOG: https://blog.linuxeye.com +### BEGIN INIT INFO +# Provides: SS +# Required-Start: $local_fs $remote_fs $network $syslog +# Required-Start: $local_fs $remote_fs $network $syslog +# Default-Start: 2 3 4 5 +# Default-Stop: 0 1 6 +# Short-Description: SS - SS-python starts daemon +# Description: SS - lightweight secured scoks5 proxy +### END INIT INFO +# +# chkconfig: - 90 10 +# description: SS start/stop/status/restart script + +SS_bin=/usr/local/python/bin/ssserver +SS_conf=/etc/shadowsocks/config.json + +#SS_USAGE is the message if this script is called without any options +SS_USAGE="Usage: $0 {\e[00;32mstart\e[00m|\e[00;31mstop\e[00m|\e[00;32mstatus\e[00m|\e[00;31mrestart\e[00m}" + +#SHUTDOWN_WAIT is wait time in seconds for SS proccess to stop +SHUTDOWN_WAIT=20 + +SS_pid(){ + echo `ps -ef | grep $SS_bin | grep -v grep | tr -s " "|cut -d" " -f2` +} + +start() { + pid=$(SS_pid) + if [ -n "$pid" ]; then + echo -e "\e[00;31mSS is already running (pid: $pid)\e[00m" + else + $SS_bin -c $SS_conf -d start + RETVAL=$? + if [ "$RETVAL" = "0" ]; then + echo -e "\e[00;32mStarting SS\e[00m" + else + echo -e "\e[00;32mSS start Failed\e[00m" + fi + status + fi + return 0 +} + +status(){ + pid=$(SS_pid) + if [ -n "$pid" ]; then + echo -e "\e[00;32mSS is running with pid: $pid\e[00m" + else + echo -e "\e[00;31mSS is not running\e[00m" + fi +} + +stop(){ + pid=$(SS_pid) + if [ -n "$pid" ]; then + echo -e "\e[00;31mStoping SS\e[00m" + $SS_bin -c $SS_conf -d stop + let kwait=$SHUTDOWN_WAIT + count=0; + until [ `ps -p $pid | grep -c $pid` = '0' ] || [ $count -gt $kwait ] + do + echo -n -e "\e[00;31mwaiting for processes to exit\e[00m\n"; + sleep 1 + let count=$count+1; + done + + if [ $count -gt $kwait ]; then + echo -n -e "\n\e[00;31mkilling processes which didn't stop after $SHUTDOWN_WAIT seconds\e[00m" + kill -9 $pid + fi + else + echo -e "\e[00;31mSS is not running\e[00m" + fi + + return 0 +} + +case $1 in + start) + start + ;; + stop) + stop + ;; + restart) + stop + start + ;; + status) + status + ;; + *) + echo -e $SS_USAGE + ;; +esac +exit 0 diff --git a/init.d/Supervisor-init-CentOS b/init.d/Supervisor-init-CentOS new file mode 100755 index 00000000..d90a53e4 --- /dev/null +++ b/init.d/Supervisor-init-CentOS @@ -0,0 +1,150 @@ +#!/bin/bash +# +# supervisord This scripts turns supervisord on +# +# Author: Mike McGrath (based off yumupdatesd) +# Jason Koppe adjusted to read sysconfig, +# use supervisord tools to start/stop, conditionally wait +# for child processes to shutdown, and startup later +# Mikhail Mingalev Merged +# redhat-init-jkoppe and redhat-sysconfig-jkoppe, and +# made the script "simple customizable". +# Brendan Maguire Added OPTIONS to +# SUPERVISORCTL status call +# +# chkconfig: 345 83 04 +# +# description: supervisor is a process control utility. It has a web based +# xmlrpc interface as well as a few other nifty features. +# Script was originally written by Jason Koppe . +# + +# source function library +. /etc/rc.d/init.d/functions + +set -a + +PREFIX=/usr + +SUPERVISORD=$PREFIX/bin/supervisord +SUPERVISORCTL=$PREFIX/bin/supervisorctl + +PIDFILE=/var/run/supervisord.pid +LOCKFILE=/var/lock/subsys/supervisord + +OPTIONS="-c /etc/supervisord.conf" + +# unset this variable if you don't care to wait for child processes to shutdown before removing the $LOCKFILE-lock +WAIT_FOR_SUBPROCESSES=yes + +# remove this if you manage number of open files in some other fashion +ulimit -n 96000 + +RETVAL=0 + + +running_pid() { + # Check if a given process pid's cmdline matches a given name + pid=$1 + name=$2 + [ -z "$pid" ] && return 1 + [ ! -d /proc/$pid ] && return 1 + (cat /proc/$pid/cmdline | tr "\000" "\n"|grep -q $name) || return 1 + return 0 +} + +running() { +# Check if the process is running looking at /proc +# (works for all users) + + # No pidfile, probably no daemon present + [ ! -f "$PIDFILE" ] && return 1 + # Obtain the pid and check it against the binary name + pid=`cat $PIDFILE` + running_pid $pid $SUPERVISORD || return 1 + return 0 +} + +start() { + echo "Starting supervisord: " + + if [ -e $PIDFILE ]; then + echo "ALREADY STARTED" + return 1 + fi + + # start supervisord with options from sysconfig (stuff like -c) + $SUPERVISORD $OPTIONS + + # show initial startup status + $SUPERVISORCTL $OPTIONS status + + # only create the subsyslock if we created the PIDFILE + [ -e $PIDFILE ] && touch $LOCKFILE +} + +stop() { + echo -n "Stopping supervisord: " + $SUPERVISORCTL $OPTIONS shutdown + if [ -n "$WAIT_FOR_SUBPROCESSES" ]; then + echo "Waiting roughly 60 seconds for $PIDFILE to be removed after child processes exit" + for sleep in 2 2 2 2 4 4 4 4 8 8 8 8 last; do + if [ ! -e $PIDFILE ] ; then + echo "Supervisord exited as expected in under $total_sleep seconds" + break + else + if [[ $sleep -eq "last" ]] ; then + echo "Supervisord still working on shutting down. We've waited roughly 60 seconds, we'll let it do its thing from here" + return 1 + else + sleep $sleep + total_sleep=$(( $total_sleep + $sleep )) + fi + fi + done + fi + + # always remove the subsys. We might have waited a while, but just remove it at this point. + rm -f $LOCKFILE +} + +restart() { + stop + start +} + +case "$1" in + start) + start + RETVAL=$? + ;; + stop) + stop + RETVAL=$? + ;; + restart|force-reload) + restart + RETVAL=$? + ;; + reload) + $SUPERVISORCTL $OPTIONS reload + RETVAL=$? + ;; + condrestart) + [ -f $LOCKFILE ] && restart + RETVAL=$? + ;; + status) + $SUPERVISORCTL $OPTIONS status + if running ; then + RETVAL=0 + else + RETVAL=1 + fi + ;; + *) + echo $"Usage: $0 {start|stop|status|restart|reload|force-reload|condrestart}" + exit 1 +esac + +exit $RETVAL diff --git a/init.d/Tomcat-init b/init.d/Tomcat-init index 19f6a16b..0c45c2f2 100755 --- a/init.d/Tomcat-init +++ b/init.d/Tomcat-init @@ -31,7 +31,7 @@ TOMCAT_USAGE="Usage: $0 {\e[00;32mstart\e[00m|\e[00;31mstop\e[00m|\e[00;32mstatu SHUTDOWN_WAIT=20 tomcat_pid() { - echo `ps -ef | grep java | grep $CATALINA_HOME/ | grep -v grep | tr -s " "|cut -d" " -f2` + echo `ps -ef | grep $CATALINA_HOME/ | grep -v grep | tr -s " "|cut -d" " -f2` } start() { @@ -87,12 +87,7 @@ stop() { user_exists() { if id -u $1 >/dev/null 2>&1; then - islogin=`cat /etc/passwd | grep ^${TOMCAT_USER}: | grep nologin$` - if [ "${islogin: -7}" = "nologin" ]; then - echo "0" - else - echo "1" - fi + echo "1" else echo "0" fi diff --git a/init.d/httpd.service b/init.d/httpd.service deleted file mode 100644 index cfd0dcfa..00000000 --- a/init.d/httpd.service +++ /dev/null @@ -1,18 +0,0 @@ -[Unit] -Description=The Apache HTTP Server -After=network.target - -[Service] -Type=forking -PIDFile=/var/run/httpd.pid -ExecStartPre=/usr/local/apache/bin/apachectl -t -ExecStart=/usr/local/apache/bin/apachectl -k start -ExecReload=/usr/local/apache/bin/apachectl -k graceful -ExecStop=/usr/local/apache/bin/apachectl -k graceful-stop -PrivateTmp=true -LimitNOFILE=1000000 -LimitNPROC=1000000 -LimitCORE=1000000 - -[Install] -WantedBy=multi-user.target diff --git a/init.d/memcached.service b/init.d/memcached.service deleted file mode 100644 index e8c3ec4c..00000000 --- a/init.d/memcached.service +++ /dev/null @@ -1,88 +0,0 @@ -# It's not recommended to modify this file in-place, because it will be -# overwritten during upgrades. If you want to customize, the best -# way is to use the "systemctl edit" command to create an override unit. -# -# For example, to pass additional options, create an override unit -# (as is done by systemctl edit) and enter the following: -# -# [Service] -# Environment=OPTIONS="-l 127.0.0.1,::1" - - -[Unit] -Description=memcached daemon -After=network.target - -[Service] -Environment=PORT=11211 -Environment=USER=memcached -Environment=MAXCONN=1024 -Environment=CACHESIZE=256 -Environment="OPTIONS=-l 127.0.0.1" -ExecStart=/usr/bin/memcached -p ${PORT} -u ${USER} -m ${CACHESIZE} -c ${MAXCONN} $OPTIONS - -# Set up a new file system namespace and mounts private /tmp and /var/tmp -# directories so this service cannot access the global directories and -# other processes cannot access this service's directories. -PrivateTmp=true - -# Mounts the /usr, /boot, and /etc directories read-only for processes -# invoked by this unit. -ProtectSystem=full - -# Ensures that the service process and all its children can never gain new -# privileges -NoNewPrivileges=true - -# Sets up a new /dev namespace for the executed processes and only adds API -# pseudo devices such as /dev/null, /dev/zero or /dev/random (as well as -# the pseudo TTY subsystem) to it, but no physical devices such as /dev/sda. -PrivateDevices=true - -# Required for dropping privileges and running as a different user -CapabilityBoundingSet=CAP_SETGID CAP_SETUID CAP_SYS_RESOURCE - -# Restricts the set of socket address families accessible to the processes -# of this unit. Protects against vulnerabilities such as CVE-2016-8655 -RestrictAddressFamilies=AF_INET AF_INET6 AF_UNIX - - -# Some security features are not in the older versions of systemd used by -# e.g. RHEL7/CentOS 7. The below settings are automatically edited at package -# build time to uncomment them if the target platform supports them. - -# Attempts to create memory mappings that are writable and executable at -# the same time, or to change existing memory mappings to become executable -# are prohibited. -##safer##MemoryDenyWriteExecute=true - -# Explicit module loading will be denied. This allows to turn off module -# load and unload operations on modular kernels. It is recommended to turn -# this on for most services that do not need special file systems or extra -# kernel modules to work. -##safer##ProtectKernelModules=true - -# Kernel variables accessible through /proc/sys, /sys, /proc/sysrq-trigger, -# /proc/latency_stats, /proc/acpi, /proc/timer_stats, /proc/fs and /proc/irq -# will be made read-only to all processes of the unit. Usually, tunable -# kernel variables should only be written at boot-time, with the sysctl.d(5) -# mechanism. Almost no services need to write to these at runtime; it is hence -# recommended to turn this on for most services. -##safer##ProtectKernelTunables=true - -# The Linux Control Groups (cgroups(7)) hierarchies accessible through -# /sys/fs/cgroup will be made read-only to all processes of the unit. -# Except for container managers no services should require write access -# to the control groups hierarchies; it is hence recommended to turn this -# on for most services -##safer##ProtectControlGroups=true - -# Any attempts to enable realtime scheduling in a process of the unit are -# refused. -##safer##RestrictRealtime=true - -# Takes away the ability to create or manage any kind of namespace -##safer##RestrictNamespaces=true - -[Install] -WantedBy=multi-user.target diff --git a/init.d/mongod.service b/init.d/mongod.service deleted file mode 100644 index 02bfe721..00000000 --- a/init.d/mongod.service +++ /dev/null @@ -1,37 +0,0 @@ -[Unit] -Description=MongoDB Database Server -After=multi-user.target -Documentation=https://docs.mongodb.org/manual - -[Service] -User=mongod -Group=mongod -Environment="OPTIONS=-f /etc/mongod.conf" -EnvironmentFile=-/etc/sysconfig/mongod -ExecStart=/usr/local/mongodb/bin/mongod $OPTIONS -ExecStartPre=/bin/mkdir -p /var/run/mongodb -ExecStartPre=/bin/chown mongod:mongod /var/run/mongodb -ExecStartPre=/bin/chmod 0755 /var/run/mongodb -PermissionsStartOnly=true -PIDFile=/var/run/mongodb/mongod.pid -Type=forking -# file size -LimitFSIZE=infinity -# cpu time -LimitCPU=infinity -# virtual memory size -LimitAS=infinity -# open files -LimitNOFILE=64000 -# processes/threads -LimitNPROC=64000 -# locked memory -LimitMEMLOCK=infinity -# total threads (user+kernel) -TasksMax=infinity -TasksAccounting=false -# Recommended limits for for mongod as specified in -# http://docs.mongodb.org/manual/reference/ulimit/#recommended-settings - -[Install] -WantedBy=multi-user.target diff --git a/init.d/nginx.service b/init.d/nginx.service deleted file mode 100644 index 79e39881..00000000 --- a/init.d/nginx.service +++ /dev/null @@ -1,20 +0,0 @@ -[Unit] -Description=nginx - high performance web server -Documentation=http://nginx.org/en/docs/ -After=network.target - -[Service] -Type=forking -PIDFile=/var/run/nginx.pid -ExecStartPost=/bin/sleep 0.1 -ExecStartPre=/usr/local/nginx/sbin/nginx -t -c /usr/local/nginx/conf/nginx.conf -ExecStart=/usr/local/nginx/sbin/nginx -c /usr/local/nginx/conf/nginx.conf -ExecReload=/bin/kill -s HUP $MAINPID -ExecStop=/bin/kill -s QUIT $MAINPID -TimeoutStartSec=120 -LimitNOFILE=1000000 -LimitNPROC=1000000 -LimitCORE=1000000 - -[Install] -WantedBy=multi-user.target diff --git a/init.d/php-fpm.service b/init.d/php-fpm.service deleted file mode 100644 index 6538a505..00000000 --- a/init.d/php-fpm.service +++ /dev/null @@ -1,16 +0,0 @@ -[Unit] -Description=The PHP FastCGI Process Manager -Documentation=http://php.net/docs.php -After=network.target - -[Service] -Type=simple -PIDFile=/usr/local/php/var/run/php-fpm.pid -ExecStart=/usr/local/php/sbin/php-fpm --nodaemonize --fpm-config /usr/local/php/etc/php-fpm.conf -ExecReload=/bin/kill -USR2 $MAINPID -LimitNOFILE=1000000 -LimitNPROC=1000000 -LimitCORE=1000000 - -[Install] -WantedBy=multi-user.target diff --git a/init.d/postgresql.service b/init.d/postgresql.service deleted file mode 100644 index 107ff5f1..00000000 --- a/init.d/postgresql.service +++ /dev/null @@ -1,39 +0,0 @@ -[Unit] -Description=PostgreSQL database server -After=network.target - -[Service] -Type=forking - -User=postgres -Group=postgres - -# Where to send early-startup messages from the server (before the logging -# options of postgresql.conf take effect) -# This is normally controlled by the global default set by systemd -# StandardOutput=syslog - -# Disable OOM kill on the postmaster -OOMScoreAdjust=-1000 -# ... but allow it still to be effective for child processes -# (note that these settings are ignored by Postgres releases before 9.5) -Environment=PG_OOM_ADJUST_FILE=/proc/self/oom_score_adj -Environment=PG_OOM_ADJUST_VALUE=0 - -# Maximum number of seconds pg_ctl will wait for postgres to start. Note that -# PGSTARTTIMEOUT should be less than TimeoutSec value. -Environment=PGSTARTTIMEOUT=270 - -Environment=PGDATA=/data/pgsql - -ExecStart=/usr/local/pgsql/bin/pg_ctl start -D ${PGDATA} -s -w -t ${PGSTARTTIMEOUT} -ExecStop=/usr/local/pgsql/bin/pg_ctl stop -D ${PGDATA} -s -m fast -ExecReload=/usr/local/pgsql/bin/pg_ctl reload -D ${PGDATA} -s - -# Give a reasonable amount of time for the server to start up/shut down. -# Ideally, the timeout for starting PostgreSQL server should be handled more -# nicely by pg_ctl in ExecStart, so keep its timeout smaller than this value. -TimeoutSec=300 - -[Install] -WantedBy=multi-user.target diff --git a/init.d/pureftpd.service b/init.d/pureftpd.service deleted file mode 100644 index 31bb779b..00000000 --- a/init.d/pureftpd.service +++ /dev/null @@ -1,11 +0,0 @@ -[Unit] -Description=Pure-FTPd FTP server -After=network.target - -[Service] -Type=forking -PIDFile=/var/run/pure-ftpd.pid -ExecStart=/usr/local/pureftpd/sbin/pure-ftpd /usr/local/pureftpd/etc/pure-ftpd.conf - -[Install] -WantedBy=multi-user.target diff --git a/init.d/redis-server.service b/init.d/redis-server.service deleted file mode 100644 index cf67b4c3..00000000 --- a/init.d/redis-server.service +++ /dev/null @@ -1,23 +0,0 @@ -[Unit] -Description=Redis In-Memory Data Store -After=network.target - -[Service] -Type=forking -PIDFile=/var/run/redis/redis.pid -User=redis -Group=redis - -Environment=statedir=/var/run/redis -PermissionsStartOnly=true -ExecStartPre=/bin/mkdir -p ${statedir} -ExecStartPre=/bin/chown -R redis:redis ${statedir} -ExecStart=/usr/local/redis/bin/redis-server /usr/local/redis/etc/redis.conf -ExecStop=/bin/kill -s TERM $MAINPID -Restart=always -LimitNOFILE=1000000 -LimitNPROC=1000000 -LimitCORE=1000000 - -[Install] -WantedBy=multi-user.target diff --git a/install.sh b/install.sh index 2be059dd..c429103a 100755 --- a/install.sh +++ b/install.sh @@ -1,21 +1,25 @@ #!/bin/bash # Author: yeho -# BLOG: https://linuxeye.com +# BLOG: https://blog.linuxeye.com # +# Notes: OneinStack for CentOS/RadHat 5+ Debian 6+ and Ubuntu 12+ # +# Project home page: +# https://oneinstack.com +# https://github.com/lj2007331/oneinstack export PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin clear printf " ####################################################################### -# Install # +# OneinStack for CentOS/RadHat 5+ Debian 6+ and Ubuntu 12+ # +# For more information please visit https://oneinstack.com # ####################################################################### " -# Check if user is root -[ $(id -u) != "0" ] && { echo "${CFAILURE}Error: You must be root to run this script${CEND}"; exit 1; } -current_dir=$(dirname "`readlink -f $0`") -pushd ${current_dir} > /dev/null +# get pwd +sed -i "s@^oneinstack_dir.*@oneinstack_dir=`pwd`@" ./options.conf + . ./versions.txt . ./options.conf . ./include/color.sh @@ -24,1184 +28,752 @@ pushd ${current_dir} > /dev/null . ./include/download.sh . ./include/get_char.sh -dbrootpwd=`< /dev/urandom tr -dc A-Za-z0-9 | head -c8` -dbpostgrespwd=`< /dev/urandom tr -dc A-Za-z0-9 | head -c8` -dbmongopwd=`< /dev/urandom tr -dc A-Za-z0-9 | head -c8` -dbinstallmethod=1 - -version() { - echo "version: 2.6" - echo "updated date: 2023-02-04" -} - -Show_Help() { - version - echo "Usage: $0 command ...[parameters].... - --version, -v Show version info - --nginx_option [1-3] Install Nginx server version - --apache Install Apache - --apache_mode_option [1-2] Apache2.4 mode, 1(default): php-fpm, 2: mod_php - --apache_mpm_option [1-3] Apache2.4 MPM, 1(default): event, 2: prefork, 3: worker - --php_option [1-15] Install PHP version - --mphp_ver [53~85] Install another PHP version (PATH: ${php_install_dir}\${mphp_ver}) - --mphp_addons Only install another PHP addons - --phpcache_option [1-3] Install PHP opcode cache, default: 1 opcache - --php_extensions [ext name] Install PHP extensions, include zendguardloader,ioncube, - sourceguardian,imagick,gmagick,fileinfo,imap,ldap,calendar,phalcon, - yaf,yar,redis,memcached,memcache,mongodb,swoole,xdebug - --nodejs Install Nodejs - --tomcat_option [1-4] Install Tomcat version - --jdk_option [1-3] Install JDK version - --db_option [1-14] Install DB version - --dbinstallmethod [1-2] DB install method, default: 1 binary install - --dbrootpwd [password] DB super password - --pureftpd Install Pure-Ftpd - --redis Install Redis - --memcached Install Memcached - --phpmyadmin Install phpMyAdmin - --ssh_port [No.] SSH port - --firewall Enable firewall - --md5sum Check md5sum - --reboot Restart the server after installation - " -} -ARG_NUM=$# -TEMP=`getopt -o hvV --long help,version,nginx_option:,apache,apache_mode_option:,apache_mpm_option:,php_option:,mphp_ver:,mphp_addons,phpcache_option:,php_extensions:,nodejs,tomcat_option:,jdk_option:,db_option:,dbrootpwd:,dbinstallmethod:,pureftpd,redis,memcached,phpmyadmin,ssh_port:,firewall,md5sum,reboot -- "$@" 2>/dev/null` -[ $? != 0 ] && echo "${CWARNING}ERROR: unknown argument! ${CEND}" && Show_Help && exit 1 -eval set -- "${TEMP}" -while :; do - [ -z "$1" ] && break; - case "$1" in - -h|--help) - Show_Help; exit 0 - ;; - -v|-V|--version) - version; exit 0 - ;; - --nginx_option) - nginx_option=$2; shift 2 - [[ ! ${nginx_option} =~ ^[1-3]$ ]] && { echo "${CWARNING}nginx_option input error! Please only input number 1~3${CEND}"; exit 1; } - [ -e "${nginx_install_dir}/sbin/nginx" ] && { echo "${CWARNING}Nginx already installed! ${CEND}"; unset nginx_option; } - [ -e "${tengine_install_dir}/sbin/nginx" ] && { echo "${CWARNING}Tengine already installed! ${CEND}"; unset nginx_option; } - [ -e "${openresty_install_dir}/nginx/sbin/nginx" ] && { echo "${CWARNING}OpenResty already installed! ${CEND}"; unset nginx_option; } - ;; - --apache) - apache_flag=y; shift 1 - [ -e "${apache_install_dir}/bin/httpd" ] && { echo "${CWARNING}Aapche already installed! ${CEND}"; unset apache_flag; } - ;; - --apache_mode_option) - apache_mode_option=$2; shift 2 - [[ ! ${apache_mode_option} =~ ^[1-2]$ ]] && { echo "${CWARNING}apache_mode_option input error! Please only input number 1~2${CEND}"; exit 1; } - ;; - --apache_mpm_option) - apache_mpm_option=$2; shift 2 - [[ ! ${apache_mpm_option} =~ ^[1-3]$ ]] && { echo "${CWARNING}apache_mpm_option input error! Please only input number 1~3${CEND}"; exit 1; } - ;; - --php_option) - php_option=$2; shift 2 - [[ ! ${php_option} =~ ^[1-9]$|^1[0-5]$ ]] && { echo "${CWARNING}php_option input error! Please only input number 1~15${CEND}"; exit 1; } - [ -e "${php_install_dir}/bin/phpize" ] && { echo "${CWARNING}PHP already installed! ${CEND}"; unset php_option; } - ;; - --mphp_ver) - mphp_ver=$2; mphp_flag=y; shift 2 - [[ ! "${mphp_ver}" =~ ^5[3-6]$|^7[0-5]$|^8[0-5]$ ]] && { echo "${CWARNING}mphp_ver input error! Please only input number 53~85${CEND}"; exit 1; } - ;; - --mphp_addons) - mphp_addons_flag=y; shift 1 - ;; - --phpcache_option) - phpcache_option=$2; shift 2 - ;; - --php_extensions) - php_extensions=$2; shift 2 - [ -n "`echo ${php_extensions} | grep -w zendguardloader`" ] && pecl_zendguardloader=1 - [ -n "`echo ${php_extensions} | grep -w ioncube`" ] && pecl_ioncube=1 - [ -n "`echo ${php_extensions} | grep -w sourceguardian`" ] && pecl_sourceguardian=1 - [ -n "`echo ${php_extensions} | grep -w imagick`" ] && pecl_imagick=1 - [ -n "`echo ${php_extensions} | grep -w gmagick`" ] && pecl_gmagick=1 - [ -n "`echo ${php_extensions} | grep -w fileinfo`" ] && pecl_fileinfo=1 - [ -n "`echo ${php_extensions} | grep -w imap`" ] && pecl_imap=1 - [ -n "`echo ${php_extensions} | grep -w ldap`" ] && pecl_ldap=1 - [ -n "`echo ${php_extensions} | grep -w calendar`" ] && pecl_calendar=1 - [ -n "`echo ${php_extensions} | grep -w phalcon`" ] && pecl_phalcon=1 - [ -n "`echo ${php_extensions} | grep -w yaf`" ] && pecl_yaf=1 - [ -n "`echo ${php_extensions} | grep -w yar`" ] && pecl_yar=1 - [ -n "`echo ${php_extensions} | grep -w redis`" ] && pecl_redis=1 - [ -n "`echo ${php_extensions} | grep -w memcached`" ] && pecl_memcached=1 - [ -n "`echo ${php_extensions} | grep -w memcache`" ] && pecl_memcache=1 - [ -n "`echo ${php_extensions} | grep -w mongodb`" ] && pecl_mongodb=1 - [ -n "`echo ${php_extensions} | grep -w swoole`" ] && pecl_swoole=1 - [ -n "`echo ${php_extensions} | grep -w xdebug`" ] && pecl_xdebug=1 - ;; - --nodejs) - nodejs_flag=y; shift 1 - [ -e "${nodejs_install_dir}/bin/node" ] && { echo "${CWARNING}Nodejs already installed! ${CEND}"; unset nodejs_flag; } - ;; - --tomcat_option) - tomcat_option=$2; shift 2 - [[ ! ${tomcat_option} =~ ^[1-4]$ ]] && { echo "${CWARNING}tomcat_option input error! Please only input number 1~4${CEND}"; exit 1; } - [ -e "$tomcat_install_dir/conf/server.xml" ] && { echo "${CWARNING}Tomcat already installed! ${CEND}" ; unset tomcat_option; } - ;; - --jdk_option) - jdk_option=$2; shift 2 - [[ ! ${jdk_option} =~ ^[1-3]$ ]] && { echo "${CWARNING}jdk_option input error! Please only input number 1~3${CEND}"; exit 1; } - ;; - --db_option) - db_option=$2; shift 2 - if [[ "${db_option}" =~ ^[1-9]$|^1[0-2]$ ]]; then - [ -d "${db_install_dir}/support-files" ] && { echo "${CWARNING}MySQL already installed! ${CEND}"; unset db_option; } - elif [ "${db_option}" == '13' ]; then - [ -e "${pgsql_install_dir}/bin/psql" ] && { echo "${CWARNING}PostgreSQL already installed! ${CEND}"; unset db_option; } - elif [ "${db_option}" == '14' ]; then - [ -e "${mongo_install_dir}/bin/mongo" ] && { echo "${CWARNING}MongoDB already installed! ${CEND}"; unset db_option; } - else - echo "${CWARNING}db_option input error! Please only input number 1~14${CEND}" - exit 1 - fi - ;; - --dbrootpwd) - dbrootpwd=$2; shift 2 - dbpostgrespwd="${dbrootpwd}" - dbmongopwd="${dbrootpwd}" - ;; - --dbinstallmethod) - dbinstallmethod=$2; shift 2 - [[ ! ${dbinstallmethod} =~ ^[1-2]$ ]] && { echo "${CWARNING}dbinstallmethod input error! Please only input number 1~2${CEND}"; exit 1; } - ;; - --pureftpd) - pureftpd_flag=y; shift 1 - [ -e "${pureftpd_install_dir}/sbin/pure-ftpwho" ] && { echo "${CWARNING}Pure-FTPd already installed! ${CEND}"; unset pureftpd_flag; } - ;; - --redis) - redis_flag=y; shift 1 - [ -e "${redis_install_dir}/bin/redis-server" ] && { echo "${CWARNING}redis-server already installed! ${CEND}"; unset redis_flag; } - ;; - --memcached) - memcached_flag=y; shift 1 - [ -e "${memcached_install_dir}/bin/memcached" ] && { echo "${CWARNING}memcached-server already installed! ${CEND}"; unset memcached_flag; } - ;; - --phpmyadmin) - phpmyadmin_flag=y; shift 1 - [ -d "${wwwroot_dir}/default/phpMyAdmin" ] && { echo "${CWARNING}phpMyAdmin already installed! ${CEND}"; unset phpmyadmin_flag; } - ;; - --ssh_port) - ssh_port=$2; shift 2 - ;; - --firewall) - firewall_flag=y; shift 1 - ;; - --md5sum) - md5sum_flag=y; shift 1 - ;; - --reboot) - reboot_flag=y; shift 1 - ;; - --) - shift - ;; - *) - echo "${CWARNING}ERROR: unknown argument! ${CEND}" && Show_Help && exit 1 - ;; - esac -done +# Check if user is root +[ $(id -u) != "0" ] && { echo "${CFAILURE}Error: You must be root to run this script${CEND}"; exit 1; } -# Check md5sum -if [ ${ARG_NUM} == 0 ] && [ ! -e ~/.lnmp ]; then - # Check md5sum - while :; do echo - read -e -p "Do you want to check md5sum? [y/n]: " md5sum_flag - if [[ ! ${md5sum_flag} =~ ^[y,n]$ ]]; then - echo "${CWARNING}input error! Please only input 'y' or 'n'${CEND}" - else - break - fi - done -fi -if [ "${md5sum_flag}" == 'y' ]; then - [ -e "${current_dir}.tar.gz" ] && tool_file=${current_dir}.tar.gz - [ -e "${current_dir}-full.tar.gz" ] && tool_file=${current_dir}-full.tar.gz - script_md5=${tool_file##*/} - if [ -e "${tool_file}" ]; then - now_script_md5=$(md5sum ${tool_file} | awk '{print $1}') - latest_script_md5=$(curl --connect-timeout 3 -m 5 -s ${mirror_link}/md5sum.txt | grep ${script_md5} | awk '{print $1}') - if [ "${now_script_md5}" != "${latest_script_md5}" ]; then - echo "${CFAILURE}Error: The md5 value of the installation package does not match the official website, please download again, url: ${mirror_link}/${script_md5}${CEND}" - exit 1 - fi - else - echo "${CFAILURE}Error: ${tool_file} does not exist${CEND}" - exit 1 - fi -fi +mkdir -p $wwwroot_dir/default $wwwlogs_dir +[ -d /data ] && chmod 755 /data # Use default SSH port 22. If you use another SSH port on your server if [ -e "/etc/ssh/sshd_config" ]; then - [ -z "`grep ^Port /etc/ssh/sshd_config`" ] && now_ssh_port=22 || now_ssh_port=`grep ^Port /etc/ssh/sshd_config | awk '{print $2}' | head -1` + [ -z "`grep ^Port /etc/ssh/sshd_config`" ] && ssh_port=22 || ssh_port=`grep ^Port /etc/ssh/sshd_config | awk '{print $2}'` while :; do echo - [ ${ARG_NUM} == 0 ] && read -e -p "Please input SSH port(Default: ${now_ssh_port}): " ssh_port - ssh_port=${ssh_port:-${now_ssh_port}} - 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 + read -p "Please input SSH port(Default: $ssh_port): " SSH_PORT + [ -z "$SSH_PORT" ] && SSH_PORT=$ssh_port + 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 break else echo "${CWARNING}input error! Input range: 22,1025~65534${CEND}" - exit 1 fi done - if [ -z "`grep ^Port /etc/ssh/sshd_config`" -a "${ssh_port}" != '22' ]; then - sed -i "s@^#Port.*@&\nPort ${ssh_port}@" /etc/ssh/sshd_config + if [ -z "`grep ^Port /etc/ssh/sshd_config`" -a "$SSH_PORT" != '22' ]; then + sed -i "s@^#Port.*@&\nPort $SSH_PORT@" /etc/ssh/sshd_config elif [ -n "`grep ^Port /etc/ssh/sshd_config`" ]; then - sed -i "s@^Port.*@Port ${ssh_port}@" /etc/ssh/sshd_config + sed -i "s@^Port.*@Port $SSH_PORT@" /etc/ssh/sshd_config fi fi -if [ ${ARG_NUM} == 0 ]; then - if [ ! -e ~/.lnmp ]; then - # check firewall - while :; do echo - read -e -p "Do you want to enable firewall? [y/n]: " firewall_flag - if [[ ! ${firewall_flag} =~ ^[y,n]$ ]]; then - echo "${CWARNING}input error! Please only input 'y' or 'n'${CEND}" - else - break - fi - done - fi - - # check Web server - while :; do echo - read -e -p "Do you want to install Web server? [y/n]: " web_flag - if [[ ! ${web_flag} =~ ^[y,n]$ ]]; then - echo "${CWARNING}input error! Please only input 'y' or 'n'${CEND}" - else - if [ "${web_flag}" == 'y' ]; then - # Nginx/Tegine/OpenResty - while :; do echo - echo 'Please select Nginx server:' - echo -e "\t${CMSG}1${CEND}. Install Nginx" - echo -e "\t${CMSG}2${CEND}. Install Tengine" - echo -e "\t${CMSG}3${CEND}. Install OpenResty" - echo -e "\t${CMSG}4${CEND}. Do not install" - read -e -p "Please input a number:(Default 1 press Enter) " nginx_option - nginx_option=${nginx_option:-1} - if [[ ! ${nginx_option} =~ ^[1-4]$ ]]; then - echo "${CWARNING}input error! Please only input number 1~4${CEND}" - else - [ "${nginx_option}" != '4' -a -e "${nginx_install_dir}/sbin/nginx" ] && { echo "${CWARNING}Nginx already installed! ${CEND}"; unset nginx_option; } - [ "${nginx_option}" != '4' -a -e "${tengine_install_dir}/sbin/nginx" ] && { echo "${CWARNING}Tengine already installed! ${CEND}"; unset nginx_option; } - [ "${nginx_option}" != '4' -a -e "${openresty_install_dir}/nginx/sbin/nginx" ] && { echo "${CWARNING}OpenResty already installed! ${CEND}"; unset nginx_option; } - break - fi - done - - # Apache - while :; do echo - read -e -p "Do you want to install Apache? [y/n]: " apache_flag - if [[ ! ${apache_flag} =~ ^[y,n]$ ]]; then - echo "${CWARNING}input error! Please only input 'y' or 'n'${CEND}" - else - [ "${apache_flag}" == 'y' -a -e "${apache_install_dir}/bin/httpd" ] && { echo "${CWARNING}Aapche already installed! ${CEND}"; unset apache_flag; } - break - fi - done - # Apache2.4 mode and Apache2.4 MPM - if [ "${apache_flag}" == 'y' -o -e "${apache_install_dir}/bin/httpd" ]; then - while :; do echo - echo 'Please select Apache mode:' - echo -e "\t${CMSG}1${CEND}. php-fpm" - echo -e "\t${CMSG}2${CEND}. mod_php" - read -e -p "Please input a number:(Default 1 press Enter) " apache_mode_option - apache_mode_option=${apache_mode_option:-1} - if [[ ! ${apache_mode_option} =~ ^[1-2]$ ]]; then - echo "${CWARNING}input error! Please only input number 1~2${CEND}" - else - break - fi - done - while :; do echo - echo 'Please select Apache MPM:' - echo -e "\t${CMSG}1${CEND}. event" - echo -e "\t${CMSG}2${CEND}. prefork" - echo -e "\t${CMSG}3${CEND}. worker" - read -e -p "Please input a number:(Default 1 press Enter) " apache_mpm_option - apache_mpm_option=${apache_mpm_option:-1} - if [[ ! ${apache_mpm_option} =~ ^[1-3]$ ]]; then - echo "${CWARNING}input error! Please only input number 1~3${CEND}" - else - break - fi - done +# check Web server +while :; do echo + read -p "Do you want to install Web server? [y/n]: " Web_yn + if [[ ! $Web_yn =~ ^[y,n]$ ]]; then + echo "${CWARNING}input error! Please only input 'y' or 'n'${CEND}" + else + if [ "$Web_yn" == 'y' ]; then + # Nginx/Tegine/OpenResty + while :; do echo + echo 'Please select Nginx server:' + echo -e "\t${CMSG}1${CEND}. Install Nginx" + echo -e "\t${CMSG}2${CEND}. Install Tengine" + echo -e "\t${CMSG}3${CEND}. Install OpenResty" + echo -e "\t${CMSG}4${CEND}. Do not install" + read -p "Please input a number:(Default 1 press Enter) " Nginx_version + [ -z "$Nginx_version" ] && Nginx_version=1 + if [[ ! $Nginx_version =~ ^[1-4]$ ]]; then + echo "${CWARNING}input error! Please only input number 1,2,3,4${CEND}" + else + [ "$Nginx_version" != '4' -a -e "$nginx_install_dir/sbin/nginx" ] && { echo "${CWARNING}Nginx already installed! ${CEND}"; Nginx_version=Other; } + [ "$Nginx_version" != '4' -a -e "$tengine_install_dir/sbin/nginx" ] && { echo "${CWARNING}Tengine already installed! ${CEND}"; Nginx_version=Other; } + [ "$Nginx_version" != '4' -a -e "$openresty_install_dir/nginx/sbin/nginx" ] && { echo "${CWARNING}OpenResty already installed! ${CEND}"; Nginx_version=Other; } + break fi - # Tomcat - while :; do echo - echo 'Please select tomcat server:' - echo -e "\t${CMSG}1${CEND}. Install Tomcat-10" - echo -e "\t${CMSG}2${CEND}. Install Tomcat-9" - echo -e "\t${CMSG}3${CEND}. Install Tomcat-8" - echo -e "\t${CMSG}4${CEND}. Install Tomcat-7" - echo -e "\t${CMSG}5${CEND}. Do not install" - read -e -p "Please input a number:(Default 5 press Enter) " tomcat_option - tomcat_option=${tomcat_option:-5} - if [[ ! ${tomcat_option} =~ ^[1-5]$ ]]; then - echo "${CWARNING}input error! Please only input number 1~5${CEND}" - else - [ "${tomcat_option}" != '5' -a -e "$tomcat_install_dir/conf/server.xml" ] && { echo "${CWARNING}Tomcat already installed! ${CEND}" ; unset tomcat_option; } - if [[ "${tomcat_option}" =~ ^1$ ]]; then - while :; do echo - echo 'Please select JDK version:' - echo -e "\t${CMSG}2${CEND}. Install openjdk-11-jdk" - echo -e "\t${CMSG}3${CEND}. Install openjdk-17-jdk" - read -e -p "Please input a number:(Default 1 press Enter) " jdk_option - jdk_option=${jdk_option:-2} - if [[ ! ${jdk_option} =~ ^[2-3]$ ]]; then - echo "${CWARNING}input error! Please only input number 2~3${CEND}" - else - break - fi - done - elif [[ "${tomcat_option}" =~ ^[2-3]$ ]]; then - while :; do echo - echo 'Please select JDK version:' - echo -e "\t${CMSG}1${CEND}. Install openjdk-8-jdk" - echo -e "\t${CMSG}2${CEND}. Install openjdk-11-jdk" - echo -e "\t${CMSG}3${CEND}. Install openjdk-17-jdk" - read -e -p "Please input a number:(Default 1 press Enter) " jdk_option - jdk_option=${jdk_option:-1} - if [[ ! ${jdk_option} =~ ^[1-3]$ ]]; then - echo "${CWARNING}input error! Please only input number 1~3${CEND}" - else - break - fi - done - elif [ "${tomcat_option}" == '4' ]; then - while :; do echo - echo 'Please select JDK version:' - echo -e "\t${CMSG}1${CEND}. Install openjdk-8-jdk" - read -e -p "Please input a number:(Default 1 press Enter) " jdk_option - jdk_option=${jdk_option:-1} - if [[ ! ${jdk_option} =~ ^1$ ]]; then - echo "${CWARNING}input error! Please only input number 1${CEND}" - else - break - fi - done - fi - break - fi - done - fi - break + done + # Apache + while :; do echo + echo 'Please select Apache server:' + echo -e "\t${CMSG}1${CEND}. Install Apache-2.4" + echo -e "\t${CMSG}2${CEND}. Install Apache-2.2" + echo -e "\t${CMSG}3${CEND}. Do not install" + read -p "Please input a number:(Default 3 press Enter) " Apache_version + [ -z "$Apache_version" ] && Apache_version=3 + if [[ ! $Apache_version =~ ^[1-3]$ ]]; then + echo "${CWARNING}input error! Please only input number 1,2,3${CEND}" + else + [ "$Apache_version" != '3' -a -e "$apache_install_dir/conf/httpd.conf" ] && { echo "${CWARNING}Aapche already installed! ${CEND}"; Apache_version=Other; } + break + fi + done + # Tomcat + #while :; do echo + # echo 'Please select tomcat server:' + # echo -e "\t${CMSG}1${CEND}. Install Tomcat-8" + # echo -e "\t${CMSG}2${CEND}. Install Tomcat-7" + # echo -e "\t${CMSG}3${CEND}. Install Tomcat-6" + # echo -e "\t${CMSG}4${CEND}. Do not install" + # read -p "Please input a number:(Default 4 press Enter) " Tomcat_version + # [ -z "$Tomcat_version" ] && Tomcat_version=4 + # if [[ ! $Tomcat_version =~ ^[1-4]$ ]]; then + # echo "${CWARNING}input error! Please only input number 1,2,3,4${CEND}" + # else + # [ "$Tomcat_version" != '4' -a -e "$tomcat_install_dir/conf/server.xml" ] && { echo "${CWARNING}Tomcat already installed! ${CEND}" ; Tomcat_version=Other; } + # if [ "$Tomcat_version" == '1' ]; then + # while :; do echo + # echo 'Please select JDK version:' + # echo -e "\t${CMSG}1${CEND}. Install JDK-1.8" + # echo -e "\t${CMSG}2${CEND}. Install JDK-1.7" + # read -p "Please input a number:(Default 2 press Enter) " JDK_version + # [ -z "$JDK_version" ] && JDK_version=2 + # if [[ ! $JDK_version =~ ^[1-2]$ ]]; then + # echo "${CWARNING}input error! Please only input number 1,2${CEND}" + # else + # break + # fi + # done + # elif [ "$Tomcat_version" == '2' ]; then + # while :; do echo + # echo 'Please select JDK version:' + # echo -e "\t${CMSG}1${CEND}. Install JDK-1.8" + # echo -e "\t${CMSG}2${CEND}. Install JDK-1.7" + # echo -e "\t${CMSG}3${CEND}. Install JDK-1.6" + # read -p "Please input a number:(Default 2 press Enter) " JDK_version + # [ -z "$JDK_version" ] && JDK_version=2 + # if [[ ! $JDK_version =~ ^[1-3]$ ]]; then + # echo "${CWARNING}input error! Please only input number 1,2,3${CEND}" + # else + # break + # fi + # done + # elif [ "$Tomcat_version" == '3' ]; then + # while :; do echo + # echo 'Please select JDK version:' + # echo -e "\t${CMSG}2${CEND}. Install JDK-1.7" + # echo -e "\t${CMSG}3${CEND}. Install JDK-1.6" + # read -p "Please input a number:(Default 2 press Enter) " JDK_version + # [ -z "$JDK_version" ] && JDK_version=2 + # if [[ ! $JDK_version =~ ^[2-3]$ ]]; then + # echo "${CWARNING}input error! Please only input number 2,3${CEND}" + # else + # break + # fi + # done + # fi + # break + # fi + #done fi - done + break + fi +done - # choice database - while :; do echo - read -e -p "Do you want to install Database? [y/n]: " db_flag - if [[ ! ${db_flag} =~ ^[y,n]$ ]]; then - echo "${CWARNING}input error! Please only input 'y' or 'n'${CEND}" - else - if [ "${db_flag}" == 'y' ]; then - while :; do echo - echo 'Please select a version of the Database:' - echo -e "\t${CMSG} 1${CEND}. Install MySQL-8.4" - echo -e "\t${CMSG} 2${CEND}. Install MySQL-8.0" - echo -e "\t${CMSG} 3${CEND}. Install MySQL-5.7" - echo -e "\t${CMSG} 4${CEND}. Install MySQL-5.5" - echo -e "\t${CMSG} 5${CEND}. Install MariaDB-11.8" - echo -e "\t${CMSG} 6${CEND}. Install MariaDB-11.4" - echo -e "\t${CMSG} 7${CEND}. Install MariaDB-10.11" - echo -e "\t${CMSG} 8${CEND}. Install MariaDB-5.5" - echo -e "\t${CMSG} 9${CEND}. Install Percona-8.4" - echo -e "\t${CMSG}10${CEND}. Install Percona-8.0" - echo -e "\t${CMSG}11${CEND}. Install Percona-5.7" - echo -e "\t${CMSG}12${CEND}. Install Percona-5.5" - echo -e "\t${CMSG}13${CEND}. Install PostgreSQL" - echo -e "\t${CMSG}14${CEND}. Install MongoDB" - read -e -p "Please input a number:(Default 2 press Enter) " db_option - db_option=${db_option:-2} - if [[ "${db_option}" =~ ^[1-9]$|^1[0-4]$ ]]; then - if [ "${db_option}" == '13' ]; then - [ -e "${pgsql_install_dir}/bin/psql" ] && { echo "${CWARNING}PostgreSQL already installed! ${CEND}"; unset db_option; break; } - elif [ "${db_option}" == '14' ]; then - [ -e "${mongo_install_dir}/bin/mongo" ] && { echo "${CWARNING}MongoDB already installed! ${CEND}"; unset db_option; break; } - else - [ -d "${db_install_dir}/support-files" ] && { echo "${CWARNING}MySQL already installed! ${CEND}"; unset db_option; break; } - fi - while :; do - if [ "${db_option}" == '13' ]; then - read -e -p "Please input the postgres password of PostgreSQL(default: ${dbpostgrespwd}): " dbpwd - dbpwd=${dbpwd:-${dbpostgrespwd}} - elif [ "${db_option}" == '14' ]; then - read -e -p "Please input the root password of MongoDB(default: ${dbmongopwd}): " dbpwd - dbpwd=${dbpwd:-${dbmongopwd}} +# choice database +while :; do echo + read -p "Do you want to install Database? [y/n]: " DB_yn + if [[ ! $DB_yn =~ ^[y,n]$ ]]; then + echo "${CWARNING}input error! Please only input 'y' or 'n'${CEND}" + else + if [ "$DB_yn" == 'y' ]; then + [ -d "$db_install_dir/support-files" ] && { echo "${CWARNING}Database already installed! ${CEND}"; DB_yn=Other; break; } + while :; do echo + echo 'Please select a version of the Database:' + echo -e "\t${CMSG} 1${CEND}. Install MySQL-5.7" + echo -e "\t${CMSG} 2${CEND}. Install MySQL-5.6" + echo -e "\t${CMSG} 3${CEND}. Install MySQL-5.5" + echo -e "\t${CMSG} 4${CEND}. Install MariaDB-10.1" + echo -e "\t${CMSG} 5${CEND}. Install MariaDB-10.0" + echo -e "\t${CMSG} 6${CEND}. Install MariaDB-5.5" + echo -e "\t${CMSG} 7${CEND}. Install Percona-5.7" + echo -e "\t${CMSG} 8${CEND}. Install Percona-5.6" + echo -e "\t${CMSG} 9${CEND}. Install Percona-5.5" + echo -e "\t${CMSG}10${CEND}. Install AliSQL-5.6" + read -p "Please input a number:(Default 2 press Enter) " DB_version + [ -z "$DB_version" ] && DB_version=2 + if [ ${DB_version} -ge 1 >/dev/null 2>&1 -a ${DB_version} -le 10 >/dev/null 2>&1 ]; then + while :; do + read -p "Please input the root password of database: " dbrootpwd + [ -n "`echo $dbrootpwd | grep '[+|&]'`" ] && { echo "${CWARNING}input error,not contain a plus sign (+) and & ${CEND}"; continue; } + (( ${#dbrootpwd} >= 5 )) && sed -i "s+^dbrootpwd.*+dbrootpwd='$dbrootpwd'+" ./options.conf && break || echo "${CWARNING}database root password least 5 characters! ${CEND}" + done + # choose install methods + if [[ $DB_version =~ ^[1-9]$ ]]; then + while :; do echo + echo "Please choose installation of the database:" + echo -e "\t${CMSG}1${CEND}. Install database from binary package." + echo -e "\t${CMSG}2${CEND}. Install database from source package." + read -p "Please input a number:(Default 1 press Enter) " dbInstallMethods + [ -z "$dbInstallMethods" ] && dbInstallMethods=1 + if [[ ! $dbInstallMethods =~ ^[1-2]$ ]]; then + echo "${CWARNING}input error! Please only input number 1,2${CEND}" else - read -e -p "Please input the root password of MySQL(default: ${dbrootpwd}): " dbpwd - dbpwd=${dbpwd:-${dbrootpwd}} - fi - [ -n "`echo ${dbpwd} | grep '[+|&]'`" ] && { echo "${CWARNING}input error,not contain a plus sign (+) and & ${CEND}"; continue; } - if (( ${#dbpwd} >= 5 )); then - if [ "${db_option}" == '13' ]; then - dbpostgrespwd=${dbpwd} - elif [ "${db_option}" == '14' ]; then - dbmongopwd=${dbpwd} - else - dbrootpwd=${dbpwd} - fi break - else - echo "${CWARNING}password least 5 characters! ${CEND}" fi done - # choose install methods - if [[ "${db_option}" =~ ^[1-9]$|^1[0-2]$ ]]; then - while :; do echo - echo "Please choose installation of the database:" - echo -e "\t${CMSG}1${CEND}. Install database from binary package." - echo -e "\t${CMSG}2${CEND}. Install database from source package." - read -e -p "Please input a number:(Default 1 press Enter) " dbinstallmethod - dbinstallmethod=${dbinstallmethod:-1} - if [[ ! ${dbinstallmethod} =~ ^[1-2]$ ]]; then - echo "${CWARNING}input error! Please only input number 1~2${CEND}" - else - break - fi - done - fi - break - else - echo "${CWARNING}input error! Please only input number 1~14${CEND}" - fi - done - fi - break - fi - done - - # choice php - while :; do echo - read -e -p "Do you want to install PHP? [y/n]: " php_flag - if [[ ! ${php_flag} =~ ^[y,n]$ ]]; then - echo "${CWARNING}input error! Please only input 'y' or 'n'${CEND}" - else - if [ "${php_flag}" == 'y' ]; then - [ -e "${php_install_dir}/bin/phpize" ] && { echo "${CWARNING}PHP already installed! ${CEND}"; unset php_option; break; } - while :; do echo - echo 'Please select a version of the PHP:' - echo -e "\t${CMSG} 1${CEND}. Install php-5.3" - echo -e "\t${CMSG} 2${CEND}. Install php-5.4" - echo -e "\t${CMSG} 3${CEND}. Install php-5.5" - echo -e "\t${CMSG} 4${CEND}. Install php-5.6" - echo -e "\t${CMSG} 5${CEND}. Install php-7.0" - echo -e "\t${CMSG} 6${CEND}. Install php-7.1" - echo -e "\t${CMSG} 7${CEND}. Install php-7.2" - echo -e "\t${CMSG} 8${CEND}. Install php-7.3" - echo -e "\t${CMSG} 9${CEND}. Install php-7.4" - echo -e "\t${CMSG}10${CEND}. Install php-8.0" - echo -e "\t${CMSG}11${CEND}. Install php-8.1" - echo -e "\t${CMSG}12${CEND}. Install php-8.2" - echo -e "\t${CMSG}13${CEND}. Install php-8.3" - echo -e "\t${CMSG}14${CEND}. Install php-8.4" - echo -e "\t${CMSG}15${CEND}. Install php-8.4" - read -e -p "Please input a number:(Default 14 press Enter) " php_option - php_option=${php_option:-14} - if [[ ! ${php_option} =~ ^[1-9]$|^1[0-5]$ ]]; then - echo "${CWARNING}input error! Please only input number 1~15${CEND}" - else - break fi - done - fi - break + break + else + echo "${CWARNING}input error! Please only input number 1,2,3,4,5,6,7,8,9,10${CEND}" + fi + done fi - done - - # check php ver - if [ -e "${php_install_dir}/bin/phpize" ]; then - PHP_detail_ver=$(${php_install_dir}/bin/php-config --version) - PHP_main_ver=${PHP_detail_ver%.*} + break fi +done - # PHP opcode cache and extensions - if [[ ${php_option} =~ ^[1-9]$|^1[0-4]$ ]] || [ -e "${php_install_dir}/bin/phpize" ]; then - while :; do echo - read -e -p "Do you want to install opcode cache of the PHP? [y/n]: " phpcache_flag - if [[ ! ${phpcache_flag} =~ ^[y,n]$ ]]; then - echo "${CWARNING}input error! Please only input 'y' or 'n'${CEND}" - else - if [ "${phpcache_flag}" == 'y' ]; then - if [ "${php_option}" == '1' -o "${PHP_main_ver}" == '5.3' ]; then - while :; do - echo 'Please select a opcode cache of the PHP:' - echo -e "\t${CMSG}1${CEND}. Install Zend OPcache" - echo -e "\t${CMSG}2${CEND}. Install APCU" - echo -e "\t${CMSG}3${CEND}. Install eAccelerator-0.9" - read -e -p "Please input a number:(Default 1 press Enter) " phpcache_option - phpcache_option=${phpcache_option:-1} - if [[ ! ${phpcache_option} =~ ^[1-3]$ ]]; then - echo "${CWARNING}input error! Please only input number 1~3${CEND}" - else - break +# check PHP +while :; do echo + read -p "Do you want to install PHP? [y/n]: " PHP_yn + if [[ ! $PHP_yn =~ ^[y,n]$ ]]; then + echo "${CWARNING}input error! Please only input 'y' or 'n'${CEND}" + else + if [ "$PHP_yn" == 'y' ]; then + [ -e "$php_install_dir/bin/phpize" ] && { echo "${CWARNING}PHP already installed! ${CEND}"; PHP_yn=Other; break; } + while :; do echo + echo 'Please select a version of the PHP:' + echo -e "\t${CMSG}1${CEND}. Install php-5.3" + echo -e "\t${CMSG}2${CEND}. Install php-5.4" + echo -e "\t${CMSG}3${CEND}. Install php-5.5" + echo -e "\t${CMSG}4${CEND}. Install php-5.6" + echo -e "\t${CMSG}5${CEND}. Install php-7.0" + echo -e "\t${CMSG}6${CEND}. Install php-7.1" + read -p "Please input a number:(Default 4 press Enter) " PHP_version + [ -z "$PHP_version" ] && PHP_version=4 + if [[ ! $PHP_version =~ ^[1-6]$ ]]; then + echo "${CWARNING}input error! Please only input number 1,2,3,4,5,6${CEND}" + else + while :; do echo + read -p "Do you want to install opcode cache of the PHP? [y/n]: " PHP_cache_yn + if [[ ! $PHP_cache_yn =~ ^[y,n]$ ]]; then + echo "${CWARNING}input error! Please only input 'y' or 'n'${CEND}" + else + if [ "$PHP_cache_yn" == 'y' ]; then + if [ $PHP_version == 1 ]; then + while :; do + echo 'Please select a opcode cache of the PHP:' + echo -e "\t${CMSG}1${CEND}. Install Zend OPcache" + echo -e "\t${CMSG}2${CEND}. Install XCache" + echo -e "\t${CMSG}3${CEND}. Install APCU" + echo -e "\t${CMSG}4${CEND}. Install eAccelerator-0.9" + read -p "Please input a number:(Default 1 press Enter) " PHP_cache + [ -z "$PHP_cache" ] && PHP_cache=1 + if [[ ! $PHP_cache =~ ^[1-4]$ ]]; then + echo "${CWARNING}input error! Please only input number 1,2,3,4${CEND}" + else + break + fi + done + fi + if [ $PHP_version == 2 ]; then + while :; do + echo 'Please select a opcode cache of the PHP:' + echo -e "\t${CMSG}1${CEND}. Install Zend OPcache" + echo -e "\t${CMSG}2${CEND}. Install XCache" + echo -e "\t${CMSG}3${CEND}. Install APCU" + echo -e "\t${CMSG}4${CEND}. Install eAccelerator-1.0-dev" + read -p "Please input a number:(Default 1 press Enter) " PHP_cache + [ -z "$PHP_cache" ] && PHP_cache=1 + if [[ ! $PHP_cache =~ ^[1-4]$ ]]; then + echo "${CWARNING}input error! Please only input number 1,2,3,4${CEND}" + else + break + fi + done + fi + if [ $PHP_version == 3 ]; then + while :; do + echo 'Please select a opcode cache of the PHP:' + echo -e "\t${CMSG}1${CEND}. Install Zend OPcache" + echo -e "\t${CMSG}2${CEND}. Install XCache" + echo -e "\t${CMSG}3${CEND}. Install APCU" + read -p "Please input a number:(Default 1 press Enter) " PHP_cache + [ -z "$PHP_cache" ] && PHP_cache=1 + if [[ ! $PHP_cache =~ ^[1-3]$ ]]; then + echo "${CWARNING}input error! Please only input number 1,2,3${CEND}" + else + break + fi + done + fi + if [ $PHP_version == 4 ]; then + while :; do + echo 'Please select a opcode cache of the PHP:' + echo -e "\t${CMSG}1${CEND}. Install Zend OPcache" + echo -e "\t${CMSG}2${CEND}. Install XCache" + echo -e "\t${CMSG}3${CEND}. Install APCU" + read -p "Please input a number:(Default 1 press Enter) " PHP_cache + [ -z "$PHP_cache" ] && PHP_cache=1 + if [[ ! $PHP_cache =~ ^[1-3]$ ]]; then + echo "${CWARNING}input error! Please only input number 1,2,3${CEND}" + else + break + fi + done + fi + if [[ $PHP_version =~ ^[5-6]$ ]]; then + while :; do + echo 'Please select a opcode cache of the PHP:' + echo -e "\t${CMSG}1${CEND}. Install Zend OPcache" + echo -e "\t${CMSG}3${CEND}. Install APCU" + read -p "Please input a number:(Default 1 press Enter) " PHP_cache + [ -z "$PHP_cache" ] && PHP_cache=1 + if [[ ! $PHP_cache =~ ^[1,3]$ ]]; then + echo "${CWARNING}input error! Please only input number 1,3${CEND}" + else + break + fi + done + fi fi - done - fi - if [ "${php_option}" == '2' -o "${PHP_main_ver}" == '5.4' ]; then + break + fi + done + if [ "$PHP_cache" == '2' ]; then while :; do - echo 'Please select a opcode cache of the PHP:' - echo -e "\t${CMSG}1${CEND}. Install Zend OPcache" - echo -e "\t${CMSG}2${CEND}. Install APCU" - echo -e "\t${CMSG}3${CEND}. Install eAccelerator-1.0-dev" - read -e -p "Please input a number:(Default 1 press Enter) " phpcache_option - phpcache_option=${phpcache_option:-1} - if [[ ! ${phpcache_option} =~ ^[1-3]$ ]]; then - echo "${CWARNING}input error! Please only input number 1~3${CEND}" - else - break - fi + read -p "Please input xcache admin password: " xcache_admin_pass + (( ${#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}" done fi - if [ "${php_option}" == '3' -o "${PHP_main_ver}" == '5.5' ]; then - while :; do - echo 'Please select a opcode cache of the PHP:' - echo -e "\t${CMSG}1${CEND}. Install Zend OPcache" - echo -e "\t${CMSG}2${CEND}. Install APCU" - read -e -p "Please input a number:(Default 1 press Enter) " phpcache_option - phpcache_option=${phpcache_option:-1} - if [[ ! ${phpcache_option} =~ ^[1-2]$ ]]; then - echo "${CWARNING}input error! Please only input number 1~2${CEND}" + if [[ $PHP_version =~ ^[1-4]$ ]] && [ "$PHP_cache" != '1' -a "${armPlatform}" != "y" ]; then + while :; do echo + read -p "Do you want to install ZendGuardLoader? [y/n]: " ZendGuardLoader_yn + if [[ ! $ZendGuardLoader_yn =~ ^[y,n]$ ]]; then + echo "${CWARNING}input error! Please only input 'y' or 'n'${CEND}" else break fi done fi - if [ "${php_option}" == '4' -o "${PHP_main_ver}" == '5.6' ]; then - while :; do - echo 'Please select a opcode cache of the PHP:' - echo -e "\t${CMSG}1${CEND}. Install Zend OPcache" - echo -e "\t${CMSG}2${CEND}. Install APCU" - read -e -p "Please input a number:(Default 1 press Enter) " phpcache_option - phpcache_option=${phpcache_option:-1} - if [[ ! ${phpcache_option} =~ ^[1-2]$ ]]; then - echo "${CWARNING}input error! Please only input number 1~2${CEND}" + + # ionCube + if [ "${TARGET_ARCH}" != "arm64" -a "$PHP_version" != '6' ]; then + while :; do echo + read -p "Do you want to install ionCube? [y/n]: " ionCube_yn + if [[ ! $ionCube_yn =~ ^[y,n]$ ]]; then + echo "${CWARNING}input error! Please only input 'y' or 'n'${CEND}" else break fi done fi - if [[ ${php_option} =~ ^[5-9]$|^1[0-4]$ ]] || [[ "${PHP_main_ver}" =~ ^7.[0-4]$|^8.[0-4]$ ]]; then + + # ImageMagick or GraphicsMagick + while :; do echo + read -p "Do you want to install ImageMagick or GraphicsMagick? [y/n]: " Magick_yn + if [[ ! $Magick_yn =~ ^[y,n]$ ]]; then + echo "${CWARNING}input error! Please only input 'y' or 'n'${CEND}" + else + break + fi + done + + if [ "$Magick_yn" == 'y' ]; then while :; do - echo 'Please select a opcode cache of the PHP:' - echo -e "\t${CMSG}1${CEND}. Install Zend OPcache" - echo -e "\t${CMSG}2${CEND}. Install APCU" - read -e -p "Please input a number:(Default 1 press Enter) " phpcache_option - phpcache_option=${phpcache_option:-1} - if [[ ! ${phpcache_option} =~ ^[1-2]$ ]]; then - echo "${CWARNING}input error! Please only input number 1~2${CEND}" + echo 'Please select ImageMagick or GraphicsMagick:' + echo -e "\t${CMSG}1${CEND}. Install ImageMagick" + echo -e "\t${CMSG}2${CEND}. Install GraphicsMagick" + read -p "Please input a number:(Default 1 press Enter) " Magick + [ -z "$Magick" ] && Magick=1 + if [[ ! $Magick =~ ^[1-2]$ ]]; then + echo "${CWARNING}input error! Please only input number 1,2${CEND}" else break fi done fi + break fi - break - fi - done - # PHP extension - while :; do - echo - echo 'Please select PHP extensions:' - echo -e "\t${CMSG} 0${CEND}. Do not install" - echo -e "\t${CMSG} 1${CEND}. Install zendguardloader(PHP<=5.6)" - echo -e "\t${CMSG} 2${CEND}. Install ioncube" - echo -e "\t${CMSG} 3${CEND}. Install sourceguardian(PHP<=7.2)" - echo -e "\t${CMSG} 4${CEND}. Install imagick" - echo -e "\t${CMSG} 5${CEND}. Install gmagick" - echo -e "\t${CMSG} 6${CEND}. Install fileinfo" - echo -e "\t${CMSG} 7${CEND}. Install imap" - echo -e "\t${CMSG} 8${CEND}. Install ldap" - echo -e "\t${CMSG} 9${CEND}. Install phalcon(PHP>=5.5)" - echo -e "\t${CMSG}10${CEND}. Install yaf(PHP>=7.0)" - echo -e "\t${CMSG}11${CEND}. Install redis" - echo -e "\t${CMSG}12${CEND}. Install memcached" - echo -e "\t${CMSG}13${CEND}. Install memcache" - echo -e "\t${CMSG}14${CEND}. Install mongodb" - echo -e "\t${CMSG}15${CEND}. Install swoole" - echo -e "\t${CMSG}16${CEND}. Install xdebug(PHP>=5.5)" - read -e -p "Please input numbers:(Default '4 11 12' press Enter) " phpext_option - phpext_option=${phpext_option:-'4 11 12'} - [ "${phpext_option}" == '0' ] && break - array_phpext=(${phpext_option}) - array_all=(1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16) - for v in ${array_phpext[@]} - do - [ -z "`echo ${array_all[@]} | grep -w ${v}`" ] && phpext_flag=1 done - if [ "${phpext_flag}" == '1' ]; then - unset phpext_flag - echo; echo "${CWARNING}input error! Please only input number 4 11 12 and so on${CEND}"; echo - continue - else - [ -n "`echo ${array_phpext[@]} | grep -w 1`" ] && pecl_zendguardloader=1 - [ -n "`echo ${array_phpext[@]} | grep -w 2`" ] && pecl_ioncube=1 - [ -n "`echo ${array_phpext[@]} | grep -w 3`" ] && pecl_sourceguardian=1 - [ -n "`echo ${array_phpext[@]} | grep -w 4`" ] && pecl_imagick=1 - [ -n "`echo ${array_phpext[@]} | grep -w 5`" ] && pecl_gmagick=1 - [ -n "`echo ${array_phpext[@]} | grep -w 6`" ] && pecl_fileinfo=1 - [ -n "`echo ${array_phpext[@]} | grep -w 7`" ] && pecl_imap=1 - [ -n "`echo ${array_phpext[@]} | grep -w 8`" ] && pecl_ldap=1 - [ -n "`echo ${array_phpext[@]} | grep -w 9`" ] && pecl_phalcon=1 - [ -n "`echo ${array_phpext[@]} | grep -w 10`" ] && pecl_yaf=1 - [ -n "`echo ${array_phpext[@]} | grep -w 11`" ] && pecl_redis=1 - [ -n "`echo ${array_phpext[@]} | grep -w 12`" ] && pecl_memcached=1 - [ -n "`echo ${array_phpext[@]} | grep -w 13`" ] && pecl_memcache=1 - [ -n "`echo ${array_phpext[@]} | grep -w 14`" ] && pecl_mongodb=1 - [ -n "`echo ${array_phpext[@]} | grep -w 15`" ] && pecl_swoole=1 - [ -n "`echo ${array_phpext[@]} | grep -w 16`" ] && pecl_xdebug=1 - break - fi - done + fi + break fi +done - # check Nodejs - while :; do echo - read -e -p "Do you want to install Nodejs? [y/n]: " nodejs_flag - if [[ ! ${nodejs_flag} =~ ^[y,n]$ ]]; then - echo "${CWARNING}input error! Please only input 'y' or 'n'${CEND}" - else - [ "${nodejs_flag}" == 'y' -a -e "${nodejs_install_dir}/bin/node" ] && { echo "${CWARNING}Nodejs already installed! ${CEND}"; unset nodejs_flag; } - break - fi - done +# check Pureftpd +while :; do echo + read -p "Do you want to install Pure-FTPd? [y/n]: " FTP_yn + if [[ ! $FTP_yn =~ ^[y,n]$ ]]; then + echo "${CWARNING}input error! Please only input 'y' or 'n'${CEND}" + else + [ "$FTP_yn" == 'y' -a -e "$pureftpd_install_dir/sbin/pure-ftpwho" ] && { echo "${CWARNING}Pure-FTPd already installed! ${CEND}"; FTP_yn=Other; } + break + fi +done - # check Pureftpd +# check phpMyAdmin +if [[ $PHP_version =~ ^[1-6]$ ]] || [ -e "$php_install_dir/bin/phpize" ]; then while :; do echo - read -e -p "Do you want to install Pure-FTPd? [y/n]: " pureftpd_flag - if [[ ! ${pureftpd_flag} =~ ^[y,n]$ ]]; then + read -p "Do you want to install phpMyAdmin? [y/n]: " phpMyAdmin_yn + if [[ ! $phpMyAdmin_yn =~ ^[y,n]$ ]]; then echo "${CWARNING}input error! Please only input 'y' or 'n'${CEND}" else - [ "${pureftpd_flag}" == 'y' -a -e "${pureftpd_install_dir}/sbin/pure-ftpwho" ] && { echo "${CWARNING}Pure-FTPd already installed! ${CEND}"; unset pureftpd_flag; } + [ "$phpMyAdmin_yn" == 'y' -a -d "$wwwroot_dir/default/phpMyAdmin" ] && { echo "${CWARNING}phpMyAdmin already installed! ${CEND}"; phpMyAdmin_yn=Other; } break fi done +fi - # check phpMyAdmin - if [[ ${php_option} =~ ^[1-9]$|^1[0-5]$ ]] || [ -e "${php_install_dir}/bin/phpize" ]; then - while :; do echo - read -e -p "Do you want to install phpMyAdmin? [y/n]: " phpmyadmin_flag - if [[ ! ${phpmyadmin_flag} =~ ^[y,n]$ ]]; then - echo "${CWARNING}input error! Please only input 'y' or 'n'${CEND}" - else - [ "${phpmyadmin_flag}" == 'y' -a -d "${wwwroot_dir}/default/phpMyAdmin" ] && { echo "${CWARNING}phpMyAdmin already installed! ${CEND}"; unset phpmyadmin_flag; } - break - fi - done +# check redis +while :; do echo + read -p "Do you want to install redis? [y/n]: " redis_yn + if [[ ! $redis_yn =~ ^[y,n]$ ]]; then + echo "${CWARNING}input error! Please only input 'y' or 'n'${CEND}" + else + break fi +done - # check redis - while :; do echo - read -e -p "Do you want to install redis-server? [y/n]: " redis_flag - if [[ ! ${redis_flag} =~ ^[y,n]$ ]]; then - echo "${CWARNING}input error! Please only input 'y' or 'n'${CEND}" - else - [ "${redis_flag}" == 'y' -a -e "${redis_install_dir}/bin/redis-server" ] && { echo "${CWARNING}redis-server already installed! ${CEND}"; unset redis_flag; } - break - fi - done +# check memcached +while :; do echo + read -p "Do you want to install memcached? [y/n]: " memcached_yn + if [[ ! $memcached_yn =~ ^[y,n]$ ]]; then + echo "${CWARNING}input error! Please only input 'y' or 'n'${CEND}" + else + break + fi +done - # check memcached - while :; do echo - read -e -p "Do you want to install memcached-server? [y/n]: " memcached_flag - if [[ ! ${memcached_flag} =~ ^[y,n]$ ]]; then - echo "${CWARNING}input error! Please only input 'y' or 'n'${CEND}" - else - [ "${memcached_flag}" == 'y' -a -e "${memcached_install_dir}/bin/memcached" ] && { echo "${CWARNING}memcached-server already installed! ${CEND}"; unset memcached_flag; } - break +while :; do echo + read -p "Do you want to install HHVM? [y/n]: " HHVM_yn + if [[ ! $HHVM_yn =~ ^[y,n]$ ]]; then + echo "${CWARNING}input error! Please only input 'y' or 'n'${CEND}" + else + if [ "$HHVM_yn" == 'y' ]; then + [ -e "/usr/bin/hhvm" ] && { echo "${CWARNING}HHVM already installed! ${CEND}"; HHVM_yn=Other; break; } + if [ "$OS" == 'CentOS' -a "$OS_BIT" == '64' ] && [ -n "`grep -E ' 7\.| 6\.[5-9]' /etc/redhat-release`" ]; then + break + else + echo + echo "${CWARNING}HHVM only support CentOS6.5+ 64bit, CentOS7 64bit! ${CEND}" + echo "Press Ctrl+c to cancel or Press any key to continue..." + char=`get_char` + HHVM_yn=Other + fi fi - done -fi - -if [[ ${nginx_option} =~ ^[1-3]$ ]] || [ "${apache_flag}" == 'y' ] || [[ ${tomcat_option} =~ ^[1-4]$ ]]; then - [ ! -d ${wwwroot_dir}/default ] && mkdir -p ${wwwroot_dir}/default - [ ! -d ${wwwlogs_dir} ] && mkdir -p ${wwwlogs_dir} -fi -[ -d /data ] && chmod 755 /data - -# install wget gcc curl -if [ ! -e ~/.lnmp ]; then - downloadDepsSrc=1 - [ "${PM}" == 'apt-get' ] && apt-get -y update > /dev/null - [ "${PM}" == 'yum' ] && yum clean all > /dev/null - ${PM} -y install wget gcc curl > /dev/null -fi + break + fi +done # get the IP information -IPADDR=$(./include/ois.${ARCH} ip_local) -OUTIP_STATE=$(./include/ois.${ARCH} ip_state) +IPADDR=`./include/get_ipaddr.py` +PUBLIC_IPADDR=`./include/get_public_ipaddr.py` +IPADDR_COUNTRY_ISP=`./include/get_ipaddr_state.py $PUBLIC_IPADDR` +IPADDR_COUNTRY=`echo $IPADDR_COUNTRY_ISP | awk '{print $1}'` +[ "`echo $IPADDR_COUNTRY_ISP | awk '{print $2}'`"x == '1000323'x ] && IPADDR_ISP=aliyun -# openSSL -. ./include/openssl.sh +# del openssl for jcloud +[ -e "/usr/local/bin/openssl" ] && rm -rf /usr/local/bin/openssl +[ -e "/usr/local/include/openssl" ] && rm -rf /usr/local/include/openssl -# Check download source packages -. ./include/check_download.sh - -[ "${armplatform}" == "y" ] && dbinstallmethod=2 -checkDownload 2>&1 | tee -a ${current_dir}/install.log +# Check binary dependencies packages +. ./include/check_sw.sh +case "${OS}" in + "CentOS") + installDepsCentOS 2>&1 | tee ${oneinstack_dir}/install.log + ;; + "Debian") + installDepsDebian 2>&1 | tee ${oneinstack_dir}/install.log + ;; + "Ubuntu") + installDepsUbuntu 2>&1 | tee ${oneinstack_dir}/install.log + ;; +esac -# get OS Memory +# init +startTime=`date +%s` . ./include/memory.sh +case "${OS}" in + "CentOS") + . include/init_CentOS.sh 2>&1 | tee -a ${oneinstack_dir}/install.log + [ -n "$(gcc --version | head -n1 | grep '4\.1\.')" ] && export CC="gcc44" CXX="g++44" + ;; + "Debian") + . include/init_Debian.sh 2>&1 | tee -a ${oneinstack_dir}/install.log + ;; + "Ubuntu") + . include/init_Ubuntu.sh 2>&1 | tee -a ${oneinstack_dir}/install.log + ;; +esac -if [ ! -e ~/.lnmp ]; then - # Check binary dependencies packages - . ./include/check_sw.sh - case "${Family}" in - "rhel") - installDepsRHEL 2>&1 | tee ${current_dir}/install.log - . include/init_RHEL.sh 2>&1 | tee -a ${current_dir}/install.log - ;; - "debian") - installDepsDebian 2>&1 | tee ${current_dir}/install.log - . include/init_Debian.sh 2>&1 | tee -a ${current_dir}/install.log - ;; - "ubuntu") - installDepsUbuntu 2>&1 | tee ${current_dir}/install.log - . include/init_Ubuntu.sh 2>&1 | tee -a ${current_dir}/install.log - ;; - esac - # Install dependencies from source package - installDepsBySrc 2>&1 | tee -a ${current_dir}/install.log -fi - -# start Time -startTime=`date +%s` +# Check download source packages +. ./include/check_download.sh +downloadDepsSrc=1 +checkDownload 2>&1 | tee -a ${oneinstack_dir}/install.log -# openSSL -Install_openSSL | tee -a ${current_dir}/install.log +# Install dependencies from source package +installDepsBySrc 2>&1 | tee -a ${oneinstack_dir}/install.log # Jemalloc -if [[ ${nginx_option} =~ ^[1-3]$ ]] || [[ "${db_option}" =~ ^[1-9]$|^1[0-2]$ ]]; then +if [[ $Nginx_version =~ ^[1-3]$ ]] || [ "$DB_yn" == 'y' ]; then . include/jemalloc.sh - Install_Jemalloc | tee -a ${current_dir}/install.log + Install_Jemalloc | tee -a $oneinstack_dir/install.log +fi + +# openSSL +. ./include/openssl.sh +if [ "$Debian_version" == '8' -o "$Ubuntu_version" == '16' ] && [ "$PHP_version" == '1' ]; then + # Problem building php-5.3 with openssl + Install_openSSL100 | tee -a $oneinstack_dir/install.log +fi +if [[ $Tomcat_version =~ ^[1-3]$ ]] || [ "$DB_yn" == 'y' -a "$Apache_version" == '1' ]; then + Install_openSSL102 | tee -a $oneinstack_dir/install.log fi # Database -case "${db_option}" in +case "${DB_version}" in 1) - . include/mysql-8.4.sh - Install_MySQL84 2>&1 | tee -a ${current_dir}/install.log + if [ "${dbInstallMethods}" == "2" ]; then + . include/boost.sh + installBoost 2>&1 | tee -a ${oneinstack_dir}/install.log + fi + . include/mysql-5.7.sh + Install_MySQL57 2>&1 | tee -a ${oneinstack_dir}/install.log ;; 2) - . include/mysql-8.0.sh - Install_MySQL80 2>&1 | tee -a ${current_dir}/install.log + . include/mysql-5.6.sh + Install_MySQL56 2>&1 | tee -a ${oneinstack_dir}/install.log ;; 3) - . include/mysql-5.7.sh - Install_MySQL57 2>&1 | tee -a ${current_dir}/install.log + . include/mysql-5.5.sh + Install_MySQL55 2>&1 | tee -a ${oneinstack_dir}/install.log ;; 4) - . include/mysql-5.5.sh - Install_MySQL55 2>&1 | tee -a ${current_dir}/install.log + if [ "${dbInstallMethods}" == "2" ]; then + . include/boost.sh + installBoost 2>&1 | tee -a ${oneinstack_dir}/install.log + fi + . include/mariadb-10.1.sh + Install_MariaDB101 2>&1 | tee -a ${oneinstack_dir}/install.log ;; 5) - . include/mariadb-11.8.sh - Install_MariaDB118 2>&1 | tee -a ${current_dir}/install.log + . include/mariadb-10.0.sh + Install_MariaDB100 2>&1 | tee -a ${oneinstack_dir}/install.log ;; 6) - . include/mariadb-11.4.sh - Install_MariaDB114 2>&1 | tee -a ${current_dir}/install.log + . include/mariadb-5.5.sh + Install_MariaDB55 2>&1 | tee -a ${oneinstack_dir}/install.log ;; 7) - . include/mariadb-10.11.sh - Install_MariaDB1011 2>&1 | tee -a ${current_dir}/install.log + if [ "${dbInstallMethods}" == "2" ]; then + . include/boost.sh + installBoost 2>&1 | tee -a ${oneinstack_dir}/install.log + fi + . include/percona-5.7.sh + Install_Percona57 2>&1 | tee -a ${oneinstack_dir}/install.log ;; 8) - . include/mariadb-5.5.sh - Install_MariaDB55 2>&1 | tee -a ${current_dir}/install.log + . include/percona-5.6.sh + Install_Percona56 2>&1 | tee -a ${oneinstack_dir}/install.log ;; 9) - [ "${Family}" == 'rhel' ] && [ "${RHEL_ver}" == '8' ] && dbinstallmethod=2 && checkDownload - . include/percona-8.4.sh - Install_Percona84 2>&1 | tee -a ${current_dir}/install.log - ;; - 10) - [ "${Family}" == 'rhel' ] && [ "${RHEL_ver}" == '8' ] && dbinstallmethod=2 && checkDownload - . include/percona-8.0.sh - Install_Percona80 2>&1 | tee -a ${current_dir}/install.log - ;; - 11) - . include/percona-5.7.sh - Install_Percona57 2>&1 | tee -a ${current_dir}/install.log - ;; - 12) . include/percona-5.5.sh - Install_Percona55 2>&1 | tee -a ${current_dir}/install.log + Install_Percona55 2>&1 | tee -a ${oneinstack_dir}/install.log ;; - 13) - . include/postgresql.sh - Install_PostgreSQL 2>&1 | tee -a ${current_dir}/install.log - ;; - 14) - . include/mongodb.sh - Install_MongoDB 2>&1 | tee -a ${current_dir}/install.log + 10) + . include/alisql-5.6.sh + Install_AliSQL56 2>&1 | tee -a $oneinstack_dir/install.log ;; esac +# Apache +if [ "$Apache_version" == '1' ]; then + . include/apache-2.4.sh + Install_Apache24 2>&1 | tee -a $oneinstack_dir/install.log +elif [ "$Apache_version" == '2' ]; then + . include/apache-2.2.sh + Install_Apache22 2>&1 | tee -a $oneinstack_dir/install.log +fi + # PHP -case "${php_option}" in +case "${PHP_version}" in 1) . include/php-5.3.sh - Install_PHP53 2>&1 | tee -a ${current_dir}/install.log + Install_PHP53 2>&1 | tee -a ${oneinstack_dir}/install.log ;; 2) . include/php-5.4.sh - Install_PHP54 2>&1 | tee -a ${current_dir}/install.log + Install_PHP54 2>&1 | tee -a ${oneinstack_dir}/install.log ;; 3) . include/php-5.5.sh - Install_PHP55 2>&1 | tee -a ${current_dir}/install.log + Install_PHP55 2>&1 | tee -a ${oneinstack_dir}/install.log ;; 4) . include/php-5.6.sh - Install_PHP56 2>&1 | tee -a ${current_dir}/install.log + Install_PHP56 2>&1 | tee -a ${oneinstack_dir}/install.log ;; 5) . include/php-7.0.sh - Install_PHP70 2>&1 | tee -a ${current_dir}/install.log + Install_PHP70 2>&1 | tee -a ${oneinstack_dir}/install.log ;; 6) . include/php-7.1.sh - Install_PHP71 2>&1 | tee -a ${current_dir}/install.log - ;; - 7) - . include/php-7.2.sh - Install_PHP72 2>&1 | tee -a ${current_dir}/install.log - ;; - 8) - . include/php-7.3.sh - Install_PHP73 2>&1 | tee -a ${current_dir}/install.log - ;; - 9) - . include/php-7.4.sh - Install_PHP74 2>&1 | tee -a ${current_dir}/install.log - ;; - 10) - . include/php-8.0.sh - Install_PHP80 2>&1 | tee -a ${current_dir}/install.log - ;; - 11) - . include/php-8.1.sh - Install_PHP81 2>&1 | tee -a ${current_dir}/install.log - ;; - 12) - . include/php-8.2.sh - Install_PHP82 2>&1 | tee -a ${current_dir}/install.log - ;; - 13) - . include/php-8.3.sh - Install_PHP83 2>&1 | tee -a ${current_dir}/install.log - ;; - 14) - . include/php-8.4.sh - Install_PHP84 2>&1 | tee -a ${current_dir}/install.log - ;; - 15) - . include/php-8.5.sh - Install_PHP85 2>&1 | tee -a ${current_dir}/install.log + Install_PHP71 2>&1 | tee -a ${oneinstack_dir}/install.log ;; esac -PHP_addons() { - # PHP opcode cache - case "${phpcache_option}" in - 1) - . include/zendopcache.sh - Install_ZendOPcache 2>&1 | tee -a ${current_dir}/install.log - ;; - 2) - . include/apcu.sh - Install_APCU 2>&1 | tee -a ${current_dir}/install.log - ;; - 3) - . include/eaccelerator.sh - Install_eAccelerator 2>&1 | tee -a ${current_dir}/install.log - ;; - esac - - # ZendGuardLoader - if [ "${pecl_zendguardloader}" == '1' ]; then - . include/ZendGuardLoader.sh - Install_ZendGuardLoader 2>&1 | tee -a ${current_dir}/install.log - fi - - # ioncube - if [ "${pecl_ioncube}" == '1' ]; then - . include/ioncube.sh - Install_ionCube 2>&1 | tee -a ${current_dir}/install.log - fi - - # SourceGuardian - if [ "${pecl_sourceguardian}" == '1' ]; then - . include/sourceguardian.sh - Install_SourceGuardian 2>&1 | tee -a ${current_dir}/install.log - fi - - # imagick - if [ "${pecl_imagick}" == '1' ]; then - . include/ImageMagick.sh - Install_ImageMagick 2>&1 | tee -a ${current_dir}/install.log - Install_pecl_imagick 2>&1 | tee -a ${current_dir}/install.log - fi - - # gmagick - if [ "${pecl_gmagick}" == '1' ]; then - . include/GraphicsMagick.sh - Install_GraphicsMagick 2>&1 | tee -a ${current_dir}/install.log - Install_pecl_gmagick 2>&1 | tee -a ${current_dir}/install.log - fi - - # fileinfo - if [ "${pecl_fileinfo}" == '1' ]; then - . include/pecl_fileinfo.sh - Install_pecl_fileinfo 2>&1 | tee -a ${current_dir}/install.log - fi - - # imap - if [ "${pecl_imap}" == '1' ]; then - . include/pecl_imap.sh - Install_pecl_imap 2>&1 | tee -a ${current_dir}/install.log - fi - - # ldap - if [ "${pecl_ldap}" == '1' ]; then - . include/pecl_ldap.sh - Install_pecl_ldap 2>&1 | tee -a ${current_dir}/install.log - fi - - # calendar - if [ "${pecl_calendar}" == '1' ]; then - . include/pecl_calendar.sh - Install_pecl_calendar 2>&1 | tee -a ${current_dir}/install.log - fi - - # phalcon - if [ "${pecl_phalcon}" == '1' ]; then - . include/pecl_phalcon.sh - Install_pecl_phalcon 2>&1 | tee -a ${current_dir}/install.log - fi - - # yaf - if [ "${pecl_yaf}" == '1' ]; then - . include/pecl_yaf.sh - Install_pecl_yaf 2>&1 | tee -a ${current_dir}/install.log - fi - - # yar - if [ "${pecl_yar}" == '1' ]; then - . include/pecl_yar.sh - Install_pecl_yar 2>&1 | tee -a ${current_dir}/install.log - fi - - # pecl_memcached - if [ "${pecl_memcached}" == '1' ]; then - . include/memcached.sh - Install_pecl_memcached 2>&1 | tee -a ${current_dir}/install.log - fi - - # pecl_memcache - if [ "${pecl_memcache}" == '1' ]; then - . include/memcached.sh - Install_pecl_memcache 2>&1 | tee -a ${current_dir}/install.log - fi - - # pecl_redis - if [ "${pecl_redis}" == '1' ]; then - . include/redis.sh - Install_pecl_redis 2>&1 | tee -a ${current_dir}/install.log - fi - - # pecl_mongodb - if [ "${pecl_mongodb}" == '1' ]; then - . include/pecl_mongodb.sh - Install_pecl_mongodb 2>&1 | tee -a ${current_dir}/install.log - fi - - # swoole - if [ "${pecl_swoole}" == '1' ]; then - . include/pecl_swoole.sh - Install_pecl_swoole 2>&1 | tee -a ${current_dir}/install.log - fi - - # xdebug - if [ "${pecl_xdebug}" == '1' ]; then - . include/pecl_xdebug.sh - Install_pecl_xdebug 2>&1 | tee -a ${current_dir}/install.log - fi - - # pecl_pgsql - if [ -e "${pgsql_install_dir}/bin/psql" ]; then - . include/pecl_pgsql.sh - Install_pecl_pgsql 2>&1 | tee -a ${current_dir}/install.log - fi -} - -[ "${mphp_addons_flag}" != 'y' ] && PHP_addons +# ImageMagick or GraphicsMagick +if [ "$Magick" == '1' ]; then + . include/ImageMagick.sh + [ ! -d "/usr/local/imagemagick" ] && Install_ImageMagick 2>&1 | tee -a $oneinstack_dir/install.log + [ ! -e "`$php_install_dir/bin/php-config --extension-dir`/imagick.so" ] && Install_php-imagick 2>&1 | tee -a $oneinstack_dir/install.log +elif [ "$Magick" == '2' ]; then + . include/GraphicsMagick.sh + [ ! -d "/usr/local/graphicsmagick" ] && Install_GraphicsMagick 2>&1 | tee -a $oneinstack_dir/install.log + [ ! -e "`$php_install_dir/bin/php-config --extension-dir`/gmagick.so" ] && Install_php-gmagick 2>&1 | tee -a $oneinstack_dir/install.log +fi -if [ "${mphp_flag}" == 'y' ]; then - . include/mphp.sh - Install_MPHP 2>&1 | tee -a ${current_dir}/install.log - php_install_dir=${php_install_dir}${mphp_ver} - PHP_addons +# ionCube +if [ "$ionCube_yn" == 'y' ]; then + . include/ioncube.sh + Install_ionCube 2>&1 | tee -a $oneinstack_dir/install.log fi -# JDK -case "${jdk_option}" in +# PHP opcode cache +case "${PHP_cache}" in 1) - . include/openjdk-8.sh - Install_OpenJDK8 2>&1 | tee -a ${current_dir}/install.log + if [[ "${PHP_version}" =~ ^[1,2]$ ]]; then + . include/zendopcache.sh + Install_ZendOPcache 2>&1 | tee -a ${oneinstack_dir}/install.log + fi ;; 2) - . include/openjdk-11.sh - Install_OpenJDK11 2>&1 | tee -a ${current_dir}/install.log + . include/xcache.sh + Install_XCache 2>&1 | tee -a ${oneinstack_dir}/install.log ;; 3) - . include/openjdk-17.sh - Install_OpenJDK17 2>&1 | tee -a ${current_dir}/install.log + . include/apcu.sh + Install_APCU 2>&1 | tee -a ${oneinstack_dir}/install.log + ;; + 4) + if [[ "${PHP_version}" =~ ^[1,2]$ ]]; then + . include/eaccelerator.sh + Install_eAccelerator 2>&1 | tee -a ${oneinstack_dir}/install.log + fi ;; esac -# Nginx server -case "${nginx_option}" in +# ZendGuardLoader (php <= 5.6) +if [ "$ZendGuardLoader_yn" == 'y' ]; then + . include/ZendGuardLoader.sh + Install_ZendGuardLoader 2>&1 | tee -a $oneinstack_dir/install.log +fi + +# Web server +case "${Nginx_version}" in 1) . include/nginx.sh - Install_Nginx 2>&1 | tee -a ${current_dir}/install.log + Install_Nginx 2>&1 | tee -a ${oneinstack_dir}/install.log ;; 2) . include/tengine.sh - Install_Tengine 2>&1 | tee -a ${current_dir}/install.log + Install_Tengine 2>&1 | tee -a ${oneinstack_dir}/install.log ;; 3) . include/openresty.sh - Install_OpenResty 2>&1 | tee -a ${current_dir}/install.log + Install_OpenResty 2>&1 | tee -a ${oneinstack_dir}/install.log ;; esac -# Apache -if [ "${apache_flag}" == 'y' ]; then - apache_mode_option=${apache_mode_option:-1} - apache_mpm_option=${apache_mpm_option:-1} - . include/apache.sh - Install_Apache 2>&1 | tee -a ${current_dir}/install.log -fi - -# Tomcat -case "${tomcat_option}" in +# JDK +case "${JDK_version}" in 1) - . include/tomcat-10.sh - Install_Tomcat10 2>&1 | tee -a ${current_dir}/install.log + . include/jdk-1.8.sh + Install-JDK18 2>&1 | tee -a ${oneinstack_dir}/install.log ;; 2) - . include/tomcat-9.sh - Install_Tomcat9 2>&1 | tee -a ${current_dir}/install.log + . include/jdk-1.7.sh + Install-JDK17 2>&1 | tee -a ${oneinstack_dir}/install.log ;; 3) + . include/jdk-1.6.sh + Install-JDK16 2>&1 | tee -a ${oneinstack_dir}/install.log + ;; +esac + +case "${Tomcat_version}" in + 1) . include/tomcat-8.sh - Install_Tomcat8 2>&1 | tee -a ${current_dir}/install.log + Install_Tomcat8 2>&1 | tee -a ${oneinstack_dir}/install.log ;; - 4) + 2) . include/tomcat-7.sh - Install_Tomcat7 2>&1 | tee -a ${current_dir}/install.log + Install_Tomcat7 2>&1 | tee -a ${oneinstack_dir}/install.log + ;; + 3) + . include/tomcat-6.sh + Install_Tomcat6 2>&1 | tee -a ${oneinstack_dir}/install.log ;; esac -# Nodejs -if [ "${nodejs_flag}" == 'y' ]; then - . include/nodejs.sh - Install_Nodejs 2>&1 | tee -a ${current_dir}/install.log -fi - # Pure-FTPd -if [ "${pureftpd_flag}" == 'y' ]; then +if [ "${FTP_yn}" == 'y' ]; then . include/pureftpd.sh - Install_PureFTPd 2>&1 | tee -a ${current_dir}/install.log + Install_PureFTPd 2>&1 | tee -a ${oneinstack_dir}/install.log fi # phpMyAdmin -if [ "${phpmyadmin_flag}" == 'y' ]; then +if [ "${phpMyAdmin_yn}" == 'y' ]; then . include/phpmyadmin.sh - Install_phpMyAdmin 2>&1 | tee -a ${current_dir}/install.log + Install_phpMyAdmin 2>&1 | tee -a ${oneinstack_dir}/install.log fi # redis -if [ "${redis_flag}" == 'y' ]; then +if [ "${redis_yn}" == 'y' ]; then . include/redis.sh - Install_redis_server 2>&1 | tee -a ${current_dir}/install.log + [ ! -d "${redis_install_dir}" ] && Install_redis-server 2>&1 | tee -a ${oneinstack_dir}/install.log + [ -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 fi # memcached -if [ "${memcached_flag}" == 'y' ]; then +if [ "${memcached_yn}" == 'y' ]; then . include/memcached.sh - Install_memcached_server 2>&1 | tee -a ${current_dir}/install.log + [ ! -d "${memcached_install_dir}/include/memcached" ] && Install_memcached 2>&1 | tee -a ${oneinstack_dir}/install.log + [ -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 + [ -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 fi # index example -if [ -d "${wwwroot_dir}/default" ]; then +if [ ! -e "${wwwroot_dir}/default/index.html" -a "${Web_yn}" == 'y' ]; then . include/demo.sh - DEMO 2>&1 | tee -a ${current_dir}/install.log + DEMO 2>&1 | tee -a ${oneinstack_dir}/install.log fi # get web_install_dir and db_install_dir . include/check_dir.sh +# HHVM +if [ "${HHVM_yn}" == 'y' ]; then + . include/hhvm_CentOS.sh + Install_hhvm_CentOS 2>&1 | tee -a ${oneinstack_dir}/install.log +fi + # Starting DB [ -d "/etc/mysql" ] && /bin/mv /etc/mysql{,_bk} -[ -d "${db_install_dir}/support-files" ] && [ -z "`ps -ef | grep mysqld_safe | grep -v grep`" ] && service mysqld start - -# reload php -[ -e "${php_install_dir}/sbin/php-fpm" ] && { [ -e "/bin/systemctl" ] && systemctl reload php-fpm || service php-fpm reload; } -[ -n "${mphp_ver}" -a -e "${php_install_dir}${mphp_ver}/sbin/php-fpm" ] && { [ -e "/bin/systemctl" ] && systemctl reload php${mphp_ver}-fpm || service php${mphp_ver}-fpm reload; } -[ -e "${apache_install_dir}/bin/apachectl" ] && ${apache_install_dir}/bin/apachectl -k graceful - +[ -d "${db_install_dir}/support-files" -a -z "$(ps -ef | grep -v grep | grep mysql)" ] && /etc/init.d/mysqld start endTime=`date +%s` ((installTime=($endTime-$startTime)/60)) echo "####################Congratulations########################" -echo "Total Install Time: ${CQUESTION}${installTime}${CEND} minutes" -[[ "${nginx_option}" =~ ^[1-3]$ ]] && echo -e "\n$(printf "%-32s" "Nginx install dir":)${CMSG}${web_install_dir}${CEND}" -[ "${apache_flag}" == 'y' ] && echo -e "\n$(printf "%-32s" "Apache install dir":)${CMSG}${apache_install_dir}${CEND}" -[[ "${tomcat_option}" =~ ^[1-4]$ ]] && echo -e "\n$(printf "%-32s" "Tomcat install dir":)${CMSG}${tomcat_install_dir}${CEND}" -[[ "${db_option}" =~ ^[1-9]$|^1[0-2]$ ]] && echo -e "\n$(printf "%-32s" "Database install dir:")${CMSG}${db_install_dir}${CEND}" -[[ "${db_option}" =~ ^[1-9]$|^1[0-2]$ ]] && echo "$(printf "%-32s" "Database data dir:")${CMSG}${db_data_dir}${CEND}" -[[ "${db_option}" =~ ^[1-9]$|^1[0-2]$ ]] && echo "$(printf "%-32s" "Database user:")${CMSG}root${CEND}" -[[ "${db_option}" =~ ^[1-9]$|^1[0-2]$ ]] && echo "$(printf "%-32s" "Database password:")${CMSG}${dbrootpwd}${CEND}" -[ "${db_option}" == '13' ] && echo -e "\n$(printf "%-32s" "PostgreSQL install dir:")${CMSG}${pgsql_install_dir}${CEND}" -[ "${db_option}" == '13' ] && echo "$(printf "%-32s" "PostgreSQL data dir:")${CMSG}${pgsql_data_dir}${CEND}" -[ "${db_option}" == '13' ] && echo "$(printf "%-32s" "PostgreSQL user:")${CMSG}postgres${CEND}" -[ "${db_option}" == '13' ] && echo "$(printf "%-32s" "postgres password:")${CMSG}${dbpostgrespwd}${CEND}" -[ "${db_option}" == '14' ] && echo -e "\n$(printf "%-32s" "MongoDB install dir:")${CMSG}${mongo_install_dir}${CEND}" -[ "${db_option}" == '14' ] && echo "$(printf "%-32s" "MongoDB data dir:")${CMSG}${mongo_data_dir}${CEND}" -[ "${db_option}" == '14' ] && echo "$(printf "%-32s" "MongoDB user:")${CMSG}root${CEND}" -[ "${db_option}" == '14' ] && echo "$(printf "%-32s" "MongoDB password:")${CMSG}${dbmongopwd}${CEND}" -[[ "${php_option}" =~ ^[1-9]$|^1[0-5]$ ]] && echo -e "\n$(printf "%-32s" "PHP install dir:")${CMSG}${php_install_dir}${CEND}" -[ "${phpcache_option}" == '1' ] && echo "$(printf "%-32s" "Opcache Control Panel URL:")${CMSG}http://${IPADDR}/ocp.php${CEND}" -[ "${phpcache_option}" == '2' ] && echo "$(printf "%-32s" "APC Control Panel URL:")${CMSG}http://${IPADDR}/apc.php${CEND}" -[ "${phpcache_option}" == '3' -a -e "${php_install_dir}/etc/php.d/02-eaccelerator.ini" ] && echo "$(printf "%-32s" "eAccelerator Control Panel URL:")${CMSG}http://${IPADDR}/control.php${CEND}" -[ "${phpcache_option}" == '3' -a -e "${php_install_dir}/etc/php.d/02-eaccelerator.ini" ] && echo "$(printf "%-32s" "eAccelerator user:")${CMSG}admin${CEND}" -[ "${phpcache_option}" == '3' -a -e "${php_install_dir}/etc/php.d/02-eaccelerator.ini" ] && echo "$(printf "%-32s" "eAccelerator password:")${CMSG}eAccelerator${CEND}" -[ "${pureftpd_flag}" == 'y' ] && echo -e "\n$(printf "%-32s" "Pure-FTPd install dir:")${CMSG}${pureftpd_install_dir}${CEND}" -[ "${pureftpd_flag}" == 'y' ] && echo "$(printf "%-32s" "Create FTP virtual script:")${CMSG}./pureftpd_vhost.sh${CEND}" -[ "${phpmyadmin_flag}" == 'y' ] && echo -e "\n$(printf "%-32s" "phpMyAdmin dir:")${CMSG}${wwwroot_dir}/default/phpMyAdmin${CEND}" -[ "${phpmyadmin_flag}" == 'y' ] && echo "$(printf "%-32s" "phpMyAdmin Control Panel URL:")${CMSG}http://${IPADDR}/phpMyAdmin${CEND}" -[ "${redis_flag}" == 'y' ] && echo -e "\n$(printf "%-32s" "redis install dir:")${CMSG}${redis_install_dir}${CEND}" -[ "${memcached_flag}" == 'y' ] && echo -e "\n$(printf "%-32s" "memcached install dir:")${CMSG}${memcached_install_dir}${CEND}" -if [[ ${nginx_option} =~ ^[1-3]$ ]] || [ "${apache_flag}" == 'y' ] || [[ ${tomcat_option} =~ ^[1-4]$ ]]; then - echo -e "\n$(printf "%-32s" "Index URL:")${CMSG}http://${IPADDR}/${CEND}" -fi -if [ ${ARG_NUM} == 0 ]; then - while :; do echo - echo "${CMSG}Please restart the server and see if the services start up fine.${CEND}" - read -e -p "Do you want to restart OS ? [y/n]: " reboot_flag - if [[ ! "${reboot_flag}" =~ ^[y,n]$ ]]; then - echo "${CWARNING}input error! Please only input 'y' or 'n'${CEND}" - else - break - fi - done -fi -[ "${reboot_flag}" == 'y' ] && reboot +echo "Total OneinStack Install Time: ${CQUESTION}${installTime}${CEND} minutes" +[ "${Web_yn}" == 'y' -a "${Nginx_version}" != '4' -a "${Apache_version}" == '3' ] && echo -e "\n$(printf "%-32s" "Nginx install dir":)${CMSG}${web_install_dir}${CEND}" +[ "${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}" +[ "${Web_yn}" == 'y' -a "${Nginx_version}" == '4' -a "${Apache_version}" != '3' ] && echo -e "\n$(printf "%-32s" "Apache install dir":)${CMSG}${apache_install_dir}${CEND}" +[[ "${Tomcat_version}" =~ ^[1,2]$ ]] && echo -e "\n$(printf "%-32s" "Tomcat install dir":)${CMSG}${tomcat_install_dir}${CEND}" +[ "${DB_yn}" == 'y' ] && echo -e "\n$(printf "%-32s" "Database install dir:")${CMSG}${db_install_dir}${CEND}" +[ "${DB_yn}" == 'y' ] && echo "$(printf "%-32s" "Database data dir:")${CMSG}${db_data_dir}${CEND}" +[ "${DB_yn}" == 'y' ] && echo "$(printf "%-32s" "Database user:")${CMSG}root${CEND}" +[ "${DB_yn}" == 'y' ] && echo "$(printf "%-32s" "Database password:")${CMSG}${dbrootpwd}${CEND}" +[ "${PHP_yn}" == 'y' ] && echo -e "\n$(printf "%-32s" "PHP install dir:")${CMSG}${php_install_dir}${CEND}" +[ "${PHP_cache}" == '1' ] && echo "$(printf "%-32s" "Opcache Control Panel url:")${CMSG}http://${IPADDR}/ocp.php${CEND}" +[ "${PHP_cache}" == '2' ] && echo "$(printf "%-32s" "xcache Control Panel url:")${CMSG}http://${IPADDR}/xcache${CEND}" +[ "${PHP_cache}" == '2' ] && echo "$(printf "%-32s" "xcache user:")${CMSG}admin${CEND}" +[ "${PHP_cache}" == '2' ] && echo "$(printf "%-32s" "xcache password:")${CMSG}${xcache_admin_pass}${CEND}" +[ "${PHP_cache}" == '3' ] && echo "$(printf "%-32s" "APC Control Panel url:")${CMSG}http://${IPADDR}/apc.php${CEND}" +[ "${PHP_cache}" == '4' ] && echo "$(printf "%-32s" "eAccelerator Control Panel url:")${CMSG}http://${IPADDR}/control.php${CEND}" +[ "${PHP_cache}" == '4' ] && echo "$(printf "%-32s" "eAccelerator user:")${CMSG}admin${CEND}" +[ "${PHP_cache}" == '4' ] && echo "$(printf "%-32s" "eAccelerator password:")${CMSG}eAccelerator${CEND}" +[ "${FTP_yn}" == 'y' ] && echo -e "\n$(printf "%-32s" "Pure-FTPd install dir:")${CMSG}${pureftpd_install_dir}${CEND}" +[ "${FTP_yn}" == 'y' ] && echo "$(printf "%-32s" "Create FTP virtual script:")${CMSG}./pureftpd_vhost.sh${CEND}" +[ "${phpMyAdmin_yn}" == 'y' ] && echo -e "\n$(printf "%-32s" "phpMyAdmin dir:")${CMSG}${wwwroot_dir}/default/phpMyAdmin${CEND}" +[ "${phpMyAdmin_yn}" == 'y' ] && echo "$(printf "%-32s" "phpMyAdmin Control Panel url:")${CMSG}http://${IPADDR}/phpMyAdmin${CEND}" +[ "${redis_yn}" == 'y' ] && echo -e "\n$(printf "%-32s" "redis install dir:")${CMSG}${redis_install_dir}${CEND}" +[ "${memcached_yn}" == 'y' ] && echo -e "\n$(printf "%-32s" "memcached install dir:")${CMSG}${memcached_install_dir}${CEND}" +[ "${Web_yn}" == 'y' ] && echo -e "\n$(printf "%-32s" "index url:")${CMSG}http://${IPADDR}/${CEND}" +while :; do echo + echo "${CMSG}Please restart the server and see if the services start up fine.${CEND}" + read -p "Do you want to restart OS ? [y/n]: " restart_yn + if [[ ! "${restart_yn}" =~ ^[y,n]$ ]]; then + echo "${CWARNING}input error! Please only input 'y' or 'n'${CEND}" + else + break + fi +done +[ "${restart_yn}" == 'y' ] && reboot diff --git a/options.conf b/options.conf index 46083afc..292a568b 100644 --- a/options.conf +++ b/options.conf @@ -1,13 +1,8 @@ -# mirror link -mirror_link=http://mirrors.linuxeye.com - -# set the default timezone -timezone=Asia/Shanghai +# operating environment for the current working directory +oneinstack_dir= # Nginx Apache and PHP-FPM process is run as $run_user(Default "www"), you can freely specify run_user=www -# Nginx Apache and PHP-FPM process is run as $run_group(Default "www"), you can freely specify -run_group=www # set the default install path, you can freely specify nginx_install_dir=/usr/local/nginx @@ -19,26 +14,19 @@ tomcat_install_dir=/usr/local/tomcat mysql_install_dir=/usr/local/mysql mariadb_install_dir=/usr/local/mariadb percona_install_dir=/usr/local/percona -pgsql_install_dir=/usr/local/pgsql -mongo_install_dir=/usr/local/mongodb +alisql_install_dir=/usr/local/alisql php_install_dir=/usr/local/php -nodejs_install_dir=/usr/local/node - pureftpd_install_dir=/usr/local/pureftpd memcached_install_dir=/usr/local/memcached redis_install_dir=/usr/local/redis -openssl_install_dir=/usr/local/openssl -imagick_install_dir=/usr/local/imagemagick -gmagick_install_dir=/usr/local/graphicsmagick -curl_install_dir=/usr/local/curl -freetype_install_dir=/usr/local/freetype +python_install_dir=/usr/local/python -apr_install_dir=/usr/local/apr +openssl_install_dir=/usr/local/openssl # Add modules nginx_modules_options='' @@ -49,8 +37,7 @@ php_modules_options='' mysql_data_dir=/data/mysql mariadb_data_dir=/data/mariadb percona_data_dir=/data/percona -pgsql_data_dir=/data/pgsql -mongo_data_dir=/data/mongodb +alisql_data_dir=/data/alisql # web directory, you can customize wwwroot_dir=/data/wwwroot @@ -59,15 +46,9 @@ wwwroot_dir=/data/wwwroot wwwlogs_dir=/data/wwwlogs ######################################################################### -# [MySQL/MariaDB/Percona] automatically generated, You can't change +# automatically generated, You can't change dbrootpwd= -# [PostgreSQL] automatically generated, You can't change -dbpostgrespwd= - -# [MongoDB] automatically generated, You can't change -dbmongopwd= - ######################################################################### # Backup Dest directory, change this if you have someother location backup_dir=/data/backup @@ -75,7 +56,7 @@ backup_dir=/data/backup # How many days before the backup directory will be removed expired_days=5 -# local,remote,oss,cos,upyun,qiniu,s3,gdrive,dropbox +# local ; remote ; local,remote backup_destination= # db ; web, You can't change @@ -84,20 +65,8 @@ backup_content= # aliyun OSS Bucket, You can't change oss_bucket= -# qcloud OSS Bucket, You can't change -cos_bucket= - -# qiniu Bucket, You can't change -qiniu_bucket= - -# Amazon S3 Bucket, You can't change -s3_bucket= - # The backup of the database, You can't change db_name= # The backup of the website, You can't change website_name= - -# lnmp.tar.gz md5, You can't change -script_md5= diff --git a/pureftpd_vhost.sh b/pureftpd_vhost.sh index 7f8b2533..a0f735d6 100755 --- a/pureftpd_vhost.sh +++ b/pureftpd_vhost.sh @@ -1,218 +1,78 @@ #!/bin/bash # Author: yeho -# BLOG: https://linuxeye.com +# BLOG: https://blog.linuxeye.com # +# Notes: OneinStack for CentOS/RadHat 5+ Debian 6+ and Ubuntu 12+ # +# Project home page: +# https://oneinstack.com +# https://github.com/lj2007331/oneinstack export PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin clear printf " ####################################################################### +# OneinStack for CentOS/RadHat 5+ Debian 6+ and Ubuntu 12+ # # FTP virtual user account management # +# For more information please visit https://oneinstack.com # ####################################################################### " -# Check if user is root -[ $(id -u) != "0" ] && { echo "${CFAILURE}Error: You must be root to run this script${CEND}"; exit 1; } -current_dir=$(dirname "`readlink -f $0`") -pushd ${current_dir} > /dev/null . ./options.conf . ./include/color.sh -[ ! -d "${pureftpd_install_dir}" ] && { echo "${CFAILURE}FTP server does not exist! ${CEND}"; exit 1; } +# Check if user is root +[ $(id -u) != "0" ] && { echo "${CFAILURE}Error: You must be root to run this script${CEND}"; exit 1; } -FTP_conf=${pureftpd_install_dir}/etc/pure-ftpd.conf -FTP_tmp_passfile=${pureftpd_install_dir}/etc/pureftpd_psss.tmp -Puredbfile=${pureftpd_install_dir}/etc/pureftpd.pdb -Passwdfile=${pureftpd_install_dir}/etc/pureftpd.passwd -FTP_bin=${pureftpd_install_dir}/bin/pure-pw -[ -z "`grep ^PureDB ${FTP_conf}`" ] && { echo "${CFAILURE}pure-ftpd is not own password database${CEND}" ; exit 1; } +[ ! -d "$pureftpd_install_dir" ] && { echo "${CFAILURE}FTP server does not exist! ${CEND}"; exit 1; } -ARG_NUM=$# -Show_Help() { - echo - echo "Usage: $0 command ...[parameters].... - --help, -h Show this help message - --useradd,--add Add username - --usermod Modify directory - --passwd Modify password - --userdel,--delete Delete User - --listalluser,--list List all User - --showuser List User details - --username,-u [ftp username] Ftp username - --password,-p [ftp password] Ftp password - --directory,-d,-D [ftp directory] Ftp home directory - " -} - -TEMP=`getopt -o hu:p:d:D: --long help,useradd,add,usermod,passwd,userdel,delete,listalluser,list,showuser,username:,password:,directory: -- "$@" 2>/dev/null` -[ $? != 0 ] && echo "${CWARNING}ERROR: unknown argument! ${CEND}" && Show_Help && exit 1 -eval set -- "${TEMP}" -while :; do - [ -z "$1" ] && break; - case "$1" in - -h|--help) - Show_Help; exit 0 - ;; - --add|--useradd) - useradd_flag=y; shift 1 - ;; - --usermod) - usermod_flag=y; shift 1 - ;; - --passwd) - passwd_flag=y; shift 1 - ;; - --delete|--userdel) - userdel_flag=y; shift 1 - ;; - --list|--listalluser) - listalluser_flag=y; shift 1 - ;; - --showuser) - showuser_flag=y; shift 1 - ;; - -u|--username) - username_flag=y; User=$2; shift 2 - ;; - -p|--password) - password_flag=y; Password=$2; shift 2 - ;; - -d|-D|--directory) - directory_flag=y; Directory=$2; shift 2 - ;; - --) - shift - ;; - *) - echo "${CWARNING}ERROR: unknown argument! ${CEND}" && Show_Help && exit 1 - ;; - esac -done +FTP_conf=$pureftpd_install_dir/etc/pure-ftpd.conf +FTP_tmp_passfile=$pureftpd_install_dir/etc/pureftpd_psss.tmp +Puredbfile=$pureftpd_install_dir/etc/pureftpd.pdb +Passwdfile=$pureftpd_install_dir/etc/pureftpd.passwd +FTP_bin=$pureftpd_install_dir/bin/pure-pw +[ -z "`grep ^PureDB $FTP_conf`" ] && { echo "${CFAILURE}pure-ftpd is not own password database${CEND}" ; exit 1; } USER() { - while :; do - if [ "${username_flag}" != 'y' ]; then - echo - read -e -p "Please input a username: " User - fi - if [ -z "${User}" ]; then - echo "${CWARNING}username can't be NULL! ${CEND}" - else - break - fi - done +while :; do echo + read -p "Please input a username: " User + if [ -z "$User" ]; then + echo "${CWARNING}username can't be NULL! ${CEND}" + else + break + fi +done } PASSWORD() { - while :; do - if [ "${password_flag}" != 'y' ]; then - echo - read -e -p "Please input the password: " Password - fi - [ -n "`echo ${Password} | grep '[+|&]'`" ] && { echo "${CWARNING}input error,not contain a plus sign (+) and &${CEND}"; continue; } - if (( ${#Password} >= 5 )); then - echo -e "${Password}\n${Password}" > ${FTP_tmp_passfile} - break - else - echo "${CWARNING}Ftp password least 5 characters! ${CEND}" - fi - done -} - -DIRECTORY() { - while :; do - if [ "${directory_flag}" != 'y' ]; then - echo - read -e -p "Please input the directory(Default directory: ${wwwroot_dir}): " Directory - fi - Directory=${Directory:-${wwwroot_dir}} - if [ ! -d "${Directory}" ]; then - echo "${CWARNING}The directory does not exist${CEND}" - else - break - fi - done -} - -UserAdd() { - USER - [ -e "${Passwdfile}" ] && [ -n "`grep ^${User}: ${Passwdfile}`" ] && { echo "${CQUESTION}[${User}] is already existed! ${CEND}"; exit 1; } - PASSWORD;DIRECTORY - ${FTP_bin} useradd ${User} -f ${Passwdfile} -u ${run_user} -g ${run_group} -d ${Directory} -m < ${FTP_tmp_passfile} - ${FTP_bin} mkdb ${Puredbfile} -f ${Passwdfile} > /dev/null 2>&1 - echo "#####################################" - echo - echo "[${User}] create successful! " - echo - echo "You user name is : ${CMSG}${User}${CEND}" - echo "You Password is : ${CMSG}${Password}${CEND}" - echo "You directory is : ${CMSG}${Directory}${CEND}" - echo -} - -UserMod() { - USER - [ -e "${Passwdfile}" ] && [ -z "`grep ^${User}: ${Passwdfile}`" ] && { echo "${CQUESTION}[${User}] was not existed! ${CEND}"; exit 1; } - DIRECTORY - ${FTP_bin} usermod ${User} -f ${Passwdfile} -d ${Directory} -m - ${FTP_bin} mkdb ${Puredbfile} -f ${Passwdfile} > /dev/null 2>&1 - echo "#####################################" - echo - echo "[${User}] modify a successful! " - echo - echo "You user name is : ${CMSG}${User}${CEND}" - echo "You new directory is : ${CMSG}${Directory}${CEND}" - echo -} - -UserPasswd() { - USER - [ -e "${Passwdfile}" ] && [ -z "`grep ^${User}: ${Passwdfile}`" ] && { echo "${CQUESTION}[${User}] was not existed! ${CEND}"; exit 1; } - PASSWORD - ${FTP_bin} passwd ${User} -f ${Passwdfile} -m < ${FTP_tmp_passfile} - ${FTP_bin} mkdb ${Puredbfile} -f ${Passwdfile} > /dev/null 2>&1 - echo "#####################################" - echo - echo "[${User}] Password changed successfully! " - echo - echo "You user name is : ${CMSG}${User}${CEND}" - echo "You new password is : ${CMSG}${Password}${CEND}" - echo -} - -UserDel() { - if [ ! -e "${Passwdfile}" ]; then - echo "${CQUESTION}User was not existed! ${CEND}" +while :; do echo + read -p "Please input the password: " Password + [ -n "`echo $Password | grep '[+|&]'`" ] && { echo "${CWARNING}input error,not contain a plus sign (+) and &${CEND}"; continue; } + if (( ${#Password} >= 5 ));then + echo -e "${Password}\n$Password" > $FTP_tmp_passfile + break else - ${FTP_bin} list + echo "${CWARNING}Ftp password least 5 characters! ${CEND}" fi - - USER - [ -e "${Passwdfile}" ] && [ -z "`grep ^${User}: ${Passwdfile}`" ] && { echo "${CQUESTION}[${User}] was not existed! ${CEND}"; exit 1; } - ${FTP_bin} userdel ${User} -f ${Passwdfile} -m - ${FTP_bin} mkdb ${Puredbfile} -f ${Passwdfile} > /dev/null 2>&1 - echo - echo "[${User}] have been deleted! " +done } -ListAllUser() { - if [ ! -e "${Passwdfile}" ]; then - echo "${CQUESTION}User was not existed! ${CEND}" +DIRECTORY() { +while :; do echo + read -p "Please input the directory(Default directory: $wwwroot_dir): " Directory + if [ -z "$Directory" ]; then + Directory="$wwwroot_dir" + fi + if [ ! -d "$Directory" ]; then + echo "${CWARNING}The directory does not exist${CEND}" else - ${FTP_bin} list + break fi +done } -ShowUser() { - USER - [ -e "${Passwdfile}" ] && [ -z "`grep ^${User}: ${Passwdfile}`" ] && { echo "${CQUESTION}[${User}] was not existed! ${CEND}"; exit 1; } - ${FTP_bin} show ${User} -} - -Menu() { - while :; do - printf " +while :; do + printf " What Are You Doing? \t${CMSG}1${CEND}. UserAdd \t${CMSG}2${CEND}. UserMod @@ -222,44 +82,83 @@ What Are You Doing? \t${CMSG}6${CEND}. ShowUser \t${CMSG}q${CEND}. Exit " - read -e -p "Please input the correct option: " Number - if [[ ! ${Number} =~ ^[1-6,q]$ ]]; then - echo "${CFAILURE}input error! Please only input 1~6 and q${CEND}" - else - case "${Number}" in - 1) - UserAdd - ;; - 2) - UserMod - ;; - 3) - UserPasswd - ;; - 4) - UserDel - ;; - 5) - ListAllUser - ;; - 6) - ShowUser - ;; - q) - exit - ;; - esac - fi - done -} - -if [ ${ARG_NUM} == 0 ]; then - Menu -else - [ "${useradd_flag}" == 'y' ] && UserAdd - [ "${usermod_flag}" == 'y' ] && UserMod - [ "${passwd_flag}" == 'y' ] && UserPasswd - [ "${userdel_flag}" == 'y' ] && UserDel - [ "${listalluser_flag}" == 'y' ] && ListAllUser - [ "${showuser_flag}" == 'y' ] && ShowUser -fi + read -p "Please input the correct option: " Number + if [[ ! $Number =~ ^[1-6,q]$ ]]; then + echo "${CFAILURE}input error! Please only input 1 ~ 6 and q${CEND}" + else + case "$Number" in + 1) + USER + [ -e "$Passwdfile" ] && [ -n "`grep ^${User}: $Passwdfile`" ] && { echo "${CQUESTION}[$User] is already existed! ${CEND}"; continue; } + PASSWORD;DIRECTORY + $FTP_bin useradd $User -f $Passwdfile -u $run_user -g $run_user -d $Directory -m < $FTP_tmp_passfile + $FTP_bin mkdb $Puredbfile -f $Passwdfile > /dev/null 2>&1 + echo "#####################################" + echo + echo "[$User] create successful! " + echo + echo "You user name is : ${CMSG}$User${CEND}" + echo "You Password is : ${CMSG}$Password${CEND}" + echo "You directory is : ${CMSG}$Directory${CEND}" + echo + ;; + 2) + USER + [ -e "$Passwdfile" ] && [ -z "`grep ^${User}: $Passwdfile`" ] && { echo "${CQUESTION}[$User] was not existed! ${CEND}"; continue; } + DIRECTORY + $FTP_bin usermod $User -f $Passwdfile -d $Directory -m + $FTP_bin mkdb $Puredbfile -f $Passwdfile > /dev/null 2>&1 + echo "#####################################" + echo + echo "[$User] modify a successful! " + echo + echo "You user name is : ${CMSG}$User${CEND}" + echo "You new directory is : ${CMSG}$Directory${CEND}" + echo + ;; + 3) + USER + [ -e "$Passwdfile" ] && [ -z "`grep ^${User}: $Passwdfile`" ] && { echo "${CQUESTION}[$User] was not existed! ${CEND}"; continue; } + PASSWORD + $FTP_bin passwd $User -f $Passwdfile -m < $FTP_tmp_passfile + $FTP_bin mkdb $Puredbfile -f $Passwdfile > /dev/null 2>&1 + echo "#####################################" + echo + echo "[$User] Password changed successfully! " + echo + echo "You user name is : ${CMSG}$User${CEND}" + echo "You new password is : ${CMSG}$Password${CEND}" + echo + ;; + 4) + if [ ! -e "$Passwdfile" ]; then + echo "${CQUESTION}User was not existed! ${CEND}" + else + $FTP_bin list + fi + + USER + [ -e "$Passwdfile" ] && [ -z "`grep ^${User}: $Passwdfile`" ] && { echo "${CQUESTION}[$User] was not existed! ${CEND}"; continue; } + $FTP_bin userdel $User -f $Passwdfile -m + $FTP_bin mkdb $Puredbfile -f $Passwdfile > /dev/null 2>&1 + echo + echo "[$User] have been deleted! " + ;; + 5) + if [ ! -e "$Passwdfile" ]; then + echo "${CQUESTION}User was not existed! ${CEND}" + else + $FTP_bin list + fi + ;; + 6) + USER + [ -e "$Passwdfile" ] && [ -z "`grep ^${User}: $Passwdfile`" ] && { echo "${CQUESTION}[$User] was not existed! ${CEND}"; continue; } + $FTP_bin show $User + ;; + q) + exit + ;; + esac + fi +done diff --git a/reset_db_root_password.sh b/reset_db_root_password.sh index cc0f8605..18ea9500 100755 --- a/reset_db_root_password.sh +++ b/reset_db_root_password.sh @@ -1,76 +1,42 @@ #!/bin/bash # Author: yeho -# BLOG: https://linuxeye.com +# BLOG: https://blog.linuxeye.com # +# Notes: OneinStack for CentOS/RadHat 5+ Debian 6+ and Ubuntu 12+ # +# Project home page: +# https://oneinstack.com +# https://github.com/lj2007331/oneinstack export PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin clear printf " ####################################################################### -# Reset Database root password # +# OneinStack for CentOS/RadHat 5+ Debian 6+ and Ubuntu 12+ # +# Reset Database root password for OneinStack # +# For more information please visit https://oneinstack.com # ####################################################################### " -current_dir=$(dirname "`readlink -f $0`") -pushd ${current_dir} > /dev/null + . ./options.conf . ./include/color.sh . ./include/check_dir.sh -[ ! -d "${db_install_dir}" ] && { echo "${CFAILURE}Database is not installed on your system! ${CEND}"; exit 1; } - -Show_Help() { - echo "Usage: $0 command ...[parameters].... - -h, --help print this help. - -q, --quiet quiet operation. - -f, --force Lost Database Password? Forced reset password. - -p, --password [pass] DB super password. - " -} -New_dbrootpwd="`< /dev/urandom tr -dc A-Za-z0-9 | head -c8`" -TEMP=`getopt -o hqfp: --long help,quiet,force,password: -- "$@" 2>/dev/null` -[ $? != 0 ] && echo "${CWARNING}ERROR: unknown argument! ${CEND}" && Show_Help && exit 1 -eval set -- "${TEMP}" -while :; do - [ -z "$1" ] && break; - case "$1" in - -h|--help) - Show_Help; exit 0 - ;; - -q|--quiet) - quiet_flag=y; shift 1 - ;; - -f|--force) - force_flag=y; shift 1 - ;; - -p|--password) - New_dbrootpwd=$2; shift 2 - password_flag=y - ;; - --) - shift - ;; - *) - echo "${CWARNING}ERROR: unknown argument! ${CEND}" && Show_Help && exit 1 - ;; - esac -done - -Input_dbrootpwd() { +Reset_db_root_password() +{ + [ ! -d "$db_install_dir" ] && { echo "${CFAILURE}Database is not installed on your system! ${CEND}"; exit 1; } while :; do echo - read -e -p "Please input the root password of database: " New_dbrootpwd - [ -n "`echo ${New_dbrootpwd} | grep '[+|&]'`" ] && { echo "${CWARNING}input error,not contain a plus sign (+) and &${CEND}"; continue; } + read -p "Please input the root password of database: " New_dbrootpwd + [ -n "`echo $New_dbrootpwd | grep '[+|&]'`" ] && { echo "${CWARNING}input error,not contain a plus sign (+) and &${CEND}"; continue; } (( ${#New_dbrootpwd} >= 5 )) && break || echo "${CWARNING}database root password least 5 characters! ${CEND}" done -} - -Reset_Interaction_dbrootpwd() { - ${db_install_dir}/bin/mysqladmin -uroot -p"${dbrootpwd}" password "${New_dbrootpwd}" -h localhost > /dev/null 2>&1 + + $db_install_dir/bin/mysqladmin -uroot -p"$dbrootpwd" password "$New_dbrootpwd" -h localhost > /dev/null 2>&1 status_Localhost=`echo $?` - ${db_install_dir}/bin/mysqladmin -uroot -p"${dbrootpwd}" password "${New_dbrootpwd}" -h 127.0.0.1 > /dev/null 2>&1 + $db_install_dir/bin/mysqladmin -uroot -p"$dbrootpwd" password "$New_dbrootpwd" -h 127.0.0.1 > /dev/null 2>&1 status_127=`echo $?` - if [ ${status_Localhost} == '0' -a ${status_127} == '0' ]; then - sed -i "s+^dbrootpwd.*+dbrootpwd='${New_dbrootpwd}'+" ./options.conf + if [ $status_Localhost == '0' -a $status_127 == '0' ]; then + sed -i "s+^dbrootpwd.*+dbrootpwd='$New_dbrootpwd'+" ./options.conf echo echo "Password reset succesfully! " echo "The new password: ${CMSG}${New_dbrootpwd}${CEND}" @@ -79,63 +45,4 @@ Reset_Interaction_dbrootpwd() { echo "${CFAILURE}Reset Database root password failed! ${CEND}" fi } - -Reset_force_dbrootpwd() { - DB_Ver="`${db_install_dir}/bin/mysql_config --version`" - echo "${CMSG}Stopping MySQL...${CEND}" - service mysqld stop > /dev/null 2>&1 - while [ -n "`ps -ef | grep mysqld | grep -v grep | awk '{print $2}'`" ]; do - sleep 1 - done - echo "${CMSG}skip grant tables...${CEND}" - sed -i '/\[mysqld\]/a\skip-grant-tables' /etc/my.cnf - service mysqld start > /dev/null 2>&1 - sed -i '/^skip-grant-tables/d' /etc/my.cnf - while [ -z "`ps -ef | grep 'mysqld ' | grep -v grep | awk '{print $2}'`" ]; do - sleep 1 - done - if echo "${DB_Ver}" | grep -Eqi '^8.4.|^8.0.|^5.7.|^10.[4-5].|^11.4.|^10.11.'; then - ${db_install_dir}/bin/mysql -uroot -hlocalhost << EOF -flush privileges; -ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY "${New_dbrootpwd}"; -ALTER USER 'root'@'127.0.0.1' IDENTIFIED WITH mysql_native_password BY "${New_dbrootpwd}"; -flush privileges; -EOF - else - ${db_install_dir}/bin/mysql -uroot -hlocalhost << EOF -update mysql.user set password = Password("${New_dbrootpwd}") where User = 'root'; -EOF - fi - if [ $? -eq 0 ]; then - killall mysqld - while [ -n "`ps -ef | grep mysqld | grep -v grep | awk '{print $2}'`" ]; do - sleep 1 - done - [ -n "`ps -ef | grep mysqld | grep -v grep | awk '{print $2}'`" ] && ps -ef | grep mysqld | grep -v grep | awk '{print $2}' | xargs kill -9 > /dev/null 2>&1 - service mysqld start > /dev/null 2>&1 - sed -i "s+^dbrootpwd.*+dbrootpwd='${New_dbrootpwd}'+" ./options.conf - [ -e ~/ReadMe ] && sed -i "s+^MySQL root password:.*+MySQL root password: ${New_dbrootpwd}+" ~/ReadMe - echo - echo "Password reset succesfully! " - echo "The new password: ${CMSG}${New_dbrootpwd}${CEND}" - echo - fi -} - -[ "${password_flag}" == 'y' ] && quiet_flag=y -if [ "${quiet_flag}" == 'y' ]; then - if [ "${force_flag}" == 'y' ]; then - Reset_force_dbrootpwd - else - sleep 2 && [ ! -e /tmp/mysql.sock ] && service mysqld start - Reset_Interaction_dbrootpwd - fi -else - Input_dbrootpwd - if [ "${force_flag}" == 'y' ]; then - Reset_force_dbrootpwd - else - Reset_Interaction_dbrootpwd - fi -fi -popd > /dev/null +Reset_db_root_password diff --git a/src/adoptium.key b/src/adoptium.key deleted file mode 100644 index 7d76f7ab..00000000 --- a/src/adoptium.key +++ /dev/null @@ -1,31 +0,0 @@ ------BEGIN PGP PUBLIC KEY BLOCK----- - -mQENBGGTvTQBCAC6ey144n7CG8foafF6mwgIBN1fIm1ILZDuGS4tMr0/XI8pgJnT -QvsPxZWEvtSm7bEMObzEoZJcXwjBcJl1B0ui8k5kHMTI75gCmZPsoKLFWIEpuRBQ -PBocusw80apDmLnNDQLVQvDFtEua5gaNa/fRw9YsmBoXBqvgrjFUIdGyWoQvH5+a -9OYlWD9n5VV0gnVMb+aclwVzB/zJw3kHGSgzuMtlAHeQiah7Y8yomQn/UIX8yqDf -+11sP3+c87YcjkRqImRTtmKEDcEtGPAIXC6SYA+uEEkbYE0Fy0chkvtnVWJ597fa -Epai4rnICU8zoJ6X5z3v1aM2WerhX9oq9X8PABEBAAG0QEFkb3B0aXVtIEdQRyBL -ZXkgKERFQi9SUE0gU2lnbmluZyBLZXkpIDx0ZW11cmluLWRldkBlY2xpcHNlLm9y -Zz6JAVIEEwEIADwWIQQ7BNdTyQUNml00PzmEPEilZfjwSwUCYZO9NAIbAwULCQgH -AgMiAgEGFQoJCAsCBBYCAwECHgcCF4AACgkQhDxIpWX48Et4AggAjjJzYWuKV3nG -7ngInngl8G/m9JoHr7BmwgcQXYhdy5hVkMcUx5JLeXz2LMBUH/F2nD595hgjMabk -kVib20X8lq9RsNbdfc2hBcWU6qyHKxsIqT4boI2/XDyEzzMyyZWWNGo/27Ci7Xmj -pWu31nh0pDdPqdyWDIKojbVVnxlCRY8as8Sm+1ufi709KCi4MuwHNsUlCSwb/fju -NKeHkrHbLcHKUUIEcmTSKRWrpMYBzm1HYOGBz4xPuELwUfUp71ehfoyBZlp6RDRf -l5TYI1FmCyHuvjNhrJgWv7bOTcf8yObGY+TEUhzc4xQqCrF4ur9d3opvsuPBQsv+ -Klqi5KSZgrkBDQRhk700AQgAq14okly8cFrpYVenEQPiB75AUZfKRpMduiR6IxAj -SKcH7aSoFZ9AubUEBVpZsyT5svxoEPe1i4TdbF+m9FGy42EcOlLa3ArLTj5H8FRl -UdGZB9I5mk4GptOzPM+aHMMu92vW/ZwjuS8DvOiQSp+cUmG1EqOMJSM7e/4BM71z -E+OKaVJCj79pEzhG3SK/IC/OlxxyETT66NSfYJd7Sw5R6Vr19am/uNU690W0CJ+q -VQeFpmDMr7LnfdFRIh+lJe05+PvWXeidkGjox5cbG52wf8aRIR/FgkfcFvqRMN1f -B+dVOWueloUeVAnzcUznOKmUEs7LP9ObJhYHHgup4IAU2wARAQABiQE2BBgBCAAg -FiEEOwTXU8kFDZpdND85hDxIpWX48EsFAmGTvTQCGwwACgkQhDxIpWX48EvXHQf/ -Q0nZsGDXnZHiBoojeSdpkO7WBjMIP3w1GdLvRpPQrS8TfOPbZuoevzCNh38Y3gwF -yelJspvzDQrBXhgkzAGlucYg8Y7KHa5Ebm7iDgMzc37L1hYSZTYCqwd7aowfgy34 -hOk3B67LffkJpIh738Oa9CtlwxQ9xcytmBmQ1fBBOwm/9IhAwHPQuydYIs4DxWbj -0MGSP4fDntU7e4UjsHNmhudDcYol0FaqdHHIIB9C/G4CzetRwHFOn3b4JwXMU7YU -6aJA3mXhi3hggMC3wkT2HHZ/TquuOdNc02fypWOCDOHz0alBBJNqoVUNFNqU3tfJ -wI4qF/KKq9BfyfucAs0ykA== -=szki ------END PGP PUBLIC KEY BLOCK----- \ No newline at end of file diff --git a/src/libmemcached-build.patch b/src/libmemcached-build.patch deleted file mode 100644 index df58c9fb..00000000 --- a/src/libmemcached-build.patch +++ /dev/null @@ -1,21 +0,0 @@ -diff -up ./clients/memflush.cc.old ./clients/memflush.cc ---- ./clients/memflush.cc.old 2017-02-12 10:12:59.615209225 +0100 -+++ ./clients/memflush.cc 2017-02-12 10:13:39.998382783 +0100 -@@ -39,7 +39,7 @@ int main(int argc, char *argv[]) - { - options_parse(argc, argv); - -- if (opt_servers == false) -+ if (!opt_servers) - { - char *temp; - -@@ -48,7 +48,7 @@ int main(int argc, char *argv[]) - opt_servers= strdup(temp); - } - -- if (opt_servers == false) -+ if (!opt_servers) - { - std::cerr << "No Servers provided" << std::endl; - exit(EXIT_FAILURE); diff --git a/src/php5.3-fileinfo.patch b/src/php5.3-fileinfo.patch deleted file mode 100644 index 4b8e970a..00000000 --- a/src/php5.3-fileinfo.patch +++ /dev/null @@ -1,35 +0,0 @@ ---- a/ext/fileinfo/fileinfo.c 2025-06-11 15:20:52.077008458 +0800 -+++ b/ext/fileinfo/fileinfo.c 2025-06-11 15:21:48.711442786 +0800 -@@ -18,6 +18,13 @@ - - /* $Id$ */ - -+#ifndef uint -+typedef unsigned int uint; -+#endif -+#ifndef ulong -+typedef unsigned long ulong; -+#endif -+ - #ifdef HAVE_CONFIG_H - #include "config.h" - #endif ---- a/ext/fileinfo/libmagic/apprentice.c 2025-06-11 15:24:18.831594049 +0800 -+++ b/ext/fileinfo/libmagic/apprentice.c 2025-06-11 15:24:58.509898340 +0800 -@@ -40,6 +40,7 @@ FILE_RCSID("@(#)$File: apprentice.c,v 1. - #include "magic.h" - #include "patchlevel.h" - #include -+#include - - #if defined(__hpux) && !defined(HAVE_STRTOULL) - #if SIZEOF_LONG == 8 -@@ -778,7 +779,7 @@ apprentice_load(struct magic_set *ms, st - int mflen; - char mfn[MAXPATHLEN]; - -- dir = php_stream_opendir(fn, REPORT_ERRORS, NULL); -+ dir = php_stream_opendir((char *)fn, REPORT_ERRORS, NULL); - if (!dir) { - errs++; - goto out; diff --git a/src/php5.3patch b/src/php5.3patch index 73a375fa..285299d5 100644 --- a/src/php5.3patch +++ b/src/php5.3patch @@ -8,9 +8,9 @@ index b3f94ec..7613119 100644 #include "ext/standard/php_string.h" +#include "ext/standard/php_smart_str.h" + - + #define DEBUG_FILE_UPLOAD ZEND_DEBUG - + @@ -462,6 +464,66 @@ static int find_boundary(multipart_buffer *self, char *boundary TSRMLS_DC) static int multipart_buffer_headers(multipart_buffer *self, zend_llist *header TSRMLS_DC) { @@ -77,4 +77,4 @@ index b3f94ec..7613119 100644 + char *line; mime_header_entry prev_entry, entry; int prev_len, cur_len; - + diff --git a/ss.sh b/ss.sh new file mode 100755 index 00000000..46306b38 --- /dev/null +++ b/ss.sh @@ -0,0 +1,286 @@ +#!/bin/bash +# Author: yeho +# BLOG: https://blog.linuxeye.com +# +# Notes: OneinStack for CentOS/RadHat 5+ Debian 6+ and Ubuntu 12+ +# Install SS Server +# +# Project home page: +# https://oneinstack.com +# https://github.com/lj2007331/oneinstack + +export PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin +clear +printf " +####################################################################### +# OneinStack for CentOS/RadHat 6+ Debian 6+ and Ubuntu 12+ # +# Install SS Server # +# For more information please visit https://oneinstack.com # +####################################################################### +" + +# get pwd +sed -i "s@^oneinstack_dir.*@oneinstack_dir=$(pwd)@" ./options.conf + +pushd src > /dev/null +. ../options.conf +. ../versions.txt +. ../include/color.sh +. ../include/check_os.sh +. ../include/download.sh +. ../include/python.sh + +# Check if user is root +[ $(id -u) != '0' ] && { echo "${CFAILURE}Error: You must be root to run this script${CEND}"; exit 1; } + +PUBLIC_IPADDR=$(../include/get_public_ipaddr.py) + +[ "${CentOS_RHEL_version}" == '5' ] && { echo "${CWARNING}SS only support CentOS6,7 or Debian or Ubuntu! ${CEND}"; exit 1; } + +Check_SS() { + [ -f /usr/local/bin/ss-server ] && SS_version=1 + [ -f ${python_install_dir}/bin/ssserver ] && SS_version=2 +} + +AddUser_SS() { + while :; do echo + read -p "Please input password for SS: " SS_password + [ -n "$(echo ${SS_password} | grep '[+|&]')" ] && { echo "${CWARNING}input error,not contain a plus sign (+) and & ${CEND}"; continue; } + (( ${#SS_password} >= 5 )) && break || echo "${CWARNING}SS password least 5 characters! ${CEND}" + done +} + +Iptables_set() { + if [ -e '/etc/sysconfig/iptables' ]; then + SS_Already_port=$(grep -oE '9[0-9][0-9][0-9]' /etc/sysconfig/iptables | head -n 1) + elif [ -e '/etc/iptables.up.rules' ]; then + SS_Already_port=$(grep -oE '9[0-9][0-9][0-9]' /etc/iptables.up.rules | head -n 1) + fi + + if [ -n "${SS_Already_port}" ]; then + let SS_Default_port="${SS_Already_port}+1" + else + SS_Default_port=9001 + fi + + while :; do echo + read -p "Please input SS port(Default: ${SS_Default_port}): " SS_port + [ -z "${SS_port}" ] && SS_port=${SS_Default_port} + if [ ${SS_port} -ge 1 >/dev/null 2>&1 -a ${SS_port} -le 65535 >/dev/null 2>&1 ]; then + [ -z "$(netstat -tpln | grep :${SS_port}$)" ] && break || echo "${CWARNING}This port is already used! ${CEND}" + else + echo "${CWARNING}input error! Input range: 1~65535${CEND}" + fi + done + + if [ "${OS}" == 'CentOS' ]; then + if [ -z "$(grep -E ${SS_port} /etc/sysconfig/iptables)" ]; then + iptables -I INPUT 4 -p udp -m state --state NEW -m udp --dport ${SS_port} -j ACCEPT + iptables -I INPUT 4 -p tcp -m state --state NEW -m tcp --dport ${SS_port} -j ACCEPT + service iptables save + fi + elif [[ ${OS} =~ ^Ubuntu$|^Debian$ ]]; then + if [ -z "$(grep -E ${SS_port} /etc/iptables.up.rules)" ]; then + iptables -I INPUT 4 -p udp -m state --state NEW -m udp --dport ${SS_port} -j ACCEPT + iptables -I INPUT 4 -p tcp -m state --state NEW -m tcp --dport ${SS_port} -j ACCEPT + iptables-save > /etc/iptables.up.rules + fi + else + echo "${CWARNING}This port is already in iptables! ${CEND}" + fi + +} + +Def_parameter() { + if [ "${OS}" == "CentOS" ]; then + while :; do echo + echo "Please select SS server version:" + echo -e "\t${CMSG}1${CEND}. Install SS-libev" + echo -e "\t${CMSG}2${CEND}. Install SS-python" + read -p "Please input a number:(Default 1 press Enter) " SS_version + [ -z "${SS_version}" ] && SS_version=1 + if [[ ! "${SS_version}" =~ ^[1-2]$ ]]; then + echo "${CWARNING}input error! Please only input number 1,2${CEND}" + else + break + fi + done + AddUser_SS + Iptables_set + pkgList="wget unzip openssl-devel gcc swig autoconf libtool libevent automake make curl curl-devel zlib-devel perl perl-devel cpio expat-devel gettext-devel git asciidoc xmlto pcre-devel mbedtls-devel udns-devel libev-devel" + for Package in ${pkgList}; do + yum -y install ${Package} + done + elif [[ "${OS}" =~ ^Ubuntu$|^Debian$ ]]; then + SS_version=2 + AddUser_SS + Iptables_set + apt-get -y update + pkgList="curl wget unzip gcc swig automake make perl cpio git libmbedtls-dev libudns-dev libev-dev" + for Package in ${pkgList}; do + apt-get -y install $Package + done + fi +} + +Install_SS-python() { + [ ! -e "${python_install_dir}/bin/python" ] && Install_Python + ${python_install_dir}/bin/pip install M2Crypto + ${python_install_dir}/bin/pip install greenlet + ${python_install_dir}/bin/pip install gevent + ${python_install_dir}/bin/pip install shadowsocks + if [ -f ${python_install_dir}/bin/ssserver ]; then + /bin/cp ../init.d/SS-python-init /etc/init.d/shadowsocks + chmod +x /etc/init.d/shadowsocks + sed -i "s@SS_bin=.*@SS_bin=${python_install_dir}/bin/ssserver@" /etc/init.d/shadowsocks + [ "${OS}" == "CentOS" ] && { chkconfig --add shadowsocks; chkconfig shadowsocks on; } + [[ "${OS}" =~ ^Ubuntu$|^Debian$ ]] && update-rc.d shadowsocks defaults + else + echo + echo "${CQUESTION}SS-python install failed! Please visit https://oneinstack.com${CEND}" + exit 1 + fi +} + +Install_SS-libev() { + src_url=http://mirrors.linuxeye.com/oneinstack/src/shadowsocks-libev-3.0.4.tar.gz && Download_src + src_url=http://mirrors.linuxeye.com/oneinstack/src/libsodium-1.0.12.tar.gz && Download_src + tar xzf shadowsocks-libev-3.0.4.tar.gz + tar xzf libsodium-1.0.12.tar.gz + pushd libsodium-1.0.12 + ./configure + make -j ${THREAD} && make install + popd + pushd shadowsocks-libev-3.0.4 + ./configure + make -j ${THREAD} && make install + popd + if [ -f /usr/local/bin/ss-server ]; then + /bin/cp ../init.d/SS-libev-init /etc/init.d/shadowsocks + chmod +x /etc/init.d/shadowsocks + [ "${OS}" == "CentOS" ] && { chkconfig --add shadowsocks; chkconfig shadowsocks on; } + else + echo + echo "${CQUESTION}SS-libev install failed! Please visit https://oneinstack.com${CEND}" + exit 1 + fi + +} + +Uninstall_SS() { + while :; do echo + read -p "Do you want to uninstall SS? [y/n]: " SS_yn + if [[ ! "${SS_yn}" =~ ^[y,n]$ ]]; then + echo "${CWARNING}input error! Please only input 'y' or 'n'${CEND}" + else + break + fi + done + + if [ "${SS_yn}" == 'y' ]; then + [ -n "$(ps -ef | grep -v grep | grep -iE "ssserver|ss-server")" ] && /etc/init.d/shadowsocks stop + [ "${OS}" == "CentOS" ] && chkconfig --del shadowsocks + [[ "${OS}" =~ ^Ubuntu$|^Debian$ ]] && update-rc.d -f shadowsocks remove + rm -rf /etc/shadowsocks /var/run/shadowsocks.pid /etc/init.d/shadowsocks + if [ "${SS_version}" == '1' ]; then + rm -f /usr/local/bin/{ss-local,ss-tunnel,ss-server,ss-manager,ss-redir} + rm -f /usr/local/lib/libshadowsocks.* + rm -f /usr/local/include/shadowsocks.h + rm -f /usr/local/lib/pkgconfig/shadowsocks-libev.pc + rm -f /usr/local/share/man/man1/{ss-local.1,ss-tunnel.1,ss-server.1,ss-manager.1,ss-redir.1,shadowsocks.8} + if [ $? -eq 0 ]; then + echo "${CSUCCESS}SS-libev uninstall successful! ${CEND}" + else + echo "${CFAILURE}SS-libev uninstall failed! ${CEND}" + fi + elif [ "${SS_version}" == '2' ]; then + ${python_install_dir}/bin/pip uninstall -y shadowsocks + if [ $? -eq 0 ]; then + echo "${CSUCCESS}SS-python uninstall successful! ${CEND}" + else + echo "${CFAILURE}SS-python uninstall failed! ${CEND}" + fi + fi + fi +} + +Config_SS() { + [ ! -d "/etc/shadowsocks" ] && mkdir /etc/shadowsocks + [ "${SS_version}" == '1' ] && cat > /etc/shadowsocks/config.json << EOF +{ + "server":"0.0.0.0", + "server_port":${SS_port}, + "local_address":"127.0.0.1", + "local_port":1080, + "password":"${SS_password}", + "timeout":300, + "method":"aes-256-cfb", +} +EOF + + [ "${SS_version}" == '2' ] && cat > /etc/shadowsocks/config.json << EOF +{ + "server":"0.0.0.0", + "local_address":"127.0.0.1", + "local_port":1080, + "port_password":{ + "${SS_port}":"${SS_password}" + }, + "timeout":300, + "method":"aes-256-cfb", + "fast_open":false +} +EOF +} + +AddUser_Config_SS() { + [ ! -e /etc/shadowsocks/config.json ] && { echo "${CFAILURE}SS is not installed! ${CEND}"; exit 1; } + [ -z "$(grep \"${SS_port}\" /etc/shadowsocks/config.json)" ] && sed -i "s@\"port_password\":{@\"port_password\":{\n\t\"${SS_port}\":\"${SS_password}\",@" /etc/shadowsocks/config.json || { echo "${CWARNING}This port is already in /etc/shadowsocks/config.json${CEND}"; exit 1; } +} + +Print_User_SS() { + printf " +Your Server IP: ${CMSG}${PUBLIC_IPADDR}${CEND} +Your Server Port: ${CMSG}${SS_port}${CEND} +Your Password: ${CMSG}${SS_password}${CEND} +Your Local IP: ${CMSG}127.0.0.1${CEND} +Your Local Port: ${CMSG}1080${CEND} +Your Encryption Method: ${CMSG}aes-256-cfb${CEND} +" +} + +case "$1" in +install) + Def_parameter + [ "${SS_version}" == '1' ] && Install_SS-libev + [ "${SS_version}" == '2' ] && Install_SS-python + Config_SS + service shadowsocks start + Print_User_SS + ;; +adduser) + Check_SS + if [ "${SS_version}" == '2' ]; then + AddUser_SS + Iptables_set + AddUser_Config_SS + service shadowsocks restart + Print_User_SS + else + printf " + Sorry, we have no plan to support multi port configuration. Actually you can use multiple instances instead. For example: + ss-server -c /etc/shadowsocks/config1.json -f /var/run/shadowsocks-server/pid1 + ss-server -c /etc/shadowsocks/config2.json -f /var/run/shadowsocks-server/pid2 + " + fi + ;; +uninstall) + Check_SS + Uninstall_SS + ;; +*) + echo + echo "Usage: ${CMSG}$0${CEND} { ${CMSG}install${CEND} | ${CMSG}adduser${CEND} | ${CMSG}uninstall${CEND} }" + echo + exit 1 +esac diff --git a/tools/ckssh.py b/tools/ckssh.py new file mode 100755 index 00000000..cdef6b02 --- /dev/null +++ b/tools/ckssh.py @@ -0,0 +1,13 @@ +#!/usr/bin/python +# Author: yeho +# Blog: http://blog.linuxeye.com + +import socket,sys +sk = socket.socket(socket.AF_INET, socket.SOCK_STREAM) +sk.settimeout(1) +try: + sk.connect((sys.argv[1],int(sys.argv[2]))) + print 'ok' +except Exception: + print 'no' +sk.close() diff --git a/tools/cos/__init__.py b/tools/cos/__init__.py new file mode 100644 index 00000000..6a073e94 --- /dev/null +++ b/tools/cos/__init__.py @@ -0,0 +1,10 @@ +#!/usr/bin/env python +# coding=utf-8 + +from qcloud_cos import CosClient +from qcloud_cos import UploadFileRequest +from qcloud_cos import CreateFolderRequest +from qcloud_cos import DelFileRequest +from qcloud_cos import DelFolderRequest +from qcloud_cos import ListFolderRequest +import threadpool diff --git a/tools/cos/qcloud_cos/__init__.py b/tools/cos/qcloud_cos/__init__.py new file mode 100644 index 00000000..ef1a0f01 --- /dev/null +++ b/tools/cos/qcloud_cos/__init__.py @@ -0,0 +1,31 @@ +#!/usr/bin/env python +# -*- coding: utf-8 -*- +from .cos_client import CosClient +from .cos_client import CosConfig +from .cos_client import CredInfo +from .cos_request import UploadFileRequest +from .cos_request import UploadSliceFileRequest +from .cos_request import UpdateFileRequest +from .cos_request import UpdateFolderRequest +from .cos_request import DelFolderRequest +from .cos_request import DelFileRequest +from .cos_request import CreateFolderRequest +from .cos_request import StatFileRequest +from .cos_request import StatFolderRequest +from .cos_request import ListFolderRequest +from .cos_request import DownloadFileRequest +from .cos_request import MoveFileRequest +from .cos_auth import Auth +from .cos_cred import CredInfo + + +import logging + +try: + from logging import NullHandler +except ImportError: + class NullHandler(logging.Handler): + def emit(self, record): + pass + +logging.getLogger(__name__).addHandler(NullHandler()) diff --git a/tools/cos/qcloud_cos/cos_auth.py b/tools/cos/qcloud_cos/cos_auth.py new file mode 100644 index 00000000..8b0d0918 --- /dev/null +++ b/tools/cos/qcloud_cos/cos_auth.py @@ -0,0 +1,70 @@ +#!/usr/bin/env python +# -*- coding: utf-8 -*- + +import random +import time +import urllib +import hmac +import hashlib +import binascii +import base64 + + +class Auth(object): + def __init__(self, cred): + self.cred = cred + + def app_sign(self, bucket, cos_path, expired, upload_sign=True): + appid = self.cred.get_appid() + bucket = bucket.encode('utf8') + secret_id = self.cred.get_secret_id().encode('utf8') + now = int(time.time()) + rdm = random.randint(0, 999999999) + cos_path = urllib.quote(cos_path.encode('utf8'), '~/') + if upload_sign: + fileid = '/%s/%s%s' % (appid, bucket, cos_path) + else: + fileid = cos_path + + if expired != 0 and expired < now: + expired = now + expired + + sign_tuple = (appid, secret_id, expired, now, rdm, fileid, bucket) + + plain_text = 'a=%s&k=%s&e=%d&t=%d&r=%d&f=%s&b=%s' % sign_tuple + secret_key = self.cred.get_secret_key().encode('utf8') + sha1_hmac = hmac.new(secret_key, plain_text, hashlib.sha1) + hmac_digest = sha1_hmac.hexdigest() + hmac_digest = binascii.unhexlify(hmac_digest) + sign_hex = hmac_digest + plain_text + sign_base64 = base64.b64encode(sign_hex) + return sign_base64 + + def sign_once(self, bucket, cos_path): + """单次签名(针对删除和更新操作) + + :param bucket: bucket名称 + :param cos_path: 要操作的cos路径, 以'/'开始 + :return: 签名字符串 + """ + return self.app_sign(bucket, cos_path, 0) + + def sign_more(self, bucket, cos_path, expired): + """多次签名(针对上传文件,创建目录, 获取文件目录属性, 拉取目录列表) + + :param bucket: bucket名称 + :param cos_path: 要操作的cos路径, 以'/'开始 + :param expired: 签名过期时间, UNIX时间戳, 如想让签名在30秒后过期, 即可将expired设成当前时间加上30秒 + :return: 签名字符串 + """ + return self.app_sign(bucket, cos_path, expired) + + def sign_download(self, bucket, cos_path, expired): + """下载签名(用于获取后拼接成下载链接,下载私有bucket的文件) + + :param bucket: bucket名称 + :param cos_path: 要下载的cos文件路径, 以'/'开始 + :param expired: 签名过期时间, UNIX时间戳, 如想让签名在30秒后过期, 即可将expired设成当前时间加上30秒 + :return: 签名字符串 + """ + return self.app_sign(bucket, cos_path, expired, False) diff --git a/tools/cos/qcloud_cos/cos_client.py b/tools/cos/qcloud_cos/cos_client.py new file mode 100644 index 00000000..0777ea58 --- /dev/null +++ b/tools/cos/qcloud_cos/cos_client.py @@ -0,0 +1,176 @@ +#!/usr/bin/env python +# -*- coding: utf-8 -*- + +import requests +from cos_cred import CredInfo +from cos_config import CosConfig +from cos_op import FileOp +from cos_op import FolderOp +from cos_request import UploadFileRequest +from cos_request import UploadSliceFileRequest +from cos_request import UpdateFileRequest +from cos_request import UpdateFolderRequest +from cos_request import DelFileRequest +from cos_request import DelFolderRequest +from cos_request import CreateFolderRequest +from cos_request import StatFolderRequest +from cos_request import StatFileRequest +from cos_request import ListFolderRequest +from cos_request import DownloadFileRequest +try: + from requests.packages.urllib3.exceptions import InsecureRequestWarning + requests.packages.urllib3.disable_warnings(InsecureRequestWarning) +except ImportError: + pass + + +class CosClient(object): + """Cos客户端类""" + + def __init__(self, appid, secret_id, secret_key, region="shanghai"): + """ 设置用户的相关信息 + + :param appid: appid + :param secret_id: secret_id + :param secret_key: secret_key + """ + self._cred = CredInfo(appid, secret_id, secret_key) + self._config = CosConfig(region=region) + self._http_session = requests.session() + self._file_op = FileOp(self._cred, self._config, self._http_session) + self._folder_op = FolderOp(self._cred, self._config, self._http_session) + + def set_config(self, config): + """设置config""" + assert isinstance(config, CosConfig) + self._config = config + self._file_op.set_config(config) + self._folder_op.set_config(config) + + def get_config(self): + """获取config""" + return self._config + + def set_cred(self, cred): + """设置用户的身份信息 + + :param cred: + :return: + """ + assert isinstance(cred, CredInfo) + self._cred = cred + self._file_op.set_cred(cred) + self._folder_op.set_cred(cred) + + def get_cred(self): + """获取用户的相关信息 + + :return: + """ + return self._cred + + def upload_file(self, request): + """ 上传文件(自动根据文件大小,选择上传策略, 强烈推荐使用),上传策略: 8MB以下适用单文件上传, 8MB(含)适用分片上传 + + :param request: + :return: + """ + assert isinstance(request, UploadFileRequest) + return self._file_op.upload_file(request) + + def upload_single_file(self, request): + """单文件上传接口, 适用用小文件8MB以下, 最大不得超过20MB, 否则会返回参数错误 + + :param request: + :return: + """ + assert isinstance(request, UploadFileRequest) + return self._file_op.upload_single_file(request) + + def upload_slice_file(self, request): + """ 分片上传接口, 适用于大文件8MB及以上 + + :param request: + :return: + """ + assert isinstance(request, UploadSliceFileRequest) + return self._file_op.upload_slice_file(request) + + def del_file(self, request): + """ 删除文件 + + :param request: + :return: + """ + assert isinstance(request, DelFileRequest) + return self._file_op.del_file(request) + + def move_file(self, request): + return self._file_op.move_file(request) + + def stat_file(self, request): + """获取文件属性 + + :param request: + :return: + """ + assert isinstance(request, StatFileRequest) + return self._file_op.stat_file(request) + + def update_file(self, request): + """更新文件属性 + + :param request: + :return: + """ + assert isinstance(request, UpdateFileRequest) + return self._file_op.update_file(request) + + def download_file(self, request): + assert isinstance(request, DownloadFileRequest) + return self._file_op.download_file(request) + + def create_folder(self, request): + """创建目录 + + :param request: + :return: + """ + assert isinstance(request, CreateFolderRequest) + return self._folder_op.create_folder(request) + + def del_folder(self, request): + """删除目录 + + :param request: + :return: + """ + assert isinstance(request, DelFolderRequest) + return self._folder_op.del_folder(request) + + def stat_folder(self, request): + """获取folder属性请求 + + :param request: + :return: + """ + assert isinstance(request, StatFolderRequest) + return self._folder_op.stat_folder(request) + + def update_folder(self, request): + """更新目录属性 + + :param request: + :return: + """ + assert isinstance(request, UpdateFolderRequest) + return self._folder_op.update_folder(request) + + def list_folder(self, request): + """获取目录下的文件和目录列表 + + :param request: + :return: + """ + assert isinstance(request, ListFolderRequest) + return self._folder_op.list_folder(request) diff --git a/tools/cos/qcloud_cos/cos_common.py b/tools/cos/qcloud_cos/cos_common.py new file mode 100644 index 00000000..b0e0f9de --- /dev/null +++ b/tools/cos/qcloud_cos/cos_common.py @@ -0,0 +1,225 @@ +# -*- coding: utf-8 -*- + +from __future__ import print_function +import struct +import io + +try: + range = xrange +except NameError: + pass + + +def _left_rotate(n, b): + """Left rotate a 32-bit integer n by b bits.""" + return ((n << b) | (n >> (32 - b))) & 0xffffffff + + +def _process_chunk(chunk, h0, h1, h2, h3, h4): + """Process a chunk of data and return the new digest variables.""" + assert len(chunk) == 64 + + w = [0] * 80 + + # Break chunk into sixteen 4-byte big-endian words w[i] + for i in range(16): + w[i] = struct.unpack(b'>I', chunk[i * 4:i * 4 + 4])[0] + + # Extend the sixteen 4-byte words into eighty 4-byte words + for i in range(16, 80): + w[i] = _left_rotate(w[i - 3] ^ w[i - 8] ^ w[i - 14] ^ w[i - 16], 1) + + # Initialize hash value for this chunk + a = h0 + b = h1 + c = h2 + d = h3 + e = h4 + + for i in range(80): + if 0 <= i <= 19: + # Use alternative 1 for f from FIPS PB 180-1 to avoid bitwise not + f = d ^ (b & (c ^ d)) + k = 0x5A827999 + elif 20 <= i <= 39: + f = b ^ c ^ d + k = 0x6ED9EBA1 + elif 40 <= i <= 59: + f = (b & c) | (b & d) | (c & d) + k = 0x8F1BBCDC + elif 60 <= i <= 79: + f = b ^ c ^ d + k = 0xCA62C1D6 + + a, b, c, d, e = ((_left_rotate(a, 5) + f + e + k + w[i]) & 0xffffffff, + a, _left_rotate(b, 30), c, d) + + # Add this chunk's hash to result so far + h0 = (h0 + a) & 0xffffffff + h1 = (h1 + b) & 0xffffffff + h2 = (h2 + c) & 0xffffffff + h3 = (h3 + d) & 0xffffffff + h4 = (h4 + e) & 0xffffffff + + return h0, h1, h2, h3, h4 + + +class Sha1Hash(object): + """A class that mimics that hashlib api and implements the SHA-1 algorithm.""" + + name = 'python-sha1' + digest_size = 20 + block_size = 64 + + def __init__(self): + # Initial digest variables + self._h = ( + 0x67452301, + 0xEFCDAB89, + 0x98BADCFE, + 0x10325476, + 0xC3D2E1F0, + ) + + # bytes object with 0 <= len < 64 used to store the end of the message + # if the message length is not congruent to 64 + self._unprocessed = b'' + # Length in bytes of all data that has been processed so far + self._message_byte_length = 0 + + def update(self, arg): + """Update the current digest. + This may be called repeatedly, even after calling digest or hexdigest. + + Arguments: + arg: bytes, bytearray, or BytesIO object to read from. + """ + if isinstance(arg, (bytes, bytearray)): + arg = io.BytesIO(arg) + + # Try to build a chunk out of the unprocessed data, if any + chunk = self._unprocessed + arg.read(64 - len(self._unprocessed)) + + # Read the rest of the data, 64 bytes at a time + while len(chunk) == 64: + self._h = _process_chunk(chunk, *self._h) + self._message_byte_length += 64 + chunk = arg.read(64) + + self._unprocessed = chunk + return self + + def digest(self): + """Produce the final hash value (big-endian) as a bytes object""" + return b''.join(struct.pack(b'>I', h) for h in self._produce_digest()) + + def hexdigest(self): + """Produce the final hash value (big-endian) as a hex string""" + return '%08x%08x%08x%08x%08x' % self._produce_digest() + + def inner_digest(self): + + tmp = struct.unpack(">5I", struct.pack("<5I", *self._h)) + return '%08x%08x%08x%08x%08x' % tmp + + def _produce_digest(self): + """Return finalized digest variables for the data processed so far.""" + # Pre-processing: + message = self._unprocessed + message_byte_length = self._message_byte_length + len(message) + + # append the bit '1' to the message + message += b'\x80' + + # append 0 <= k < 512 bits '0', so that the resulting message length (in bytes) + # is congruent to 56 (mod 64) + message += b'\x00' * ((56 - (message_byte_length + 1) % 64) % 64) + + # append length of message (before pre-processing), in bits, as 64-bit big-endian integer + message_bit_length = message_byte_length * 8 + message += struct.pack(b'>Q', message_bit_length) + + # Process the final chunk + # At this point, the length of the message is either 64 or 128 bytes. + h = _process_chunk(message[:64], *self._h) + if len(message) == 64: + return h + return _process_chunk(message[64:], *h) + + +def sha1(data): + """SHA-1 Hashing Function + A custom SHA-1 hashing function implemented entirely in Python. + Arguments: + data: A bytes or BytesIO object containing the input message to hash. + Returns: + A hex SHA-1 digest of the input message. + """ + return Sha1Hash().update(data).hexdigest() + + +class Sha1Util(object): + + @staticmethod + def get_sha1_by_slice(file_name, slice_size): + """ Get SHA array based on Qcloud Slice Upload Interface + + :param file_name: local file path + :param slice_size: slice size in bit + :return: sha array like [{“offset”:0, “datalen”:1024,”datasha”:”aaa”}, {}, {}] + """ + from os import path + + with open(file_name, 'rb') as f: + + result = [] + file_size = path.getsize(file_name) + sha1_obj = Sha1Hash() + for current_offset in range(0, file_size, slice_size): + + data_length = min(slice_size, file_size - current_offset) + sha1_obj.update(f.read(data_length)) + sha1_val = sha1_obj.inner_digest() + result.append({"offset": current_offset, "datalen": data_length, "datasha": sha1_val}) + + result[-1]['datasha'] = sha1_obj.hexdigest() + return result + + +if __name__ == '__main__': + # Imports required for command line parsing. No need for these elsewhere + import argparse + import sys + import os + + # Parse the incoming arguments + parser = argparse.ArgumentParser() + parser.add_argument('input', nargs='?', + help='input file or message to hash') + args = parser.parse_args() + + data = None + + if args.input is None: + # No argument given, assume message comes from standard input + try: + # sys.stdin is opened in text mode, which can change line endings, + # leading to incorrect results. Detach fixes this issue, but it's + # new in Python 3.1 + data = sys.stdin.detach() + except AttributeError: + # Linux ans OSX both use \n line endings, so only windows is a + # problem. + if sys.platform == "win32": + import msvcrt + + msvcrt.setmode(sys.stdin.fileno(), os.O_BINARY) + data = sys.stdin + elif os.path.isfile(args.input): + # An argument is given and it's a valid file. Read it + data = open(args.input, 'rb') + else: + data = args.input + + # Show the final digest + print('sha1-digest:', sha1(data)) diff --git a/tools/cos/qcloud_cos/cos_config.py b/tools/cos/qcloud_cos/cos_config.py new file mode 100644 index 00000000..12a24f79 --- /dev/null +++ b/tools/cos/qcloud_cos/cos_config.py @@ -0,0 +1,125 @@ +#!/usr/bin/env python +# -*- coding: utf-8 -*- + + +class CosRegionInfo(object): + + def __init__(self, region=None, hostname=None, download_hostname=None, *args, **kwargs): + self._hostname = None + self._download_hostname = None + + if region in ['sh', 'shanghai']: + self._hostname = 'sh.file.myqcloud.com' + self._download_hostname = 'cossh.myqcloud.com' + + elif region in ['gz', 'guangzhou']: + self._hostname = 'gz.file.myqcloud.com' + self._download_hostname = 'cosgz.myqcloud.com' + + elif region in ['tj', 'tianjin', 'tianjing']: # bug: for compact previous release + self._hostname = 'tj.file.myqcloud.com' + self._download_hostname = 'costj.myqcloud.com' + + elif region in ['sgp', 'singapore']: + self._hostname = 'sgp.file.myqcloud.com' + self._download_hostname = 'cosspg.myqcloud.com' + + elif region is not None: + self._hostname = '{region}.file.myqcloud.com'.format(region=region) + self._download_hostname = 'cos{region}.myqcloud.com'.format(region=region) + else: + if hostname and download_hostname: + self._hostname = hostname + self._download_hostname = download_hostname + else: + raise ValueError("region or [hostname, download_hostname] must be set, and region should be sh/gz/tj/sgp") + + @property + def hostname(self): + assert self._hostname is not None + return self._hostname + + @property + def download_hostname(self): + assert self._download_hostname is not None + return self._download_hostname + + +class CosConfig(object): + """CosConfig 有关cos的配置""" + + def __init__(self, timeout=300, sign_expired=300, enable_https=False, *args, **kwargs): + self._region = CosRegionInfo(*args, **kwargs) + self._user_agent = 'cos-python-sdk-v4' + self._timeout = timeout + self._sign_expired = sign_expired + self._enable_https = enable_https + if self._enable_https: + self._protocol = "https" + else: + self._protocol = "http" + + def get_endpoint(self): + """获取域名地址 + + :return: + """ + # tmpl = "%s://%s/files/v2" + return self._protocol + "://" + self._region.hostname + "/files/v2" + + def get_download_hostname(self): + return self._region.download_hostname + + def get_user_agent(self): + """获取HTTP头中的user_agent + + :return: + """ + return self._user_agent + + def set_timeout(self, time_out): + """设置连接超时, 单位秒 + + :param time_out: + :return: + """ + assert isinstance(time_out, int) + self._timeout = time_out + + def get_timeout(self): + """获取连接超时,单位秒 + + :return: + """ + return self._timeout + + def set_sign_expired(self, expired): + """设置签名过期时间, 单位秒 + + :param expired: + :return: + """ + assert isinstance(expired, int) + self._sign_expired = expired + + def get_sign_expired(self): + """获取签名过期时间, 单位秒 + + :return: + """ + return self._sign_expired + + @property + def enable_https(self): + assert self._enable_https is not None + return self._enable_https + + @enable_https.setter + def enable_https(self, val): + if val != self._enable_https: + if val: + self._enable_https = val + self._protocol = "https" + else: + self._enable_https = val + self._protocol = "http" diff --git a/tools/cos/qcloud_cos/cos_cred.py b/tools/cos/qcloud_cos/cos_cred.py new file mode 100644 index 00000000..7d7220d2 --- /dev/null +++ b/tools/cos/qcloud_cos/cos_cred.py @@ -0,0 +1,36 @@ +#!/usr/bin/env python +# -*- coding:utf-8 -*- + +from cos_params_check import ParamCheck + + +class CredInfo(object): + """CredInfo用户的身份信息""" + def __init__(self, appid, secret_id, secret_key): + self._appid = appid + self._secret_id = secret_id + self._secret_key = secret_key + self._param_check = ParamCheck() + + def get_appid(self): + return self._appid + + def get_secret_id(self): + return self._secret_id + + def get_secret_key(self): + return self._secret_key + + def check_params_valid(self): + if not self._param_check.check_param_int('appid', self._appid): + return False + if not self._param_check.check_param_unicode('secret_id', self._secret_id): + return False + return self._param_check.check_param_unicode('secret_key', self._secret_key) + + def get_err_tips(self): + """获取错误信息 + + :return: + """ + return self._param_check.get_err_tips() diff --git a/tools/cos/qcloud_cos/cos_err.py b/tools/cos/qcloud_cos/cos_err.py new file mode 100644 index 00000000..acf326ab --- /dev/null +++ b/tools/cos/qcloud_cos/cos_err.py @@ -0,0 +1,14 @@ +#!/usr/bin/env python +# -*- coding: utf-8 -*- + + +class CosErr(object): + """sdk错误码""" + PARAMS_ERROR = -1 # 参数错误 + NETWORK_ERROR = -2 # 网络错误 + SERVER_ERROR = -3 # server端返回错误 + UNKNOWN_ERROR = -4 # 未知错误 + + @staticmethod + def get_err_msg(errcode, err_info): + return {u'code': errcode, u'message': err_info} diff --git a/tools/cos/qcloud_cos/cos_op.py b/tools/cos/qcloud_cos/cos_op.py new file mode 100644 index 00000000..f80da8a3 --- /dev/null +++ b/tools/cos/qcloud_cos/cos_op.py @@ -0,0 +1,703 @@ +#!/usr/bin/env python +# -*- coding: utf-8 -*- + +import os +import time +import json +import hashlib +import urllib +from contextlib import closing +import cos_auth +from cos_err import CosErr +from cos_request import UploadFileRequest +from cos_request import UploadSliceFileRequest +from cos_request import UpdateFileRequest +from cos_request import DelFileRequest +from cos_request import StatFileRequest +from cos_request import CreateFolderRequest +from cos_request import UpdateFolderRequest +from cos_request import StatFolderRequest +from cos_request import DelFolderRequest +from cos_request import ListFolderRequest, DownloadFileRequest, MoveFileRequest +from cos_common import Sha1Util + +from logging import getLogger +from traceback import format_exc + +logger = getLogger(__name__) + + +class BaseOp(object): + """ + BaseOp基本操作类型 + """ + + def __init__(self, cred, config, http_session): + """ 初始化类 + + :param cred: 用户的身份信息 + :param config: cos_config配置类 + :param http_session: http 会话 + """ + self._cred = cred + self._config = config + self._http_session = http_session + self._expired_period = self._config.get_sign_expired() + + def set_cred(self, cred): + """设置用户的身份信息 + + :param cred: + :return: + """ + self._cred = cred + + def set_config(self, config): + """ 设置config + + :param config: + :return: + """ + self._config = config + self._expired_period = self._config.get_sign_expired() + + def _build_url(self, bucket, cos_path): + """生成url + + :param bucket: + :param cos_path: + :return: + """ + bucket = bucket.encode('utf8') + end_point = self._config.get_endpoint().rstrip('/').encode('utf8') + appid = self._cred.get_appid() + cos_path = urllib.quote(cos_path.encode('utf8'), '~/') + url = '%s/%s/%s%s' % (end_point, appid, bucket, cos_path) + return url + + def build_download_url(self, bucket, cos_path, sign): + # Only support http now + appid = self._cred.get_appid() + hostname = self._config.get_download_hostname() + cos_path = urllib.quote(cos_path) + url_tmpl = 'http://{bucket}-{appid}.{hostname}{cos_path}?sign={sign}' + + return url_tmpl.format(bucket=bucket, appid=appid, hostname=hostname, cos_path=cos_path, sign=sign) + + def send_request(self, method, bucket, cos_path, **kwargs): + """ 发送http请求 + + :param method: + :param bucket: + :param cos_path: + :param args: + :return: + """ + url = self._build_url(bucket, cos_path) + logger.debug("sending request, method: %s, bucket: %s, cos_path: %s" % (method, bucket, cos_path)) + + try: + if method == 'POST': + http_resp = self._http_session.post(url, verify=False, **kwargs) + else: + http_resp = self._http_session.get(url, verify=False, **kwargs) + + status_code = http_resp.status_code + if status_code == 200 or status_code == 400: + return http_resp.json() + else: + logger.warning("request failed, response message: %s" % http_resp.text) + err_detail = 'url:%s, status_code:%d' % (url, status_code) + return CosErr.get_err_msg(CosErr.NETWORK_ERROR, err_detail) + except Exception as e: + logger.exception("request failed, return SERVER_ERROR") + err_detail = 'url:%s, exception:%s traceback:%s' % (url, str(e), format_exc()) + return CosErr.get_err_msg(CosErr.SERVER_ERROR, err_detail) + + def _check_params(self, request): + """检查用户输入参数, 检查通过返回None, 否则返回一个代表错误原因的dict + + :param request: + :return: + """ + if not self._cred.check_params_valid(): + return CosErr.get_err_msg(CosErr.PARAMS_ERROR, self._cred.get_err_tips()) + if not request.check_params_valid(): + return CosErr.get_err_msg(CosErr.PARAMS_ERROR, request.get_err_tips()) + return None + + def del_base(self, request): + """删除文件或者目录, is_file_op为True表示是文件操作 + + :param request: + :return: + """ + check_params_ret = self._check_params(request) + if check_params_ret is not None: + return check_params_ret + + auth = cos_auth.Auth(self._cred) + bucket = request.get_bucket_name() + cos_path = request.get_cos_path() + sign = auth.sign_once(bucket, cos_path) + + http_header = dict() + http_header['Authorization'] = sign + http_header['Content-Type'] = 'application/json' + http_header['User-Agent'] = self._config.get_user_agent() + + http_body = {'op': 'delete'} + + timeout = self._config.get_timeout() + return self.send_request('POST', bucket, cos_path, headers=http_header, data=json.dumps(http_body), timeout=timeout) + + def stat_base(self, request): + """获取文件和目录的属性 + + :param request: + :return: + """ + check_params_ret = self._check_params(request) + if check_params_ret is not None: + return check_params_ret + + auth = cos_auth.Auth(self._cred) + bucket = request.get_bucket_name() + cos_path = request.get_cos_path() + expired = int(time.time()) + self._expired_period + sign = auth.sign_more(bucket, cos_path, expired) + + http_header = dict() + http_header['Authorization'] = sign + http_header['User-Agent'] = self._config.get_user_agent() + + http_body = dict() + http_body['op'] = 'stat' + + timeout = self._config.get_timeout() + return self.send_request('GET', bucket, cos_path, headers=http_header, params=http_body, timeout=timeout) + + +class FileOp(BaseOp): + """FileOp 文件相关操作""" + + def __init__(self, cred, config, http_session): + """ 初始化类 + + :param cred: 用户的身份信息 + :param config: cos_config配置类 + :param http_session: http 会话 + """ + BaseOp.__init__(self, cred, config, http_session) + # 单文件上传的最大上限是20MB + self.max_single_file = 20 * 1024 * 1024 + + @staticmethod + def _sha1_content(content): + """获取content的sha1 + + :param content: + :return: + """ + sha1_obj = hashlib.sha1() + sha1_obj.update(content) + return sha1_obj.hexdigest() + + def update_file(self, request): + """更新文件 + + :param request: + :return: + """ + assert isinstance(request, UpdateFileRequest) + logger.debug("request: " + str(request.get_custom_headers())) + check_params_ret = self._check_params(request) + if check_params_ret is not None: + return check_params_ret + + logger.debug("params verify successfully") + auth = cos_auth.Auth(self._cred) + bucket = request.get_bucket_name() + cos_path = request.get_cos_path() + sign = auth.sign_once(bucket, cos_path) + + http_header = dict() + http_header['Authorization'] = sign + http_header['Content-Type'] = 'application/json' + http_header['User-Agent'] = self._config.get_user_agent() + + http_body = dict() + http_body['op'] = 'update' + + if request.get_biz_attr() is not None: + http_body['biz_attr'] = request.get_biz_attr() + + if request.get_authority() is not None: + http_body['authority'] = request.get_authority() + + if request.get_custom_headers() is not None and len(request.get_custom_headers()) is not 0: + http_body['custom_headers'] = request.get_custom_headers() + logger.debug("Update Request Header: " + json.dumps(http_body)) + timeout = self._config.get_timeout() + return self.send_request('POST', bucket, cos_path, headers=http_header, data=json.dumps(http_body), timeout=timeout) + + def del_file(self, request): + """删除文件 + + :param request: + :return: + """ + assert isinstance(request, DelFileRequest) + return self.del_base(request) + + def stat_file(self, request): + """获取文件的属性 + + :param request: + :return: + """ + assert isinstance(request, StatFileRequest) + return self.stat_base(request) + + def upload_file(self, request): + """上传文件, 根据用户的文件大小,选择单文件上传和分片上传策略 + + :param request: + :return: + """ + assert isinstance(request, UploadFileRequest) + check_params_ret = self._check_params(request) + if check_params_ret is not None: + return check_params_ret + + local_path = request.get_local_path() + file_size = os.path.getsize(local_path) + + suit_single_file_zie = 8 * 1024 * 1024 + if file_size < suit_single_file_zie: + return self.upload_single_file(request) + else: + bucket = request.get_bucket_name() + cos_path = request.get_cos_path() + local_path = request.get_local_path() + slice_size = 1024 * 1024 + biz_attr = request.get_biz_attr() + upload_slice_request = UploadSliceFileRequest(bucket, cos_path, local_path, slice_size, biz_attr) + upload_slice_request.set_insert_only(request.get_insert_only()) + return self.upload_slice_file(upload_slice_request) + + def upload_single_file(self, request): + """ 单文件上传 + + :param request: + :return: + """ + assert isinstance(request, UploadFileRequest) + check_params_ret = self._check_params(request) + if check_params_ret is not None: + return check_params_ret + + local_path = request.get_local_path() + file_size = os.path.getsize(local_path) + # 判断文件是否超过单文件最大上限, 如果超过则返回错误 + # 并提示用户使用别的接口 + if file_size > self.max_single_file: + return CosErr.get_err_msg(CosErr.NETWORK_ERROR, 'file is too big, please use upload_file interface') + + auth = cos_auth.Auth(self._cred) + bucket = request.get_bucket_name() + cos_path = request.get_cos_path() + expired = int(time.time()) + self._expired_period + sign = auth.sign_more(bucket, cos_path, expired) + + http_header = dict() + http_header['Authorization'] = sign + http_header['User-Agent'] = self._config.get_user_agent() + + with open(local_path, 'rb') as f: + file_content = f.read() + + http_body = dict() + http_body['op'] = 'upload' + http_body['filecontent'] = file_content + http_body['sha'] = FileOp._sha1_content(file_content) + http_body['biz_attr'] = request.get_biz_attr() + http_body['insertOnly'] = str(request.get_insert_only()) + + timeout = self._config.get_timeout() + ret = self.send_request('POST', bucket, cos_path, headers=http_header, files=http_body, timeout=timeout) + + if request.get_insert_only() != 0: + return ret + + if ret[u'code'] == 0: + return ret + + # try to delete object, and re-post request + del_request = DelFileRequest(bucket_name=request.get_bucket_name(), cos_path=request.get_cos_path()) + ret = self.del_file(del_request) + if ret[u'code'] == 0: + return self.send_request('POST', bucket, cos_path, headers=http_header, files=http_body, timeout=timeout) + else: + return ret + + def _upload_slice_file(self, request): + assert isinstance(request, UploadSliceFileRequest) + check_params_ret = self._check_params(request) + if check_params_ret is not None: + return check_params_ret + + local_path = request.get_local_path() + slice_size = request.get_slice_size() + enable_sha1 = request.enable_sha1 + + if enable_sha1 is True: + sha1_by_slice_list = Sha1Util.get_sha1_by_slice(local_path, slice_size) + request.sha1_list = sha1_by_slice_list + request.sha1_content = sha1_by_slice_list[-1]["datasha"] + else: + request.sha1_list = None + request.sha1_content = None + + control_ret = self._upload_slice_control(request) + + # 表示控制分片已经产生错误信息 + if control_ret[u'code'] != 0: + return control_ret + + # 命中秒传 + if u'access_url' in control_ret[u'data']: + return control_ret + + local_path = request.get_local_path() + file_size = os.path.getsize(local_path) + slice_size = control_ret[u'data'][u'slice_size'] + offset = 0 + session = control_ret[u'data'][u'session'] + # ?concurrency + if request._max_con <= 1 or ( + u'serial_upload' in control_ret[u'data'] and control_ret[u'data'][u'serial_upload'] == 1): + + logger.info("upload file serially") + slice_idx = 0 + with open(local_path, 'rb') as local_file: + + while offset < file_size: + file_content = local_file.read(slice_size) + + data_ret = self._upload_slice_data(request, file_content, session, offset) + + if data_ret[u'code'] == 0: + if u'access_url' in data_ret[u'data']: + return data_ret + else: + return data_ret + + offset += slice_size + slice_idx += 1 + else: + logger.info('upload file concurrently') + from threadpool import SimpleThreadPool + pool = SimpleThreadPool(request._max_con) + + slice_idx = 0 + with open(local_path, 'rb') as local_file: + + while offset < file_size: + file_content = local_file.read(slice_size) + + pool.add_task(self._upload_slice_data, request, file_content, session, offset) + + offset += slice_size + slice_idx += 1 + + pool.wait_completion() + result = pool.get_result() + if not result['success_all']: + return {u'code': 1, u'message': str(result)} + + data_ret = self._upload_slice_finish(request, session, file_size) + return data_ret + + def upload_slice_file(self, request): + """分片文件上传(串行) + + :param request: + :return: + """ + ret = self._upload_slice_file(request) + + if ret[u'code'] == 0: + return ret + + if request.get_insert_only() == 0: + del_request = DelFileRequest(request.get_bucket_name(), request.get_cos_path()) + ret = self.del_file(del_request) + if ret[u'code'] == 0: + return self._upload_slice_file(request) + else: + return ret + else: + return ret + + def _upload_slice_finish(self, request, session, filesize): + auth = cos_auth.Auth(self._cred) + bucket = request.get_bucket_name() + cos_path = request.get_cos_path() + expired = int(time.time()) + self._expired_period + sign = auth.sign_more(bucket, cos_path, expired) + + http_header = dict() + http_header['Authorization'] = sign + http_header['User-Agent'] = self._config.get_user_agent() + + http_body = dict() + http_body['op'] = "upload_slice_finish" + http_body['session'] = session + http_body['filesize'] = str(filesize) + if request.sha1_list is not None: + http_body['sha'] = request.sha1_list[-1]["datasha"] + timeout = self._config.get_timeout() + + return self.send_request('POST', bucket, cos_path, headers=http_header, files=http_body, timeout=timeout) + + def _upload_slice_control(self, request): + """串行分片第一步, 上传控制分片 + + :param request: + :return: + """ + auth = cos_auth.Auth(self._cred) + bucket = request.get_bucket_name() + cos_path = request.get_cos_path() + expired = int(time.time()) + self._expired_period + sign = auth.sign_more(bucket, cos_path, expired) + + http_header = dict() + http_header['Authorization'] = sign + http_header['User-Agent'] = self._config.get_user_agent() + + local_path = request.get_local_path() + file_size = os.path.getsize(local_path) + slice_size = request.get_slice_size() + biz_atrr = request.get_biz_attr() + + http_body = dict() + http_body['op'] = 'upload_slice_init' + if request.enable_sha1: + http_body['sha'] = request.sha1_list[-1]["datasha"] + http_body['uploadparts'] = json.dumps(request.sha1_list) + http_body['filesize'] = str(file_size) + http_body['slice_size'] = str(slice_size) + http_body['biz_attr'] = biz_atrr + http_body['insertOnly'] = str(request.get_insert_only()) + + timeout = self._config.get_timeout() + return self.send_request('POST', bucket, cos_path, headers=http_header, files=http_body, timeout=timeout) + + def _upload_slice_data(self, request, file_content, session, offset, retry=3): + """串行分片第二步, 上传数据分片 + + :param request: + :param file_content: + :param session: + :param offset: + :return: + """ + bucket = request.get_bucket_name() + cos_path = request.get_cos_path() + auth = cos_auth.Auth(self._cred) + expired = int(time.time()) + self._expired_period + sign = auth.sign_more(bucket, cos_path, expired) + + http_header = dict() + http_header['Authorization'] = sign + http_header['User-Agent'] = self._config.get_user_agent() + + http_body = dict() + http_body['op'] = 'upload_slice_data' + http_body['filecontent'] = file_content + http_body['session'] = session + http_body['offset'] = str(offset) + if request.sha1_content is not None: + http_body['sha'] = request.sha1_content + + timeout = self._config.get_timeout() + + for _ in range(retry): + ret = self.send_request('POST', bucket, cos_path, headers=http_header, files=http_body, timeout=timeout) + if ret['code'] == 0: + return ret + else: + return ret + + def __download_url(self, uri, filename): + session = self._http_session + + with closing(session.get(uri, stream=True, timeout=150)) as ret: + if ret.status_code in [200, 206]: + + if 'Content-Length' in ret.headers: + content_len = int(ret.headers['Content-Length']) + else: + raise IOError("download failed without Content-Length header") + + file_len = 0 + with open(filename, 'wb') as f: + for chunk in ret.iter_content(chunk_size=1024): + if chunk: + file_len += len(chunk) + f.write(chunk) + f.flush() + if file_len != content_len: + raise IOError("download failed with incomplete file") + else: + raise IOError("download failed with status code:" + str(ret.status_code)) + + def download_file(self, request): + assert isinstance(request, DownloadFileRequest) + + auth = cos_auth.Auth(self._cred) + sign = auth.sign_download(request.get_bucket_name(), request.get_cos_path(), self._config.get_sign_expired()) + url = self.build_download_url(request.get_bucket_name(), request.get_cos_path(), sign) + logger.info("Uri is %s" % url) + try: + self.__download_url(url, request._local_filename) + return {u'code': 0, u'message': "download successfully"} + except Exception as e: + return {u'code': 1, u'message': "download failed, exception: " + str(e)} + + def __move_file(self, request): + + auth = cos_auth.Auth(self._cred) + bucket = request.get_bucket_name() + cos_path = request.get_cos_path() + sign = auth.sign_once(bucket, cos_path) + + http_header = dict() + http_header['Authorization'] = sign + http_header['User-Agent'] = self._config.get_user_agent() + + http_body = dict() + http_body['op'] = 'move' + http_body['dest_fileid'] = request.dest_path + http_body['to_over_write'] = str(1 if request.overwrite else 0) + + timeout = self._config.get_timeout() + return self.send_request('POST', bucket, cos_path, headers=http_header, params=http_body, timeout=timeout) + + def move_file(self, request): + + assert isinstance(request, MoveFileRequest) + return self.__move_file(request) + + +class FolderOp(BaseOp): + """FolderOp 目录相关操作""" + def __init__(self, cred, config, http_session): + BaseOp.__init__(self, cred, config, http_session) + + def update_folder(self, request): + """更新目录 + + :param request: + :return: + """ + assert isinstance(request, UpdateFolderRequest) + check_params_ret = self._check_params(request) + if check_params_ret is not None: + return check_params_ret + + auth = cos_auth.Auth(self._cred) + bucket = request.get_bucket_name() + cos_path = request.get_cos_path() + sign = auth.sign_once(bucket, cos_path) + + http_header = dict() + http_header['Authorization'] = sign + http_header['Content-Type'] = 'application/json' + http_header['User-Agent'] = self._config.get_user_agent() + + http_body = dict() + http_body['op'] = 'update' + http_body['biz_attr'] = request.get_biz_attr() + + timeout = self._config.get_timeout() + return self.send_request('POST', bucket, cos_path, headers=http_header, data=json.dumps(http_body), timeout=timeout) + + def del_folder(self, request): + """删除目录 + + :param request: + :return: + """ + assert isinstance(request, DelFolderRequest) + return self.del_base(request) + + def stat_folder(self, request): + """获取目录属性 + + :param request: + :return: + """ + assert isinstance(request, StatFolderRequest) + return self.stat_base(request) + + def create_folder(self, request): + """创建目录 + + :param request: + :return: + """ + assert isinstance(request, CreateFolderRequest) + check_params_ret = self._check_params(request) + if check_params_ret is not None: + return check_params_ret + + auth = cos_auth.Auth(self._cred) + bucket = request.get_bucket_name() + cos_path = request.get_cos_path() + expired = int(time.time()) + self._expired_period + sign = auth.sign_more(bucket, cos_path, expired) + + http_header = dict() + http_header['Authorization'] = sign + http_header['Content-Type'] = 'application/json' + http_header['User-Agent'] = self._config.get_user_agent() + + http_body = dict() + http_body['op'] = 'create' + http_body['biz_attr'] = request.get_biz_attr() + + timeout = self._config.get_timeout() + return self.send_request('POST', bucket, cos_path, headers=http_header, data=json.dumps(http_body), timeout=timeout) + + def list_folder(self, request): + """list目录 + + :param request: + :return: + """ + assert isinstance(request, ListFolderRequest) + check_params_ret = self._check_params(request) + if check_params_ret is not None: + return check_params_ret + + http_body = dict() + http_body['op'] = 'list' + http_body['num'] = request.get_num() + + http_body['context'] = request.get_context() + + auth = cos_auth.Auth(self._cred) + bucket = request.get_bucket_name() + list_path = request.get_cos_path() + request.get_prefix() + expired = int(time.time()) + self._expired_period + sign = auth.sign_more(bucket, list_path, expired) + + http_header = dict() + http_header['Authorization'] = sign + http_header['User-Agent'] = self._config.get_user_agent() + + timeout = self._config.get_timeout() + return self.send_request('GET', bucket, list_path, headers=http_header, params=http_body, timeout=timeout) diff --git a/tools/cos/qcloud_cos/cos_params_check.py b/tools/cos/qcloud_cos/cos_params_check.py new file mode 100644 index 00000000..4d1a4061 --- /dev/null +++ b/tools/cos/qcloud_cos/cos_params_check.py @@ -0,0 +1,225 @@ +#!/usr/bin/env python +# -*- coding: utf-8 -*- +import os +import re + + +class ParamCheck(object): + """BaseRequest基本类型的请求""" + def __init__(self): + self._err_tips = u'' + + def get_err_tips(self): + """获取错误信息 + + :return: + """ + return self._err_tips + + def check_param_unicode(self, param_name, param_value): + """检查参数是否是unicode + + :param param_name: param_name 参数名 + :param param_value: param_value 参数值 + :return: + """ + if param_value is None: + self._err_tips = param_name + ' is None!' + return False + if not isinstance(param_value, unicode): + self._err_tips = param_name + ' is not unicode!' + return False + return True + + def check_param_int(self, param_name, param_value): + """检查参数是否是int + + :param param_name: param_name 参数名 + :param param_value: param_value 参数值 + :return: + """ + if param_value is None: + self._err_tips = param_name + ' is None!' + return False + if not isinstance(param_value, int): + self._err_tips = param_name + ' is not int!' + return False + return True + + def check_cos_path_valid(self, cos_path, is_file_path): + """检查cos_path是否合法 + + 路径必须以/开始,文件路径则不能以/结束, 目录路径必须以/结束 + + :param cos_path: + :param is_file_path: + :return: True for valid path, other False + """ + if cos_path[0] != u'/': + self._err_tips = 'cos path must start with /' + return False + + last_letter = cos_path[len(cos_path) - 1] + if is_file_path and last_letter == u'/': + self._err_tips = 'for file operation, cos_path must not end with /' + return False + elif not is_file_path and last_letter != u'/': + self._err_tips = 'for folder operation, cos_path must end with /' + return False + else: + pass + + illegal_letters = ['?', '*', ':', '|', '\\', '<', '>', '"'] + for illegal_letter in illegal_letters: + if cos_path.find(illegal_letter) != -1: + self._err_tips = 'cos path contain illegal letter %s' % illegal_letter + return False + + pattern = re.compile(r'/(\s*)/') + if pattern.search(cos_path): + self._err_tips = 'cos path contain illegal letter / /' + return False + return True + + def check_not_cos_root(self, cos_path): + """检查不是cos的根路径 + + 不能对根路径操作的有 1 update 2 create 3 delete + :param cos_path: + :return: + """ + if cos_path == u'/': + self._err_tips = 'bucket operation is not supported by sdk,' + ' please use cos console: https://console.qcloud.com/cos' + return False + else: + return True + + def check_local_file_valid(self, local_path): + """检查本地文件有效(存在并且可读) + + :param local_path: + :return: + """ + if not os.path.exists(local_path): + self._err_tips = 'local_file %s not exist!' % local_path + return False + if not os.path.isfile(local_path): + self._err_tips = 'local_file %s is not regular file!' % local_path + return False + if not os.access(local_path, os.R_OK): + self._err_tips = 'local_file %s is not readable!' % local_path + return False + return True + + def check_slice_size(self, slice_size): + """检查分片大小有效 + + :param slice_size: + :return: + """ + min_size = 64 * 1024 # 512KB + max_size = 3 * 1024 * 1024 # 20MB + + if max_size >= slice_size >= min_size: + return True + else: + self._err_tips = 'slice_size is invalid, only accept [%d, %d]' \ + % (min_size, max_size) + return False + + def check_insert_only(self, insert_only): + """检查文件上传的insert_only参数 + + :param insert_only: + :return: + """ + if insert_only != 1 and insert_only != 0: + self._err_tips = 'insert_only only support 0 and 1' + return False + else: + return True + + def check_move_over_write(self, to_over_write): + """检查move的over write标志 + + :param to_over_write: + :return: + """ + if to_over_write != 1 and to_over_write != 0: + self._err_tips = 'to_over_write only support 0 and 1' + return False + else: + return True + + def check_file_authority(self, authority): + """检查文件的authority属性 + + 合法的取值只有eInvalid, eWRPrivate, eWPrivateRPublic和空值 + :param authority: + :return: + """ + if authority != u''and authority != u'eInvalid' and authority != u'eWRPrivate' and authority != u'eWPrivateRPublic': + self._err_tips = 'file authority valid value is: eInvalid, eWRPrivate, eWPrivateRPublic' + return False + else: + return True + + def check_x_cos_meta_dict(self, x_cos_meta_dict): + """检查x_cos_meta_dict, key和value都必须是UTF8编码 + + :param x_cos_meta_dict: + :return: + """ + prefix_len = len('x-cos-meta-') + for key in x_cos_meta_dict.keys(): + if not self.check_param_unicode('x-cos-meta-key', key): + return False + if not self.check_param_unicode('x-cos-meta-value', x_cos_meta_dict[key]): + return False + if key[0:prefix_len] != u'x-cos-meta-': + self._err_tips = 'x-cos-meta key must start with x-cos-meta-' + return False + if len(key) == prefix_len: + self._err_tips = 'x-cos-meta key must not just be x-cos-meta-' + return False + if len(x_cos_meta_dict[key]) == 0: + self._err_tips = 'x-cos-meta value must not be empty' + return False + return True + + def check_update_flag(self, flag): + """检查更新文件的flag + + :param flag: + :return: + """ + if flag == 0: + self._err_tips = 'no any attribute to be updated!' + return False + else: + return True + + def check_list_order(self, list_order): + """ 检查list folder的order + + :param list_order: 合法取值0(正序), 1(逆序) + :return: + """ + if list_order != 0 and list_order != 1: + self._err_tips = 'list order is invalid, please use 0(positive) or 1(reverse)!' + return False + else: + return True + + def check_list_pattern(self, list_pattern): + """检查list folder的pattern + + :param list_pattern: 合法取值eListBoth, eListDirOnly, eListFileOnly + :return: + """ + if list_pattern != u'eListBoth' and list_pattern != u'eListDirOnly' and list_pattern != u'eListFileOnly': + self._err_tips = 'list pattern is invalid, please use eListBoth or eListDirOnly or eListFileOnly' + return False + else: + return True diff --git a/tools/cos/qcloud_cos/cos_request.py b/tools/cos/qcloud_cos/cos_request.py new file mode 100644 index 00000000..d2394f9a --- /dev/null +++ b/tools/cos/qcloud_cos/cos_request.py @@ -0,0 +1,626 @@ +#!/usr/bin/env python +# -*- coding: utf-8 -*- + +"""the request type in tencent qcloud cos""" + +from cos_params_check import ParamCheck +import collections + + +class BaseRequest(object): + """BaseRequest基本类型的请求""" + + def __init__(self, bucket_name, cos_path): + """ 类初始化 + + :param bucket_name: bucket的名称 + :param cos_path: cos的绝对路径, 即从bucket下的根/开始 + """ + self._bucket_name = bucket_name.strip() + self._cos_path = cos_path.strip() + self._param_check = ParamCheck() + + def set_bucket_name(self, bucket_name=u''): + """设置bucket_name + + :param bucket_name: + :return: + """ + self._bucket_name = bucket_name.strip() + + def get_bucket_name(self): + """获取bucket_name + + :return: + """ + return self._bucket_name + + def set_cos_path(self, cos_path=u''): + """设置cos_path + + :param cos_path: + :return: + """ + self._cos_path = cos_path.strip() + + def get_cos_path(self): + """获取cos_path + + :return: + """ + return self._cos_path + + def get_err_tips(self): + """获取错误信息 + + :return: + """ + return self._param_check.get_err_tips() + + def check_params_valid(self): + """检查参数是否合法 + + :return: + """ + if not self._param_check.check_param_unicode('bucket', self._bucket_name): + return False + return self._param_check.check_param_unicode('cos_path', self._cos_path) + + +class CreateFolderRequest(BaseRequest): + """CreateFolderRequest 创建目录类型的请求""" + + def __init__(self, bucket_name, cos_path, biz_attr=u''): + """ + + :param bucket_name: bucket的名称 + :param cos_path: cos的绝对路径, 从bucket根/开始 + :param biz_attr: 目录的属性 + """ + super(CreateFolderRequest, self).__init__(bucket_name, cos_path) + self._biz_attr = biz_attr + + def set_biz_attr(self, biz_attr): + """设置biz_attr + + :param biz_attr: + :return: + """ + self._biz_attr = biz_attr + + def get_biz_attr(self): + """ 获取biz_attr + + :return: + """ + return self._biz_attr + + def check_params_valid(self): + """检查参数是否合法 + + :return: + """ + if not super(CreateFolderRequest, self).check_params_valid(): + return False + if not self._param_check.check_param_unicode('biz_attr', self._biz_attr): + return False + if not self._param_check.check_cos_path_valid(self._cos_path, is_file_path=False): + return False + return self._param_check.check_not_cos_root(self._cos_path) + + +class UploadFileRequest(BaseRequest): + """ + UploadFileRequest 单文件上传请求 + """ + + def __init__(self, bucket_name, cos_path, local_path, biz_attr=u'', insert_only=1): + """ + + :param bucket_name: bucket的名称 + :param cos_path: cos的绝对路径(目的路径), 从bucket根/开始 + :param local_path: 上传的本地文件路径(源路径) + :param biz_attr: 文件的属性 + :param insert_only: 是否覆盖写, 0覆盖, 1不覆盖,返回错误 + """ + super(UploadFileRequest, self).__init__(bucket_name, cos_path) + self._local_path = local_path.strip() + self._biz_attr = biz_attr + self._insert_only = insert_only + + def set_local_path(self, local_path): + """设置local_path + + :param local_path: + :return: + """ + self._local_path = local_path.strip() + + def get_local_path(self): + """获取local_path + + :return: + """ + return self._local_path + + def set_biz_attr(self, biz_attr): + """设置biz_attr + + :param biz_attr: + :return: + """ + self._biz_attr = biz_attr + + def get_biz_attr(self): + """获取biz_attr + + :return: + """ + return self._biz_attr + + def set_insert_only(self, insert_only): + """设置insert_only,0表示如果文件存在, 则覆盖 + + :param insert_only: + :return: + """ + self._insert_only = insert_only + + def get_insert_only(self): + """获取insert_only + + :return: + """ + return self._insert_only + + def check_params_valid(self): + """检查参数是否有效 + + :return: + """ + if not super(UploadFileRequest, self).check_params_valid(): + return False + if not self._param_check.check_cos_path_valid(self._cos_path, is_file_path=True): + return False + if not self._param_check.check_param_unicode('biz_attr', self._biz_attr): + return False + if not self._param_check.check_param_unicode('local_path', self._local_path): + return False + if not self._param_check.check_local_file_valid(self._local_path): + return False + if not self._param_check.check_param_int('insert_only', self._insert_only): + return False + return self._param_check.check_insert_only(self._insert_only) + + +class UploadSliceFileRequest(UploadFileRequest): + """ + UploadSliceFileRequest 分片文件上传请求 + """ + + def __init__(self, bucket_name, cos_path, local_path, slice_size=1024*1024, biz_attr=u'', enable_sha1=False, max_con=1): + """ + + :param bucket_name: bucket的名称 + :param cos_path: cos的绝对路径(目的路径), 从bucket根/开始 + :param local_path: 上传的本地文件路径(源路径) + :param slice_size: 文件的属性 + :param biz_attr: 分片大小(字节, 默认1MB) + :param enable_sha1: 是否启用sha1校验 + """ + super(UploadSliceFileRequest, self).__init__(bucket_name, cos_path, local_path, biz_attr) + self._slice_size = slice_size + self._enable_sha1 = enable_sha1 + self._max_con = max_con + + @property + def enable_sha1(self): + return self._enable_sha1 + + @enable_sha1.setter + def enable_sha1(self, val): + if val in (True, False): + self._enable_sha1 = val + else: + raise ValueError("enable_sha1 should be True/False") + + def set_slice_size(self, slice_size): + """设置分片大小 + + :param slice_size: + :return: + """ + self._slice_size = slice_size + + def get_slice_size(self): + """获取分片大小 + + :return: + """ + return self._slice_size + + def check_params_valid(self): + """检查参数是否有效 + + :return: + """ + if not super(UploadSliceFileRequest, self).check_params_valid(): + return False + + if self._enable_sha1 and self._slice_size != 1024*1024: + self._param_check._err_tips = 'slice_size is invalid, slice must be 1MB with enable_sha1' + return False + + return self._param_check.check_slice_size(self._slice_size) + + +class UpdateFolderRequest(BaseRequest): + """UpdateFolderRequest 更新目录请求""" + + def __init__(self, bucket_name, cos_path, biz_attr=u''): + """ + + :param bucket_name: bucket name + :param cos_path: the path on cos + :param biz_attr: biz attributes + """ + super(UpdateFolderRequest, self).__init__(bucket_name, cos_path) + self._biz_attr = biz_attr + + def set_biz_attr(self, biz_attr): + """设置biz_attr + + :param biz_attr: + :return: + """ + self._biz_attr = biz_attr + + def get_biz_attr(self): + """获取biz_attr + + :return: + """ + return self._biz_attr + + def check_params_valid(self): + """检查参数是否有效 + + :return: + """ + if not super(UpdateFolderRequest, self).check_params_valid(): + return False + if not self._param_check.check_cos_path_valid(self._cos_path, is_file_path=False): + return False + if not self._param_check.check_not_cos_root(self._cos_path): + return False + return self._param_check.check_param_unicode('biz_attr', self._biz_attr) + + +class UpdateFileRequest(BaseRequest): + """UpdateFileRequest 更新文件请求 """ + + def __init__(self, bucket_name, cos_path): + """ 初始化类 + + biz_attr: 要更新的文件的属性 + authority: 文件权限: + eInvalid(继承bucket), + eWRPrivate(私有读写), + eWPrivateRPublic(私有写, 公有读) + customer_header: 用户自定义的HTTP请求头,包括以下成员 + cache_control: 文件的缓存机制,参见HTTP的Cache-Control + content_type: 文件的MIME信息,参见HTTP的Content-Type + content_disposition: MIME协议的扩展,参见HTTP的Content-Disposition + content_language: 文件的语言, 参见HTTP的Content-Language + content_encoding: body的编码, 参见HTTP的Content-Encoding + _x_cos_meta_dict: 用户自定义的属性, key是以x-cos-meta-开头,value为属性值 + + :param bucket_name: bucket的名称 + :param cos_path: cos的绝对路径, 从bucket根/开始 + """ + super(UpdateFileRequest, self).__init__(bucket_name, cos_path) + self._biz_attr = None + self._custom_headers = {} + self._authority = None + self._cache_control = None + self._content_type = None + self._content_disposition = None + self._content_language = None + self._content_encoding = None + self._x_cos_meta_dict = dict() + + def set_biz_attr(self, biz_attr): + """设置biz_attr""" + self._biz_attr = biz_attr + + def get_biz_attr(self): + """获取biz_attr""" + return self._biz_attr + + # 设置authority, 合法取值如下所示 + # eInvalid(继承bucket), + # eWRPrivate(私有读写), + # eWPrivateRPublic(私有写, 公有读) + def set_authority(self, authority): + """设置authority, + + 合法取值:eInvalid(继承bucket),eWRPrivate(私有读写),eWPrivateRPublic(私有写, 公有读) + :param authority: + :return: + """ + self._authority = authority + + def get_authority(self): + """获取authority""" + return self._authority + + def set_cache_control(self, cache_control): + """设置缓存机制Cache-Control""" + self._cache_control = cache_control + self._custom_headers[u'Cache-Control'] = cache_control + + def set_content_type(self, content_type): + """设置Content-Type""" + self._content_type = content_type + self._custom_headers['Content-Type'] = content_type + + def set_content_disposition(self, content_disposition): + """设置Content-Disposition""" + self._content_disposition = content_disposition + self._custom_headers['Content-Disposition'] = content_disposition + + def set_content_language(self, content_language): + """设置Content-Language""" + self._content_language = content_language + self._custom_headers['Content-Language'] = content_language + + def set_content_encoding(self, content_encoding): + """设置Content-Encoding""" + self._content_encoding = content_encoding + self._custom_headers['Content-Encoding'] = content_encoding + + def set_x_cos_meta(self, key, value): + """设置自定义的x-cos-meta + + key以x-cos-meta-开头,例如自定义key为u'x-cos-meta-len', value为u'1024' + :param key: + :param value: + :return: + """ + self._x_cos_meta_dict[key] = value + self._custom_headers[key] = value + + def _convert_dict(self, data): + """convert a dict's keys & values from `unicode` to `str` + + :param data: + :return: + """ + if isinstance(data, basestring): + return str(data) + elif isinstance(data, collections.Mapping): + return dict(map(self._convert_dict, data.iteritems())) + elif isinstance(data, collections.Iterable): + return type(data)(map(self._convert_dict, data)) + else: + return data + + def get_custom_headers(self): + """ 获取自定义的HTTP头""" + return self._convert_dict(self._custom_headers) + + def check_params_valid(self): + """ 检查参数是否合法""" + if not super(UpdateFileRequest, self).check_params_valid(): + return False + + if not self._param_check.check_cos_path_valid(self._cos_path, is_file_path=True): + return False + + if self._biz_attr is not None: + if not self._param_check.check_param_unicode('biz_attr', self._biz_attr): + return False + + if self._authority is not None: + if not self._param_check.check_param_unicode('authority', self._authority): + return False + + if self._authority is not None: + if not self._param_check.check_file_authority(self._authority): + return False + + if self._cache_control is not None: + if not self._param_check.check_param_unicode('cache_control', self._cache_control): + return False + + if self._content_type is not None: + if not self._param_check.check_param_unicode('content_type', self._content_type): + return False + + if self._content_disposition is not None: + if not self._param_check.check_param_unicode('content_disposition', self._content_disposition): + return False + + if self._content_language is not None: + if not self._param_check.check_param_unicode('content_language', self._content_language): + return False + + if self._content_encoding is not None: + if not self._param_check.check_param_unicode('content_encoding', self._content_encoding): + return False + + return self._param_check.check_x_cos_meta_dict(self._x_cos_meta_dict) + + +class StatFileRequest(BaseRequest): + """StatRequest 获取文件属性请求""" + + def __init__(self, bucket_name, cos_path): + """ + :param bucket_name: bucket的名称 + :param cos_path: cos的文件路径, 从bucket根/开始, 不以/结束 + """ + super(StatFileRequest, self).__init__(bucket_name, cos_path) + + def check_params_valid(self): + """检查参数是否合法""" + if not super(StatFileRequest, self).check_params_valid(): + return False + return self._param_check.check_cos_path_valid(self._cos_path, is_file_path=True) + + +class StatFolderRequest(BaseRequest): + """StatRequest 获取目录属性请求 """ + + def __init__(self, bucket_name, cos_path): + """ + + :param bucket_name: bucket的名称 + :param cos_path: cos的目录路径, 从bucket根/开始, 以/结束 + """ + super(StatFolderRequest, self).__init__(bucket_name, cos_path) + + def check_params_valid(self): + """检查参数是否合法""" + if not super(StatFolderRequest, self).check_params_valid(): + return False + return self._param_check.check_cos_path_valid(self._cos_path, is_file_path=False) + + +class DelFileRequest(BaseRequest): + """ DelFileRequest 删除文件请求 """ + + def __init__(self, bucket_name, cos_path): + """ + + :param bucket_name: bucket的名称 + :param cos_path: cos的文件路径, 从bucket根/开始, 不以/结束 + """ + super(DelFileRequest, self).__init__(bucket_name, cos_path) + + def check_params_valid(self): + """检查参数是否合法""" + if not super(DelFileRequest, self).check_params_valid(): + return False + return self._param_check.check_cos_path_valid(self._cos_path, is_file_path=True) + + +class DelFolderRequest(BaseRequest): + """DelFolderRequest 删除目录请求""" + + def __init__(self, bucket_name, cos_path): + """ + + :param bucket_name: bucket的名称 + :param cos_path: cos的目录路径, 从bucket根/开始, 以/结束 + """ + super(DelFolderRequest, self).__init__(bucket_name, cos_path) + + def check_params_valid(self): + """ 检查参数合法""" + if not super(DelFolderRequest, self).check_params_valid(): + return False + if not self._param_check.check_cos_path_valid(self._cos_path, is_file_path=False): + return False + return self._param_check.check_not_cos_root(self._cos_path) + + +class ListFolderRequest(BaseRequest): + """ListFolderRequest 获取目录列表的请求""" + + def __init__(self, bucket_name, cos_path, num=199, prefix=u'', context=u''): + """ + :param bucket_name: bucket的名称 + :param cos_path: cos的绝对路径, 从bucket根/开始 + :param num: 搜索数量 + :param prefix: 搜索前缀 + :param context: 搜索上下文 + """ + super(ListFolderRequest, self).__init__(bucket_name, cos_path) + self._num = num + self._prefix = prefix + self._context = context + + def set_num(self, num): + """设置List数量 + + :param num: + :return: + """ + self._num = num + + def get_num(self): + """获取List数量 + + :return: + """ + """ + + :return: + """ + return self._num + + def set_prefix(self, prefix): + """设置前缀""" + self._prefix = prefix + + def get_prefix(self): + """获取前缀""" + return self._prefix + + def set_context(self, context): + """设置搜索上下文""" + self._context = context + + def get_context(self): + """获取搜索上下文""" + return self._context + + def check_params_valid(self): + """检查参数是否有效""" + if not super(ListFolderRequest, self).check_params_valid(): + return False + if not self._param_check.check_cos_path_valid(self._cos_path, is_file_path=False): + return False + if not self._param_check.check_param_unicode('prefix', self._prefix): + return False + return self._param_check.check_param_unicode('context', self._context) + + +class DownloadFileRequest(BaseRequest): + def __init__(self, bucket_name, cos_path, local_filename, range_start=None, range_end=None, *args, **kwargs): + super(DownloadFileRequest, self).__init__(bucket_name, cos_path) + + self._local_filename = local_filename + self._range_start = range_start + self._range_end = range_end + + def check_params_valid(self): + if not super(DownloadFileRequest, self).check_params_valid(): + return False + + from os import path + if path.exists(self._local_filename): + return False + + +class MoveFileRequest(BaseRequest): + + def __init__(self, bucket_name, cos_path, dest_path, overwrite=False): + super(MoveFileRequest, self).__init__(bucket_name, cos_path) + self._dest_path = dest_path + if isinstance(overwrite, bool): + if overwrite: + self._overwrite = 1 + else: + self._overwrite = 0 + else: + raise ValueError("overwrite must be an instance of Boolean") + + @property + def dest_path(self): + return self._dest_path + + @property + def overwrite(self): + return self._overwrite diff --git a/tools/cos/threadpool.py b/tools/cos/threadpool.py new file mode 100644 index 00000000..6bb3e283 --- /dev/null +++ b/tools/cos/threadpool.py @@ -0,0 +1,423 @@ +# -*- coding: UTF-8 -*- +"""Easy to use object-oriented thread pool framework. + +A thread pool is an object that maintains a pool of worker threads to perform +time consuming operations in parallel. It assigns jobs to the threads +by putting them in a work request queue, where they are picked up by the +next available thread. This then performs the requested operation in the +background and puts the results in another queue. + +The thread pool object can then collect the results from all threads from +this queue as soon as they become available or after all threads have +finished their work. It's also possible, to define callbacks to handle +each result as it comes in. + +The basic concept and some code was taken from the book "Python in a Nutshell, +2nd edition" by Alex Martelli, O'Reilly 2006, ISBN 0-596-10046-9, from section +14.5 "Threaded Program Architecture". I wrapped the main program logic in the +ThreadPool class, added the WorkRequest class and the callback system and +tweaked the code here and there. Kudos also to Florent Aide for the exception +handling mechanism. + +Basic usage:: + + >>> pool = ThreadPool(poolsize) + >>> requests = makeRequests(some_callable, list_of_args, callback) + >>> [pool.putRequest(req) for req in requests] + >>> pool.wait() + +See the end of the module code for a brief, annotated usage example. + +Website : http://chrisarndt.de/projects/threadpool/ + +""" +__docformat__ = "restructuredtext en" + +__all__ = [ + 'makeRequests', + 'NoResultsPending', + 'NoWorkersAvailable', + 'ThreadPool', + 'WorkRequest', + 'WorkerThread' +] + +__author__ = "Christopher Arndt" +__version__ = '1.3.2' +__license__ = "MIT license" + + +# standard library modules +import sys +import threading +import traceback + +try: + import Queue # Python 2 +except ImportError: + import queue as Queue # Python 3 + + +# exceptions +class NoResultsPending(Exception): + """All work requests have been processed.""" + pass + +class NoWorkersAvailable(Exception): + """No worker threads available to process remaining requests.""" + pass + + +# internal module helper functions +def _handle_thread_exception(request, exc_info): + """Default exception handler callback function. + + This just prints the exception info via ``traceback.print_exception``. + + """ + traceback.print_exception(*exc_info) + + +# utility functions +def makeRequests(callable_, args_list, callback=None, + exc_callback=_handle_thread_exception): + """Create several work requests for same callable with different arguments. + + Convenience function for creating several work requests for the same + callable where each invocation of the callable receives different values + for its arguments. + + ``args_list`` contains the parameters for each invocation of callable. + Each item in ``args_list`` should be either a 2-item tuple of the list of + positional arguments and a dictionary of keyword arguments or a single, + non-tuple argument. + + See docstring for ``WorkRequest`` for info on ``callback`` and + ``exc_callback``. + + """ + requests = [] + for item in args_list: + if isinstance(item, tuple): + requests.append( + WorkRequest(callable_, item[0], item[1], callback=callback, + exc_callback=exc_callback) + ) + else: + requests.append( + WorkRequest(callable_, [item], None, callback=callback, + exc_callback=exc_callback) + ) + return requests + + +# classes +class WorkerThread(threading.Thread): + """Background thread connected to the requests/results queues. + + A worker thread sits in the background and picks up work requests from + one queue and puts the results in another until it is dismissed. + + """ + + def __init__(self, requests_queue, results_queue, poll_timeout=5, **kwds): + """Set up thread in daemonic mode and start it immediatedly. + + ``requests_queue`` and ``results_queue`` are instances of + ``Queue.Queue`` passed by the ``ThreadPool`` class when it creates a + new worker thread. + + """ + threading.Thread.__init__(self, **kwds) + self.setDaemon(1) + self._requests_queue = requests_queue + self._results_queue = results_queue + self._poll_timeout = poll_timeout + self._dismissed = threading.Event() + self.start() + + def run(self): + """Repeatedly process the job queue until told to exit.""" + while True: + if self._dismissed.isSet(): + # we are dismissed, break out of loop + break + # get next work request. If we don't get a new request from the + # queue after self._poll_timout seconds, we jump to the start of + # the while loop again, to give the thread a chance to exit. + try: + request = self._requests_queue.get(True, self._poll_timeout) + #except Queue.Empty: + except: + continue + else: + if self._dismissed.isSet(): + # we are dismissed, put back request in queue and exit loop + self._requests_queue.put(request) + break + try: + result = request.callable(*request.args, **request.kwds) + self._results_queue.put((request, result)) + except: + request.exception = True + self._results_queue.put((request, sys.exc_info())) + + def dismiss(self): + """Sets a flag to tell the thread to exit when done with current job. + """ + self._dismissed.set() + + +class WorkRequest: + """A request to execute a callable for putting in the request queue later. + + See the module function ``makeRequests`` for the common case + where you want to build several ``WorkRequest`` objects for the same + callable but with different arguments for each call. + + """ + + def __init__(self, callable_, args=None, kwds=None, requestID=None, + callback=None, exc_callback=_handle_thread_exception): + """Create a work request for a callable and attach callbacks. + + A work request consists of the a callable to be executed by a + worker thread, a list of positional arguments, a dictionary + of keyword arguments. + + A ``callback`` function can be specified, that is called when the + results of the request are picked up from the result queue. It must + accept two anonymous arguments, the ``WorkRequest`` object and the + results of the callable, in that order. If you want to pass additional + information to the callback, just stick it on the request object. + + You can also give custom callback for when an exception occurs with + the ``exc_callback`` keyword parameter. It should also accept two + anonymous arguments, the ``WorkRequest`` and a tuple with the exception + details as returned by ``sys.exc_info()``. The default implementation + of this callback just prints the exception info via + ``traceback.print_exception``. If you want no exception handler + callback, just pass in ``None``. + + ``requestID``, if given, must be hashable since it is used by + ``ThreadPool`` object to store the results of that work request in a + dictionary. It defaults to the return value of ``id(self)``. + + """ + if requestID is None: + self.requestID = id(self) + else: + try: + self.requestID = hash(requestID) + except TypeError: + raise TypeError("requestID must be hashable.") + self.exception = False + self.callback = callback + self.exc_callback = exc_callback + self.callable = callable_ + self.args = args or [] + self.kwds = kwds or {} + + def __str__(self): + return "" % \ + (self.requestID, self.args, self.kwds, self.exception) + +class ThreadPool: + """A thread pool, distributing work requests and collecting results. + + See the module docstring for more information. + + """ + + def __init__(self, num_workers, q_size=0, resq_size=0, poll_timeout=5): + """Set up the thread pool and start num_workers worker threads. + + ``num_workers`` is the number of worker threads to start initially. + + If ``q_size > 0`` the size of the work *request queue* is limited and + the thread pool blocks when the queue is full and it tries to put + more work requests in it (see ``putRequest`` method), unless you also + use a positive ``timeout`` value for ``putRequest``. + + If ``resq_size > 0`` the size of the *results queue* is limited and the + worker threads will block when the queue is full and they try to put + new results in it. + + .. warning: + If you set both ``q_size`` and ``resq_size`` to ``!= 0`` there is + the possibilty of a deadlock, when the results queue is not pulled + regularly and too many jobs are put in the work requests queue. + To prevent this, always set ``timeout > 0`` when calling + ``ThreadPool.putRequest()`` and catch ``Queue.Full`` exceptions. + + """ + self._requests_queue = Queue.Queue(q_size) + self._results_queue = Queue.Queue(resq_size) + self.workers = [] + self.dismissedWorkers = [] + self.workRequests = {} + self.createWorkers(num_workers, poll_timeout) + + def createWorkers(self, num_workers, poll_timeout=5): + """Add num_workers worker threads to the pool. + + ``poll_timout`` sets the interval in seconds (int or float) for how + ofte threads should check whether they are dismissed, while waiting for + requests. + + """ + for i in range(num_workers): + self.workers.append(WorkerThread(self._requests_queue, + self._results_queue, poll_timeout=poll_timeout)) + + def dismissWorkers(self, num_workers, do_join=False): + """Tell num_workers worker threads to quit after their current task.""" + dismiss_list = [] + for i in range(min(num_workers, len(self.workers))): + worker = self.workers.pop() + worker.dismiss() + dismiss_list.append(worker) + + if do_join: + for worker in dismiss_list: + worker.join() + else: + self.dismissedWorkers.extend(dismiss_list) + + def joinAllDismissedWorkers(self): + """Perform Thread.join() on all worker threads that have been dismissed. + """ + for worker in self.dismissedWorkers: + worker.join() + self.dismissedWorkers = [] + + def putRequest(self, request, block=True, timeout=None): + """Put work request into work queue and save its id for later.""" + assert isinstance(request, WorkRequest) + # don't reuse old work requests + assert not getattr(request, 'exception', None) + self._requests_queue.put(request, block, timeout) + self.workRequests[request.requestID] = request + + def poll(self, block=False): + """Process any new results in the queue.""" + while True: + # still results pending? + if not self.workRequests: + raise NoResultsPending + # are there still workers to process remaining requests? + elif block and not self.workers: + raise NoWorkersAvailable + try: + # get back next results + request, result = self._results_queue.get(block=block) + # has an exception occured? + if request.exception and request.exc_callback: + request.exc_callback(request, result) + # hand results to callback, if any + if request.callback and not \ + (request.exception and request.exc_callback): + request.callback(request, result) + del self.workRequests[request.requestID] + #except Queue.Empty: + except: + break + + def wait(self): + """Wait for results, blocking until all have arrived.""" + while 1: + try: + self.poll(True) + except NoResultsPending: + break + + +################ +# USAGE EXAMPLE +################ + +if __name__ == '__main__': + import random + import time + + # the work the threads will have to do (rather trivial in our example) + def do_something(data): + time.sleep(random.randint(1,5)) + result = round(random.random() * data, 5) + # just to show off, we throw an exception once in a while + if result > 5: + raise RuntimeError("Something extraordinary happened!") + return result + + # this will be called each time a result is available + def print_result(request, result): + print("**** Result from request #%s: %r" % (request.requestID, result)) + + # this will be called when an exception occurs within a thread + # this example exception handler does little more than the default handler + def handle_exception(request, exc_info): + if not isinstance(exc_info, tuple): + # Something is seriously wrong... + print(request) + print(exc_info) + raise SystemExit + print("**** Exception occured in request #%s: %s" % \ + (request.requestID, exc_info)) + + # assemble the arguments for each job to a list... + data = [random.randint(1,10) for i in range(20)] + # ... and build a WorkRequest object for each item in data + requests = makeRequests(do_something, data, print_result, handle_exception) + # to use the default exception handler, uncomment next line and comment out + # the preceding one. + #requests = makeRequests(do_something, data, print_result) + + # or the other form of args_lists accepted by makeRequests: ((,), {}) + data = [((random.randint(1,10),), {}) for i in range(20)] + requests.extend( + makeRequests(do_something, data, print_result, handle_exception) + #makeRequests(do_something, data, print_result) + # to use the default exception handler, uncomment next line and comment + # out the preceding one. + ) + + # we create a pool of 3 worker threads + print("Creating thread pool with 3 worker threads.") + main = ThreadPool(3) + + # then we put the work requests in the queue... + for req in requests: + main.putRequest(req) + print("Work request #%s added." % req.requestID) + # or shorter: + # [main.putRequest(req) for req in requests] + + # ...and wait for the results to arrive in the result queue + # by using ThreadPool.wait(). This would block until results for + # all work requests have arrived: + # main.wait() + + # instead we can poll for results while doing something else: + i = 0 + while True: + try: + time.sleep(0.5) + main.poll() + print("Main thread working...") + print("(active worker threads: %i)" % (threading.activeCount()-1, )) + if i == 10: + print("**** Adding 3 more worker threads...") + main.createWorkers(3) + if i == 20: + print("**** Dismissing 2 worker threads...") + main.dismissWorkers(2) + i += 1 + except KeyboardInterrupt: + print("**** Interrupted!") + break + except NoResultsPending: + print("**** No pending results.") + break + if main.dismissedWorkers: + print("Joining all dismissed worker threads...") + main.joinAllDismissedWorkers() diff --git a/tools/coscmd b/tools/coscmd new file mode 100755 index 00000000..790b293c --- /dev/null +++ b/tools/coscmd @@ -0,0 +1,508 @@ +#!/usr/bin/env python +#coding:utf-8 + +import sys,os +import datetime +import random +import threading +import time +import datetime +import logging +import ConfigParser +from optparse import OptionParser +from logging.handlers import RotatingFileHandler +from time import strftime, localtime +from time import sleep +from datetime import date +from datetime import timedelta +from cos import CosClient +from cos import UploadFileRequest +from cos import CreateFolderRequest +from cos import DelFileRequest +from cos import DelFolderRequest +from cos import ListFolderRequest +from cos import threadpool + +MAX_RETRY_TIMES = 3 +LOG_SAVE_EVERY_NUM = 1024 +ONE_TASK_DEL_FILE_NUMS = 50 +log_level = 1 +log_file_name = "del_file.log" +dir_thread_num = 2 +file_thread_num = 5 +log_out_to_screen = 1 +delete_folder_fail_exist = 0 + +CONFIGFILE = "%s/.coscredentials" % os.path.expanduser('~') +CONFIGSECTION = 'COSCredentials' + +HAS_FORK = hasattr(os, 'fork') + +HELP = \ +'''coscmd: + config --appid=[appid] --id=[secret_id] --key=[secret_key] --region=[region] --bucket=[bucket] + ls cosdir + mkdir dirname + put localfile cosdir + rm(delete,del) object + ''' + +CMD_LIST = {} +def cmd_configure(args, options): + if options.appid is None or options.secret_id is None or options.secret_key is None or options.region is None or options.bucket is None: + print("%s miss parameters, use --appid=[appid] --id=[secret_id] --key=[secret_key] --region=[region] --bucket=[bucket] to specify appid/id/key/region/bucket pair" % args[0]) + sys.exit(-1) + config = ConfigParser.RawConfigParser() + config.add_section(CONFIGSECTION) + config.set(CONFIGSECTION, 'appid', options.appid) + config.set(CONFIGSECTION, 'secret_id', options.secret_id) + config.set(CONFIGSECTION, 'secret_key', options.secret_key) + if options.region in ['sh','gz','tj','sgp']: + config.set(CONFIGSECTION, 'region', options.region) + else: + print("input region error, setup use : --region={sh,gz,tj,sgp}") + sys.exit(-1) + config.set(CONFIGSECTION, 'bucket', options.bucket) + cfgfile = open(CONFIGFILE, 'w+') + config.write(cfgfile) + print("Your configuration is saved into %s ." % CONFIGFILE) + cfgfile.close() + import stat + os.chmod(CONFIGFILE, stat.S_IREAD | stat.S_IWRITE) + +def cmd_loadconfigure(): + config = ConfigParser.ConfigParser() + config.read(CONFIGFILE) + global appid + global secret_id + global secret_key + global region + global bucket + appid = int(config.get(CONFIGSECTION, 'appid')) + secret_id = config.get(CONFIGSECTION, 'secret_id').decode('utf-8') + secret_key = config.get(CONFIGSECTION, 'secret_key').decode('utf-8') + region = config.get(CONFIGSECTION, 'region') + bucket = config.get(CONFIGSECTION, 'bucket').decode('utf-8') + if len(secret_id) == 0 or len(secret_key) == 0 or len(region) == 0 or len(bucket) == 0: + print("can't get appid/secret_id/secret_key/region/bucket, setup use : config --appid=[appid] --id=[secret_id] --key=[secret_key] --region=[region] --bucket=[bucket]") + sys.exit(1) + +def cmd_lsdir(COSDIR): + cosdir = COSDIR.decode('utf-8') + request = ListFolderRequest(bucket, cosdir) + list_folder_ret = cos_client.list_folder(request) + if list_folder_ret[u'code'] == 0: + print(True) + else: + print("%s, appid/secret_id/secret_key/region/bucket invalid"% list_folder_ret[u'message']) + +def cmd_mkdir(COSDIR): + cosdir = COSDIR.decode('utf-8') + request = CreateFolderRequest(bucket, cosdir) + create_folder_ret = cos_client.create_folder(request) + if create_folder_ret[u'code'] == 0: + print("mkdir cos://%s%s OK" % (bucket,COSDIR)) + else: + print(create_folder_ret[u'message']) + +def cmd_put(LOCALFILE,COSFILE): + localfile = LOCALFILE.decode('utf-8') + cosfile = COSFILE.decode('utf-8') + request = UploadFileRequest(bucket, cosfile, localfile) + request.set_insert_only(0) + upload_file_ret = cos_client.upload_file(request) + if upload_file_ret[u'code'] == 0: + print("put cos://%s%s OK" % (bucket,COSFILE)) + else: + print(upload_file_ret[u'message']) + +def loginit(): + global config + if (log_file_name == ""): + return + log_level = logging.ERROR + if log_level == 0: + log_level = logging.DEBUG + if log_level == 1: + log_level = logging.INFO + if log_level == 2: + log_level = logging.WARNING + + #定义一个RotatingFileHandler,最多备份5个日志文件,每个日志文件最大20M + logger = logging.getLogger("") + Rthandler = RotatingFileHandler(log_file_name, maxBytes= 20*1024*1024,backupCount=5) + Rthandler.setLevel(log_level) + formatter = logging.Formatter('%(asctime)s %(levelname)s %(message)s') + Rthandler.setFormatter(formatter) + logger.addHandler(Rthandler) + #输出日志到屏幕 + console = logging.StreamHandler() + console.setFormatter(formatter) + if (log_out_to_screen == 1): + logger.addHandler(console) + + logger.setLevel(log_level) + return logger + +#日期相关操作 +class Dateop(): + @staticmethod + def isValidDate(str): + try: + time.strptime(str, "%Y""%m""%d") + return True + except: + return False + + @staticmethod + def getdaystr(n=0): + dt = date.today()-timedelta(days=n) + tt = dt.timetuple() + daystr = strftime("%Y""%m""%d",tt) + return daystr + + @staticmethod + def cmpDateAgo(t1,t2): + if (Dateop.isValidDate(t1)==False or Dateop.isValidDate(t2)==False): + return False + if (int(t1) <= int (t2)): + return True + return False + + @staticmethod + def isNeedDeleteDir(dirname, n=0): + if (len(dirname) != 8): + return False + if Dateop.isValidDate(dirname) == False: + return False + d2 = Dateop.getdaystr(n); + if Dateop.cmpDateAgo(dirname, d2): + return True + return False +#删除文件统计 +class FileStat(): + global cos_log + def __init__(self): + self.delfilesuccnum = 0 + self.deldirsuccnum = 0 + self.delfilefailnum = 0 + self.deldirfailnum = 0 + self.lock = threading.Lock() + + def addDelFileFailNum(self,num=1): + self.lock.acquire(1) + self.delfilefailnum += num + self.lock.release() + def addDelDirFailNum(self,num=1): + self.lock.acquire(1) + self.deldirfailnum += num + self.lock.release() + def addDelDirSuccNum(self, num=1): + self.lock.acquire(1) + self.deldirsuccnum += num + self.lock.release() + def addDelFileSuccNum(self, num=1): + self.lock.acquire(1) + self.delfilesuccnum += num + self.lock.release() + def printStat(self): + msg ="".join(["delfilesuccnum=",str(self.delfilesuccnum), + ",delfilefailnum=",str(self.delfilefailnum), + ",deldirsuccnum=",str(self.deldirsuccnum), + ",deldirfailnum=",str(self.deldirfailnum)]) + print(msg) + def logStat(self): + curtime = time.strftime("%Y-%m-%d %H:%M:%S", time.localtime()) + log = ''.join(["delfilenum=",str(self.delfilesuccnum), + ",deldirnum=",str(self.deldirsuccnum),",delfilefailnum=", + str(self.delfilefailnum),",deldirfailnum=",str(self.deldirfailnum)]) + cos_log.info(log) + +#执行时间统计 +class TimeStat(object): + global cos_log + def __init__(self): + self.start() + def start(self): + self.start = datetime.datetime.now() + self.t1 = time.time() + msg = "delete task started ..........." + cos_log.info(msg) + def end(self): + self.end = datetime.datetime.now() + self.t2 = time.time() + msg = "delete task ended\n\nrm task finished,\ntimecost:"+str(self.t2-self.t1) + " (s)" + cos_log.info(msg) + +#删除文件列表中的文件 +def delfiles(cos_client, bucket, filelist): + for f in filelist: + delfile(cos_client, bucket, f) + +def delfolders(cos_client, bucket, folderlist): + for f in folderlist: + delfolder(cos_client, bucket, f) + +#文件夹删除 +def delfolder(cos_client, bucket, folder): + global stat + global cos_log + if not folder: + return 0 + delfolderreq = DelFolderRequest(bucket, folder) + retry = 0 + while (retry < MAX_RETRY_TIMES): + ret = cos_client.del_folder(delfolderreq) + #msg = "delfolder fail, bucket="+bucket+",folder="+folder+ret['message'] + msg = "delfolder fail, bucket="+bucket+",folder="+folder+str(ret.get('message')) + if (ret['code'] == 0): + break + elif (ret['code'] == -166): + cos_log.warning(msg) + break + #操作太频繁,频控 + elif (ret['code'] == -71): + sleep(random.randint(1,5)) + cos_log.warning(msg) + retry += 1 + continue + #文件夹非空 + elif (ret['code'] == -173): + break + else: + cos_log.warning(msg) + retry += 1 + if (ret['code'] != 0 and ret['code'] != -166): + stat.addDelDirFailNum() + #cos_log.error("delfolder fail, bucket="+bucket+",folder="+folder+ret['message']) + cos_log.error("delfolder fail, bucket="+bucket+",folder="+folder+str(ret.get('message'))) + return ret['code'] + if (ret['code'] == 0): + stat.addDelDirSuccNum() + msg = "delfolder success, bucket="+bucket+",folder="+folder + cos_log.info(msg) + return 0 + +#文件删除 +def delfile(cos_client, bucket, filepath): + global stat + global cos_log + delfilereq = DelFileRequest(bucket, filepath) + retry = 0 + while (retry < MAX_RETRY_TIMES): + ret = cos_client.del_file(delfilereq) + #msg = "delfile fail bucket="+bucket+",file="+filepath+ret['message'] + msg = "delfile fail bucket="+bucket+",file="+filepath+str(ret.get('message')) + if (ret['code'] == 0): + break + #文件不存在 + elif (ret['code'] == -166): + cos_log.warning(msg) + break + #单目录写操作过快 + elif (ret['code'] == -143): + sleep(random.randint(1,5)) + cos_log.warning(msg) + retry += 1 + continue + #操作太频繁,频控 + elif (ret['code'] == -71): + sleep(random.randint(1,5)) + cos_log.warning(msg) + retry += 1 + continue + else: + cos_log.warning(msg) + retry += 1 + continue + if (ret['code'] != 0 and ret['code'] != -166): + stat.addDelFileFailNum() + #cos_log.error("delfile fail, bucket="+bucket+",file="+filepath+ret['message']) + cos_log.error("delfile fail, bucket="+bucket+",file="+filepath+str(ret.get('message'))) + return ret['code'] + if (ret['code'] == 0): + stat.addDelFileSuccNum() + msg = "delfile success, bucket="+bucket+",file="+filepath + cos_log.info(msg) + return 0 + +#递归文件夹进行文件删除 +def delete_r(cos_client, bucket, path, thread_pool_file): + global stat + global config + global cos_log + cos_log.debug("delete_r bucket:"+bucket+",path:"+path) + context = u"" + #递归文件夹 + while True: + listfolderreq = ListFolderRequest(bucket, path, 1000, u'', context) + retry = 0 + while (retry < MAX_RETRY_TIMES): + listret = cos_client.list_folder(listfolderreq) + if listret['code'] != 0 : + retry += 1 + sleep(random.randint(1,3)) + continue + else: + break + if (listret['code'] != 0): + #cos_log.error("delete_r: list folder fail:"+path +",return msg:"+ listret['message']) + cos_log.error("delete_r: list folder fail:"+path +",return msg:"+ str(listret.get('message'))) + return listret['code'] + if (len(listret['data']['infos']) == 0): + break; + filelist = [] + dirlist = [] + for info in listret['data']['infos']: + fullname = path + info['name'] + #list出来的文件列表中文件夹和文件本身是混杂一起的 + if info.has_key('filesize'): + filelist.append(fullname) + if (len(filelist) >= ONE_TASK_DEL_FILE_NUMS): + args = [cos_client, bucket, filelist] + args_tuple = (args,None) + args_list = [args_tuple] + requests = threadpool.makeRequests(delfiles, args_list) + for req in requests: + thread_pool_file.putRequest(req) + filelist = [] + continue + else: + pass + else: + dirlist.append(fullname) + if (len(dirlist) >= ONE_TASK_DEL_FILE_NUMS): + args = [cos_client, bucket, dirlist] + args_tuple = (args,None) + args_list = [args_tuple] + requests = threadpool.makeRequests(delfolders, args_list) + for req in requests: + thread_pool_file.putRequest(req) + dirlist = [] + continue + else: + pass + pass + + if (len(filelist) > 0): + args = [cos_client, bucket, filelist] + args_tuple = (args,None) + args_list = [args_tuple] + requests = threadpool.makeRequests(delfiles, args_list) + for req in requests: + thread_pool_file.putRequest(req) + filelist = [] + else: + pass + + if (len(dirlist) > 0): + args = [cos_client, bucket, dirlist] + args_tuple = (args,None) + args_list = [args_tuple] + requests = threadpool.makeRequests(delfolders, args_list) + for req in requests: + thread_pool_file.putRequest(req) + filelist = [] + else: + pass + + cos_log.debug("delete_r thread pool file waiting\n") + thread_pool_file.wait() + cos_log.debug("delete_r thread pool file waiting end\n") + + if (listret['data']['listover'] == False): + context = listret['data']['context'] + continue + else: + break + + stat.logStat() + return 0 + +#支持Ctrl+C终止程序 +class Watcher(): + def __init__(self): + self.child = os.fork() + if self.child == 0: + return + else: + self.watch() + + def watch(self): + global cos_log + try: + os.wait() + except KeyboardInterrupt: + cos_log.ERROR("ctrl+c terminated coscmd, exiting...") + self.kill() + sys.exit() + def kill(self): + try: + os.kill(self.child, signal.SIGKILL) + except OSError: + pass + +def cmd_rm(COSDIR): + global thread_pool + global cos_log + global stat + cos_log = loginit() + stat = FileStat() + timestat = TimeStat() + if HAS_FORK: + Watcher() + path = COSDIR.decode('utf-8') + thread_pool_dir = threadpool.ThreadPool(dir_thread_num) + thread_pool_file = threadpool.ThreadPool(file_thread_num) + cos_log.debug("bucket:"+bucket +",path:"+path) + args = [cos_client, bucket, path, thread_pool_file] + args_tuple = (args, None) + args_list = [args_tuple] + requests = threadpool.makeRequests(delete_r, args_list) + for req in requests: + thread_pool_dir.putRequest(req) + + cos_log.debug("thread_pool_dir waiting.....\n") + thread_pool_dir.wait() + thread_pool_dir.dismissWorkers(dir_thread_num, True) + cos_log.debug("thread_pool_dir wait end.....\n") + + timestat.end() + stat.logStat() + +if sys.argv[1] in ['config','ls','mkdir','put','rm','delete','del'] and len(sys.argv) >= 3: + if sys.argv[1] == 'config': + parser = OptionParser() + parser.add_option("-a", "--appid", dest="appid", help="specify appid") + parser.add_option("-i", "--id", dest="secret_id", help="specify secret id") + parser.add_option("-k", "--key", dest="secret_key", help="specify secret key") + parser.add_option("-r", "--region", dest="region", help="specify region") + parser.add_option("-b", "--bucket", dest="bucket", help="specify bucket") + (options, args) = parser.parse_args() + CMD_LIST['config'] = cmd_configure + CMD_LIST['config'](args, options) + if sys.argv[1] == 'ls': + cmd_loadconfigure() + cos_client = CosClient(appid, secret_id, secret_key, region) + COSDIR = sys.argv[2] + cmd_lsdir(COSDIR) + if sys.argv[1] == 'mkdir': + cmd_loadconfigure() + cos_client = CosClient(appid, secret_id, secret_key, region) + COSDIR = sys.argv[2] + cmd_mkdir(COSDIR) + if sys.argv[1] == 'put' and len(sys.argv) == 4: + cmd_loadconfigure() + cos_client = CosClient(appid, secret_id, secret_key, region) + LOCALFILE = sys.argv[2] + COSFILE = sys.argv[3] + cmd_put(LOCALFILE,COSFILE) + if sys.argv[1] in ('rm','delete','del'): + cmd_loadconfigure() + cos_client = CosClient(appid, secret_id, secret_key, region) + COSDIR = sys.argv[2] + path = COSDIR.decode('utf-8') + cmd_rm(path) +else: + print(HELP) + exit() diff --git a/tools/db_bk.sh b/tools/db_bk.sh index 2bab1c86..f9b989c7 100755 --- a/tools/db_bk.sh +++ b/tools/db_bk.sh @@ -1,37 +1,40 @@ #!/bin/bash # Author: yeho -# BLOG: https://linuxeye.com +# BLOG: https://blog.linuxeye.com # +# Notes: OneinStack for CentOS/RadHat 5+ Debian 6+ and Ubuntu 12+ # +# Project home page: +# https://oneinstack.com +# https://github.com/lj2007331/oneinstack . ../options.conf . ../include/check_dir.sh DBname=$1 -LogFile=${backup_dir}/db.log -DumpFile=${backup_dir}/DB_${DBname}_$(date +%Y%m%d_%H%M%S).sql -NewFile=${backup_dir}/DB_${DBname}_$(date +%Y%m%d_%H%M%S).tgz -OldFile=${backup_dir}/DB_${DBname}_$(date +%Y%m%d --date="${expired_days} days ago")*.tgz +LogFile=$backup_dir/db.log +DumpFile=$backup_dir/DB_${DBname}_$(date +%Y%m%d_%H).sql +NewFile=$backup_dir/DB_${DBname}_$(date +%Y%m%d_%H).tgz +OldFile=$backup_dir/DB_${DBname}_$(date +%Y%m%d --date="$expired_days days ago")*.tgz -[ ! -e "${backup_dir}" ] && mkdir -p ${backup_dir} +[ ! -e "$backup_dir" ] && mkdir -p $backup_dir -DB_tmp=`${db_install_dir}/bin/mysql -uroot -p${dbrootpwd} -e "show databases\G" | grep ${DBname}` -[ -z "${DB_tmp}" ] && { echo "[${DBname}] not exist" >> ${LogFile} ; exit 1 ; } +DB_tmp=`$db_install_dir/bin/mysql -uroot -p$dbrootpwd -e "show databases\G" | grep $DBname` +[ -z "$DB_tmp" ] && { echo "[$DBname] not exist" >> $LogFile ; exit 1 ; } -if [ -n "`ls ${OldFile} 2>/dev/null`" ]; then - rm -f ${OldFile} - echo "[${OldFile}] Delete Old File Success" >> ${LogFile} +if [ -n "`ls $OldFile 2>/dev/null`" ];then + /bin/rm -f $OldFile + echo "[$OldFile] Delete Old File Success" >> $LogFile else - echo "[${OldFile}] Delete Old Backup File" >> ${LogFile} + echo "[$OldFile] Delete Old Backup File" >> $LogFile fi -if [ -e "${NewFile}" ]; then - echo "[${NewFile}] The Backup File is exists, Can't Backup" >> ${LogFile} +if [ -e "$NewFile" ];then + echo "[$NewFile] The Backup File is exists, Can't Backup" >> $LogFile else - ${db_install_dir}/bin/mysqldump -uroot -p${dbrootpwd} ${DBname} > ${DumpFile} - pushd ${backup_dir} > /dev/null - tar czf ${NewFile} ${DumpFile##*/} >> ${LogFile} 2>&1 - echo "[${NewFile}] Backup success ">> ${LogFile} - rm -f ${DumpFile} - popd > /dev/null + $db_install_dir/bin/mysqldump -uroot -p$dbrootpwd --databases $DBname > $DumpFile + cd $backup_dir + tar czf $NewFile ${DumpFile##*/} >> $LogFile 2>&1 + echo "[$NewFile] Backup success ">> $LogFile + /bin/rm -f $DumpFile fi diff --git a/tools/mabs.sh b/tools/mabs.sh index c386a995..b7a33890 100755 --- a/tools/mabs.sh +++ b/tools/mabs.sh @@ -1,6 +1,6 @@ #!/bin/bash # Author: yeho -# Blog: http://linuxeye.com +# Blog: http://blog.linuxeye.com ###################### proc defination ######################## # ignore rule @@ -26,7 +26,7 @@ ignore_init() { fi } -show_ver() { +show_version() { echo "version: 1.0" echo "updated date: 2014-06-08" } @@ -63,7 +63,7 @@ while :; do show_usage; exit 0 ;; -v|-V|--version) - show_ver; exit 0 + show_version; exit 0 ;; -l|--iplist) IPLIST=$2; shift 2 @@ -112,8 +112,8 @@ do while read IP PORT USER PASSWD PASSWD_2ND PASSWD_3RD PASSWD_4TH OTHERS # while read Line do - #[ -z "`echo $IP | grep -E '^[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}|CNS'`" ] && continue - if [ "$(../include/ois.${ARCH} conn_port --host ${IP} --port ${PORT})" == "false" ]; then + [ -z "`echo $IP | grep -E '^[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}|CNS'`" ] && continue + if [ "`python ./ckssh.py $IP $PORT`" == 'no' ]; then [ ! -e ipnologin.txt ] && > ipnologin.txt [ -z "`grep $IP ipnologin.txt | grep $(date +%F)`" ] && echo "`date +%F_%H%M` $IP" >> ipnologin.txt continue diff --git a/tools/mscp.exp b/tools/mscp.exp index 3a93a04a..ae7c4dde 100755 --- a/tools/mscp.exp +++ b/tools/mscp.exp @@ -70,7 +70,7 @@ for {} {1} {} { break; } - "yes/no" { + "yes/no)?" { set yesnoflag 1 send "yes\r" break; diff --git a/tools/mssh.exp b/tools/mssh.exp index 95eeb83b..194006f8 100755 --- a/tools/mssh.exp +++ b/tools/mssh.exp @@ -91,7 +91,7 @@ if { $yesnoflag == 1 } { send "$passwd\r" } - "yes/no" { + "yes/no)?" { set yesnoflag 2 send "yes\r" } diff --git a/tools/thread.sh b/tools/thread.sh index 27fb0dd4..0c126ebc 100755 --- a/tools/thread.sh +++ b/tools/thread.sh @@ -1,6 +1,6 @@ #!/bin/bash # Author: yeho -# Blog: http://linuxeye.com +# Blog: http://blog.linuxeye.com # Default Parameters myIFS=":::" diff --git a/tools/website_bk.sh b/tools/website_bk.sh index f6f8a15b..800a673b 100755 --- a/tools/website_bk.sh +++ b/tools/website_bk.sh @@ -1,34 +1,38 @@ #!/bin/bash # Author: yeho -# BLOG: https://linuxeye.com +# BLOG: https://blog.linuxeye.com # +# Notes: OneinStack for CentOS/RadHat 5+ Debian 6+ and Ubuntu 12+ # +# Project home page: +# https://oneinstack.com +# https://github.com/lj2007331/oneinstack . ../options.conf WebSite=$1 -LogFile=${backup_dir}/web.log -NewFile=${backup_dir}/Web_${WebSite}_$(date +%Y%m%d_%H).tgz -OldFile=${backup_dir}/Web_${WebSite}_$(date +%Y%m%d --date="${expired_days} days ago")*.tgz -[ ! -e "${backup_dir}" ] && mkdir -p ${backup_dir} -[ ! -e "${wwwroot_dir}/${WebSite}" ] && { echo "[${wwwroot_dir}/${WebSite}] not exist" >> ${LogFile} ; exit 1 ; } +LogFile=$backup_dir/web.log +NewFile=$backup_dir/Web_${WebSite}_$(date +%Y%m%d_%H).tgz +OldFile=$backup_dir/Web_${WebSite}_$(date +%Y%m%d --date="$expired_days days ago")*.tgz +[ ! -e "$backup_dir" ] && mkdir -p $backup_dir +[ ! -e "$wwwroot_dir/$WebSite" ] && { echo "[$wwwroot_dir/$WebSite] not exist" >> $LogFile ; exit 1 ; } -if [ `du -sm "${wwwroot_dir}/${WebSite}" | awk '{print $1}'` -lt 1024 ]; then - if [ -n "`ls ${OldFile} 2>/dev/null`" ]; then - rm -f ${OldFile} - echo "[${OldFile}] Delete Old File Success" >> ${LogFile} +if [ `du -sm "$wwwroot_dir/$WebSite" | awk '{print $1}'` -lt 1024 ];then + if [ -n "`ls $OldFile 2>/dev/null`" ];then + /bin/rm -f $OldFile + echo "[$OldFile] Delete Old File Success" >> $LogFile else - echo "[${OldFile}] Delete Old Backup File" >> ${LogFile} + echo "[$OldFile] Delete Old Backup File" >> $LogFile fi - if [ -e "${NewFile}" ]; then - echo "[${NewFile}] The Backup File is exists, Can't Backup" >> ${LogFile} + if [ -e "$NewFile" ];then + echo "[$NewFile] The Backup File is exists, Can't Backup" >> $LogFile else - pushd ${wwwroot_dir} > /dev/null - tar czf ${NewFile} ./${WebSite} >> ${LogFile} 2>&1 - echo "[${NewFile}] Backup success ">> ${LogFile} + pushd $wwwroot_dir > /dev/null + tar czf $NewFile ./${WebSite} >> $LogFile 2>&1 + echo "[$NewFile] Backup success ">> $LogFile popd > /dev/null fi else - rsync -crazP --delete ${wwwroot_dir}/${WebSite} ${backup_dir} + rsync -crazP --delete $wwwroot_dir/$WebSite $backup_dir fi diff --git a/uninstall.sh b/uninstall.sh index d537c5f4..a0c7377a 100755 --- a/uninstall.sh +++ b/uninstall.sh @@ -1,612 +1,218 @@ #!/bin/bash # Author: yeho -# BLOG: https://linuxeye.com +# BLOG: https://blog.linuxeye.com # +# Notes: OneinStack for CentOS/RadHat 5+ Debian 6+ and Ubuntu 12+ # +# Project home page: +# https://oneinstack.com +# https://github.com/lj2007331/oneinstack export PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin clear printf " ####################################################################### -# Uninstall # +# OneinStack for CentOS/RadHat 5+ Debian 6+ and Ubuntu 12+ # +# Uninstall OneinStack # +# For more information please visit https://oneinstack.com # ####################################################################### " -# Check if user is root -[ $(id -u) != "0" ] && { echo "${CFAILURE}Error: You must be root to run this script${CEND}"; exit 1; } -current_dir=$(dirname "`readlink -f $0`") -pushd ${current_dir} > /dev/null . ./options.conf . ./include/color.sh . ./include/get_char.sh . ./include/check_dir.sh -Show_Help() { - echo - echo "Usage: $0 command ...[parameters].... - --quiet, -q quiet operation - --all Uninstall All - --web Uninstall Nginx/Tengine/OpenResty/Apache/Tomcat - --mysql Uninstall MySQL/MariaDB/Percona - --postgresql Uninstall PostgreSQL - --mongodb Uninstall MongoDB - --php Uninstall PHP (PATH: ${php_install_dir}) - --mphp_ver [53~84] Uninstall another PHP version (PATH: ${php_install_dir}\${mphp_ver}) - --allphp Uninstall all PHP - --phpcache Uninstall PHP opcode cache - --php_extensions [ext name] Uninstall PHP extensions, include zendguardloader,ioncube, - sourceguardian,imagick,gmagick,fileinfo,imap,ldap,calendar,phalcon, - yaf,yar,redis,memcached,memcache,mongodb,swoole,xdebug - --pureftpd Uninstall PureFtpd - --redis Uninstall Redis-server - --memcached Uninstall Memcached-server - --phpmyadmin Uninstall phpMyAdmin - --nodejs Uninstall Nodejs (PATH: ${nodejs_install_dir}) - " -} +# Check if user is root +[ $(id -u) != "0" ] && { echo "${CFAILURE}Error: You must be root to run this script${CEND}"; exit 1; } -ARG_NUM=$# -TEMP=`getopt -o hvVq --long help,version,quiet,all,web,mysql,postgresql,mongodb,php,mphp_ver:,allphp,phpcache,php_extensions:,pureftpd,redis,memcached,phpmyadmin,nodejs -- "$@" 2>/dev/null` -[ $? != 0 ] && echo "${CWARNING}ERROR: unknown argument! ${CEND}" && Show_Help && exit 1 -eval set -- "${TEMP}" -while :; do - [ -z "$1" ] && break; - case "$1" in - -h|--help) - Show_Help; exit 0 - ;; - -q|--quiet) - quiet_flag=y - uninstall_flag=y - shift 1 - ;; - --all) - all_flag=y - web_flag=y - mysql_flag=y - postgresql_flag=y - mongodb_flag=y - allphp_flag=y - nodejs_flag=y - pureftpd_flag=y - redis_flag=y - memcached_flag=y - phpmyadmin_flag=y - shift 1 - ;; - --web) - web_flag=y; shift 1 - ;; - --mysql) - mysql_flag=y; shift 1 - ;; - --postgresql) - postgresql_flag=y; shift 1 - ;; - --mongodb) - mongodb_flag=y; shift 1 - ;; - --php) - php_flag=y; shift 1 - ;; - --mphp_ver) - mphp_ver=$2; mphp_flag=y; shift 2 - [[ ! "${mphp_ver}" =~ ^5[3-6]$|^7[0-4]$|^8[0-4]$ ]] && { echo "${CWARNING}mphp_ver input error! Please only input number 53~84${CEND}"; exit 1; } - ;; - --allphp) - allphp_flag=y; shift 1 - ;; - --phpcache) - phpcache_flag=y; shift 1 - ;; - --php_extensions) - php_extensions=$2; shift 2 - [ -n "`echo ${php_extensions} | grep -w zendguardloader`" ] && pecl_zendguardloader=1 - [ -n "`echo ${php_extensions} | grep -w ioncube`" ] && pecl_ioncube=1 - [ -n "`echo ${php_extensions} | grep -w sourceguardian`" ] && pecl_sourceguardian=1 - [ -n "`echo ${php_extensions} | grep -w imagick`" ] && pecl_imagick=1 - [ -n "`echo ${php_extensions} | grep -w gmagick`" ] && pecl_gmagick=1 - [ -n "`echo ${php_extensions} | grep -w fileinfo`" ] && pecl_fileinfo=1 - [ -n "`echo ${php_extensions} | grep -w imap`" ] && pecl_imap=1 - [ -n "`echo ${php_extensions} | grep -w ldap`" ] && pecl_ldap=1 - [ -n "`echo ${php_extensions} | grep -w calendar`" ] && pecl_calendar=1 - [ -n "`echo ${php_extensions} | grep -w phalcon`" ] && pecl_phalcon=1 - [ -n "`echo ${php_extensions} | grep -w yaf`" ] && pecl_yaf=1 - [ -n "`echo ${php_extensions} | grep -w yar`" ] && pecl_yar=1 - [ -n "`echo ${php_extensions} | grep -w redis`" ] && pecl_redis=1 - [ -n "`echo ${php_extensions} | grep -w memcached`" ] && pecl_memcached=1 - [ -n "`echo ${php_extensions} | grep -w memcache`" ] && pecl_memcache=1 - [ -n "`echo ${php_extensions} | grep -w mongodb`" ] && pecl_mongodb=1 - [ -n "`echo ${php_extensions} | grep -w swoole`" ] && pecl_swoole=1 - [ -n "`echo ${php_extensions} | grep -w xdebug`" ] && pecl_xdebug=1 - ;; - --nodejs) - nodejs_flag=y; shift 1 - ;; - --pureftpd) - pureftpd_flag=y; shift 1 - ;; - --redis) - redis_flag=y; shift 1 - ;; - --memcached) - memcached_flag=y; shift 1 - ;; - --phpmyadmin) - phpmyadmin_flag=y; shift 1 - ;; - --) - shift - ;; - *) - echo "${CWARNING}ERROR: unknown argument! ${CEND}" && Show_Help && exit 1 - ;; - esac -done + +Usage(){ + printf " +Usage: $0 [ ${CMSG}all${CEND} | ${CMSG}web${CEND} | ${CMSG}db${CEND} | ${CMSG}php${CEND} | ${CMSG}hhvm${CEND} | ${CMSG}pureftpd${CEND} | ${CMSG}redis${CEND} | ${CMSG}memcached${CEND} ] +${CMSG}all${CEND} --->Uninstall All +${CMSG}web${CEND} --->Uninstall Nginx/Tengine/Apache/Tomcat +${CMSG}db${CEND} --->Uninstall MySQL/MariaDB/Percona/AliSQL +${CMSG}php${CEND} --->Uninstall PHP +${CMSG}hhvm${CEND} --->Uninstall HHVM +${CMSG}pureftpd${CEND} --->Uninstall PureFtpd +${CMSG}redis${CEND} --->Uninstall Redis +${CMSG}memcached${CEND} --->Uninstall Memcached + +" +} Uninstall_status() { - if [ "${quiet_flag}" != 'y' ]; then - while :; do echo - read -e -p "Do you want to uninstall? [y/n]: " uninstall_flag - if [[ ! ${uninstall_flag} =~ ^[y,n]$ ]]; then - echo "${CWARNING}input error! Please only input 'y' or 'n'${CEND}" - else - break - fi - done - fi + while :; do echo + read -p "Do you want to uninstall? [y/n]: " uninstall_yn + echo + if [[ ! ${uninstall_yn} =~ ^[y,n]$ ]]; then + echo "${CWARNING}input error! Please only input 'y' or 'n'${CEND}" + else + break + fi + done } Print_Warn() { echo - echo "${CWARNING}You will uninstall lnmp, Please backup your configure files and DB data! ${CEND}" + echo "${CWARNING}You will uninstall OneinStack, Please backup your configure files and DB data! ${CEND}" } Print_web() { - [ -d "${nginx_install_dir}" ] && echo ${nginx_install_dir} - [ -d "${tengine_install_dir}" ] && echo ${tengine_install_dir} - [ -d "${openresty_install_dir}" ] && echo ${openresty_install_dir} - [ -e "/etc/init.d/nginx" ] && echo /etc/init.d/nginx - [ -e "/lib/systemd/system/nginx.service" ] && echo /lib/systemd/system/nginx.service - [ -e "/etc/logrotate.d/nginx" ] && echo /etc/logrotate.d/nginx - - [ -d "${apache_install_dir}" ] && echo ${apache_install_dir} - [ -e "/lib/systemd/system/httpd.service" ] && echo /lib/systemd/system/httpd.service - [ -e "/etc/init.d/httpd" ] && echo /etc/init.d/httpd - [ -e "/etc/logrotate.d/apache" ] && echo /etc/logrotate.d/apache - - [ -d "${tomcat_install_dir}" ] && echo ${tomcat_install_dir} - [ -e "/etc/init.d/tomcat" ] && echo /etc/init.d/tomcat - [ -e "/etc/logrotate.d/tomcat" ] && echo /etc/logrotate.d/tomcat - [ -d "/usr/java" ] && echo /usr/java - [ -d "${apr_install_dir}" ] && echo ${apr_install_dir} + [ -d "${nginx_install_dir}" ] && echo "${nginx_install_dir}" + [ -d "${tengine_install_dir}" ] && echo "${tengine_install_dir}" + [ -d "${openresty_install_dir}" ] && echo "${openresty_install_dir}" + [ -e "/etc/init.d/nginx" ] && echo '/etc/init.d/nginx' + [ -e "/etc/logrotate.d/nginx" ] && echo '/etc/logrotate.d/nginx' + + [ -d "${apache_install_dir}" ] && echo "${apache_install_dir}" + [ -e "/etc/init.d/httpd" ] && echo "/etc/init.d/httpd" + [ -e "/etc/logrotate.d/apache" ] && echo "/etc/logrotate.d/apache" + + [ -d "${tomcat_install_dir}" ] && echo "${tomcat_install_dir}" + [ -e "/etc/init.d/tomcat" ] && echo "/etc/init.d/tomcat" + [ -e "/etc/logrotate.d/tomcat" ] && echo "/etc/logrotate.d/tomcat" + [ -d "/usr/java" ] && echo '/usr/java' + [ -d "/usr/local/apr" ] && echo '/usr/local/apr' + [ -d "${openssl_install_dir}" ] && echo "${openssl_install_dir}" } Uninstall_Web() { - [ -d "${nginx_install_dir}" ] && { killall nginx > /dev/null 2>&1; rm -rf ${nginx_install_dir} /etc/init.d/nginx /etc/logrotate.d/nginx; sed -i "s@${nginx_install_dir}/sbin:@@" /etc/profile; echo "${CMSG}Nginx uninstall completed! ${CEND}"; } - [ -d "${tengine_install_dir}" ] && { killall nginx > /dev/null 2>&1; rm -rf ${tengine_install_dir} /etc/init.d/nginx /etc/logrotate.d/nginx; sed -i "s@${tengine_install_dir}/sbin:@@" /etc/profile; echo "${CMSG}Tengine uninstall completed! ${CEND}"; } - [ -d "${openresty_install_dir}" ] && { killall nginx > /dev/null 2>&1; rm -rf ${openresty_install_dir} /etc/init.d/nginx /etc/logrotate.d/nginx; sed -i "s@${openresty_install_dir}/nginx/sbin:@@" /etc/profile; echo "${CMSG}OpenResty uninstall completed! ${CEND}"; } - [ -e "/lib/systemd/system/nginx.service" ] && { systemctl disable nginx > /dev/null 2>&1; rm -f /lib/systemd/system/nginx.service; } - [ -d "${apache_install_dir}" ] && { service httpd stop > /dev/null 2>&1; rm -rf ${apache_install_dir} /etc/init.d/httpd /etc/logrotate.d/apache; sed -i "s@${apache_install_dir}/bin:@@" /etc/profile; echo "${CMSG}Apache uninstall completed! ${CEND}"; } - [ -e "/lib/systemd/system/httpd.service" ] && { systemctl disable httpd > /dev/null 2>&1; rm -f /lib/systemd/system/httpd.service; } - [ -d "${tomcat_install_dir}" ] && { killall java > /dev/null 2>&1; rm -rf ${tomcat_install_dir} /etc/init.d/tomcat /etc/logrotate.d/tomcat; echo "${CMSG}Tomcat uninstall completed! ${CEND}"; } + [ -d "${nginx_install_dir}" ] && { killall nginx > /dev/null 2>&1; rm -rf ${nginx_install_dir} /etc/init.d/nginx /etc/logrotate.d/nginx; sed -i "s@${nginx_install_dir}/sbin:@@" /etc/profile; } + [ -d "${tengine_install_dir}" ] && { killall nginx > /dev/null 2>&1; rm -rf ${tengine_install_dir} /etc/init.d/nginx /etc/logrotate.d/nginx; sed -i "s@${tengine_install_dir}/sbin:@@" /etc/profile; } + [ -d "${openresty_install_dir}" ] && { killall nginx > /dev/null 2>&1; rm -rf ${openresty_install_dir} /etc/init.d/nginx /etc/logrotate.d/nginx; sed -i "s@${openresty_install_dir}/nginx/sbin:@@" /etc/profile; } + [ -d "${apache_install_dir}" ] && { service httpd stop > /dev/null 2>&1; rm -rf ${apache_install_dir} /etc/init.d/httpd /etc/logrotate.d/apache; sed -i "s@${apache_install_dir}/bin:@@" /etc/profile; } + [ -d "${tomcat_install_dir}" ] && { killall java > /dev/null 2>&1; chmod +x /etc/logrotate.d/tomcat; rm -rf ${tomcat_install_dir} /etc/init.d/tomcat /etc/logrotate.d/tomcat /usr/local/apr; } [ -d "/usr/java" ] && { rm -rf /usr/java; sed -i '/export JAVA_HOME=/d' /etc/profile; sed -i '/export CLASSPATH=/d' /etc/profile; sed -i 's@\$JAVA_HOME/bin:@@' /etc/profile; } + [ -d "${openssl_install_dir}" ] && rm -rf ${openssl_install_dir} [ -e "${wwwroot_dir}" ] && /bin/mv ${wwwroot_dir}{,$(date +%Y%m%d%H)} sed -i 's@^website_name=.*@website_name=@' ./options.conf - sed -i 's@^backup_content=.*@backup_content=@' ./options.conf - [ -d "${apr_install_dir}" ] && rm -rf ${apr_install_dir} -} - -Print_MySQL() { - [ -e "${db_install_dir}" ] && echo ${db_install_dir} - [ -e "/etc/init.d/mysqld" ] && echo /etc/init.d/mysqld - [ -e "/etc/my.cnf" ] && echo /etc/my.cnf + sed -i 's@^local_bankup_yn=.*@local_bankup_yn=y@' ./options.conf + sed -i 's@^remote_bankup_yn=.*@remote_bankup_yn=n@' ./options.conf + echo "${CMSG}Web uninstall completed${CEND}" } -Print_PostgreSQL() { - [ -e "${pgsql_install_dir}" ] && echo ${pgsql_install_dir} - [ -e "/etc/init.d/postgresql" ] && echo /etc/init.d/postgresql - [ -e "/lib/systemd/system/postgresql.service" ] && echo /lib/systemd/system/postgresql.service +Print_DB() { + [ -e "${db_install_dir}" ] && echo "${db_install_dir}" + [ -e "/etc/init.d/mysqld" ] && echo "/etc/init.d/mysqld" + [ -e "/etc/my.cnf" ] && echo "/etc/my.cnf" } -Print_MongoDB() { - [ -e "${mongo_install_dir}" ] && echo ${mongo_install_dir} - [ -e "/etc/init.d/mongod" ] && echo /etc/init.d/mongod - [ -e "/lib/systemd/system/mongod.service" ] && echo /lib/systemd/system/mongod.service - [ -e "/etc/mongod.conf" ] && echo /etc/mongod.conf -} - -Uninstall_MySQL() { - # uninstall mysql,mariadb,percona - if [ -d "${db_install_dir}/support-files" ]; then - service mysqld stop > /dev/null 2>&1 - rm -rf ${db_install_dir} /etc/init.d/mysqld /etc/my.cnf* /etc/ld.so.conf.d/*{mysql,mariadb,percona}*.conf - id -u mysql >/dev/null 2>&1 ; [ $? -eq 0 ] && userdel mysql - [ -e "${db_data_dir}" ] && /bin/mv ${db_data_dir}{,$(date +%Y%m%d%H)} - sed -i 's@^dbrootpwd=.*@dbrootpwd=@' ./options.conf - sed -i "s@${db_install_dir}/bin:@@" /etc/profile - echo "${CMSG}MySQL uninstall completed! ${CEND}" - fi -} - -Uninstall_PostgreSQL() { - # uninstall postgresql - if [ -e "${pgsql_install_dir}/bin/psql" ]; then - service postgresql stop > /dev/null 2>&1 - rm -rf ${pgsql_install_dir} /etc/init.d/postgresql - [ -e "/lib/systemd/system/postgresql.service" ] && { systemctl disable postgresql > /dev/null 2>&1; rm -f /lib/systemd/system/postgresql.service; } - [ -e "${php_install_dir}/etc/php.d/07-pgsql.ini" ] && rm -f ${php_install_dir}/etc/php.d/07-pgsql.ini - id -u postgres >/dev/null 2>&1 ; [ $? -eq 0 ] && userdel postgres - [ -e "${pgsql_data_dir}" ] && /bin/mv ${pgsql_data_dir}{,$(date +%Y%m%d%H)} - sed -i 's@^dbpostgrespwd=.*@dbpostgrespwd=@' ./options.conf - sed -i "s@${pgsql_install_dir}/bin:@@" /etc/profile - echo "${CMSG}PostgreSQL uninstall completed! ${CEND}" - fi -} - -Uninstall_MongoDB() { - # uninstall mongodb - if [ -e "${mongo_install_dir}/bin/mongo" ]; then - service mongod stop > /dev/null 2>&1 - rm -rf ${mongo_install_dir} /etc/mongod.conf /etc/init.d/mongod /tmp/mongo*.sock - [ -e "/lib/systemd/system/mongod.service" ] && { systemctl disable mongod > /dev/null 2>&1; rm -f /lib/systemd/system/mongod.service; } - [ -e "${php_install_dir}/etc/php.d/07-mongo.ini" ] && rm -f ${php_install_dir}/etc/php.d/07-mongo.ini - [ -e "${php_install_dir}/etc/php.d/07-mongodb.ini" ] && rm -f ${php_install_dir}/etc/php.d/07-mongodb.ini - id -u mongod > /dev/null 2>&1 ; [ $? -eq 0 ] && userdel mongod - [ -e "${mongo_data_dir}" ] && /bin/mv ${mongo_data_dir}{,$(date +%Y%m%d%H)} - sed -i 's@^dbmongopwd=.*@dbmongopwd=@' ./options.conf - sed -i "s@${mongo_install_dir}/bin:@@" /etc/profile - echo "${CMSG}MongoDB uninstall completed! ${CEND}" - fi +Uninstall_DB() { + [ -e "${db_install_dir}" ] && { service mysqld stop > /dev/null 2>&1; rm -rf ${db_install_dir} /etc/init.d/mysqld /etc/my.cnf /etc/ld.so.conf.d/{mysql,mariadb,percona,alisql}*.conf; } + id -u mysql >/dev/null 2>&1 ; [ $? -eq 0 ] && userdel mysql + [ -e "${db_data_dir}" ] && /bin/mv ${db_data_dir}{,$(date +%Y%m%d%H)} + sed -i 's@^dbrootpwd=.*@dbrootpwd=@' ./options.conf + sed -i "s@${db_install_dir}/bin:@@" /etc/profile + echo "${CMSG}DB uninstall completed${CEND}" } Print_PHP() { - [ -e "${php_install_dir}" ] && echo ${php_install_dir} - [ -e "/etc/init.d/php-fpm" ] && echo /etc/init.d/php-fpm - [ -e "/lib/systemd/system/php-fpm.service" ] && echo /lib/systemd/system/php-fpm.service -} - -Print_MPHP() { - [ -e "${php_install_dir}${mphp_ver}" ] && echo ${php_install_dir}${mphp_ver} - [ -e "/etc/init.d/php${mphp_ver}-fpm" ] && echo /etc/init.d/php${mphp_ver}-fpm - [ -e "/lib/systemd/system/php${mphp_ver}-fpm.service" ] && echo /lib/systemd/system/php${mphp_ver}-fpm.service -} - -Print_ALLPHP() { - [ -e "${php_install_dir}" ] && echo ${php_install_dir} - [ -e "/etc/init.d/php-fpm" ] && echo /etc/init.d/php-fpm - [ -e "/lib/systemd/system/php-fpm.service" ] && echo /lib/systemd/system/php-fpm.service - for php_ver in 53 54 55 56 70 71 72 73 74 80 81 82 83 84; do - [ -e "${php_install_dir}${php_ver}" ] && echo ${php_install_dir}${php_ver} - [ -e "/etc/init.d/php${php_ver}-fpm" ] && echo /etc/init.d/php${php_ver}-fpm - [ -e "/lib/systemd/system/php${php_ver}-fpm.service" ] && echo /lib/systemd/system/php${php_ver}-fpm.service - done - [ -e "${imagick_install_dir}" ] && echo ${imagick_install_dir} - [ -e "${gmagick_install_dir}" ] && echo ${gmagick_install_dir} - [ -e "${curl_install_dir}" ] && echo ${curl_install_dir} - [ -e "${freetype_install_dir}" ] && echo ${freetype_install_dir} + [ -e "${php_install_dir}" ] && echo "${php_install_dir}" + [ -e "/etc/init.d/php-fpm" ] && echo "/etc/init.d/php-fpm" + [ -e "/usr/local/imagemagick" ] && echo "/usr/local/imagemagick" + [ -e "/usr/local/graphicsmagick" ] && echo '/usr/local/graphicsmagick' + [ -e "/usr/local/openssl100s" ] && echo '/usr/local/openssl100s' } Uninstall_PHP() { - [ -e "/etc/init.d/php-fpm" ] && { service php-fpm stop > /dev/null 2>&1; rm -f /etc/init.d/php-fpm; } - [ -e "/lib/systemd/system/php-fpm.service" ] && { systemctl stop php-fpm > /dev/null 2>&1; systemctl disable php-fpm > /dev/null 2>&1; rm -f /lib/systemd/system/php-fpm.service; } - [ -e "${apache_install_dir}/conf/httpd.conf" ] && [ -n "`grep libphp ${apache_install_dir}/conf/httpd.conf`" ] && sed -i '/libphp/d' ${apache_install_dir}/conf/httpd.conf - [ -e "${php_install_dir}" ] && { rm -rf ${php_install_dir}; echo "${CMSG}PHP uninstall completed! ${CEND}"; } + [ -e "${php_install_dir}/bin/phpize" -a -e "${php_install_dir}/etc/php-fpm.conf" ] && { service php-fpm stop > /dev/null 2>&1; rm -rf ${php_install_dir} /etc/init.d/php-fpm; } + [ -e "${php_install_dir}/bin/phpize" -a ! -e "${php_install_dir}/etc/php-fpm.conf" ] && rm -rf ${php_install_dir} + [ -e "/usr/local/imagemagick" ] && rm -rf /usr/local/imagemagick + [ -e "/usr/local/graphicsmagick" ] && rm -rf /usr/local/graphicsmagick + [ -e "/usr/local/openssl100s" ] && rm -rf /usr/local/openssl100s sed -i "s@${php_install_dir}/bin:@@" /etc/profile + echo "${CMSG}PHP uninstall completed${CEND}" } -Uninstall_MPHP() { - [ -e "/etc/init.d/php${mphp_ver}-fpm" ] && { service php${mphp_ver}-fpm stop > /dev/null 2>&1; rm -f /etc/init.d/php${mphp_ver}-fpm; } - [ -e "/lib/systemd/system/php${mphp_ver}-fpm.service" ] && { systemctl stop php${mphp_ver}-fpm > /dev/null 2>&1; systemctl disable php${mphp_ver}-fpm > /dev/null 2>&1; rm -f /lib/systemd/system/php${mphp_ver}-fpm.service; } - [ -e "${php_install_dir}${mphp_ver}" ] && { rm -rf ${php_install_dir}${mphp_ver}; echo "${CMSG}PHP${mphp_ver} uninstall completed! ${CEND}"; } +Print_HHVM() { + [ -e "/usr/bin/hhvm" ] && echo "/usr/bin/hhvm" + [ -e "/etc/hhvm" ] && echo "/etc/hhvm" + [ -e "/var/log/hhvm" ] && echo "/var/log/hhvm" + [ -e "/etc/supervisord.conf" ] && echo "/etc/supervisord.conf" + [ -e "/etc/init.d/supervisord" ] && echo "/etc/init.d/supervisord" } -Uninstall_ALLPHP() { - [ -e "/etc/init.d/php-fpm" ] && { service php-fpm stop > /dev/null 2>&1; rm -f /etc/init.d/php-fpm; } - [ -e "/lib/systemd/system/php-fpm.service" ] && { systemctl stop php-fpm > /dev/null 2>&1; systemctl disable php-fpm > /dev/null 2>&1; rm -f /lib/systemd/system/php-fpm.service; } - [ -e "${apache_install_dir}/conf/httpd.conf" ] && [ -n "`grep libphp ${apache_install_dir}/conf/httpd.conf`" ] && sed -i '/libphp/d' ${apache_install_dir}/conf/httpd.conf - [ -e "${php_install_dir}" ] && { rm -rf ${php_install_dir}; echo "${CMSG}PHP uninstall completed! ${CEND}"; } - sed -i "s@${php_install_dir}/bin:@@" /etc/profile - for php_ver in 53 54 55 56 70 71 72 73 74 80 81 82 83 84; do - [ -e "/etc/init.d/php${php_ver}-fpm" ] && { service php${php_ver}-fpm stop > /dev/null 2>&1; rm -f /etc/init.d/php${php_ver}-fpm; } - [ -e "/lib/systemd/system/php${php_ver}-fpm.service" ] && { systemctl stop php${php_ver}-fpm > /dev/null 2>&1; systemctl disable php${php_ver}-fpm > /dev/null 2>&1; rm -f /lib/systemd/system/php${php_ver}-fpm.service; } - [ -e "${php_install_dir}${php_ver}" ] && { rm -rf ${php_install_dir}${php_ver}; echo "${CMSG}PHP${php_ver} uninstall completed! ${CEND}"; } - done - [ -e "${imagick_install_dir}" ] && rm -rf ${imagick_install_dir} - [ -e "${gmagick_install_dir}" ] && rm -rf ${gmagick_install_dir} - [ -e "${curl_install_dir}" ] && rm -rf ${curl_install_dir} - [ -e "${freetype_install_dir}" ] && rm -rf ${freetype_install_dir} -} - -Uninstall_PHPcache() { - . include/zendopcache.sh - . include/apcu.sh - . include/eaccelerator.sh - Uninstall_ZendOPcache - Uninstall_APCU - Uninstall_eAccelerator - # reload php - [ -e "${php_install_dir}/sbin/php-fpm" ] && { [ -e "/bin/systemctl" ] && systemctl reload php-fpm || service php-fpm reload; } - [ -n "${mphp_ver}" -a -e "${php_install_dir}${mphp_ver}/sbin/php-fpm" ] && { [ -e "/bin/systemctl" ] && systemctl reload php${mphp_ver}-fpm || service php${mphp_ver}-fpm reload; } - [ -e "${apache_install_dir}/bin/apachectl" ] && ${apache_install_dir}/bin/apachectl -k graceful -} - -Uninstall_PHPext() { - # ZendGuardLoader - if [ "${pecl_zendguardloader}" == '1' ]; then - . include/ZendGuardLoader.sh - Uninstall_ZendGuardLoader - fi - - # ioncube - if [ "${pecl_ioncube}" == '1' ]; then - . include/ioncube.sh - Uninstall_ionCube - fi - - # SourceGuardian - if [ "${pecl_sourceguardian}" == '1' ]; then - . include/sourceguardian.sh - Uninstall_SourceGuardian - fi - - # imagick - if [ "${pecl_imagick}" == '1' ]; then - . include/ImageMagick.sh - Uninstall_ImageMagick - Uninstall_pecl_imagick - fi - - # gmagick - if [ "${pecl_gmagick}" == '1' ]; then - . include/GraphicsMagick.sh - Uninstall_GraphicsMagick - Uninstall_pecl_gmagick - fi - - # fileinfo - if [ "${pecl_fileinfo}" == '1' ]; then - . include/pecl_fileinfo.sh - Uninstall_pecl_fileinfo - fi - - # imap - if [ "${pecl_imap}" == '1' ]; then - . include/pecl_imap.sh - Uninstall_pecl_imap - fi - - # ldap - if [ "${pecl_ldap}" == '1' ]; then - . include/pecl_ldap.sh - Uninstall_pecl_ldap - fi - - # calendar - if [ "${pecl_calendar}" == '1' ]; then - . include/pecl_calendar.sh - Uninstall_pecl_calendar - fi - - # phalcon - if [ "${pecl_phalcon}" == '1' ]; then - . include/pecl_phalcon.sh - Uninstall_pecl_phalcon - fi - - # yaf - if [ "${pecl_yaf}" == '1' ]; then - . include/pecl_yaf.sh - Uninstall_pecl_yaf 2>&1 | tee -a ${current_dir}/install.log - fi - - # yar - if [ "${pecl_yar}" == '1' ]; then - . include/pecl_yar.sh - Uninstall_pecl_yar 2>&1 | tee -a ${current_dir}/install.log - fi - - # pecl_memcached - if [ "${pecl_memcached}" == '1' ]; then - . include/memcached.sh - Uninstall_pecl_memcached - fi - - # pecl_memcache - if [ "${pecl_memcache}" == '1' ]; then - . include/memcached.sh - Uninstall_pecl_memcache - fi - - # pecl_redis - if [ "${pecl_redis}" == '1' ]; then - . include/redis.sh - Uninstall_pecl_redis - fi - - # pecl_mongodb - if [ "${pecl_mongodb}" == '1' ]; then - . include/pecl_mongodb.sh - Uninstall_pecl_mongodb - fi - - # swoole - if [ "${pecl_swoole}" == '1' ]; then - . include/pecl_swoole.sh - Uninstall_pecl_swoole - fi - - # xdebug - if [ "${pecl_xdebug}" == '1' ]; then - . include/pecl_xdebug.sh - Uninstall_pecl_xdebug - fi - - # reload php - [ -e "${php_install_dir}/sbin/php-fpm" ] && { [ -e "/bin/systemctl" ] && systemctl reload php-fpm || service php-fpm reload; } - [ -n "${mphp_ver}" -a -e "${php_install_dir}${mphp_ver}/sbin/php-fpm" ] && { [ -e "/bin/systemctl" ] && systemctl reload php${mphp_ver}-fpm || service php${mphp_ver}-fpm reload; } - [ -e "${apache_install_dir}/bin/apachectl" ] && ${apache_install_dir}/bin/apachectl -k graceful -} - -Menu_PHPext() { - while :; do - echo 'Please select uninstall PHP extensions:' - echo -e "\t${CMSG} 0${CEND}. Do not uninstall" - echo -e "\t${CMSG} 1${CEND}. Uninstall zendguardloader(PHP<=5.6)" - echo -e "\t${CMSG} 2${CEND}. Uninstall ioncube" - echo -e "\t${CMSG} 3${CEND}. Uninstall sourceguardian(PHP<=7.2)" - echo -e "\t${CMSG} 4${CEND}. Uninstall imagick" - echo -e "\t${CMSG} 5${CEND}. Uninstall gmagick" - echo -e "\t${CMSG} 6${CEND}. Uninstall fileinfo" - echo -e "\t${CMSG} 7${CEND}. Uninstall imap" - echo -e "\t${CMSG} 8${CEND}. Uninstall ldap" - echo -e "\t${CMSG} 9${CEND}. Uninstall phalcon(PHP>=5.5)" - echo -e "\t${CMSG}10${CEND}. Uninstall redis" - echo -e "\t${CMSG}11${CEND}. Uninstall memcached" - echo -e "\t${CMSG}12${CEND}. Uninstall memcache" - echo -e "\t${CMSG}13${CEND}. Uninstall mongodb" - echo -e "\t${CMSG}14${CEND}. Uninstall swoole" - echo -e "\t${CMSG}15${CEND}. Uninstall xdebug(PHP>=5.5)" - read -e -p "Please input a number:(Default 0 press Enter) " phpext_option - phpext_option=${phpext_option:-0} - [ "${phpext_option}" == '0' ] && break - array_phpext=(${phpext_option}) - array_all=(1 2 3 4 5 6 7 8 9 10 11 12 13 14 15) - for v in ${array_phpext[@]} - do - [ -z "`echo ${array_all[@]} | grep -w ${v}`" ] && phpext_flag=1 - done - if [ "${phpext_flag}" == '1' ]; then - unset phpext_flag - echo; echo "${CWARNING}input error! Please only input number 1 2 3 14 and so on${CEND}"; echo - continue - else - [ -n "`echo ${array_phpext[@]} | grep -w 1`" ] && pecl_zendguardloader=1 - [ -n "`echo ${array_phpext[@]} | grep -w 2`" ] && pecl_ioncube=1 - [ -n "`echo ${array_phpext[@]} | grep -w 3`" ] && pecl_sourceguardian=1 - [ -n "`echo ${array_phpext[@]} | grep -w 4`" ] && pecl_imagick=1 - [ -n "`echo ${array_phpext[@]} | grep -w 5`" ] && pecl_gmagick=1 - [ -n "`echo ${array_phpext[@]} | grep -w 6`" ] && pecl_fileinfo=1 - [ -n "`echo ${array_phpext[@]} | grep -w 7`" ] && pecl_imap=1 - [ -n "`echo ${array_phpext[@]} | grep -w 8`" ] && pecl_ldap=1 - [ -n "`echo ${array_phpext[@]} | grep -w 9`" ] && pecl_phalcon=1 - [ -n "`echo ${array_phpext[@]} | grep -w 10`" ] && pecl_redis=1 - [ -n "`echo ${array_phpext[@]} | grep -w 11`" ] && pecl_memcached=1 - [ -n "`echo ${array_phpext[@]} | grep -w 12`" ] && pecl_memcache=1 - [ -n "`echo ${array_phpext[@]} | grep -w 13`" ] && pecl_mongodb=1 - [ -n "`echo ${array_phpext[@]} | grep -w 14`" ] && pecl_swoole=1 - [ -n "`echo ${array_phpext[@]} | grep -w 15`" ] && pecl_xdebug=1 - break - fi - done +Uninstall_HHVM() { + [ -e "/etc/init.d/supervisord" ] && { service supervisord stop > /dev/null 2>&1; rm -rf /etc/supervisord.conf /etc/init.d/supervisord; } + [ -e "/usr/bin/hhvm" ] && { rpm -e hhvm; rm -rf /etc/hhvm /var/log/hhvm /usr/bin/hhvm; } + echo "${CMSG}HHVM uninstall completed${CEND}" } Print_PureFtpd() { - [ -e "${pureftpd_install_dir}" ] && echo ${pureftpd_install_dir} - [ -e "/etc/init.d/pureftpd" ] && echo /etc/init.d/pureftpd - [ -e "/lib/systemd/system/pureftpd.service" ] && echo /lib/systemd/system/pureftpd.service + [ -e "$pureftpd_install_dir" ] && echo "$pureftpd_install_dir" + [ -e "/etc/init.d/pureftpd" ] && echo "/etc/init.d/pureftpd" } Uninstall_PureFtpd() { - [ -e "${pureftpd_install_dir}" ] && { service pureftpd stop > /dev/null 2>&1; rm -rf ${pureftpd_install_dir} /etc/init.d/pureftpd; echo "${CMSG}Pureftpd uninstall completed! ${CEND}"; } - [ -e "/lib/systemd/system/pureftpd.service" ] && { systemctl disable pureftpd > /dev/null 2>&1; rm -f /lib/systemd/system/pureftpd.service; } + [ -e "$pureftpd_install_dir" ] && { service pureftpd stop > /dev/null 2>&1; rm -rf $pureftpd_install_dir /etc/init.d/pureftpd; } + echo "${CMSG}Pureftpd uninstall completed${CEND}" } -Print_Redis_server() { - [ -e "${redis_install_dir}" ] && echo ${redis_install_dir} - [ -e "/etc/init.d/redis-server" ] && echo /etc/init.d/redis-server - [ -e "/lib/systemd/system/redis-server.service" ] && echo /lib/systemd/system/redis-server.service +Print_Redis() { + [ -e "$redis_install_dir" ] && echo "$redis_install_dir" + [ -e "/etc/init.d/redis-server" ] && echo "/etc/init.d/redis-server" } -Uninstall_Redis_server() { - [ -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-*; echo "${CMSG}Redis uninstall completed! ${CEND}"; } - [ -e "/lib/systemd/system/redis-server.service" ] && { systemctl disable redis-server > /dev/null 2>&1; rm -f /lib/systemd/system/redis-server.service; } +Uninstall_Redis() { + [ -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-*; } + [ -e "${php_install_dir}/etc/php.d/ext-redis.ini" ] && rm -rf ${php_install_dir}/etc/php.d/ext-redis.ini + echo "${CMSG}Redis uninstall completed${CEND}" } -Print_Memcached_server() { - [ -e "${memcached_install_dir}" ] && echo ${memcached_install_dir} - [ -e "/etc/init.d/memcached" ] && echo /etc/init.d/memcached - [ -e "/usr/bin/memcached" ] && echo /usr/bin/memcached - [ -e "/lib/systemd/system/memcached.service" ] && echo /lib/systemd/system/memcached.service +Print_Memcached() { + [ -e "${memcached_install_dir}" ] && echo "${memcached_install_dir}" + [ -e "/etc/init.d/memcached" ] && echo "/etc/init.d/memcached" + [ -e "/usr/bin/memcached" ] && echo "/usr/bin/memcached" } -Uninstall_Memcached_server() { - [ -e "${memcached_install_dir}" ] && { service memcached stop > /dev/null 2>&1; rm -rf ${memcached_install_dir} /etc/init.d/memcached /usr/bin/memcached; echo "${CMSG}Memcached uninstall completed! ${CEND}"; } - [ -e "/lib/systemd/system/memcached.service" ] && { systemctl disable memcached > /dev/null 2>&1; rm -f /lib/systemd/system/memcached.service; } +Uninstall_Memcached() { + [ -e "${memcached_install_dir}" ] && { service memcached stop > /dev/null 2>&1; rm -rf ${memcached_install_dir} /etc/init.d/memcached /usr/bin/memcached; } + [ -e "${php_install_dir}/etc/php.d/ext-memcache.ini" ] && rm -rf ${php_install_dir}/etc/php.d/ext-memcache.ini + [ -e "${php_install_dir}/etc/php.d/ext-memcached.ini" ] && rm -rf ${php_install_dir}/etc/php.d/ext-memcached.ini + echo "${CMSG}Memcached uninstall completed${CEND}" } -Print_phpMyAdmin() { - [ -d "${wwwroot_dir}/default/phpMyAdmin" ] && echo ${wwwroot_dir}/default/phpMyAdmin -} - -Uninstall_phpMyAdmin() { - [ -d "${wwwroot_dir}/default/phpMyAdmin" ] && rm -rf ${wwwroot_dir}/default/phpMyAdmin -} - -Print_openssl() { - [ -d "${openssl_install_dir}" ] && echo ${openssl_install_dir} -} - -Uninstall_openssl() { - [ -d "${openssl_install_dir}" ] && rm -rf ${openssl_install_dir} -} - -Print_Nodejs() { - [ -e "${nodejs_install_dir}" ] && echo ${nodejs_install_dir} - [ -e "/etc/profile.d/nodejs.sh" ] && echo /etc/profile.d/nodejs.sh -} - -Menu() { +Menu(){ while :; do printf " What Are You Doing? -\t${CMSG} 0${CEND}. Uninstall All -\t${CMSG} 1${CEND}. Uninstall Nginx/Tengine/OpenResty/Apache/Tomcat -\t${CMSG} 2${CEND}. Uninstall MySQL/MariaDB/Percona -\t${CMSG} 3${CEND}. Uninstall PostgreSQL -\t${CMSG} 4${CEND}. Uninstall MongoDB -\t${CMSG} 5${CEND}. Uninstall all PHP -\t${CMSG} 6${CEND}. Uninstall PHP opcode cache -\t${CMSG} 7${CEND}. Uninstall PHP extensions -\t${CMSG} 8${CEND}. Uninstall PureFtpd -\t${CMSG} 9${CEND}. Uninstall Redis -\t${CMSG}10${CEND}. Uninstall Memcached -\t${CMSG}11${CEND}. Uninstall phpMyAdmin -\t${CMSG}12${CEND}. Uninstall Nodejs (PATH: ${nodejs_install_dir}) -\t${CMSG} q${CEND}. Exit +\t${CMSG}0${CEND}. Uninstall All +\t${CMSG}1${CEND}. Uninstall Nginx/Tengine/Apache/Tomcat +\t${CMSG}2${CEND}. Uninstall MySQL/MariaDB/Percona/AliSQL +\t${CMSG}3${CEND}. Uninstall PHP +\t${CMSG}4${CEND}. Uninstall HHVM +\t${CMSG}5${CEND}. Uninstall PureFtpd +\t${CMSG}6${CEND}. Uninstall Redis +\t${CMSG}7${CEND}. Uninstall Memcached +\t${CMSG}q${CEND}. Exit " echo - read -e -p "Please input the correct option: " Number - if [[ ! "${Number}" =~ ^[0-9,q]$|^1[0-3]$ ]]; then - echo "${CWARNING}input error! Please only input 0~12 and q${CEND}" + read -p "Please input the correct option: " Number + if [[ ! $Number =~ ^[0-7,q]$ ]]; then + echo "${CWARNING}input error! Please only input 0,1,2,3,4,5,6,7 and q${CEND}" else case "$Number" in 0) Print_Warn Print_web - Print_MySQL - Print_PostgreSQL - Print_MongoDB - Print_ALLPHP + Print_DB + Print_PHP + Print_HHVM Print_PureFtpd - Print_Redis_server - Print_Memcached_server - Print_openssl - Print_phpMyAdmin - Print_Nodejs + Print_Redis + Print_Memcached + Uninstall_status - if [ "${uninstall_flag}" == 'y' ]; then + if [ "${uninstall_yn}" == 'y' ]; then Uninstall_Web - Uninstall_MySQL - Uninstall_PostgreSQL - Uninstall_MongoDB - Uninstall_ALLPHP + Uninstall_DB + Uninstall_PHP + Uninstall_HHVM Uninstall_PureFtpd - Uninstall_Redis_server - Uninstall_Memcached_server - Uninstall_openssl - Uninstall_phpMyAdmin - . include/nodejs.sh; Uninstall_Nodejs + Uninstall_Redis + Uninstall_Memcached else exit fi @@ -615,64 +221,38 @@ What Are You Doing? Print_Warn Print_web Uninstall_status - [ "${uninstall_flag}" == 'y' ] && Uninstall_Web || exit + [ "${uninstall_yn}" == 'y' ] && Uninstall_Web || exit ;; 2) Print_Warn - Print_MySQL + Print_DB Uninstall_status - [ "${uninstall_flag}" == 'y' ] && Uninstall_MySQL || exit + [ "${uninstall_yn}" == 'y' ] && Uninstall_DB || exit ;; 3) - Print_Warn - Print_PostgreSQL + Print_PHP Uninstall_status - [ "${uninstall_flag}" == 'y' ] && Uninstall_PostgreSQL || exit + [ "${uninstall_yn}" == 'y' ] && Uninstall_PHP || exit ;; 4) - Print_Warn - Print_MongoDB + Print_HHVM Uninstall_status - [ "${uninstall_flag}" == 'y' ] && Uninstall_MongoDB || exit + [ "${uninstall_yn}" == 'y' ] && Uninstall_HHVM || exit ;; 5) - Print_ALLPHP + Print_PureFtpd Uninstall_status - [ "${uninstall_flag}" == 'y' ] && Uninstall_ALLPHP || exit + [ "${uninstall_yn}" == 'y' ] && Uninstall_PureFtpd || exit ;; 6) + Print_Redis Uninstall_status - [ "${uninstall_flag}" == 'y' ] && Uninstall_PHPcache || exit + [ "${uninstall_yn}" == 'y' ] && Uninstall_Redis || exit ;; 7) - Menu_PHPext - [ "${phpext_option}" != '0' ] && Uninstall_status - [ "${uninstall_flag}" == 'y' ] && Uninstall_PHPext || exit - ;; - 8) - Print_PureFtpd + Print_Memcached Uninstall_status - [ "${uninstall_flag}" == 'y' ] && Uninstall_PureFtpd || exit - ;; - 9) - Print_Redis_server - Uninstall_status - [ "${uninstall_flag}" == 'y' ] && Uninstall_Redis_server || exit - ;; - 10) - Print_Memcached_server - Uninstall_status - [ "${uninstall_flag}" == 'y' ] && Uninstall_Memcached_server || exit - ;; - 11) - Print_phpMyAdmin - Uninstall_status - [ "${uninstall_flag}" == 'y' ] && Uninstall_phpMyAdmin || exit - ;; - 12) - Print_Nodejs - Uninstall_status - [ "${uninstall_flag}" == 'y' ] && { . include/nodejs.sh; Uninstall_Nodejs; } || exit + [ "${uninstall_yn}" == 'y' ] && Uninstall_Memcached || exit ;; q) exit @@ -682,46 +262,74 @@ What Are You Doing? done } -if [ ${ARG_NUM} == 0 ]; then +if [ $# == 0 ]; then Menu -else - [ "${web_flag}" == 'y' ] && Print_web - [ "${mysql_flag}" == 'y' ] && Print_MySQL - [ "${postgresql_flag}" == 'y' ] && Print_PostgreSQL - [ "${mongodb_flag}" == 'y' ] && Print_MongoDB - if [ "${allphp_flag}" == 'y' ]; then - Print_ALLPHP - else - [ "${php_flag}" == 'y' ] && Print_PHP - [ "${mphp_flag}" == 'y' ] && [ "${phpcache_flag}" != 'y' ] && [ -z "${php_extensions}" ] && Print_MPHP - fi - [ "${pureftpd_flag}" == 'y' ] && Print_PureFtpd - [ "${redis_flag}" == 'y' ] && Print_Redis_server - [ "${memcached_flag}" == 'y' ] && Print_Memcached_server - [ "${phpmyadmin_flag}" == 'y' ] && Print_phpMyAdmin - [ "${nodejs_flag}" == 'y' ] && Print_Nodejs - [ "${all_flag}" == 'y' ] && Print_openssl - Uninstall_status - if [ "${uninstall_flag}" == 'y' ]; then - [ "${web_flag}" == 'y' ] && Uninstall_Web - [ "${mysql_flag}" == 'y' ] && Uninstall_MySQL - [ "${postgresql_flag}" == 'y' ] && Uninstall_PostgreSQL - [ "${mongodb_flag}" == 'y' ] && Uninstall_MongoDB - if [ "${allphp_flag}" == 'y' ]; then - Uninstall_ALLPHP +elif [ $# == 1 ]; then + case $1 in + all) + Print_Warn + Print_web + Print_DB + Print_PHP + Print_HHVM + Print_PureFtpd + Print_Redis + Print_Memcached + + Uninstall_status + if [ "${uninstall_yn}" == 'y' ]; then + Uninstall_Web + Uninstall_DB + Uninstall_PHP + Uninstall_HHVM + Uninstall_PureFtpd + Uninstall_Redis + Uninstall_Memcached else - [ "${php_flag}" == 'y' ] && Uninstall_PHP - [ "${phpcache_flag}" == 'y' ] && Uninstall_PHPcache - [ -n "${php_extensions}" ] && Uninstall_PHPext - [ "${mphp_flag}" == 'y' ] && [ "${phpcache_flag}" != 'y' ] && [ -z "${php_extensions}" ] && Uninstall_MPHP - [ "${mphp_flag}" == 'y' ] && [ "${phpcache_flag}" == 'y' ] && { php_install_dir=${php_install_dir}${mphp_ver}; Uninstall_PHPcache; } - [ "${mphp_flag}" == 'y' ] && [ -n "${php_extensions}" ] && { php_install_dir=${php_install_dir}${mphp_ver}; Uninstall_PHPext; } + exit fi - [ "${pureftpd_flag}" == 'y' ] && Uninstall_PureFtpd - [ "${redis_flag}" == 'y' ] && Uninstall_Redis_server - [ "${memcached_flag}" == 'y' ] && Uninstall_Memcached_server - [ "${phpmyadmin_flag}" == 'y' ] && Uninstall_phpMyAdmin - [ "${nodejs_flag}" == 'y' ] && { . include/nodejs.sh; Uninstall_Nodejs; } - [ "${all_flag}" == 'y' ] && Uninstall_openssl - fi + ;; + web) + Print_Warn + Print_web + Uninstall_status + [ "${uninstall_yn}" == 'y' ] && Uninstall_Web || exit + ;; + db) + Print_Warn + Print_DB + Uninstall_status + [ "${uninstall_yn}" == 'y' ] && Uninstall_DB || exit + ;; + php) + Print_PHP + Uninstall_status + [ "${uninstall_yn}" == 'y' ] && Uninstall_PHP || exit + ;; + hhvm) + Print_HHVM + Uninstall_status + [ "${uninstall_yn}" == 'y' ] && Uninstall_HHVM || exit + ;; + pureftpd) + Print_PureFtpd + Uninstall_status + [ "${uninstall_yn}" == 'y' ] && Uninstall_PureFtpd || exit + ;; + redis) + Print_Redis + Uninstall_status + [ "${uninstall_yn}" == 'y' ] && Uninstall_Redis || exit + ;; + memcached) + Print_Memcached + Uninstall_status + [ "${uninstall_yn}" == 'y' ] && Uninstall_Memcached || exit + ;; + *) + Usage + ;; + esac +else + Usage fi diff --git a/upgrade.sh b/upgrade.sh index 327e7a72..5342d1ea 100755 --- a/upgrade.sh +++ b/upgrade.sh @@ -1,21 +1,25 @@ #!/bin/bash # Author: yeho -# BLOG: https://linuxeye.com +# BLOG: https://blog.linuxeye.com # +# Notes: OneinStack for CentOS/RadHat 5+ Debian 6+ and Ubuntu 12+ # +# Project home page: +# https://oneinstack.com +# https://github.com/lj2007331/oneinstack export PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin clear printf " ####################################################################### -# Upgrade Software versions # +# OneinStack for CentOS/RadHat 5+ Debian 6+ and Ubuntu 12+ # +# Upgrade Software versions for OneinStack # +# For more information please visit https://oneinstack.com # ####################################################################### " -# Check if user is root -[ $(id -u) != "0" ] && { echo "${CFAILURE}Error: You must be root to run this script${CEND}"; exit 1; } +# get pwd +sed -i "s@^oneinstack_dir.*@oneinstack_dir=`pwd`@" ./options.conf -current_dir=$(dirname "`readlink -f $0`") -pushd ${current_dir} > /dev/null . ./versions.txt . ./options.conf . ./include/color.sh @@ -29,160 +33,109 @@ pushd ${current_dir} > /dev/null . ./include/upgrade_redis.sh . ./include/upgrade_memcached.sh . ./include/upgrade_phpmyadmin.sh -. ./include/upgrade_script.sh -# get the out ip country -OUTIP_STATE=$(./include/ois.${ARCH} ip_state) +# Check if user is root +[ $(id -u) != "0" ] && { echo "${CFAILURE}Error: You must be root to run this script${CEND}"; exit 1; } -Show_Help() { - echo - echo "Usage: $0 command ...[version].... - --help, -h Show this help message - --nginx [version] Upgrade Nginx - --tengine [version] Upgrade Tengine - --openresty [version] Upgrade OpenResty - --apache [version] Upgrade Apache - --tomcat [version] Upgrade Tomcat - --db [version] Upgrade MySQL/MariaDB/Percona - --php [version] Upgrade PHP - --redis [version] Upgrade Redis - --memcached [version] Upgrade Memcached - --phpmyadmin [version] Upgrade phpMyAdmin - --script Upgrade scripts latest - --acme.sh Upgrade acme.sh latest - " -} +# get the IP information +PUBLIC_IPADDR=`./include/get_public_ipaddr.py` +IPADDR_COUNTRY=`./include/get_ipaddr_state.py $PUBLIC_IPADDR | awk '{print $1}'` -ARG_NUM=$# -TEMP=`getopt -o h --long help,nginx:,tengine:,openresty:,apache:,tomcat:,db:,php:,redis:,memcached:,phpmyadmin:,script,acme.sh -- "$@" 2>/dev/null` -[ $? != 0 ] && echo "${CWARNING}ERROR: unknown argument! ${CEND}" && Show_Help && exit 1 -eval set -- "${TEMP}" -while :; do - [ -z "$1" ] && break; - case "$1" in - -h|--help) - Show_Help; exit 0 - ;; - --nginx) - nginx_flag=y; NEW_nginx_ver=$2; shift 2 - ;; - --tengine) - tengine_flag=y; NEW_tengine_ver=$2; shift 2 - ;; - --openresty) - openresty_flag=y; NEW_openresy_ver=$2; shift 2 - ;; - --apache) - apache_flag=y; NEW_apache_ver=$2; shift 2 - ;; - --tomcat) - tomcat_flag=y; NEW_tomcat_ver=$2; shift 2 - ;; - --db) - db_flag=y; NEW_db_ver=$2; shift 2 - ;; - --php) - php_flag=y; NEW_php_ver=$2; shift 2 - ;; - --redis) - redis_flag=y; NEW_redis_ver=$2; shift 2 - ;; - --memcached) - memcached_flag=y; NEW_memcached_ver=$2; shift 2 - ;; - --phpmyadmin) - phpmyadmin_flag=y; NEW_phpmyadmin_ver=$2; shift 2 - ;; - --script) - NEW_Script_ver=latest; shift 1 - ;; - --acme.sh) - NEW_acme_ver=latest; shift 1 - ;; - --) - shift - ;; - *) - echo "${CWARNING}ERROR: unknown argument! ${CEND}" && Show_Help && exit 1 - ;; - esac -done +Usage(){ + printf " +Usage: $0 [ ${CMSG}web${CEND} | ${CMSG}db${CEND} | ${CMSG}php${CEND} | ${CMSG}redis${CEND} | ${CMSG}memcached${CEND} | ${CMSG}phpmyadmin${CEND} ] +${CMSG}web${CEND} --->Upgrade Nginx/Tengine/OpenResty +${CMSG}db${CEND} --->Upgrade MySQL/MariaDB/Percona +${CMSG}php${CEND} --->Upgrade PHP +${CMSG}redis${CEND} --->Upgrade Redis +${CMSG}memcached${CEND} --->Upgrade Memcached +${CMSG}phpmyadmin${CEND} --->Upgrade phpMyAdmin -Menu() { +" +} + +Menu(){ while :; do printf " What Are You Doing? -\t${CMSG} 1${CEND}. Upgrade Nginx/Tengine/OpenResty -\t${CMSG} 2${CEND}. Upgrade Apache -\t${CMSG} 3${CEND}. Upgrade Tomcat -\t${CMSG} 4${CEND}. Upgrade MySQL/MariaDB/Percona -\t${CMSG} 5${CEND}. Upgrade PHP -\t${CMSG} 6${CEND}. Upgrade Redis -\t${CMSG} 7${CEND}. Upgrade Memcached -\t${CMSG} 8${CEND}. Upgrade phpMyAdmin -\t${CMSG} 9${CEND}. Upgrade scripts latest -\t${CMSG}10${CEND}. Upgrade acme.sh latest -\t${CMSG} q${CEND}. Exit +\t${CMSG}1${CEND}. Upgrade Nginx/Tengine/OpenResty +\t${CMSG}2${CEND}. Upgrade MySQL/MariaDB/Percona +\t${CMSG}3${CEND}. Upgrade PHP +\t${CMSG}4${CEND}. Upgrade Redis +\t${CMSG}5${CEND}. Upgrade Memcached +\t${CMSG}6${CEND}. Upgrade phpMyAdmin +\t${CMSG}q${CEND}. Exit " echo - read -e -p "Please input the correct option: " Upgrade_flag - if [[ ! "${Upgrade_flag}" =~ ^[1-9,q]$|^10$ ]]; then - echo "${CWARNING}input error! Please only input 1~10 and q${CEND}" + read -p "Please input the correct option: " Number + if [[ ! $Number =~ ^[1-6,q]$ ]]; then + echo "${CWARNING}input error! Please only input 1,2,3,4,5,6 and q${CEND}" else - case "${Upgrade_flag}" in - 1) - [ -e "${nginx_install_dir}/sbin/nginx" ] && Upgrade_Nginx - [ -e "${tengine_install_dir}/sbin/nginx" ] && Upgrade_Tengine - [ -e "${openresty_install_dir}/nginx/sbin/nginx" ] && Upgrade_OpenResty - ;; - 2) - Upgrade_Apache - ;; - 3) - Upgrade_Tomcat - ;; - 4) - Upgrade_DB - ;; - 5) - Upgrade_PHP - ;; - 6) - Upgrade_Redis - ;; - 7) - Upgrade_Memcached - ;; - 8) - Upgrade_phpMyAdmin - ;; - 9) - Upgrade_Script - ;; - 10) - [ -e ~/.acme.sh/acme.sh ] && { ~/.acme.sh/acme.sh --force --upgrade; ~/.acme.sh/acme.sh --version; } - ;; - q) - exit - ;; + case "$Number" in + 1) + if [ -e "$nginx_install_dir/sbin/nginx" ]; then + Upgrade_Nginx + elif [ -e "$tengine_install_dir/sbin/nginx" ]; then + Upgrade_Tengine + elif [ -e "$openresty_install_dir/nginx/sbin/nginx" ]; then + Upgrade_OpenResty + fi + ;; + 2) + Upgrade_DB + ;; + 3) + Upgrade_PHP + ;; + 4) + Upgrade_Redis + ;; + 5) + Upgrade_Memcached + ;; + 6) + Upgrade_phpMyAdmin + ;; + q) + exit + ;; esac fi done } -if [ ${ARG_NUM} == 0 ]; then +if [ $# == 0 ]; then Menu +elif [ $# == 1 ]; then + case $1 in + web) + if [ -e "$nginx_install_dir/sbin/nginx" ]; then + Upgrade_Nginx + elif [ -e "$tengine_install_dir/sbin/nginx" ]; then + Upgrade_Tengine + elif [ -e "$openresty_install_dir/nginx/sbin/nginx" ]; then + Upgrade_OpenResty + fi + ;; + db) + Upgrade_DB + ;; + php) + Upgrade_PHP + ;; + redis) + Upgrade_Redis + ;; + memcached) + Upgrade_Memcached + ;; + phpmyadmin) + Upgrade_phpMyAdmin + ;; + *) + Usage + ;; + esac else - [ "${nginx_flag}" == 'y' ] && Upgrade_Nginx - [ "${tengine_flag}" == 'y' ] && Upgrade_Tengine - [ "${openresty_flag}" == 'y' ] && Upgrade_OpenResty - [ "${apache_flag}" == 'y' ] && Upgrade_Apache - [ "${tomcat_flag}" == 'y' ] && Upgrade_Tomcat - [ "${db_flag}" == 'y' ] && Upgrade_DB - [ "${php_flag}" == 'y' ] && Upgrade_PHP - [ "${redis_flag}" == 'y' ] && Upgrade_Redis - [ "${memcached_flag}" == 'y' ] && Upgrade_Memcached - [ "${phpmyadmin_flag}" == 'y' ] && Upgrade_phpMyAdmin - [ "${NEW_Script_ver}" == 'latest' ] && Upgrade_Script - [ "${NEW_acme_ver}" == 'latest' ] && [ -e ~/.acme.sh/acme.sh ] && { ~/.acme.sh/acme.sh --force --upgrade; ~/.acme.sh/acme.sh --version; } + Usage fi diff --git a/versions.txt b/versions.txt index bbaa351a..b2e8f8da 100644 --- a/versions.txt +++ b/versions.txt @@ -1,116 +1,96 @@ # newest software version # Web -nginx_ver=1.28.2 -tengine_ver=3.1.0 -openresty_ver=1.29.2.1 -openssl_ver=3.4.3 - -tomcat10_ver=10.1.52 -tomcat9_ver=9.0.115 -tomcat8_ver=8.5.100 -tomcat7_ver=7.0.109 - -apache_ver=2.4.66 -pcre_ver=8.45 -apr_ver=1.7.5 -apr_util_ver=1.6.3 -nghttp2_ver=1.59.0 +nginx_version=1.12.0 +tengine_version=2.1.2 +openresty_version=1.11.2.3 +openssl_version=1.0.2k + +tomcat8_version=8.5.14 +tomcat7_version=7.0.77 +tomcat6_version=6.0.53 + +apache24_version=2.4.25 +apache22_version=2.2.32 +pcre_version=8.40 +apr_version=1.5.2 +apr_util_version=1.5.4 +nghttp2_version=1.21.1 # DB -mysql84_ver=8.4.8 -mysql80_ver=8.0.45 -mysql57_ver=5.7.44 -mysql55_ver=5.5.62 +mysql57_version=5.7.18 +mysql56_version=5.6.36 +mysql55_version=5.5.56 -mariadb118_ver=11.8.5 -mariadb114_ver=11.4.9 -mariadb1011_ver=10.11.15 -mariadb55_ver=5.5.68 +mariadb101_version=10.1.23 +mariadb100_version=10.0.30 +mariadb55_version=5.5.56 -percona84_ver=8.4.7-7 -percona80_ver=8.0.45-36 -percona57_ver=5.7.44-54 -percona55_ver=5.5.62-38.14 +percona57_version=5.7.18-14 +percona56_version=5.6.36-82.0 +percona55_version=5.5.58-38.8 -pgsql_ver=12.7 +alisql56_version=5.6.32-4 -mongodb_ver=4.0.26 +# JDK +jdk18_version=1.8.0_121 +jdk17_version=1.7.0_80 +jdk16_version=1.6.0_45 # PHP -php53_ver=5.3.29 -php54_ver=5.4.45 -php55_ver=5.5.38 -php56_ver=5.6.40 -php70_ver=7.0.33 -php71_ver=7.1.33 -php72_ver=7.2.34 -php73_ver=7.3.33 -php74_ver=7.4.33 -php80_ver=8.0.30 -php81_ver=8.1.34 -php82_ver=8.2.30 -php83_ver=8.3.30 -php84_ver=8.4.19 -php85_ver=8.5.4 - -# Nodejs -nodejs_ver=20.17.0 - -libiconv_ver=1.16 -curl_ver=8.17.0 -libmcrypt_ver=2.5.8 -mcrypt_ver=2.6.8 -mhash_ver=0.9.9.9 -freetype_ver=2.10.1 -icu4c_ver=63_1 -libsodium_ver=1.0.20 -libzip_ver=1.2.0 -argon2_ver=20171227 -binutils_ver=2.42 -imagemagick_ver=7.1.2-15 -imagick_ver=3.8.1 -graphicsmagick_ver=1.3.40 -gmagick_ver=2.0.6RC1 -zendopcache_ver=7.0.5 -apcu_ver=5.1.28 -eaccelerator_ver=0.9.6.1 -phalcon_ver=5.9.3 -yaf_ver=3.3.7 -yar_ver=2.3.4 -swoole_ver=6.2.0 -xdebug_ver=3.1.2 +php71_version=7.1.5 +php70_version=7.0.19 +php56_version=5.6.30 +php55_version=5.5.38 +php54_version=5.4.45 +php53_version=5.3.29 + +zendopcache_version=7.0.5 +xcache_version=3.2.0 +apcu_version=4.0.11 +apcu_for_php7_version=5.1.8 +ImageMagick_version=6.9.8-5 +imagick_version=3.4.3 +imagick_for_php53_version=3.3.0 +GraphicsMagick_version=1.3.25 +gmagick_for_php7_version=2.0.4RC1 +gmagick_version=1.1.7RC3 +libiconv_version=1.15 +curl_version=7.54.0 +libmcrypt_version=2.5.8 +mcrypt_version=2.6.8 +mhash_version=0.9.9.9 +eaccelerator_version=0.9.6.1 # Ftp -pureftpd_ver=1.0.52 +pureftpd_version=1.0.45 # Redis -redis_ver=7.4.8 -pecl_redis_ver=6.3.0 +redis_version=3.2.8 +redis_pecl_for_php7_version=3.1.2 +redis_pecl_version=2.2.8 # Memcached -memcached_ver=1.6.41 -libmemcached_ver=1.0.18 -pecl_memcached_ver=3.4.0 -pecl_memcache_ver=8.2 - -# MongoDB -pecl_mongodb_ver=2.1.4 +memcached_version=1.4.36 +libmemcached_version=1.0.18 +memcached_pecl_version=2.2.0 +memcached_pecl_php7_version=3.0.3 +memcache_pecl_version=3.0.8 # phpMyadmin -phpmyadmin_ver=5.2.3 +phpMyAdmin_version=4.4.15.10 # jemalloc -jemalloc_ver=5.3.0 +jemalloc_version=4.5.0 # boost -boost_ver=1.77.0 -boost_percona_ver=1.77.0 -boost_oldver=1.59.0 +boost_version=1.59.0 # Others -lua_nginx_module_ver=0.10.29 -luajit2_ver=2.1-20260311 -lua_resty_core_ver=0.1.32 -lua_resty_lrucache_ver=0.15 -lua_cjson_ver=2.1.0.16 -fail2ban_ver=master +libevent_version=2.0.22-stable +tmux_version=2.3 +htop_version=2.0.2 +bison_version=2.7.1 +python_version=2.7.13 +setuptools_version=32.0.0 +pip_version=9.0.1 +fail2ban_version=0.9.6 diff --git a/vhost.sh b/vhost.sh index 21685a8a..cb35ef64 100755 --- a/vhost.sh +++ b/vhost.sh @@ -1,148 +1,144 @@ #!/bin/bash # Author: yeho -# BLOG: https://linuxeye.com +# BLOG: https://blog.linuxeye.com # +# Notes: OneinStack for CentOS/RadHat 5+ Debian 6+ and Ubuntu 12+ # +# Project home page: +# https://oneinstack.com +# https://github.com/lj2007331/oneinstack export PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin clear printf " ####################################################################### -# Setting up virtual hosts on HTTP Server # +# OneinStack for CentOS/RadHat 5+ Debian 6+ and Ubuntu 12+ # +# For more information please visit https://oneinstack.com # ####################################################################### " -# Check if user is root -[ $(id -u) != '0' ] && { echo "${CFAILURE}Error: You must be root to run this script${CEND}"; exit 1; } -current_dir=$(dirname "`readlink -f $0`") -pushd ${current_dir} > /dev/null . ./options.conf . ./include/color.sh . ./include/check_dir.sh . ./include/check_os.sh . ./include/get_char.sh -Show_Help() { - echo - echo "Usage: $0 command ...[parameters].... - --help, -h Show this help message - --quiet, -q quiet operation - --list, -l List Virtualhost - --mphp_ver [53~84] Use another PHP version (PATH: /usr/local/php${mphp_ver}) - --proxy Use proxy - --add Add Virtualhost - --delete, --del Delete Virtualhost - --httponly Use HTTP Only - --selfsigned Use your own SSL Certificate and Key - --letsencrypt Use Let's Encrypt to Create SSL Certificate and Key - --dnsapi Use dns API to automatically issue Let's Encrypt Cert - " -} +# Check if user is root +[ $(id -u) != '0' ] && { echo "${CFAILURE}Error: You must be root to run this script${CEND}"; exit 1; } -ARG_NUM=$# -TEMP=`getopt -o hql --long help,quiet,list,proxy,mphp_ver:,add,delete,del,httponly,selfsigned,letsencrypt,dnsapi -- "$@" 2>/dev/null` -[ $? != 0 ] && echo "${CWARNING}ERROR: unknown argument! ${CEND}" && Show_Help && exit 1 -eval set -- "${TEMP}" -while :; do - [ -z "$1" ] && break; - case "$1" in - -h|--help) - Show_Help; exit 0 - ;; - -q|--quiet) - quiet_flag=y; shift 1 - ;; - -l|--list) - list_flag=y; shift 1 - ;; - --mphp_ver) - mphp_ver=$2; mphp_flag=y; shift 2 - [[ ! "${mphp_ver}" =~ ^5[3-6]$|^7[0-4]$|^8[0-4]$ ]] && { echo "${CWARNING}mphp_ver input error! Please only input number 53~84${CEND}"; unset mphp_ver mphp_flag; } - ;; - --proxy) - proxy_flag=y; shift 1 - ;; - --add) - add_flag=y; shift 1 - ;; - --delete|--del) - delete_flag=y; shift 1 - ;; - --httponly) - sslquiet_flag=y - httponly_flag=y - Domian_Mode=1 - shift 1 - ;; - --selfsigned) - sslquiet_flag=y - selfsigned_flag=y - Domian_Mode=2 - shift 1 - ;; - --letsencrypt) - sslquiet_flag=y - letsencrypt_flag=y - Domian_Mode=3 - shift 1 - ;; - --dnsapi) - sslquiet_flag=y - dnsapi_flag=y - letsencrypt_flag=y - shift 1 - ;; - --) - shift - ;; - *) - echo "${CWARNING}ERROR: unknown argument! ${CEND}" && Show_Help && exit 1 - ;; - esac -done +Usage() { + printf " +Usage: $0 [ ${CMSG}add${CEND} | ${CMSG}del${CEND} ] +${CMSG}add${CEND} --->Add Virtualhost +${CMSG}del${CEND} --->Delete Virtualhost -Choose_ENV() { - if [ -e "${apache_install_dir}/bin/apachectl" ];then - [ "$(${apache_install_dir}/bin/apachectl -v | awk -F'.' /version/'{print $2}')" == '4' ] && { Apache_main_ver=24; Apache_grant='Require all granted'; } - [ "$(${apache_install_dir}/bin/apachectl -v | awk -F'.' /version/'{print $2}')" == '2' ] && Apache_main_ver=22 - fi - if [ -e "${php_install_dir}/bin/phpize" -a -e "${tomcat_install_dir}/conf/server.xml" ] && [[ -z ${proxy_flag} || "${proxy_flag}" != 'y' ]]; then - Number=11 +" +} + +Choose_env() { + if [ -e "${php_install_dir}/bin/phpize" -a -e "${tomcat_install_dir}/conf/server.xml" -a -e "/usr/bin/hhvm" ]; then + Number=111 while :; do echo echo "Please choose to use environment:" echo -e "\t${CMSG}1${CEND}. Use php" echo -e "\t${CMSG}2${CEND}. Use java" - read -e -p "Please input a number:(Default 1 press Enter) " ENV_FLAG - ENV_FLAG=${ENV_FLAG:-1} - if [[ ! ${ENV_FLAG} =~ ^[1-2]$ ]]; then - echo "${CWARNING}input error! Please only input number 1~2${CEND}" + echo -e "\t${CMSG}3${CEND}. Use hhvm" + read -p "Please input a number:(Default 1 press Enter) " Choose_number + [ -z "${Choose_number}" ] && Choose_number=1 + if [[ ! ${Choose_number} =~ ^[1-3]$ ]]; then + echo "${CWARNING}input error! Please only input number 1,2,3${CEND}" else break fi done - case "${ENV_FLAG}" in + case "${Choose_number}" in 1) NGX_FLAG=php ;; 2) NGX_FLAG=java ;; + 3) + NGX_FLAG=hhvm + ;; esac - elif [ -e "${php_install_dir}/bin/phpize" -a ! -e "${tomcat_install_dir}/conf/server.xml" ]; then - Number=10 + elif [ -e "${php_install_dir}/bin/phpize" -a -e "${tomcat_install_dir}/conf/server.xml" -a ! -e "/usr/bin/hhvm" ]; then + Number=110 + while :; do echo + echo "Please choose to use environment:" + echo -e "\t${CMSG}1${CEND}. Use php" + echo -e "\t${CMSG}2${CEND}. Use java" + read -p "Please input a number:(Default 1 press Enter) " Choose_number + [ -z "${Choose_number}" ] && Choose_number=1 + if [[ ! ${Choose_number} =~ ^[1-2]$ ]]; then + echo "${CWARNING}input error! Please only input number 1,2${CEND}" + else + break + fi + done + [ "${Choose_number}" == '1' ] && NGX_FLAG=php + [ "${Choose_number}" == '2' ] && NGX_FLAG=java + elif [ -e "${php_install_dir}/bin/phpize" -a ! -e "${tomcat_install_dir}/conf/server.xml" -a ! -e "/usr/bin/hhvm" ]; then + Number=100 NGX_FLAG=php - elif [ ! -e "${php_install_dir}/bin/phpize" -a -e "${tomcat_install_dir}/conf/server.xml" ]; then - Number=01 + elif [ -e "${php_install_dir}/bin/phpize" -a ! -e "${tomcat_install_dir}/conf/server.xml" -a -e "/usr/bin/hhvm" ]; then + Number=101 + while :; do echo + echo "Please choose to use environment:" + echo -e "\t${CMSG}1${CEND}. Use php" + echo -e "\t${CMSG}2${CEND}. Use hhvm" + read -p "Please input a number:(Default 1 press Enter) " Choose_number + [ -z "${Choose_number}" ] && Choose_number=1 + if [[ ! ${Choose_number} =~ ^[1-2]$ ]]; then + echo "${CWARNING}input error! Please only input number 1,2${CEND}" + else + break + fi + done + [ "${Choose_number}" == '1' ] && NGX_FLAG=php + [ "${Choose_number}" == '2' ] && NGX_FLAG=hhvm + elif [ ! -e "${php_install_dir}/bin/phpize" -a -e "${tomcat_install_dir}/conf/server.xml" -a -e "/usr/bin/hhvm" ]; then + Number=011 + while :; do echo + echo "Please choose to use environment:" + echo -e "\t${CMSG}1${CEND}. Use java" + echo -e "\t${CMSG}2${CEND}. Use hhvm" + read -p "Please input a number:(Default 1 press Enter) " Choose_number + [ -z "${Choose_number}" ] && Choose_number=1 + if [[ ! ${Choose_number} =~ ^[1-2]$ ]]; then + echo "${CWARNING}input error! Please only input number 1,2${CEND}" + else + break + fi + done + [ "${Choose_number}" == '1' ] && NGX_FLAG=java + [ "${Choose_number}" == '2' ] && NGX_FLAG=hhvm + elif [ ! -e "${php_install_dir}/bin/phpize" -a -e "${tomcat_install_dir}/conf/server.xml" -a ! -e "/usr/bin/hhvm" ]; then + Number=010 NGX_FLAG=java + elif [ ! -e "${php_install_dir}/bin/phpize" -a ! -e "${tomcat_install_dir}/conf/server.xml" -a -e "/usr/bin/hhvm" ]; then + Number=001 + NGX_FLAG=hhvm else - Number=00 + Number=000 NGX_FLAG=php fi + + case "${NGX_FLAG}" in + "php") + NGX_CONF=$(echo -e "location ~ [^/]\.php(/|$) {\n #fastcgi_pass remote_php_ip:9000;\n fastcgi_pass unix:/dev/shm/php-cgi.sock;\n fastcgi_index index.php;\n include fastcgi.conf;\n }") + ;; + "java") + NGX_CONF=$(echo -e "location ~ {\n proxy_pass http://127.0.0.1:8080;\n include proxy.conf;\n }") + ;; + "hhvm") + NGX_CONF=$(echo -e "location ~ .*\.(php|php5)?$ {\n fastcgi_pass unix:/var/log/hhvm/sock;\n fastcgi_index index.php;\n fastcgi_param SCRIPT_FILENAME \$document_root\$fastcgi_script_name;\n include fastcgi_params;\n }") + ;; + esac } -Create_SSL() { - if [ "${Domian_Mode}" == '2' ]; then - printf " +Create_self_SSL() { + printf " You are about to be asked to enter information that will be incorporated into your certificate request. What you are about to enter is what is called a Distinguished Name or a DN. @@ -150,90 +146,69 @@ There are quite a few fields but you can leave some blank For some fields there will be a default value, If you enter '.', the field will be left blank. " - echo - read -e -p "Country Name (2 letter code) [CN]: " SELFSIGNEDSSL_C - SELFSIGNEDSSL_C=${SELFSIGNEDSSL_C:-CN} - # shellcheck disable=SC2104 - [ ${#SELFSIGNEDSSL_C} != 2 ] && { echo "${CWARNING}input error, You must input 2 letter code country name${CEND}"; continue; } - echo - read -e -p "State or Province Name (full name) [Shanghai]: " SELFSIGNEDSSL_ST - SELFSIGNEDSSL_ST=${SELFSIGNEDSSL_ST:-Shanghai} - echo - read -e -p "Locality Name (eg, city) [Shanghai]: " SELFSIGNEDSSL_L - SELFSIGNEDSSL_L=${SELFSIGNEDSSL_L:-Shanghai} - echo - read -e -p "Organization Name (eg, company) [Example Inc.]: " SELFSIGNEDSSL_O - SELFSIGNEDSSL_O=${SELFSIGNEDSSL_O:-"Example Inc."} - echo - read -e -p "Organizational Unit Name (eg, section) [IT Dept.]: " SELFSIGNEDSSL_OU - SELFSIGNEDSSL_OU=${SELFSIGNEDSSL_OU:-"IT Dept."} - openssl req -utf8 -new -newkey rsa:2048 -sha256 -nodes -out ${PATH_SSL}/${domain}.csr -keyout ${PATH_SSL}/${domain}.key -subj "/C=${SELFSIGNEDSSL_C}/ST=${SELFSIGNEDSSL_ST}/L=${SELFSIGNEDSSL_L}/O=${SELFSIGNEDSSL_O}/OU=${SELFSIGNEDSSL_OU}/CN=${domain}" > /dev/null 2>&1 - openssl x509 -req -days 36500 -sha256 -in ${PATH_SSL}/${domain}.csr -signkey ${PATH_SSL}/${domain}.key -out ${PATH_SSL}/${domain}.crt > /dev/null 2>&1 - elif [ "${Domian_Mode}" == '3' -o "${dnsapi_flag}" == 'y' ]; then - while :; do echo - echo 'Please select domain cert key length.' - echo "${CMSG}Enter one of 2048, 3072, 4096, 8192 will issue a RSA cert.${CEND}" - echo "${CMSG}Enter one of ec-256, ec-384, ec-521 will issue a ECC cert.${CEND}" - echo - read -e -p "Please enter your cert key length (default ec-256): " CERT_KEYLENGTH - if [ "${CERT_KEYLENGTH}" == "" ]; then - CERT_KEYLENGTH="ec-256" - break - elif [[ "${CERT_KEYLENGTH}" =~ ^2048$|^3072$|^4096$|^8192$|^ec-256$|^ec-384$|^ec-521$ ]]; then - break - else - echo "${CWARNING}input error!${CEND}" - fi + echo + read -p "Country Name (2 letter code) [CN]: " SELFSIGNEDSSL_C + [ -z "${SELFSIGNEDSSL_C}" ] && SELFSIGNEDSSL_C="CN" + + echo + read -p "State or Province Name (full name) [Shanghai]: " SELFSIGNEDSSL_ST + [ -z "${SELFSIGNEDSSL_ST}" ] && SELFSIGNEDSSL_ST="Shanghai" + + echo + read -p "Locality Name (eg, city) [Shanghai]: " SELFSIGNEDSSL_L + [ -z "${SELFSIGNEDSSL_L}" ] && SELFSIGNEDSSL_L="Shanghai" + + echo + read -p "Organization Name (eg, company) [Example Inc.]: " SELFSIGNEDSSL_O + [ -z "${SELFSIGNEDSSL_O}" ] && SELFSIGNEDSSL_O="Example Inc." + + echo + read -p "Organizational Unit Name (eg, section) [IT Dept.]: " SELFSIGNEDSSL_OU + [ -z "${SELFSIGNEDSSL_O}U" ] && SELFSIGNEDSSL_OU="IT Dept." + + openssl req -new -newkey rsa:2048 -sha256 -nodes -out ${PATH_SSL}/${domain}.csr -keyout ${PATH_SSL}/${domain}.key -subj "/C=${SELFSIGNEDSSL_C}/ST=${SELFSIGNEDSSL_ST}/L=${SELFSIGNEDSSL_L}/O=${SELFSIGNEDSSL_O}/OU=${SELFSIGNEDSSL_OU}/CN=${domain}" > /dev/null 2>&1 + openssl x509 -req -days 36500 -sha256 -in ${PATH_SSL}/${domain}.csr -signkey ${PATH_SSL}/${domain}.key -out ${PATH_SSL}/${domain}.crt > /dev/null 2>&1 +} + +Create_SSL() { + if [ -e "${python_install_dir}/bin/certbot" ]; then + while :; do echo + read -p "Do you want to use a Let's Encrypt certificate? [y/n]: " letsencrypt_yn + if [[ ! ${letsencrypt_yn} =~ ^[y,n]$ ]]; then + echo "${CWARNING}input error! Please only input 'y' or 'n'${CEND}" + else + break + fi + done + if [ "${letsencrypt_yn}" == 'y' ]; then + PUBLIC_IPADDR=$(./include/get_public_ipaddr.py) + for D in ${domain} ${moredomainame} + do + Domain_IPADDR=$(ping ${D} -c1 | sed '1{s/[^(]*(//;s/).*//;q}') + [ "${PUBLIC_IPADDR%.*}" != "${Domain_IPADDR%.*}" ] && { echo; echo "${CFAILURE}DNS problem: NXDOMAIN looking up A for ${D}${CEND}"; echo; exit 1; } done - if [ ! -e ~/.acme.sh/ca/acme.zerossl.com/v2/DV90/account.key ]; then - while :; do echo - read -e -p "Please enter your email: " EMAIL + + #add Email + while : + do echo - if [[ "${EMAIL}" =~ ^[A-Za-z0-9._-]+@[A-Za-z0-9._-]+\.[A-Za-z]{2,9}$ ]]; then - break + read -p "Please enter Administrator Email(example: admin@example.com): " Admin_Email + if [ -z "$(echo ${Admin_Email} | grep '.*@.*\..*')" ]; then + echo "${CWARNING}input error! ${CEND}" else - echo "${CWARNING}input error!${CEND}" - fi - done - ~/.acme.sh/acme.sh --register-account -m ${EMAIL} - fi - ~/.acme.sh/acme.sh --set-default-ca --server letsencrypt - if [ "${moredomain}" == "*.${domain}" -o "${dnsapi_flag}" == 'y' ]; then - while :; do echo - echo 'Please select DNS provider:' - echo "${CMSG}dp${CEND},${CMSG}cx${CEND},${CMSG}ali${CEND},${CMSG}cf${CEND},${CMSG}aws${CEND},${CMSG}linode${CEND},${CMSG}he${CEND},${CMSG}namesilo${CEND},${CMSG}dgon${CEND},${CMSG}freedns${CEND},${CMSG}gd${CEND},${CMSG}namecom${CEND} and so on." - read -e -p "Please enter your DNS provider: " DNS_PRO - if [ -e ~/.acme.sh/dnsapi/dns_${DNS_PRO}.sh ]; then - break - else - echo "${CWARNING}You DNS api mode is not supported${CEND}" - fi - done - while :; do echo - echo "Syntax: export Key1=Value1 ; export Key2=Value1" - read -e -p "Please enter your dnsapi parameters: " DNS_PAR - echo - eval ${DNS_PAR} - if [ $? == 0 ]; then break - else - echo "${CWARNING}Syntax error! PS: export Ali_Key=LTq ; export Ali_Secret=0q5E${CEND}" fi done - [ "${moredomainame_flag}" == 'y' ] && moredomainame_D="$(for D in ${moredomainame}; do echo -d ${D}; done)" - ~/.acme.sh/acme.sh --force --issue -k ${CERT_KEYLENGTH} --dns dns_${DNS_PRO} -d ${domain} ${moredomainame_D} - else - if [ "${nginx_ssl_flag}" == 'y' ]; then + + [ "${moredomainame_yn}" == 'y' ] && moredomainame_D="$(for D in ${moredomainame}; do echo -d ${D}; done)" + if [ "${nginx_ssl_yn}" == 'y' ]; then [ ! -d ${web_install_dir}/conf/vhost ] && mkdir ${web_install_dir}/conf/vhost - if [ -n "`ifconfig | grep inet6`" ]; then - echo "server { listen 80; listen [::]:80; server_name ${domain}${moredomainame}; root ${vhostdir}; access_log off; }" > ${web_install_dir}/conf/vhost/${domain}.conf - else - echo "server { listen 80; server_name ${domain}${moredomainame}; root ${vhostdir}; access_log off; }" > ${web_install_dir}/conf/vhost/${domain}.conf - fi + echo "server { server_name ${domain}${moredomainame}; root ${vhostdir}; access_log off; }" > ${web_install_dir}/conf/vhost/${domain}.conf ${web_install_dir}/sbin/nginx -s reload fi - if [ "${apache_ssl_flag}" == 'y' ]; then + + if [ "${apache_ssl_yn}" == 'y' ]; then [ ! -d ${apache_install_dir}/conf/vhost ] && mkdir ${apache_install_dir}/conf/vhost cat > ${apache_install_dir}/conf/vhost/${domain}.conf << EOF @@ -244,7 +219,7 @@ If you enter '.', the field will be left blank. SetOutputFilter DEFLATE Options FollowSymLinks ExecCGI - ${Apache_grant} + Require all granted AllowOverride All Order allow,deny Allow from all @@ -252,172 +227,95 @@ If you enter '.', the field will be left blank. EOF - ${apache_install_dir}/bin/apachectl -k graceful + /etc/init.d/httpd restart > /dev/null fi - auth_file="`< /dev/urandom tr -dc A-Za-z0-9 | head -c8`".html - auth_str='linuxeye'; echo ${auth_str} > ${vhostdir}/${auth_file} - for D in ${domain} ${moredomainame} - do - curl_str=`curl --connect-timeout 30 -4 -s $D/${auth_file} 2>&1` - [ "${curl_str}" != "${auth_str}" ] && { echo; echo "${CFAILURE}Let's Encrypt Verify error! DNS problem: NXDOMAIN looking up A for ${D}${CEND}"; } - done - rm -f ${vhostdir}/${auth_file} - [ "${moredomainame_flag}" == 'y' ] && moredomainame_D="$(for D in ${moredomainame}; do echo -d ${D}; done)" - ~/.acme.sh/acme.sh --force --issue -k ${CERT_KEYLENGTH} -w ${vhostdir} -d ${domain} ${moredomainame_D} - fi - [ -e "${PATH_SSL}/${domain}.crt" ] && rm -f ${PATH_SSL}/${domain}.{crt,key} - Nginx_cmd="/bin/systemctl restart nginx" - Apache_cmd="${apache_install_dir}/bin/apachectl -k graceful" - if [ -e "${web_install_dir}/sbin/nginx" -a -e "${apache_install_dir}/bin/httpd" ]; then - Command="${Nginx_cmd};${Apache_cmd}" - elif [ -e "${web_install_dir}/sbin/nginx" -a ! -e "${apache_install_dir}/bin/httpd" ]; then - Command="${Nginx_cmd}" - elif [ ! -e "${web_install_dir}/sbin/nginx" -a -e "${apache_install_dir}/bin/httpd" ]; then - Command="${Apache_cmd}" + + ${python_install_dir}/bin/certbot certonly --webroot --agree-tos --quiet --email ${Admin_Email} -w ${vhostdir} -d ${domain} ${moredomainame_D} + if [ -s "/etc/letsencrypt/live/${domain}/cert.pem" ]; then + [ -e "${PATH_SSL}/${domain}.crt" ] && rm -rf ${PATH_SSL}/${domain}.{crt,key} + ln -s /etc/letsencrypt/live/${domain}/fullchain.pem ${PATH_SSL}/${domain}.crt + ln -s /etc/letsencrypt/live/${domain}/privkey.pem ${PATH_SSL}/${domain}.key + if [ -e "${web_install_dir}/sbin/nginx" -a -e "${apache_install_dir}/conf/httpd.conf" ]; then + Cron_Command="/etc/init.d/nginx reload;/etc/init.d/httpd graceful" + elif [ -e "${web_install_dir}/sbin/nginx" -a ! -e "${apache_install_dir}/conf/httpd.conf" ]; then + Cron_Command="/etc/init.d/nginx reload" + elif [ ! -e "${web_install_dir}/sbin/nginx" -a -e "${apache_install_dir}/conf/httpd.conf" ]; then + Cron_Command="/etc/init.d/httpd graceful" + fi + [ "${OS}" == "CentOS" ] && Cron_file=/var/spool/cron/root || Cron_file=/var/spool/cron/crontabs/root + [ -z "$(grep 'certbot renew' ${Cron_file})" ] && echo "30 2 * * 1 ${python_install_dir}/bin/certbot renew --renew-hook \"${Cron_Command}\"" >> $Cron_file + else + echo "${CFAILURE}Error: Let's Encrypt SSL certificate installation failed! ${CEND}" + exit 1 fi - if [ -s ~/.acme.sh/${domain}/fullchain.cer ] && [[ "${CERT_KEYLENGTH}" =~ ^2048$|^3072$|^4096$|^8192$ ]]; then - ~/.acme.sh/acme.sh --force --install-cert -d ${domain} --fullchain-file ${PATH_SSL}/${domain}.crt --key-file ${PATH_SSL}/${domain}.key --reloadcmd "${Command}" > /dev/null - elif [ -s ~/.acme.sh/${domain}_ecc/fullchain.cer ] && [[ "${CERT_KEYLENGTH}" =~ ^ec-256$|^ec-384$|^ec-521$ ]]; then - ~/.acme.sh/acme.sh --force --install-cert --ecc -d ${domain} --fullchain-file ${PATH_SSL}/${domain}.crt --key-file ${PATH_SSL}/${domain}.key --reloadcmd "${Command}" > /dev/null else - echo "${CFAILURE}Error: Create Let's Encrypt SSL Certificate failed! ${CEND}" - [ -e "${web_install_dir}/conf/vhost/${domain}.conf" ] && rm -f ${web_install_dir}/conf/vhost/${domain}.conf - [ -e "${apache_install_dir}/conf/vhost/${domain}.conf" ] && rm -f ${apache_install_dir}/conf/vhost/${domain}.conf - exit 1 + Create_self_SSL fi + else + Create_self_SSL fi } -Print_SSL() { - if [ "${Domian_Mode}" == '2' ]; then +Print_ssl() { + if [ "${letsencrypt_yn}" == 'y' ]; then + echo "$(printf "%-30s" "Let's Encrypt SSL Certificate:")${CMSG}/etc/letsencrypt/live/${domain}/fullchain.pem${CEND}" + echo "$(printf "%-30s" "SSL Private Key:")${CMSG}/etc/letsencrypt/live/${domain}/privkey.pem${CEND}" + else echo "$(printf "%-30s" "Self-signed SSL Certificate:")${CMSG}${PATH_SSL}/${domain}.crt${CEND}" echo "$(printf "%-30s" "SSL Private Key:")${CMSG}${PATH_SSL}/${domain}.key${CEND}" echo "$(printf "%-30s" "SSL CSR File:")${CMSG}${PATH_SSL}/${domain}.csr${CEND}" - elif [ "${Domian_Mode}" == '3' -o "${dnsapi_flag}" == 'y' ]; then - echo "$(printf "%-30s" "Let's Encrypt SSL Certificate:")${CMSG}${PATH_SSL}/${domain}.crt${CEND}" - echo "$(printf "%-30s" "SSL Private Key:")${CMSG}${PATH_SSL}/${domain}.key${CEND}" fi } -Input_Add_proxy() { - while :; do echo - read -e -p "Please input the correct proxy_pass: " Proxy_Pass - if [ -z "$(echo $Proxy_Pass | grep -E '^http://|https://')" ]; then - echo "${CFAILURE}input error! Please only input example http://192.168.1.1:8080${CEND}" - else - echo "proxy_pass=${Proxy_Pass}" - break - fi - done -} Input_Add_domain() { - if [ "${sslquiet_flag}" != 'y' ]; then - while :;do - printf " -What Are You Doing? -\t${CMSG}1${CEND}. Use HTTP Only -\t${CMSG}2${CEND}. Use your own SSL Certificate and Key -\t${CMSG}3${CEND}. Use Let's Encrypt to Create SSL Certificate and Key -\t${CMSG}q${CEND}. Exit -" - read -e -p "Please input the correct option: " Domian_Mode - if [[ ! "${Domian_Mode}" =~ ^[1-3,q]$ ]]; then - echo "${CFAILURE}input error! Please only input 1~3 and q${CEND}" + if [ -e "${web_install_dir}/sbin/nginx" ]; then + while :; do echo + read -p "Do you want to setup SSL under Nginx? [y/n]: " nginx_ssl_yn + if [[ ! ${nginx_ssl_yn} =~ ^[y,n]$ ]]; then + echo "${CWARNING}input error! Please only input 'y' or 'n'${CEND}" + else + break + fi + done + elif [ ! -e "${web_install_dir}/sbin/nginx" -a -e "${apache_install_dir}/bin/apachectl" ]; then + while :; do echo + read -p "Do you want to setup SSL under Apache? [y/n]: " apache_ssl_yn + if [[ ! ${apache_ssl_yn} =~ ^[y,n]$ ]]; then + echo "${CWARNING}input error! Please only input 'y' or 'n'${CEND}" else break fi done fi - #Multiple_PHP - if [ $(ls /dev/shm/php*-cgi.sock 2> /dev/null | wc -l) -ge 2 ]; then - if [ "${mphp_flag}" != 'y' ]; then - PHP_detail_ver=`${php_install_dir}/bin/php-config --version` - PHP_main_ver=${PHP_detail_ver%.*} - while :; do echo - echo 'Please select a version of the PHP:' - echo -e "\t${CMSG} 0${CEND}. PHP ${PHP_main_ver} (default)" - [ -e "/dev/shm/php53-cgi.sock" ] && echo -e "\t${CMSG} 1${CEND}. PHP 5.3" - [ -e "/dev/shm/php54-cgi.sock" ] && echo -e "\t${CMSG} 2${CEND}. PHP 5.4" - [ -e "/dev/shm/php55-cgi.sock" ] && echo -e "\t${CMSG} 3${CEND}. PHP 5.5" - [ -e "/dev/shm/php56-cgi.sock" ] && echo -e "\t${CMSG} 4${CEND}. PHP 5.6" - [ -e "/dev/shm/php70-cgi.sock" ] && echo -e "\t${CMSG} 5${CEND}. PHP 7.0" - [ -e "/dev/shm/php71-cgi.sock" ] && echo -e "\t${CMSG} 6${CEND}. PHP 7.1" - [ -e "/dev/shm/php72-cgi.sock" ] && echo -e "\t${CMSG} 7${CEND}. PHP 7.2" - [ -e "/dev/shm/php73-cgi.sock" ] && echo -e "\t${CMSG} 8${CEND}. PHP 7.3" - [ -e "/dev/shm/php74-cgi.sock" ] && echo -e "\t${CMSG} 9${CEND}. PHP 7.4" - [ -e "/dev/shm/php80-cgi.sock" ] && echo -e "\t${CMSG}10${CEND}. PHP 8.0" - [ -e "/dev/shm/php81-cgi.sock" ] && echo -e "\t${CMSG}11${CEND}. PHP 8.1" - [ -e "/dev/shm/php82-cgi.sock" ] && echo -e "\t${CMSG}12${CEND}. PHP 8.2" - [ -e "/dev/shm/php83-cgi.sock" ] && echo -e "\t${CMSG}13${CEND}. PHP 8.3" - [ -e "/dev/shm/php84-cgi.sock" ] && echo -e "\t${CMSG}14${CEND}. PHP 8.4" - [ -e "/dev/shm/php85-cgi.sock" ] && echo -e "\t${CMSG}14${CEND}. PHP 8.5" - read -e -p "Please input a number:(Default 0 press Enter) " php_option - php_option=${php_option:-0} - if [[ ! ${php_option} =~ ^[0-9]$|^1[0-5]$ ]]; then - echo "${CWARNING}input error! Please only input number 1~15${CEND}" - else - break - fi - done - fi - [ "${php_option}" == '1' ] && mphp_ver=53 - [ "${php_option}" == '2' ] && mphp_ver=54 - [ "${php_option}" == '3' ] && mphp_ver=55 - [ "${php_option}" == '4' ] && mphp_ver=56 - [ "${php_option}" == '5' ] && mphp_ver=70 - [ "${php_option}" == '6' ] && mphp_ver=71 - [ "${php_option}" == '7' ] && mphp_ver=72 - [ "${php_option}" == '8' ] && mphp_ver=73 - [ "${php_option}" == '9' ] && mphp_ver=74 - [ "${php_option}" == '10' ] && mphp_ver=80 - [ "${php_option}" == '11' ] && mphp_ver=81 - [ "${php_option}" == '12' ] && mphp_ver=82 - [ "${php_option}" == '13' ] && mphp_ver=83 - [ "${php_option}" == '14' ] && mphp_ver=84 - [ "${php_option}" == '15' ] && mphp_ver=85 - [ ! -e "/dev/shm/php${mphp_ver}-cgi.sock" ] && unset mphp_ver - fi - - case "${NGX_FLAG}" in - "php") - NGX_CONF=$(echo -e "location ~ [^/]\.php(/|$) {\n #fastcgi_pass remote_php_ip:9000;\n fastcgi_pass unix:/dev/shm/php${mphp_ver}-cgi.sock;\n fastcgi_index index.php;\n include fastcgi.conf;\n }") - ;; - "java") - NGX_CONF=$(echo -e "location ~ {\n proxy_pass http://127.0.0.1:8080;\n include proxy.conf;\n }") - ;; - esac + [ "${apache_ssl_yn}" == 'y' ] && { PATH_SSL=${apache_install_dir}/conf/ssl; [ ! -d "${PATH_SSL}" ] && mkdir ${PATH_SSL}; } + [ "${nginx_ssl_yn}" == 'y' ] && { PATH_SSL=${web_install_dir}/conf/ssl; [ ! -d "${PATH_SSL}" ] && mkdir ${PATH_SSL}; } - if [ "${Domian_Mode}" == '3' -o "${dnsapi_flag}" == 'y' ] && [ ! -e ~/.acme.sh/acme.sh ]; then - pushd ${current_dir}/src > /dev/null - [ ! -e acme.sh-master.tar.gz ] && wget -qc ${mirror_link}/src/acme.sh-master.tar.gz - tar xzf acme.sh-master.tar.gz - pushd acme.sh-master > /dev/null - ./acme.sh --install > /dev/null 2>&1 - popd > /dev/null - popd > /dev/null - fi - [ -e ~/.acme.sh/account.conf ] && sed -i '/^CERT_HOME=/d' ~/.acme.sh/account.conf - if [[ "${Domian_Mode}" =~ ^[2-3]$ ]] || [ "${dnsapi_flag}" == 'y' ]; then - if [ -e "${web_install_dir}/sbin/nginx" ]; then - nginx_ssl_flag=y - PATH_SSL=${web_install_dir}/conf/ssl - [ ! -d "${PATH_SSL}" ] && mkdir ${PATH_SSL} - elif [ ! -e "${web_install_dir}/sbin/nginx" -a -e "${apache_install_dir}/bin/httpd" ]; then - apache_ssl_flag=y - PATH_SSL=${apache_install_dir}/conf/ssl - [ ! -d "${PATH_SSL}" ] && mkdir ${PATH_SSL} + while :; do echo + read -p "Please input domain(example: www.example.com): " domain + if [ -z "$(echo ${domain} | grep '.*\..*')" ]; then + echo "${CWARNING}input error! ${CEND}" + else + break fi - elif [ "${Domian_Mode}" == 'q' ]; then - exit 1 - fi + done while :; do echo - read -e -p "Please input domain(example: www.example.com): " domain - if [ -z "$(echo ${domain} | grep '.*\..*')" ]; then - echo "${CWARNING}Your ${domain} is invalid! ${CEND}" + echo "Please input the directory for the domain:${domain} :" + read -p "(Default directory: ${wwwroot_dir}/${domain}): " vhostdir + if [ -n "${vhostdir}" -a -z "$(echo ${vhostdir} | grep '^/')" ]; then + echo "${CWARNING}input error! Press Enter to continue...${CEND}" else + if [ -z "${vhostdir}" ]; then + vhostdir="${wwwroot_dir}/${domain}" + echo "Virtual Host Directory=${CMSG}${vhostdir}${CEND}" + fi + echo + echo "Create Virtul Host directory......" + mkdir -p ${vhostdir} + echo "set permissions of Virtual Host directory......" + chown -R ${run_user}.${run_user} ${vhostdir} break fi done @@ -430,41 +328,21 @@ What Are You Doing? else echo "domain=${domain}" fi - if [[ -z ${proxy_flag} || "${proxy_flag}" != 'y' ]]; then - while :; do echo - echo "Please input the directory for the domain:${domain} :" - read -e -p "(Default directory: ${wwwroot_dir}/${domain}): " vhostdir - if [ -n "${vhostdir}" -a -z "$(echo ${vhostdir} | grep '^/')" ]; then - echo "${CWARNING}input error! Press Enter to continue...${CEND}" - else - if [ -z "${vhostdir}" ]; then - vhostdir="${wwwroot_dir}/${domain}" - echo "Virtual Host Directory=${CMSG}${vhostdir}${CEND}" - fi - echo - echo "Create Virtul Host directory......" - mkdir -p ${vhostdir} - echo "set permissions of Virtual Host directory......" - chown -R ${run_user}:${run_group} ${vhostdir} - break - fi - done - fi while :; do echo - read -e -p "Do you want to add more domain name? [y/n]: " moredomainame_flag - if [[ ! ${moredomainame_flag} =~ ^[y,n]$ ]]; then + read -p "Do you want to add more domain name? [y/n]: " moredomainame_yn + if [[ ! ${moredomainame_yn} =~ ^[y,n]$ ]]; then echo "${CWARNING}input error! Please only input 'y' or 'n'${CEND}" else break fi done - if [ "${moredomainame_flag}" == 'y' ]; then + if [ "${moredomainame_yn}" == 'y' ]; then while :; do echo - read -e -p "Type domainname or IP(example: example.com other.example.com): " moredomain + read -p "Type domainname or IP(example: example.com other.example.com): " moredomain if [ -z "$(echo ${moredomain} | grep '.*\..*')" ]; then - echo "${CWARNING}Your ${domain} is invalid! ${CEND}" + echo "${CWARNING}input error! ${CEND}" else [ "${moredomain}" == "${domain}" ] && echo "${CWARNING}Domain name already exists! ${CND}" && continue echo domain list="$moredomain" @@ -477,52 +355,49 @@ What Are You Doing? if [ -e "${web_install_dir}/sbin/nginx" ]; then while :; do echo - read -e -p "Do you want to redirect from ${moredomain} to ${domain}? [y/n]: " redirect_flag - if [[ ! ${redirect_flag} =~ ^[y,n]$ ]]; then + read -p "Do you want to redirect from ${moredomain} to ${domain}? [y/n]: " redirect_yn + if [[ ! ${redirect_yn} =~ ^[y,n]$ ]]; then echo "${CWARNING}input error! Please only input 'y' or 'n'${CEND}" else break fi done - [ "${redirect_flag}" == 'y' ] && Nginx_redirect="if (\$host != ${domain}) { return 301 \$scheme://${domain}\$request_uri; }" + [ "${redirect_yn}" == 'y' ] && Nginx_redirect="if (\$host != $domain) { return 301 \$scheme://${domain}\$request_uri; }" fi fi - if [ "${nginx_ssl_flag}" == 'y' ]; then + if [ "${nginx_ssl_yn}" == 'y' ]; then while :; do echo - read -e -p "Do you want to redirect all HTTP requests to HTTPS? [y/n]: " https_flag - if [[ ! ${https_flag} =~ ^[y,n]$ ]]; then + read -p "Do you want to redirect all HTTP requests to HTTPS? [y/n]: " https_yn + if [[ ! ${https_yn} =~ ^[y,n]$ ]]; then echo "${CWARNING}input error! Please only input 'y' or 'n'${CEND}" else break fi done - Create_SSL - if [ -n "`ifconfig | grep inet6`" ]; then - Nginx_conf=$(echo -e "listen 80;\n listen [::]:80;\n listen 443 ssl;\n listen [::]:443 ssl;\n http2 on;\n ssl_certificate ${PATH_SSL}/${domain}.crt;\n ssl_certificate_key ${PATH_SSL}/${domain}.key;\n ssl_protocols TLSv1.2 TLSv1.3;\n ssl_ecdh_curve X25519:prime256v1:secp384r1:secp521r1;\n ssl_ciphers ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-CHACHA20-POLY1305:ECDHE-RSA-CHACHA20-POLY1305:ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-GCM-SHA256:DHE-RSA-AES256-GCM-SHA384:DHE-RSA-AES128-GCM-SHA256;\n ssl_conf_command Ciphersuites TLS_AES_256_GCM_SHA384:TLS_CHACHA20_POLY1305_SHA256:TLS_AES_128_GCM_SHA256;\n ssl_conf_command Options PrioritizeChaCha;\n ssl_prefer_server_ciphers on;\n ssl_session_timeout 10m;\n ssl_session_cache shared:SSL:10m;\n ssl_buffer_size 2k;\n add_header Strict-Transport-Security max-age=15768000;\n") + if [[ "$(${web_install_dir}/sbin/nginx -V 2>&1 | grep -Eo 'with-http_v2_module')" = 'with-http_v2_module' ]]; then + LISTENOPT="443 ssl http2" else - Nginx_conf=$(echo -e "listen 80;\n listen 443 ssl;\n http2 on;\n ssl_certificate ${PATH_SSL}/${domain}.crt;\n ssl_certificate_key ${PATH_SSL}/${domain}.key;\n ssl_protocols TLSv1.2 TLSv1.3;\n ssl_ecdh_curve X25519:prime256v1:secp384r1:secp521r1;\n ssl_ciphers ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-CHACHA20-POLY1305:ECDHE-RSA-CHACHA20-POLY1305:ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-GCM-SHA256:DHE-RSA-AES256-GCM-SHA384:DHE-RSA-AES128-GCM-SHA256;\n ssl_conf_command Ciphersuites TLS_AES_256_GCM_SHA384:TLS_CHACHA20_POLY1305_SHA256:TLS_AES_128_GCM_SHA256;\n ssl_conf_command Options PrioritizeChaCha;\n ssl_prefer_server_ciphers on;\n ssl_session_timeout 10m;\n ssl_session_cache shared:SSL:10m;\n ssl_buffer_size 2k;\n add_header Strict-Transport-Security max-age=15768000;\n") + LISTENOPT="443 ssl spdy" fi + Create_SSL + Nginx_conf=$(echo -e "listen 80;\n listen ${LISTENOPT};\n ssl_certificate ${PATH_SSL}/${domain}.crt;\n ssl_certificate_key ${PATH_SSL}/${domain}.key;\n ssl_protocols TLSv1 TLSv1.1 TLSv1.2;\n ssl_ciphers EECDH+CHACHA20:EECDH+AES128:RSA+AES128:EECDH+AES256:RSA+AES256:EECDH+3DES:RSA+3DES:!MD5;\n ssl_prefer_server_ciphers on;\n ssl_session_timeout 10m;\n ssl_session_cache builtin:1000 shared:SSL:10m;\n ssl_buffer_size 1400;\n add_header Strict-Transport-Security max-age=15768000;\n ssl_stapling on;\n ssl_stapling_verify on;\n") Apache_SSL=$(echo -e "SSLEngine on\n SSLCertificateFile \"${PATH_SSL}/${domain}.crt\"\n SSLCertificateKeyFile \"${PATH_SSL}/${domain}.key\"") - elif [ "${apache_ssl_flag}" == 'y' ]; then + elif [ "$apache_ssl_yn" == 'y' ]; then Create_SSL Apache_SSL=$(echo -e "SSLEngine on\n SSLCertificateFile \"${PATH_SSL}/${domain}.crt\"\n SSLCertificateKeyFile \"${PATH_SSL}/${domain}.key\"") [ -z "$(grep 'Listen 443' ${apache_install_dir}/conf/httpd.conf)" ] && sed -i "s@Listen 80@&\nListen 443@" ${apache_install_dir}/conf/httpd.conf [ -z "$(grep 'ServerName 0.0.0.0:443' ${apache_install_dir}/conf/httpd.conf)" ] && sed -i "s@ServerName 0.0.0.0:80@&\nServerName 0.0.0.0:443@" ${apache_install_dir}/conf/httpd.conf else - if [ -n "`ifconfig | grep inet6`" ]; then - Nginx_conf=$(echo -e "listen 80;\n listen [::]:80;") - else - Nginx_conf=$(echo -e "listen 80;") - fi + Nginx_conf="listen 80;" fi } Nginx_anti_hotlinking() { while :; do echo - read -e -p "Do you want to add hotlink protection? [y/n]: " anti_hotlinking_flag - if [[ ! ${anti_hotlinking_flag} =~ ^[y,n]$ ]]; then + read -p "Do you want to add hotlink protection? [y/n]: " anti_hotlinking_yn + if [[ ! $anti_hotlinking_yn =~ ^[y,n]$ ]]; then echo "${CWARNING}input error! Please only input 'y' or 'n'${CEND}" else break @@ -535,44 +410,42 @@ Nginx_anti_hotlinking() { domain_allow="*.${domain} ${domain}" fi - if [ "${anti_hotlinking_flag}" == 'y' ]; then - if [ "${moredomainame_flag}" == 'y' -a "${moredomain}" != "*.${domain}" ]; then + if [ "${anti_hotlinking_yn}" == 'y' ]; then + if [ "${moredomainame_yn}" == 'y' ]; then domain_allow_all=${domain_allow}${moredomainame} else domain_allow_all=${domain_allow} fi - domain_allow_all=`echo ${domain_allow_all} | tr ' ' '\n' | awk '!a[$1]++' | xargs` - anti_hotlinking=$(echo -e "location ~ .*\.(wma|wmv|asf|mp3|mmf|zip|rar|jpg|gif|png|swf|flv|mp4)$ {\n valid_referers none blocked ${domain_allow_all};\n if (\$invalid_referer) {\n return 403;\n }\n }") + anti_hotlinking=$(echo -e "location ~ .*\.(wma|wmv|asf|mp3|mmf|zip|rar|jpg|gif|png|swf|flv|mp4)$ {\n valid_referers none blocked ${domain_allow_all};\n if (\$invalid_referer) {\n rewrite ^/ http://www.linuxeye.com/403.html;\n return 403;\n }\n }") + else + anti_hotlinking= fi } Nginx_rewrite() { [ ! -d "${web_install_dir}/conf/rewrite" ] && mkdir ${web_install_dir}/conf/rewrite while :; do echo - read -e -p "Allow Rewrite rule? [y/n]: " rewrite_flag - if [[ ! "${rewrite_flag}" =~ ^[y,n]$ ]]; then + read -p "Allow Rewrite rule? [y/n]: " rewrite_yn + if [[ ! "${rewrite_yn}" =~ ^[y,n]$ ]]; then echo "${CWARNING}input error! Please only input 'y' or 'n'${CEND}" else break fi done - if [ "${rewrite_flag}" == 'n' ]; then + if [ "${rewrite_yn}" == 'n' ]; then rewrite="none" touch "${web_install_dir}/conf/rewrite/${rewrite}.conf" else echo echo "Please input the rewrite of programme :" - echo "${CMSG}wordpress${CEND},${CMSG}opencart${CEND},${CMSG}magento2${CEND},${CMSG}drupal${CEND},${CMSG}joomla${CEND},${CMSG}codeigniter${CEND},${CMSG}laravel${CEND}" - echo "${CMSG}thinkphp${CEND},${CMSG}pathinfo${CEND},${CMSG}discuz${CEND},${CMSG}typecho${CEND},${CMSG}ecshop${CEND},${CMSG}nextcloud${CEND},${CMSG}zblog${CEND},${CMSG}whmcs${CEND} rewrite was exist." - read -e -p "(Default rewrite: other): " rewrite + echo "${CMSG}wordpress${CEND},${CMSG}opencart${CEND},${CMSG}magento2${CEND},${CMSG}drupal${CEND},${CMSG}joomla${CEND},${CMSG}laravel${CEND},${CMSG}thinkphp${CEND},${CMSG}discuz${CEND},${CMSG}typecho${CEND},${CMSG}ecshop${CEND} rewrite was exist." + read -p "(Default rewrite: other): " rewrite if [ "${rewrite}" == "" ]; then rewrite="other" fi echo "You choose rewrite=${CMSG}$rewrite${CEND}" - [ "${NGX_FLAG}" == 'php' -a "${rewrite}" == "joomla" ] && NGX_CONF=$(echo -e "location ~ \\.php\$ {\n #fastcgi_pass remote_php_ip:9000;\n fastcgi_pass unix:/dev/shm/php${mphp_ver}-cgi.sock;\n fastcgi_index index.php;\n include fastcgi.conf;\n }") - [ "${NGX_FLAG}" == 'php' ] && [[ "${rewrite}" =~ ^codeigniter$|^thinkphp$|^pathinfo$ ]] && NGX_CONF=$(echo -e "location ~ [^/]\.php(/|\$) {\n #fastcgi_pass remote_php_ip:9000;\n fastcgi_pass unix:/dev/shm/php${mphp_ver}-cgi.sock;\n fastcgi_index index.php;\n include fastcgi.conf;\n fastcgi_split_path_info ^(.+?\.php)(/.*)\$;\n set \$path_info \$fastcgi_path_info;\n fastcgi_param PATH_INFO \$path_info;\n try_files \$fastcgi_script_name =404; \n }") - [ "${NGX_FLAG}" == 'php' -a "${rewrite}" == "typecho" ] && NGX_CONF=$(echo -e "location ~ .*\.php(\/.*)*\$ {\n #fastcgi_pass remote_php_ip:9000;\n fastcgi_pass unix:/dev/shm/php${mphp_ver}-cgi.sock;\n fastcgi_index index.php;\n include fastcgi.conf;\n set \$path_info \"\";\n set \$real_script_name \$fastcgi_script_name;\n if (\$fastcgi_script_name ~ \"^(.+?\.php)(/.+)\$\") {\n set \$real_script_name \$1;\n set \$path_info \$2;\n }\n fastcgi_param SCRIPT_FILENAME \$document_root\$real_script_name;\n fastcgi_param SCRIPT_NAME \$real_script_name;\n fastcgi_param PATH_INFO \$path_info;\n }") - if [[ ! "${rewrite}" =~ ^magento2$|^pathinfo$ ]]; then + [ "${NGX_FLAG}" == 'php' -a "${rewrite}" == "thinkphp" ] && NGX_CONF=$(echo -e "location ~ \.php {\n #fastcgi_pass remote_php_ip:9000;\n fastcgi_pass unix:/dev/shm/php-cgi.sock;\n fastcgi_index index.php;\n include fastcgi_params;\n set \$real_script_name \$fastcgi_script_name;\n if (\$fastcgi_script_name ~ \"^(.+?\.php)(/.+)\$\") {\n set \$real_script_name \$1;\n #set \$path_info \$2;\n }\n fastcgi_param SCRIPT_FILENAME \$document_root\$real_script_name;\n fastcgi_param SCRIPT_NAME \$real_script_name;\n #fastcgi_param PATH_INFO \$path_info;\n }") + if [ "${rewrite}" != 'magento2' ]; then if [ -e "config/${rewrite}.conf" ]; then /bin/cp config/${rewrite}.conf ${web_install_dir}/conf/rewrite/${rewrite}.conf else @@ -583,20 +456,20 @@ Nginx_rewrite() { } Nginx_log() { - while :; do echo - read -e -p "Allow Nginx/Tengine/OpenResty access_log? [y/n]: " access_flag - if [[ ! "${access_flag}" =~ ^[y,n]$ ]]; then - echo "${CWARNING}input error! Please only input 'y' or 'n'${CEND}" +while :; do echo + read -p "Allow Nginx/Tengine/OpenResty access_log? [y/n]: " access_yn + if [[ ! "${access_yn}" =~ ^[y,n]$ ]]; then + echo "${CWARNING}input error! Please only input 'y' or 'n'${CEND}" else - break + break fi - done - if [ "${access_flag}" == 'n' ]; then - Nginx_log="access_log off;" - else - Nginx_log="access_log ${wwwlogs_dir}/${domain}_nginx.log combined;" +done +if [ "${access_yn}" == 'n' ]; then + N_log="access_log off;" +else + N_log="access_log ${wwwlogs_dir}/${domain}_nginx.log combined;" echo "You access log file=${CMSG}${wwwlogs_dir}/${domain}_nginx.log${CEND}" - fi +fi } Create_nginx_tomcat_conf() { @@ -605,7 +478,7 @@ Create_nginx_tomcat_conf() { server { ${Nginx_conf} server_name ${domain}${moredomainame}; - ${Nginx_log} + ${N_log} index index.html index.htm index.jsp; root ${vhostdir}; ${Nginx_redirect} @@ -620,25 +493,20 @@ server { expires 7d; access_log off; } - location ~ /(\.user\.ini|\.ht|\.git|\.svn|\.project|LICENSE|README\.md) { + location ~ /\.ht { deny all; } - location /.well-known { - allow all; - } ${NGX_CONF} } EOF - [ "${https_flag}" == 'y' ] && sed -i "s@^root.*;@&\nif (\$ssl_protocol = \"\") { return 301 https://\$host\$request_uri; }@" ${web_install_dir}/conf/vhost/${domain}.conf + [ "${https_yn}" == 'y' ] && sed -i "s@^root.*;@&\nif (\$ssl_protocol = \"\") { return 301 https://\$host\$request_uri; }@" ${web_install_dir}/conf/vhost/${domain}.conf cat > ${tomcat_install_dir}/conf/vhost/${domain}.xml << EOF ${Tomcat_Domain_alias} - EOF [ -z "$(grep -o "vhost-${domain} SYSTEM" ${tomcat_install_dir}/conf/server.xml)" ] && sed -i "/vhost-localhost SYSTEM/a<\!ENTITY vhost-${domain} SYSTEM \"file://${tomcat_install_dir}/conf/vhost/${domain}.xml\">" ${tomcat_install_dir}/conf/server.xml @@ -649,22 +517,24 @@ EOF if [ $? == 0 ]; then echo "Reload Nginx......" ${web_install_dir}/sbin/nginx -s reload - service tomcat restart + /etc/init.d/tomcat restart else - rm -f ${web_install_dir}/conf/vhost/${domain}.conf + rm -rf ${web_install_dir}/conf/vhost/${domain}.conf echo "Create virtualhost ... [${CFAILURE}FAILED${CEND}]" exit 1 fi printf " ####################################################################### +# OneinStack for CentOS/RadHat 5+ Debian 6+ and Ubuntu 12+ # +# For more information please visit https://oneinstack.com # ####################################################################### " echo "$(printf "%-30s" "Your domain:")${CMSG}${domain}${CEND}" echo "$(printf "%-30s" "Nginx Virtualhost conf:")${CMSG}${web_install_dir}/conf/vhost/${domain}.conf${CEND}" echo "$(printf "%-30s" "Tomcat Virtualhost conf:")${CMSG}${tomcat_install_dir}/conf/vhost/${domain}.xml${CEND}" echo "$(printf "%-30s" "Directory of:")${CMSG}${vhostdir}${CEND}" - Print_SSL + [ "${nginx_ssl_yn}" == 'y' ] && Print_ssl } Create_tomcat_conf() { @@ -679,10 +549,12 @@ EOF [ -z "$(grep -o "vhost-${domain};" ${tomcat_install_dir}/conf/server.xml)" ] && sed -i "s@vhost-localhost;@&\n \&vhost-${domain};@" ${tomcat_install_dir}/conf/server.xml echo - service tomcat restart + /etc/init.d/tomcat restart printf " ####################################################################### +# OneinStack for CentOS/RadHat 5+ Debian 6+ and Ubuntu 12+ # +# For more information please visit https://oneinstack.com # ####################################################################### " echo "$(printf "%-30s" "Your domain:")${CMSG}${domain}${CEND}" @@ -691,13 +563,13 @@ EOF echo "$(printf "%-30s" "index url:")${CMSG}http://${domain}:8080/${CEND}" } -Create_nginx_phpfpm_conf() { +Create_nginx_php-fpm_hhvm_conf() { [ ! -d ${web_install_dir}/conf/vhost ] && mkdir ${web_install_dir}/conf/vhost cat > ${web_install_dir}/conf/vhost/${domain}.conf << EOF server { ${Nginx_conf} server_name ${domain}${moredomainame}; - ${Nginx_log} + ${N_log} index index.html index.htm index.php; root ${vhostdir}; ${Nginx_redirect} @@ -706,7 +578,6 @@ server { #error_page 502 /502.html; ${anti_hotlinking} ${NGX_CONF} - location ~ .*\.(gif|jpg|jpeg|png|bmp|swf|flv|mp4|ico)$ { expires 30d; access_log off; @@ -715,23 +586,19 @@ server { expires 7d; access_log off; } - location ~ /(\.user\.ini|\.ht|\.git|\.svn|\.project|LICENSE|README\.md) { + location ~ /\.ht { deny all; } - location /.well-known { - allow all; - } } EOF - [ "${rewrite}" == 'pathinfo' ] && sed -i '/pathinfo.conf;$/d' ${web_install_dir}/conf/vhost/${domain}.conf if [ "${rewrite}" == 'magento2' -a -e "config/${rewrite}.conf" ]; then /bin/cp config/${rewrite}.conf ${web_install_dir}/conf/vhost/${domain}.conf - sed -i "s@/dev/shm/php-cgi.sock@/dev/shm/php${mphp_ver}-cgi.sock@g" ${web_install_dir}/conf/vhost/${domain}.conf sed -i "s@^ set \$MAGE_ROOT.*;@ set \$MAGE_ROOT ${vhostdir};@" ${web_install_dir}/conf/vhost/${domain}.conf sed -i "s@^ server_name.*;@ server_name ${domain}${moredomainame};@" ${web_install_dir}/conf/vhost/${domain}.conf - sed -i "s@^ server_name.*;@&\n ${Nginx_log}@" ${web_install_dir}/conf/vhost/${domain}.conf - if [ "${anti_hotlinking_flag}" == 'y' ]; then + sed -i "s@^ server_name.*;@&\n ${N_log}@" ${web_install_dir}/conf/vhost/${domain}.conf + [ "${NGX_FLAG}" == 'hhvm' ] && sed -i 's@fastcgi_pass unix:.*;@fastcgi_pass unix:/var/log/hhvm/sock;@g' ${web_install_dir}/conf/vhost/${domain}.conf + if [ "${anti_hotlinking_yn}" == 'y' ]; then sed -i "s@^ root.*;@&\n }@" ${web_install_dir}/conf/vhost/${domain}.conf sed -i "s@^ root.*;@&\n }@" ${web_install_dir}/conf/vhost/${domain}.conf sed -i "s@^ root.*;@&\n return 403;@" ${web_install_dir}/conf/vhost/${domain}.conf @@ -741,26 +608,25 @@ EOF sed -i "s@^ root.*;@&\n location ~ .*\.(wma|wmv|asf|mp3|mmf|zip|rar|jpg|gif|png|swf|flv|mp4)\$ {@" ${web_install_dir}/conf/vhost/${domain}.conf fi - [ "${redirect_flag}" == 'y' ] && sed -i "s@^ root.*;@&\n if (\$host != ${domain}) { return 301 \$scheme://${domain}\$request_uri; }@" ${web_install_dir}/conf/vhost/${domain}.conf - - if [ "${nginx_ssl_flag}" == 'y' ]; then - sed -i "s@^ listen 80;@&\n listen 443 ssl;@" ${web_install_dir}/conf/vhost/${domain}.conf + [ "${redirect_yn}" == 'y' ] && sed -i "s@^ root.*;@&\n if (\$host != $domain) { return 301 \$scheme://${domain}\$request_uri; }@" ${web_install_dir}/conf/vhost/${domain}.conf + + if [ "${nginx_ssl_yn}" == 'y' ]; then + sed -i "s@^ listen 80;@&\n listen ${LISTENOPT};@" ${web_install_dir}/conf/vhost/${domain}.conf + sed -i "s@^ server_name.*;@&\n ssl_stapling_verify on;@" ${web_install_dir}/conf/vhost/${domain}.conf + sed -i "s@^ server_name.*;@&\n ssl_stapling on;@" ${web_install_dir}/conf/vhost/${domain}.conf sed -i "s@^ server_name.*;@&\n add_header Strict-Transport-Security max-age=15768000;@" ${web_install_dir}/conf/vhost/${domain}.conf - sed -i "s@^ server_name.*;@&\n ssl_buffer_size 2k;@" ${web_install_dir}/conf/vhost/${domain}.conf - sed -i "s@^ server_name.*;@&\n ssl_session_cache shared:SSL:10m;@" ${web_install_dir}/conf/vhost/${domain}.conf + sed -i "s@^ server_name.*;@&\n ssl_buffer_size 1400;@" ${web_install_dir}/conf/vhost/${domain}.conf + sed -i "s@^ server_name.*;@&\n ssl_session_cache builtin:1000 shared:SSL:10m;@" ${web_install_dir}/conf/vhost/${domain}.conf sed -i "s@^ server_name.*;@&\n ssl_session_timeout 10m;@" ${web_install_dir}/conf/vhost/${domain}.conf sed -i "s@^ server_name.*;@&\n ssl_prefer_server_ciphers on;@" ${web_install_dir}/conf/vhost/${domain}.conf - sed -i "s@^ server_name.*;@&\n ssl_conf_command Options PrioritizeChaCha;@" ${web_install_dir}/conf/vhost/${domain}.conf - sed -i "s@^ server_name.*;@&\n ssl_conf_command Ciphersuites TLS_AES_256_GCM_SHA384:TLS_CHACHA20_POLY1305_SHA256:TLS_AES_128_GCM_SHA256;@" ${web_install_dir}/conf/vhost/${domain}.conf - sed -i "s@^ server_name.*;@&\n ssl_ciphers ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-CHACHA20-POLY1305:ECDHE-RSA-CHACHA20-POLY1305:ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-GCM-SHA256:DHE-RSA-AES256-GCM-SHA384:DHE-RSA-AES128-GCM-SHA256;@" ${web_install_dir}/conf/vhost/${domain}.conf - sed -i "s@^ server_name.*;@&\n ssl_ecdh_curve X25519:prime256v1:secp384r1:secp521r1;@" ${web_install_dir}/conf/vhost/${domain}.conf - sed -i "s@^ server_name.*;@&\n ssl_protocols TLSv1.2 TLSv1.3;@" ${web_install_dir}/conf/vhost/${domain}.conf + sed -i "s@^ server_name.*;@&\n ssl_ciphers EECDH+CHACHA20:EECDH+AES128:RSA+AES128:EECDH+AES256:RSA+AES256:EECDH+3DES:RSA+3DES:\!MD5;@" ${web_install_dir}/conf/vhost/${domain}.conf + sed -i "s@^ server_name.*;@&\n ssl_protocols TLSv1 TLSv1.1 TLSv1.2;@" ${web_install_dir}/conf/vhost/${domain}.conf sed -i "s@^ server_name.*;@&\n ssl_certificate_key ${PATH_SSL}/${domain}.key;@" ${web_install_dir}/conf/vhost/${domain}.conf sed -i "s@^ server_name.*;@&\n ssl_certificate ${PATH_SSL}/${domain}.crt;@" ${web_install_dir}/conf/vhost/${domain}.conf fi fi - [ "${https_flag}" == 'y' ] && sed -i "s@^ root.*;@&\n if (\$ssl_protocol = \"\") { return 301 https://\$host\$request_uri; }@" ${web_install_dir}/conf/vhost/${domain}.conf + [ "${https_yn}" == 'y' ] && sed -i "s@^ root.*;@&\n if (\$ssl_protocol = \"\") { return 301 https://\$host\$request_uri; }@" ${web_install_dir}/conf/vhost/${domain}.conf echo ${web_install_dir}/sbin/nginx -t @@ -768,123 +634,44 @@ EOF echo "Reload Nginx......" ${web_install_dir}/sbin/nginx -s reload else - rm -f ${web_install_dir}/conf/vhost/${domain}.conf + rm -rf ${web_install_dir}/conf/vhost/${domain}.conf echo "Create virtualhost ... [${CFAILURE}FAILED${CEND}]" exit 1 fi printf " ####################################################################### +# OneinStack for CentOS/RadHat 5+ Debian 6+ and Ubuntu 12+ # +# For more information please visit https://oneinstack.com # ####################################################################### " echo "$(printf "%-30s" "Your domain:")${CMSG}${domain}${CEND}" echo "$(printf "%-30s" "Virtualhost conf:")${CMSG}${web_install_dir}/conf/vhost/${domain}.conf${CEND}" echo "$(printf "%-30s" "Directory of:")${CMSG}${vhostdir}${CEND}" - [ "${rewrite_flag}" == 'y' -a "${rewrite}" != 'magento2' -a "${rewrite}" != 'pathinfo' ] && echo "$(printf "%-30s" "Rewrite rule:")${CMSG}${web_install_dir}/conf/rewrite/${rewrite}.conf${CEND}" - Print_SSL -} - -Create_nginx_proxy_conf() { - [ ! -d ${web_install_dir}/conf/vhost ] && mkdir ${web_install_dir}/conf/vhost - cat > ${web_install_dir}/conf/vhost/${domain}.conf << EOF -server { - ${Nginx_conf} - server_name ${domain}${moredomainame}; - ${Nginx_log} - index index.html index.htm index.php; - ${Nginx_redirect} - location / { - proxy_pass ${Proxy_Pass}; - proxy_set_header X-Forwarded-For \$proxy_add_x_forwarded_for; - proxy_set_header Host \$http_host; - proxy_set_header X-NginX-Proxy true; - proxy_http_version 1.1; - proxy_set_header Upgrade \$http_upgrade; - proxy_set_header Connection "upgrade"; - proxy_max_temp_file_size 0; - } - - #error_page 404 /404.html; - #error_page 502 /502.html; - ${anti_hotlinking} - - location ~ .*\.(gif|jpg|jpeg|png|bmp|swf|flv|mp4|ico)$ { - expires 30d; - access_log off; - } - location ~ .*\.(js|css)?$ { - expires 7d; - access_log off; - } - location ~ /(\.user\.ini|\.ht|\.git|\.svn|\.project|LICENSE|README\.md) { - deny all; - } - location /.well-known { - allow all; - } -} -EOF - - [ "${redirect_flag}" == 'y' ] && sed -i "s@^ root.*;@&\n if (\$host != ${domain}) { return 301 \$scheme://${domain}\$request_uri; }@" ${web_install_dir}/conf/vhost/${domain}.conf - - if [ "${anti_hotlinking_flag}" == 'y' ]; then - sed -i "s@^ root.*;@&\n }@" ${web_install_dir}/conf/vhost/${domain}.conf - sed -i "s@^ root.*;@&\n }@" ${web_install_dir}/conf/vhost/${domain}.conf - sed -i "s@^ root.*;@&\n return 403;@" ${web_install_dir}/conf/vhost/${domain}.conf - sed -i "s@^ root.*;@&\n rewrite ^/ http://www.linuxeye.com/403.html;@" ${web_install_dir}/conf/vhost/${domain}.conf - sed -i "s@^ root.*;@&\n if (\$invalid_referer) {@" ${web_install_dir}/conf/vhost/${domain}.conf - sed -i "s@^ root.*;@&\n valid_referers none blocked ${domain_allow_all};@" ${web_install_dir}/conf/vhost/${domain}.conf - sed -i "s@^ root.*;@&\n location ~ .*\.(wma|wmv|asf|mp3|mmf|zip|rar|jpg|gif|png|swf|flv|mp4)\$ {@" ${web_install_dir}/conf/vhost/${domain}.conf - fi - - [ "${https_flag}" == 'y' ] && sed -i "s@^ root.*;@&\n if (\$ssl_protocol = \"\") { return 301 https://\$host\$request_uri; }@" ${web_install_dir}/conf/vhost/${domain}.conf - - echo - ${web_install_dir}/sbin/nginx -t - if [ $? == 0 ]; then - echo "Reload Nginx......" - ${web_install_dir}/sbin/nginx -s reload - else - rm -f ${web_install_dir}/conf/vhost/${domain}.conf - echo "Create virtualhost ... [${CFAILURE}FAILED${CEND}]" - exit 1 - fi - - printf " -####################################################################### -####################################################################### -" - echo "$(printf "%-30s" "Your domain:")${CMSG}${domain}${CEND}" - echo "$(printf "%-30s" "Virtualhost conf:")${CMSG}${web_install_dir}/conf/vhost/${domain}.conf${CEND}" - #echo "$(printf "%-30s" "Directory of:")${CMSG}${vhostdir}${CEND}" - [ "${rewrite_flag}" == 'y' -a "${rewrite}" != 'magento2' -a "${rewrite}" != 'pathinfo' ] && echo "$(printf "%-30s" "Rewrite rule:")${CMSG}${web_install_dir}/conf/rewrite/${rewrite}.conf${CEND}" - Print_SSL + [ "${rewrite_yn}" == 'y' -a "${rewrite}" != 'magento2' ] && echo "$(printf "%-30s" "Rewrite rule:")${CMSG}${web_install_dir}/conf/rewrite/${rewrite}.conf${CEND}" + [ "${nginx_ssl_yn}" == 'y' ] && Print_ssl } Apache_log() { while :; do echo - read -e -p "Allow Apache access_log? [y/n]: " access_flag - if [[ ! "${access_flag}" =~ ^[y,n]$ ]]; then + read -p "Allow Apache access_log? [y/n]: " access_yn + if [[ ! "${access_yn}" =~ ^[y,n]$ ]]; then echo "${CWARNING}input error! Please only input 'y' or 'n'${CEND}" else break fi done - if [ "${access_flag}" == 'n' ]; then - Apache_log='CustomLog "/dev/null" common' + if [ "${access_yn}" == 'n' ]; then + A_log='CustomLog "/dev/null" common' else - Apache_log="CustomLog \"${wwwlogs_dir}/${domain}_apache.log\" common" + A_log="CustomLog \"${wwwlogs_dir}/${domain}_apache.log\" common" echo "You access log file=${wwwlogs_dir}/${domain}_apache.log" fi } Create_apache_conf() { - if [ "${Apache_main_ver}" == '24' ]; then - if [ -e "${php_install_dir}/sbin/php-fpm" ] && [ -n "`grep -E ^LoadModule.*mod_proxy_fcgi.so ${apache_install_dir}/conf/httpd.conf`" ]; then - Apache_fcgi=$(echo -e "\n Order allow,deny\n Deny from all\n \n \n SetHandler \"proxy:unix:/dev/shm/php${mphp_ver}-cgi.sock|fcgi://localhost\"\n ") - fi - fi + [ "$(${apache_install_dir}/bin/apachectl -v | awk -F'.' /version/'{print $2}')" == '4' ] && R_TMP='Require all granted' || R_TMP= [ ! -d ${apache_install_dir}/conf/vhost ] && mkdir ${apache_install_dir}/conf/vhost cat > ${apache_install_dir}/conf/vhost/${domain}.conf << EOF @@ -893,12 +680,11 @@ Create_apache_conf() { ServerName ${domain} ${Apache_Domain_alias} ErrorLog "${wwwlogs_dir}/${domain}_error_apache.log" - ${Apache_log} - ${Apache_fcgi} + ${A_log} SetOutputFilter DEFLATE Options FollowSymLinks ExecCGI - ${Apache_grant} + ${R_TMP} AllowOverride All Order allow,deny Allow from all @@ -906,7 +692,7 @@ Create_apache_conf() { EOF - [ "${apache_ssl_flag}" == 'y' ] && cat >> ${apache_install_dir}/conf/vhost/${domain}.conf << EOF + [ "$apache_ssl_yn" == 'y' ] && cat >> ${apache_install_dir}/conf/vhost/${domain}.conf << EOF ServerAdmin admin@example.com DocumentRoot "${vhostdir}" @@ -914,12 +700,11 @@ EOF ${Apache_Domain_alias} ${Apache_SSL} ErrorLog "${wwwlogs_dir}/${domain}_error_apache.log" - ${Apache_log} - ${Apache_fcgi} + ${A_log} SetOutputFilter DEFLATE Options FollowSymLinks ExecCGI - ${Apache_grant} + ${R_TMP} AllowOverride All Order allow,deny Allow from all @@ -932,31 +717,33 @@ EOF ${apache_install_dir}/bin/apachectl -t if [ $? == 0 ]; then echo "Restart Apache......" - ${apache_install_dir}/bin/apachectl -k graceful + /etc/init.d/httpd restart else - rm -f ${apache_install_dir}/conf/vhost/${domain}.conf + rm -rf ${apache_install_dir}/conf/vhost/${domain}.conf echo "Create virtualhost ... [${CFAILURE}FAILED${CEND}]" exit 1 fi printf " ####################################################################### +# OneinStack for CentOS/RadHat 5+ Debian 6+ and Ubuntu 12+ # +# For more information please visit https://oneinstack.com # ####################################################################### " echo "$(printf "%-30s" "Your domain:")${CMSG}${domain}${CEND}" echo "$(printf "%-30s" "Virtualhost conf:")${CMSG}${apache_install_dir}/conf/vhost/${domain}.conf${CEND}" echo "$(printf "%-30s" "Directory of:")${CMSG}${vhostdir}${CEND}" - Print_SSL + [ "${apache_ssl_yn}" == 'y' ] && Print_ssl } -Create_nginx_apache_modphp_conf() { +Create_nginx_apache_mod-php_conf() { # Nginx/Tengine/OpenResty [ ! -d ${web_install_dir}/conf/vhost ] && mkdir ${web_install_dir}/conf/vhost cat > ${web_install_dir}/conf/vhost/${domain}.conf << EOF server { ${Nginx_conf} server_name ${domain}${moredomainame}; - ${Nginx_log} + ${N_log} index index.html index.htm index.php; root ${vhostdir}; ${Nginx_redirect} @@ -980,16 +767,13 @@ server { expires 7d; access_log off; } - location ~ /(\.user\.ini|\.ht|\.git|\.svn|\.project|LICENSE|README\.md) { + location ~ /\.ht { deny all; } - location /.well-known { - allow all; - } } EOF - [ "${https_flag}" == 'y' ] && sed -i "s@^ root.*;@&\n if (\$ssl_protocol = \"\") { return 301 https://\$host\$request_uri; }@" ${web_install_dir}/conf/vhost/${domain}.conf + [ "${https_yn}" == 'y' ] && sed -i "s@^ root.*;@&\n if (\$ssl_protocol = \"\") { return 301 https://\$host\$request_uri; }@" ${web_install_dir}/conf/vhost/${domain}.conf echo ${web_install_dir}/sbin/nginx -t @@ -997,16 +781,12 @@ EOF echo "Reload Nginx......" ${web_install_dir}/sbin/nginx -s reload else - rm -f ${web_install_dir}/conf/vhost/${domain}.conf + rm -rf ${web_install_dir}/conf/vhost/${domain}.conf echo "Create virtualhost ... [${CFAILURE}FAILED${CEND}]" fi # Apache - if [ "${Apache_main_ver}" == '24' ]; then - if [ -e "${php_install_dir}/sbin/php-fpm" ] && [ -n "`grep -E ^LoadModule.*mod_proxy_fcgi.so ${apache_install_dir}/conf/httpd.conf`" ]; then - Apache_fcgi=$(echo -e "\n Order allow,deny\n Deny from all\n \n \n SetHandler \"proxy:unix:/dev/shm/php${mphp_ver}-cgi.sock|fcgi://localhost\"\n ") - fi - fi + [ "$(${apache_install_dir}/bin/apachectl -v | awk -F'.' /version/'{print $2}')" == '4' ] && R_TMP="Require all granted" || R_TMP= [ ! -d ${apache_install_dir}/conf/vhost ] && mkdir ${apache_install_dir}/conf/vhost cat > ${apache_install_dir}/conf/vhost/${domain}.conf << EOF @@ -1016,12 +796,11 @@ EOF ${Apache_Domain_alias} ${Apache_SSL} ErrorLog "${wwwlogs_dir}/${domain}_error_apache.log" - ${Apache_log} - ${Apache_fcgi} + ${A_log} SetOutputFilter DEFLATE Options FollowSymLinks ExecCGI - ${Apache_grant} + ${R_TMP} AllowOverride All Order allow,deny Allow from all @@ -1034,62 +813,63 @@ EOF ${apache_install_dir}/bin/apachectl -t if [ $? == 0 ]; then echo "Restart Apache......" - ${apache_install_dir}/bin/apachectl -k graceful + /etc/init.d/httpd restart else - rm -f ${apache_install_dir}/conf/vhost/${domain}.conf + rm -rf ${apache_install_dir}/conf/vhost/${domain}.conf exit 1 fi printf " ####################################################################### +# OneinStack for CentOS/RadHat 5+ Debian 6+ and Ubuntu 12+ # +# For more information please visit https://oneinstack.com # ####################################################################### " echo "$(printf "%-30s" "Your domain:")${CMSG}${domain}${CEND}" echo "$(printf "%-30s" "Nginx Virtualhost conf:")${CMSG}${web_install_dir}/conf/vhost/${domain}.conf${CEND}" echo "$(printf "%-30s" "Apache Virtualhost conf:")${CMSG}${apache_install_dir}/conf/vhost/${domain}.conf${CEND}" echo "$(printf "%-30s" "Directory of:")${CMSG}${vhostdir}${CEND}" - Print_SSL + [ "${nginx_ssl_yn}" == 'y' ] && Print_ssl } Add_Vhost() { - if [ -e "${web_install_dir}/sbin/nginx" -a ! -e "${apache_install_dir}/bin/httpd" ]; then - Choose_ENV + if [ -e "${web_install_dir}/sbin/nginx" -a ! -e "${apache_install_dir}/conf/httpd.conf" ]; then + Choose_env Input_Add_domain Nginx_anti_hotlinking - if [ "${proxy_flag}" == "y" ]; then - Input_Add_proxy - Create_nginx_proxy_conf - else - Nginx_rewrite - if [ "${NGX_FLAG}" == "java" ]; then - Nginx_log - Create_nginx_tomcat_conf - else - Nginx_log - Create_nginx_phpfpm_conf - fi + if [ "${NGX_FLAG}" == "java" ]; then + Nginx_log + Create_nginx_tomcat_conf + else + Nginx_rewrite + Nginx_log + Create_nginx_php-fpm_hhvm_conf fi - elif [ ! -e "${web_install_dir}/sbin/nginx" -a -e "${apache_install_dir}/bin/httpd" ]; then - Choose_ENV + elif [ ! -e "${web_install_dir}/sbin/nginx" -a -e "${apache_install_dir}/conf/httpd.conf" ]; then + Choose_env Input_Add_domain Apache_log Create_apache_conf - elif [ ! -e "${web_install_dir}/sbin/nginx" -a ! -e "${apache_install_dir}/bin/httpd" -a -e "${tomcat_install_dir}/conf/server.xml" ]; then - Choose_ENV + elif [ ! -e "${web_install_dir}/sbin/nginx" -a ! -e "${apache_install_dir}/conf/httpd.conf" -a -e "${tomcat_install_dir}/conf/server.xml" ]; then + Choose_env Input_Add_domain Create_tomcat_conf - elif [ -e "${web_install_dir}/sbin/nginx" -a -e "${apache_install_dir}/bin/httpd" ]; then - Choose_ENV + elif [ -e "${web_install_dir}/sbin/nginx" -a -e "$(ls ${apache_install_dir}/modules/libphp?.so 2>/dev/null)" ]; then + Choose_env Input_Add_domain Nginx_anti_hotlinking if [ "${NGX_FLAG}" == "java" ]; then - Nginx_rewrite Nginx_log Create_nginx_tomcat_conf + elif [ "${NGX_FLAG}" == "hhvm" ]; then + Nginx_rewrite + Nginx_log + Create_nginx_php-fpm_hhvm_conf elif [ "${NGX_FLAG}" == "php" ]; then + #Nginx_rewrite Nginx_log Apache_log - Create_nginx_apache_modphp_conf + Create_nginx_apache_mod-php_conf fi else echo "Error! ${CFAILURE}Web server${CEND} not found!" @@ -1104,33 +884,28 @@ Del_NGX_Vhost() { echo "Virtualhost list:" echo ${CMSG}${Domain_List}${CEND} while :; do echo - read -e -p "Please input a domain you want to delete: " domain + read -p "Please input a domain you want to delete: " domain if [ -z "$(echo ${domain} | grep '.*\..*')" ]; then - echo "${CWARNING}Your ${domain} is invalid! ${CEND}" + echo "${CWARNING}input error! ${CEND}" else if [ -e "${web_install_dir}/conf/vhost/${domain}.conf" ]; then Directory=$(grep '^ root' ${web_install_dir}/conf/vhost/${domain}.conf | head -1 | awk -F'[ ;]' '{print $(NF-1)}') - rm -f ${web_install_dir}/conf/vhost/${domain}.conf - [ -e "${web_install_dir}/conf/ssl/${domain}.crt" ] && rm -f ${web_install_dir}/conf/ssl/${domain}.{crt,key} + rm -rf ${web_install_dir}/conf/vhost/${domain}.conf ${web_install_dir}/sbin/nginx -s reload while :; do echo - read -e -p "Do you want to delete Virtul Host directory? [y/n]: " Del_Vhost_wwwroot_flag - if [[ ! ${Del_Vhost_wwwroot_flag} =~ ^[y,n]$ ]]; then + read -p "Do you want to delete Virtul Host directory? [y/n]: " Del_Vhost_wwwroot_yn + if [[ ! ${Del_Vhost_wwwroot_yn} =~ ^[y,n]$ ]]; then echo "${CWARNING}input error! Please only input 'y' or 'n'${CEND}" else break fi done - if [ "${Del_Vhost_wwwroot_flag}" == 'y' ]; then - if [ "${quiet_flag}" != 'y' ]; then - echo "Press Ctrl+c to cancel or Press any key to continue..." - char=$(get_char) - fi + if [ "${Del_Vhost_wwwroot_yn}" == 'y' ]; then + echo "Press Ctrl+c to cancel or Press any key to continue..." + char=$(get_char) rm -rf ${Directory} fi echo - [ -d ~/.acme.sh/${domain} ] && ~/.acme.sh/acme.sh --force --remove -d ${domain} > /dev/null 2>&1 - [ -d ~/.acme.sh/${domain}_ecc ] && ~/.acme.sh/acme.sh --force --remove --ecc -d ${domain} > /dev/null 2>&1 echo "${CMSG}Domain: ${domain} has been deleted.${CEND}" echo else @@ -1139,6 +914,7 @@ Del_NGX_Vhost() { break fi done + else echo "${CWARNING}Virtualhost was not exist! ${CEND}" fi @@ -1146,10 +922,10 @@ Del_NGX_Vhost() { } Del_Apache_Vhost() { - if [ -e "${apache_install_dir}/bin/httpd" ]; then + if [ -e "${apache_install_dir}/conf/httpd.conf" ]; then if [ -e "${web_install_dir}/sbin/nginx" ]; then - rm -f ${apache_install_dir}/conf/vhost/${domain}.conf - ${apache_install_dir}/bin/apachectl -k graceful + rm -rf ${apache_install_dir}/conf/vhost/${domain}.conf + /etc/init.d/httpd restart else Domain_List=$(ls ${apache_install_dir}/conf/vhost | grep -v '0.conf' | sed "s@.conf@@g") if [ -n "${Domain_List}" ]; then @@ -1157,33 +933,28 @@ Del_Apache_Vhost() { echo "Virtualhost list:" echo ${CMSG}${Domain_List}${CEND} while :; do echo - read -e -p "Please input a domain you want to delete: " domain + read -p "Please input a domain you want to delete: " domain if [ -z "$(echo ${domain} | grep '.*\..*')" ]; then - echo "${CWARNING}Your ${domain} is invalid! ${CEND}" + echo "${CWARNING}input error! ${CEND}" else if [ -e "${apache_install_dir}/conf/vhost/${domain}.conf" ]; then Directory=$(grep '^ /dev/null 2>&1 - [ -d ~/.acme.sh/${domain}_ecc ] && ~/.acme.sh/acme.sh --force --remove --ecc -d ${domain} > /dev/null 2>&1 echo "${CSUCCESS}Domain: ${domain} has been deleted.${CEND}" else echo "${CWARNING}Virtualhost: ${domain} was not exist! ${CEND}" @@ -1202,10 +973,10 @@ Del_Apache_Vhost() { Del_Tomcat_Vhost() { if [ -e "${tomcat_install_dir}/conf/server.xml" ]; then if [ -e "${web_install_dir}/sbin/nginx" ]; then - if [ -n "$(echo ${domain} | grep '.*\..*')" ] && [ -n "$(grep vhost-${domain} ${tomcat_install_dir}/conf/server.xml)" ]; then + if [ -n "$(grep vhost-${domain} ${tomcat_install_dir}/conf/server.xml)" ]; then sed -i /vhost-${domain}/d ${tomcat_install_dir}/conf/server.xml - rm -f ${tomcat_install_dir}/conf/vhost/${domain}.xml - service tomcat restart + rm -rf ${tomcat_install_dir}/conf/vhost/${domain}.xml + /etc/init.d/tomcat restart fi else Domain_List=$(ls ${tomcat_install_dir}/conf/vhost | grep -v 'localhost.xml' | sed "s@.xml@@g") @@ -1214,28 +985,26 @@ Del_Tomcat_Vhost() { echo "Virtualhost list:" echo ${CMSG}${Domain_List}${CEND} while :; do echo - read -e -p "Please input a domain you want to delete: " domain + read -p "Please input a domain you want to delete: " domain if [ -z "$(echo ${domain} | grep '.*\..*')" ]; then - echo "${CWARNING}Your ${domain} is invalid! ${CEND}" + echo "${CWARNING}input error! ${CEND}" else if [ -n "$(grep vhost-${domain} ${tomcat_install_dir}/conf/server.xml)" ]; then sed -i /vhost-${domain}/d ${tomcat_install_dir}/conf/server.xml - rm -f ${tomcat_install_dir}/conf/vhost/${domain}.xml - service tomcat restart + rm -rf ${tomcat_install_dir}/conf/vhost/${domain}.xml + /etc/init.d/tomcat restart while :; do echo - read -e -p "Do you want to delete Virtul Host directory? [y/n]: " Del_Vhost_wwwroot_flag - if [[ ! ${Del_Vhost_wwwroot_flag} =~ ^[y,n]$ ]]; then + read -p "Do you want to delete Virtul Host directory? [y/n]: " Del_Vhost_wwwroot_yn + if [[ ! ${Del_Vhost_wwwroot_yn} =~ ^[y,n]$ ]]; then echo "${CWARNING}input error! Please only input 'y' or 'n'${CEND}" else break fi done - if [ "${Del_Vhost_wwwroot_flag}" == 'y' ]; then - if [ "${quiet_flag}" != 'y' ]; then - echo "Press Ctrl+c to cancel or Press any key to continue..." - char=$(get_char) - fi + if [ "${Del_Vhost_wwwroot_yn}" == 'y' ]; then + echo "Press Ctrl+c to cancel or Press any key to continue..." + char=$(get_char) rm -rf ${Directory} fi echo "${CSUCCESS}Domain: ${domain} has been deleted.${CEND}" @@ -1253,23 +1022,22 @@ Del_Tomcat_Vhost() { fi } -List_Vhost() { - [ -e "${tomcat_install_dir}/conf/server.xml" -a ! -d "${web_install_dir}/sbin/nginx" ] && Domain_List=$(ls ${tomcat_install_dir}/conf/vhost | grep -v 'localhost.xml' | sed "s@.xml@@g") - [ -d "${web_install_dir}/conf/vhost" ] && Domain_List=$(ls ${web_install_dir}/conf/vhost | sed "s@.conf@@g") - [ -e "${apache_install_dir}/bin/httpd" -a ! -d "${web_install_dir}/conf/vhost" ] && Domain_List=$(ls ${apache_install_dir}/conf/vhost | grep -v '0.conf' | sed "s@.conf@@g") - if [ -n "${Domain_List}" ]; then - echo - echo "Virtualhost list:" - for D in ${Domain_List}; do echo ${CMSG}${D}${CEND}; done - else - echo "${CWARNING}Virtualhost was not exist! ${CEND}" - fi -} - -if [ ${ARG_NUM} == 0 ]; then +if [ $# == 0 ]; then Add_Vhost +elif [ $# == 1 ]; then + case $1 in + add) + Add_Vhost + ;; + del) + Del_NGX_Vhost + Del_Apache_Vhost + Del_Tomcat_Vhost + ;; + *) + Usage + ;; + esac else - [ "${add_flag}" == 'y' -o "${proxy_flag}" == 'y' -o "${sslquiet_flag}" == 'y' ] && Add_Vhost - [ "${list_flag}" == 'y' ] && List_Vhost - [ "${delete_flag}" == 'y' ] && { Del_NGX_Vhost; Del_Apache_Vhost; Del_Tomcat_Vhost; } + Usage fi