From 5b9adb8422c36b9922d11a6aa7e5a9092f838ef5 Mon Sep 17 00:00:00 2001 From: "lj2007331@gmail.com" Date: Sun, 25 Mar 2018 19:23:51 +0800 Subject: [PATCH] improve --- addons.sh | 36 +++--- backup.sh | 14 +- backup_setup.sh | 27 ++-- include/alisql-5.6.sh | 1 + include/check_download.sh | 233 ++++++++++++++++------------------ include/mariadb-10.0.sh | 1 + include/mariadb-10.1.sh | 1 + include/mariadb-10.2.sh | 1 + include/mariadb-5.5.sh | 1 + include/mongodb.sh | 1 + include/mysql-5.5.sh | 1 + include/mysql-5.6.sh | 1 + include/mysql-5.7.sh | 1 + include/percona-5.5.sh | 1 + include/percona-5.6.sh | 1 + include/percona-5.7.sh | 1 + include/postgresql.sh | 1 + include/upgrade_oneinstack.sh | 2 +- include/upgrade_web.sh | 26 ++-- install.sh | 107 ++++++++-------- pureftpd_vhost.sh | 2 +- reset_db_root_password.sh | 4 +- ss.sh | 6 +- uninstall.sh | 32 ++--- upgrade.sh | 20 +-- versions.txt | 4 +- vhost.sh | 22 ++-- 27 files changed, 268 insertions(+), 280 deletions(-) diff --git a/addons.sh b/addons.sh index 23d4a4fa..64694355 100755 --- a/addons.sh +++ b/addons.sh @@ -8,7 +8,7 @@ # https://oneinstack.com # https://github.com/lj2007331/oneinstack -export PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin +export PATH=/sbin:/bin:/usr/sbin:/usr/bin:/usr/local/sbin:/usr/local/bin clear printf " ####################################################################### @@ -62,7 +62,7 @@ fi # Check PHP Extensions Check_PHP_Extension() { - [ ! -e "${php_install_dir}/bin/phpize" ] && { echo "${CWARNING}PHP was not exist! ${CEND}"; exit 1; } + [ ! -e "${php_install_dir}/bin/phpize" ] && { echo "${CWARNING}PHP was not exist! ${CEND}"; exit 1; } [ -e "`ls ${php_install_dir}/etc/php.d/0?-${PHP_extension}.ini 2> /dev/null`" ] && { echo "${CWARNING}PHP ${PHP_extension} module already installed! ${CEND}"; exit 1; } } @@ -90,7 +90,7 @@ Install_fail2ban() { ${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 + /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 @@ -99,7 +99,7 @@ Install_fail2ban() { fi if [[ "${OS}" =~ ^Ubuntu$|^Debian$ ]]; then LOGPATH=/var/log/auth.log - /bin/cp files/debian-initd /etc/init.d/fail2ban + /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 @@ -116,9 +116,9 @@ maxretry = 5 enabled = true filter = sshd action = iptables[name=SSH, port=$now_ssh_port, protocol=tcp] -logpath = $LOGPATH +logpath = $LOGPATH EOF - cat > /etc/logrotate.d/fail2ban << EOF + cat > /etc/logrotate.d/fail2ban << EOF /var/log/fail2ban.log { missingok notifempty @@ -142,7 +142,7 @@ EOF 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 + 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}"; } @@ -171,9 +171,9 @@ What Are You Doing? \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 swoole PHP Extension -\t${CMSG} 8${CEND}. Install/Uninstall xdebug PHP Extension -\t${CMSG} 9${CEND}. Install/Uninstall PHP Composer +\t${CMSG} 7${CEND}. Install/Uninstall swoole PHP Extension +\t${CMSG} 8${CEND}. Install/Uninstall xdebug PHP Extension +\t${CMSG} 9${CEND}. Install/Uninstall PHP Composer \t${CMSG}10${CEND}. Install/Uninstall fail2ban \t${CMSG} q${CEND}. Exit " @@ -435,7 +435,7 @@ What Are You Doing? ./configure --with-php-config=${php_install_dir}/bin/php-config make -j ${THREAD} && make install popd - rm -rf swoole-${swoole_ver} + rm -rf swoole-${swoole_ver} popd echo 'extension=swoole.so' > ${php_install_dir}/etc/php.d/06-swoole.ini Check_succ @@ -452,17 +452,17 @@ What Are You Doing? if [[ "${PHP_main_ver}" =~ ^7\.[0-2]$ ]]; then src_url=https://pecl.php.net/get/xdebug-${xdebug_ver}.tgz && Download_src src_url=http://mirrors.linuxeye.com/oneinstack/src/webgrind-master.zip && Download_src - tar xzf xdebug-${xdebug_ver}.tgz + tar xzf xdebug-${xdebug_ver}.tgz unzip -q webgrind-master.zip - /bin/mv webgrind-master ${wwwroot_dir}/default/webgrind - pushd xdebug-${xdebug_ver} + /bin/mv webgrind-master ${wwwroot_dir}/default/webgrind + pushd xdebug-${xdebug_ver} elif [[ "${PHP_main_ver}" =~ ^5\.[5-6]$ ]]; then src_url=https://pecl.php.net/get/xdebug-2.5.5.tgz && Download_src src_url=http://mirrors.linuxeye.com/oneinstack/src/webgrind-master.zip && Download_src - tar xzf xdebug-2.5.5.tgz + tar xzf xdebug-2.5.5.tgz unzip -q webgrind-master.zip - /bin/mv webgrind-master ${wwwroot_dir}/default/webgrind - pushd xdebug-2.5.5 + /bin/mv webgrind-master ${wwwroot_dir}/default/webgrind + pushd xdebug-2.5.5 else echo "${CWARNING}Need a PHP version >= 5.5.0 and <= 7.2.0${CEND}" exit 1 @@ -471,7 +471,7 @@ What Are You Doing? ./configure --with-php-config=${php_install_dir}/bin/php-config make -j ${THREAD} && make install popd - rm -rf xdebug-${xdebug_ver} + rm -rf xdebug-${xdebug_ver} popd [ ! -e /tmp/xdebug ] && { mkdir /tmp/xdebug; chown ${run_user}.${run_user} /tmp/xdebug; } [ ! -e /tmp/webgrind ] && { mkdir /tmp/webgrind; chown ${run_user}.${run_user} /tmp/webgrind; } diff --git a/backup.sh b/backup.sh index c04db9a3..5c5dea44 100755 --- a/backup.sh +++ b/backup.sh @@ -134,7 +134,7 @@ WEB_UPYUN_BK() { fi /usr/local/bin/upx put $PUSH_FILE /`date +%F`/Web_${W}_$(date +%Y%m%d_%H).tgz if [ $? -eq 0 ]; then - /usr/local/bin/upx rm -a `date +%F --date="${expired_days} days ago"` > /dev/null 2>&1 + /usr/local/bin/upx rm -a `date +%F --date="${expired_days} days ago"` > /dev/null 2>&1 [ -e "$PUSH_FILE" -a -z "`echo ${backup_destination} | grep -ow 'local'`" ] && rm -rf $PUSH_FILE fi done @@ -145,23 +145,23 @@ 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 + fi if [ "${DEST}" == '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 - fi + fi if [ "${DEST}" == 'oss' ]; then - [ -n "`echo ${backup_content} | grep -ow db`" ] && DB_OSS_BK + [ -n "`echo ${backup_content} | grep -ow db`" ] && DB_OSS_BK [ -n "`echo ${backup_content} | grep -ow web`" ] && WEB_OSS_BK - fi + 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 + 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 + fi done diff --git a/backup_setup.sh b/backup_setup.sh index ed1a17a4..2741cb28 100755 --- a/backup_setup.sh +++ b/backup_setup.sh @@ -8,7 +8,7 @@ # https://oneinstack.com # https://github.com/lj2007331/oneinstack -export PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin +export PATH=/sbin:/bin:/usr/sbin:/usr/bin:/usr/local/sbin:/usr/local/bin clear printf " ####################################################################### @@ -34,9 +34,9 @@ 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}3${CEND}. Aliyun OSS" echo -e "\t${CMSG}4${CEND}. Qcloud COS" - echo -e "\t${CMSG}5${CEND}. UPYUN(又拍云)" + echo -e "\t${CMSG}5${CEND}. UPYUN(又拍云)" read -p "Please input a number:(Default 1 press Enter) " desc_bk [ -z "${desc_bk}" ] && desc_bk=1 ary=(1 2 3 4 5 12 13 14 15 23 24 25 34 35 45 123 124 125 234 235 345 1234 1235 2345 12345) @@ -116,7 +116,7 @@ if [ "${content_bk}" != '1' ]; then websites=`ls ${wwwroot_dir}` while :; do echo echo "Please enter one or more name for website, separate multiple website names with commas: " - read -p "(Default website: `echo $websites | tr ' ' ','`) " website_name + 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 @@ -180,9 +180,9 @@ if [ `echo ${desc_bk} | grep -e 3` ]; then echo 'Please select your backup datacenter:' echo -e "\t ${CMSG}1${CEND}. cn-hangzhou-华东 1 (杭州) ${CMSG}2${CEND}. cn-shanghai-华东 2 (上海)" echo -e "\t ${CMSG}3${CEND}. cn-qingdao-华北 1 (青岛) ${CMSG}4${CEND}. cn-beijing-华北 2 (北京)" - echo -e "\t ${CMSG}5${CEND}. cn-zhangjiakou-华北 3 (张家口) ${CMSG}6${CEND}. cn-huhehaote-华北 5(呼和浩特)" + echo -e "\t ${CMSG}5${CEND}. cn-zhangjiakou-华北 3 (张家口) ${CMSG}6${CEND}. cn-huhehaote-华北 5(呼和浩特)" echo -e "\t ${CMSG}7${CEND}. cn-shenzhen-华南 1 (深圳) ${CMSG}8${CEND}. cn-hongkong-香港" - echo -e "\t ${CMSG}9${CEND}. us-west-美西 1 (硅谷) ${CMSG}10${CEND}. us-east-美东 1 (弗吉尼亚)" + echo -e "\t ${CMSG}9${CEND}. us-west-美西 1 (硅谷) ${CMSG}10${CEND}. us-east-美东 1 (弗吉尼亚)" echo -e "\t${CMSG}11${CEND}. ap-southeast-亚太东南 1 (新加坡) ${CMSG}12${CEND}. ap-southeast-亚太东南 2 (悉尼)" echo -e "\t${CMSG}13${CEND}. ap-southeast-亚太东南 3 (吉隆坡) ${CMSG}14${CEND}. ap-northeast-亚太东北 1 (日本)" echo -e "\t${CMSG}15${CEND}. eu-central-欧洲中部 1 (法兰克福) ${CMSG}16${CEND}. me-east-中东东部 1 (迪拜)" @@ -211,7 +211,7 @@ if [ `echo ${desc_bk} | grep -e 3` ]; then [ "${Location}" == '15' ] && Host=oss-eu-central-1-internal.aliyuncs.com [ "${Location}" == '16' ] && Host=oss-me-east-1-internal.aliyuncs.com [ "$(./include/check_port.py ${Host} 80)" == "False" ] && Host=`echo ${Host} | sed 's@-internal@@g'` - [ -e "/root/.ossutilconfig" ] && rm -f /root/.ossutilconfig + [ -e "/root/.ossutilconfig" ] && rm -f /root/.ossutilconfig while :; do echo read -p "Please enter the aliyun oss Access Key ID: " KeyID [ -z "${KeyID}" ] && continue @@ -233,7 +233,7 @@ fi if [ `echo ${desc_bk} | grep -e 4` ]; then [ ! -e "${python_install_dir}/bin/python" ] && Install_Python - [ ! -e "${python_install_dir}/lib/coscmd" ] && ${python_install_dir}/bin/pip install coscmd >/dev/null 2>&1 + [ ! -e "${python_install_dir}/lib/coscmd" ] && ${python_install_dir}/bin/pip install coscmd >/dev/null 2>&1 while :; do echo echo 'Please select your backup datacenter:' echo -e "\t ${CMSG}1${CEND}. 北京一区(华北) ${CMSG}2${CEND}. 北京" @@ -259,7 +259,7 @@ if [ `echo ${desc_bk} | grep -e 4` ]; then [ "${Location}" == '8' ] && region='na-toronto' [ "${Location}" == '9' ] && region='eu-frankfurt' while :; do echo - read -p "Please enter the Qcloud COS APPID: " APPID + read -p "Please enter the Qcloud COS APPID: " APPID [ -z "${APPID}" ] && continue echo read -p "Please enter the Qcloud COS SecretId: " SecretId @@ -268,7 +268,7 @@ if [ `echo ${desc_bk} | grep -e 4` ]; then read -p "Please enter the Qcloud COS SecretKey: " SecretKey [ -z "$SecretKey" ] && continue echo - read -p "Please enter the Qcloud COS bucket: " bucket + read -p "Please enter the Qcloud COS bucket: " bucket [ -z "${bucket}" ] && continue echo ${python_install_dir}/bin/coscmd config -u ${APPID} -a ${SecretId} -s $SecretKey -r $region -b ${bucket} >/dev/null 2>&1 @@ -293,17 +293,16 @@ if [ `echo ${desc_bk} | grep -e 5` ]; then chmod +x /usr/local/bin/upx fi while :; do echo - read -p "Please enter the ServiceName: " ServiceName + read -p "Please enter the ServiceName: " ServiceName [ -z "${ServiceName}" ] && continue echo - read -p "Please enter the Operator: " Operator + read -p "Please enter the Operator: " Operator [ -z "${Operator}" ] && continue echo - read -p "Please enter the Password: " Password + read -p "Please enter the Password: " Password [ -z "${Password}" ] && continue echo /usr/local/bin/upx login ${ServiceName} ${Operator} ${Password} >/dev/null 2>&1 - /usr/local/bin/upx ls >/dev/null 2>&1 if [ $? = 0 ]; then echo "${CMSG}ServiceName/Operator/Password OK${CEND}" echo diff --git a/include/alisql-5.6.sh b/include/alisql-5.6.sh index d0ce0acd..ba866fb1 100644 --- a/include/alisql-5.6.sh +++ b/include/alisql-5.6.sh @@ -37,6 +37,7 @@ Install_AliSQL56() { if [ -d "${alisql_install_dir}/support-files" ]; then echo never > /sys/kernel/mm/transparent_hugepage/enabled + sed -i "s+^dbrootpwd.*+dbrootpwd='${dbrootpwd}'+" ../options.conf echo "${CSUCCESS}AliSQL installed successfully! ${CEND}" rm -rf alisql-${alisql_ver} else diff --git a/include/check_download.sh b/include/check_download.sh index b4ec8451..c0227964 100644 --- a/include/check_download.sh +++ b/include/check_download.sh @@ -43,11 +43,11 @@ checkDownload() { 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=http://mirrors.linuxeye.com/apache/httpd/nghttp2-${nghttp2_ver}.tar.gz && Download_src - src_url=http://mirrors.linuxeye.com/apache/httpd/httpd-${apache24_ver}.tar.gz && Download_src + src_url=http://archive.apache.org/dist/httpd/httpd-${apache24_ver}.tar.gz && Download_src fi if [ "${apache_option}" == '2' ]; then echo "Download apache 2.2..." - src_url=http://mirrors.linuxeye.com/apache/httpd/httpd-${apache22_ver}.tar.gz && Download_src + src_url=http://archive.apache.org/dist/httpd/httpd-${apache22_ver}.tar.gz && Download_src echo "Download mod_remoteip.c for apache 2.2..." src_url=${mirrorLink}/mod_remoteip.c && Download_src @@ -106,21 +106,11 @@ checkDownload() { 1) # MySQL 5.7 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 + 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 - 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 + DOWN_ADDR_MYSQL=http://cdn.mysql.com/Downloads/MySQL-5.7 + DOWN_ADDR_MYSQL_BK=http://mysql.he.net/Downloads/MySQL-5.7 fi if [ "${dbinstallmethod}" == '1' ]; then @@ -131,10 +121,11 @@ checkDownload() { FILE_NAME=mysql-${mysql57_ver}.tar.gz fi # start download - wget -4 --tries=6 -c --no-check-certificate ${DOWN_ADDR_MYSQL}/${FILE_NAME} + src_url=${DOWN_ADDR_MYSQL}/${FILE_NAME} && Download_src + src_url=${DOWN_ADDR_MYSQL}/${FILE_NAME}.md5 && Download_src # verifying download - MYSQL_TAR_MD5=$(curl -s ${DOWN_ADDR_MYSQL}/${FILE_NAME}.md5 | grep ${FILE_NAME} | awk '{print $1}') - [ -z "${MYSQL_TAR_MD5}" ] && MYSQL_TAR_MD5=$(curl -s ${DOWN_ADDR_MYSQL_BK}/${FILE_NAME}.md5 | grep ${FILE_NAME} | awk '{print $1}') + MYSQL_TAR_MD5=$(awk '{print $1}' ${FILE_NAME}.md5) + [ -z "${MYSQL_TAR_MD5}" ] && MYSQL_TAR_MD5=$(curl -s ${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_BK}/${FILE_NAME};sleep 1 @@ -148,25 +139,14 @@ checkDownload() { echo "[${CMSG}${FILE_NAME}${CEND}] found." fi ;; - 2) # MySQL 5.6 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 + 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 - 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 + DOWN_ADDR_MYSQL=http://cdn.mysql.com/Downloads/MySQL-5.6 + DOWN_ADDR_MYSQL_BK=http://mysql.he.net/Downloads/MySQL-5.6 fi if [ "${dbinstallmethod}" == '1' ]; then @@ -176,10 +156,12 @@ checkDownload() { echo "Download MySQL 5.6 source package..." FILE_NAME=mysql-${mysql56_ver}.tar.gz fi - wget -4 --tries=6 -c --no-check-certificate ${DOWN_ADDR_MYSQL}/${FILE_NAME} + # 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=$(curl -s ${DOWN_ADDR_MYSQL}/${FILE_NAME}.md5 | grep ${FILE_NAME} | awk '{print $1}') - [ -z "${MYSQL_TAR_MD5}" ] && MYSQL_TAR_MD5=$(curl -s ${DOWN_ADDR_MYSQL_BK}/${FILE_NAME}.md5 | grep ${FILE_NAME} | awk '{print $1}') + MYSQL_TAR_MD5=$(awk '{print $1}' ${FILE_NAME}.md5) + [ -z "${MYSQL_TAR_MD5}" ] && MYSQL_TAR_MD5=$(curl -s ${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_BK}/${FILE_NAME};sleep 1 @@ -193,25 +175,14 @@ checkDownload() { echo "[${CMSG}${FILE_NAME}${CEND}] found." fi ;; - 3) # MySQL 5.5 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 + 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 - 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 + DOWN_ADDR_MYSQL=http://cdn.mysql.com/Downloads/MySQL-5.5 + DOWN_ADDR_MYSQL_BK=http://mysql.he.net/Downloads/MySQL-5.5 fi if [ "${dbinstallmethod}" == '1' ]; then @@ -222,10 +193,12 @@ checkDownload() { FILE_NAME=mysql-${mysql55_ver}.tar.gz src_url=${mirrorLink}/mysql-5.5-fix-arm-client_plugin.patch && Download_src fi - wget -4 --tries=6 -c --no-check-certificate ${DOWN_ADDR_MYSQL}/${FILE_NAME} + # 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=$(curl -s ${DOWN_ADDR_MYSQL}/${FILE_NAME}.md5 | grep ${FILE_NAME} | awk '{print $1}') - [ -z "${MYSQL_TAR_MD5}" ] && MYSQL_TAR_MD5=$(curl -s ${DOWN_ADDR_MYSQL_BK}/${FILE_NAME}.md5 | grep ${FILE_NAME} | awk '{print $1}') + MYSQL_TAR_MD5=$(awk '{print $1}' ${FILE_NAME}.md5) + [ -z "${MYSQL_TAR_MD5}" ] && MYSQL_TAR_MD5=$(curl -s ${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_BK}/${FILE_NAME};sleep 1 @@ -239,7 +212,6 @@ checkDownload() { echo "[${CMSG}${FILE_NAME}${CEND}] found." fi ;; - 4) # MariaDB 10.2 if [ "${dbinstallmethod}" == '1' ]; then @@ -247,27 +219,29 @@ checkDownload() { FILE_NAME=mariadb-${mariadb102_ver}-${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-${mariadb102_ver}/bintar-${GLIBC_FLAG}-${SYS_BIT_a} - MARAIDB_TAR_MD5=$(curl -s ${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-${mariadb102_ver}/bintar-${GLIBC_FLAG}-${SYS_BIT_a}; MARAIDB_TAR_MD5=$(curl -s ${DOWN_ADDR_MARIADB}/md5sums.txt | grep ${FILE_NAME} | awk '{print $1}'); } + DOWN_ADDR_MARIADB_BK=https://mirrors.ustc.edu.cn/mariadb/mariadb-${mariadb102_ver}/bintar-${GLIBC_FLAG}-${SYS_BIT_a} else - DOWN_ADDR_MARIADB=https://downloads.mariadb.org/interstitial/mariadb-${mariadb102_ver}/bintar-${GLIBC_FLAG}-${SYS_BIT_a} - MARAIDB_TAR_MD5=$(curl -s http://archive.mariadb.org/mariadb-${mariadb102_ver}/bintar-${GLIBC_FLAG}-${SYS_BIT_a}/md5sums.txt | grep ${FILE_NAME} | awk '{print $1}') + DOWN_ADDR_MARIADB=http://ftp.osuosl.org/pub/mariadb/mariadb-${mariadb102_ver}/bintar-${GLIBC_FLAG}-${SYS_BIT_a} + DOWN_ADDR_MARIADB_BK=http://mirror.nodesdirect.com/mariadb/mariadb-${mariadb102_ver}/bintar-${GLIBC_FLAG}-${SYS_BIT_a} fi elif [ "${dbinstallmethod}" == '2' ]; then echo "Download MariaDB 10.2 source package..." FILE_NAME=mariadb-${mariadb102_ver}.tar.gz if [ "${IPADDR_COUNTRY}"x == "CN"x ]; then DOWN_ADDR_MARIADB=https://mirrors.tuna.tsinghua.edu.cn/mariadb/mariadb-${mariadb102_ver}/source - MARAIDB_TAR_MD5=$(curl -s ${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-${mariadb102_ver}/source; MARAIDB_TAR_MD5=$(curl -s ${DOWN_ADDR_MARIADB}/md5sums.txt | grep ${FILE_NAME} | awk '{print $1}'); } + DOWN_ADDR_MARIADB_BK=https://mirrors.ustc.edu.cn/mariadb/mariadb-${mariadb102_ver}/source else - DOWN_ADDR_MARIADB=https://downloads.mariadb.org/interstitial/mariadb-${mariadb102_ver}/source - MARAIDB_TAR_MD5=$(curl -s http://archive.mariadb.org/mariadb-${mariadb102_ver}/source/md5sums.txt | grep ${FILE_NAME} | awk '{print $1}') + DOWN_ADDR_MARIADB=http://ftp.osuosl.org/pub/mariadb/mariadb-${mariadb102_ver}/source + DOWN_ADDR_MARIADB_BK=http://mirror.nodesdirect.com/mariadb/mariadb-${mariadb102_ver}/source fi fi + src_url=${DOWN_ADDR_MARIADB}/${FILE_NAME} && Download_src + wget -4 --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}/${FILE_NAME};sleep 1 + wget -c --no-check-certificate ${DOWN_ADDR_MARIADB_BK}/${FILE_NAME};sleep 1 let "tryDlCount++" [ "$(md5sum ${FILE_NAME} | awk '{print $1}')" == "${MARAIDB_TAR_MD5}" -o "${tryDlCount}" == '6' ] && break || continue done @@ -278,7 +252,6 @@ checkDownload() { echo "[${CMSG}${FILE_NAME}${CEND}] found." fi ;; - 5) # MariaDB 10.1 if [ "${dbinstallmethod}" == '1' ]; then @@ -286,27 +259,29 @@ checkDownload() { FILE_NAME=mariadb-${mariadb101_ver}-${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_ver}/bintar-${GLIBC_FLAG}-${SYS_BIT_a} - MARAIDB_TAR_MD5=$(curl -s ${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_ver}/bintar-${GLIBC_FLAG}-${SYS_BIT_a}; MARAIDB_TAR_MD5=$(curl -s ${DOWN_ADDR_MARIADB}/md5sums.txt | grep ${FILE_NAME} | awk '{print $1}'); } + DOWN_ADDR_MARIADB_BK=https://mirrors.ustc.edu.cn/mariadb/mariadb-${mariadb101_ver}/bintar-${GLIBC_FLAG}-${SYS_BIT_a} else - DOWN_ADDR_MARIADB=https://downloads.mariadb.org/interstitial/mariadb-${mariadb101_ver}/bintar-${GLIBC_FLAG}-${SYS_BIT_a} - MARAIDB_TAR_MD5=$(curl -s http://archive.mariadb.org/mariadb-${mariadb101_ver}/bintar-${GLIBC_FLAG}-${SYS_BIT_a}/md5sums.txt | grep ${FILE_NAME} | awk '{print $1}') + DOWN_ADDR_MARIADB=http://ftp.osuosl.org/pub/mariadb/mariadb-${mariadb101_ver}/bintar-${GLIBC_FLAG}-${SYS_BIT_a} + DOWN_ADDR_MARIADB_BK=http://mirror.nodesdirect.com/mariadb/mariadb-${mariadb101_ver}/bintar-${GLIBC_FLAG}-${SYS_BIT_a} fi elif [ "${dbinstallmethod}" == '2' ]; then echo "Download MariaDB 10.1 source package..." FILE_NAME=mariadb-${mariadb101_ver}.tar.gz if [ "${IPADDR_COUNTRY}"x == "CN"x ]; then DOWN_ADDR_MARIADB=https://mirrors.tuna.tsinghua.edu.cn/mariadb/mariadb-${mariadb101_ver}/source - MARAIDB_TAR_MD5=$(curl -s ${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_ver}/source; MARAIDB_TAR_MD5=$(curl -s ${DOWN_ADDR_MARIADB}/md5sums.txt | grep ${FILE_NAME} | awk '{print $1}'); } + DOWN_ADDR_MARIADB_BK=https://mirrors.ustc.edu.cn/mariadb/mariadb-${mariadb101_ver}/source else - DOWN_ADDR_MARIADB=https://downloads.mariadb.org/interstitial/mariadb-${mariadb101_ver}/source - MARAIDB_TAR_MD5=$(curl -s http://archive.mariadb.org/mariadb-${mariadb101_ver}/source/md5sums.txt | grep ${FILE_NAME} | awk '{print $1}') + DOWN_ADDR_MARIADB=http://ftp.osuosl.org/pub/mariadb/mariadb-${mariadb101_ver}/source + DOWN_ADDR_MARIADB_BK=http://mirror.nodesdirect.com/mariadb/mariadb-${mariadb101_ver}/source fi fi + src_url=${DOWN_ADDR_MARIADB}/${FILE_NAME} && Download_src + wget -4 --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}/${FILE_NAME};sleep 1 + wget -c --no-check-certificate ${DOWN_ADDR_MARIADB_BK}/${FILE_NAME};sleep 1 let "tryDlCount++" [ "$(md5sum ${FILE_NAME} | awk '{print $1}')" == "${MARAIDB_TAR_MD5}" -o "${tryDlCount}" == '6' ] && break || continue done @@ -317,7 +292,6 @@ checkDownload() { echo "[${CMSG}${FILE_NAME}${CEND}] found." fi ;; - 6) # MariaDB 10.0 if [ "${dbinstallmethod}" == '1' ]; then @@ -325,27 +299,29 @@ checkDownload() { FILE_NAME=mariadb-${mariadb100_ver}-${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_ver}/bintar-${GLIBC_FLAG}-${SYS_BIT_a} - MARAIDB_TAR_MD5=$(curl -s ${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_ver}/bintar-${GLIBC_FLAG}-${SYS_BIT_a}; MARAIDB_TAR_MD5=$(curl -s ${DOWN_ADDR_MARIADB}/md5sums.txt | grep ${FILE_NAME} | awk '{print $1}'); } + DOWN_ADDR_MARIADB_BK=https://mirrors.ustc.edu.cn/mariadb/mariadb-${mariadb100_ver}/bintar-${GLIBC_FLAG}-${SYS_BIT_a} else - DOWN_ADDR_MARIADB=https://downloads.mariadb.org/interstitial/mariadb-${mariadb100_ver}/bintar-${GLIBC_FLAG}-${SYS_BIT_a} - MARAIDB_TAR_MD5=$(curl -s http://archive.mariadb.org/mariadb-${mariadb100_ver}/bintar-${GLIBC_FLAG}-${SYS_BIT_a}/md5sums.txt | grep ${FILE_NAME} | awk '{print $1}') + DOWN_ADDR_MARIADB=http://ftp.osuosl.org/pub/mariadb/mariadb-${mariadb100_ver}/bintar-${GLIBC_FLAG}-${SYS_BIT_a} + DOWN_ADDR_MARIADB_BK=http://mirror.nodesdirect.com/mariadb/mariadb-${mariadb100_ver}/bintar-${GLIBC_FLAG}-${SYS_BIT_a} fi elif [ "${dbinstallmethod}" == '2' ]; then echo "Download MariaDB 10.0 source package..." FILE_NAME=mariadb-${mariadb100_ver}.tar.gz if [ "${IPADDR_COUNTRY}"x == "CN"x ]; then DOWN_ADDR_MARIADB=https://mirrors.tuna.tsinghua.edu.cn/mariadb/mariadb-${mariadb100_ver}/source - MARAIDB_TAR_MD5=$(curl -s ${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_ver}/source; MARAIDB_TAR_MD5=$(curl -s ${DOWN_ADDR_MARIADB}/md5sums.txt | grep ${FILE_NAME} | awk '{print $1}'); } + DOWN_ADDR_MARIADB_BK=https://mirrors.ustc.edu.cn/mariadb/mariadb-${mariadb100_ver}/source else - DOWN_ADDR_MARIADB=https://downloads.mariadb.org/interstitial/mariadb-${mariadb100_ver}/source - MARAIDB_TAR_MD5=$(curl -s http://archive.mariadb.org/mariadb-${mariadb100_ver}/source/md5sums.txt | grep ${FILE_NAME} | awk '{print $1}') + DOWN_ADDR_MARIADB=http://ftp.osuosl.org/pub/mariadb/mariadb-${mariadb100_ver}/source + DOWN_ADDR_MARIADB_BK=http://mirror.nodesdirect.com/mariadb/mariadb-${mariadb100_ver}/source fi fi + src_url=${DOWN_ADDR_MARIADB}/${FILE_NAME} && Download_src + wget -4 --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}/${FILE_NAME};sleep 1 + wget -c --no-check-certificate ${DOWN_ADDR_MARIADB_BK}/${FILE_NAME};sleep 1 let "tryDlCount++" [ "$(md5sum ${FILE_NAME} | awk '{print $1}')" == "${MARAIDB_TAR_MD5}" -o "${tryDlCount}" == '6' ] && break || continue done @@ -356,7 +332,6 @@ checkDownload() { echo "[${CMSG}${FILE_NAME}${CEND}] found." fi ;; - 7) # MariaDB 5.5 if [ "${dbinstallmethod}" == '1' ]; then @@ -364,27 +339,29 @@ checkDownload() { FILE_NAME=mariadb-${mariadb55_ver}-${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_ver}/bintar-${GLIBC_FLAG}-${SYS_BIT_a} - MARAIDB_TAR_MD5=$(curl -s ${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_ver}/bintar-${GLIBC_FLAG}-${SYS_BIT_a}; MARAIDB_TAR_MD5=$(curl -s ${DOWN_ADDR_MARIADB}/md5sums.txt | grep ${FILE_NAME} | awk '{print $1}'); } + DOWN_ADDR_MARIADB_BK=https://mirrors.ustc.edu.cn/mariadb/mariadb-${mariadb55_ver}/bintar-${GLIBC_FLAG}-${SYS_BIT_a} else - DOWN_ADDR_MARIADB=https://downloads.mariadb.org/interstitial/mariadb-${mariadb55_ver}/bintar-${GLIBC_FLAG}-${SYS_BIT_a} - MARAIDB_TAR_MD5=$(curl -s http://archive.mariadb.org/mariadb-${mariadb55_ver}/bintar-${GLIBC_FLAG}-${SYS_BIT_a}/md5sums.txt | grep ${FILE_NAME} | awk '{print $1}') + DOWN_ADDR_MARIADB=http://ftp.osuosl.org/pub/mariadb/mariadb-${mariadb55_ver}/bintar-${GLIBC_FLAG}-${SYS_BIT_a} + DOWN_ADDR_MARIADB_BK=http://mirror.nodesdirect.com/mariadb/mariadb-${mariadb55_ver}/bintar-${GLIBC_FLAG}-${SYS_BIT_a} fi elif [ "${dbinstallmethod}" == '2' ]; then echo "Download MariaDB 5.5 source package..." FILE_NAME=mariadb-${mariadb55_ver}.tar.gz if [ "${IPADDR_COUNTRY}"x == "CN"x ]; then DOWN_ADDR_MARIADB=https://mirrors.tuna.tsinghua.edu.cn/mariadb/mariadb-${mariadb55_ver}/source - MARAIDB_TAR_MD5=$(curl -s ${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_ver}/source; MARAIDB_TAR_MD5=$(curl -s ${DOWN_ADDR_MARIADB}/md5sums.txt | grep ${FILE_NAME} | awk '{print $1}'); } + DOWN_ADDR_MARIADB_BK=https://mirrors.ustc.edu.cn/mariadb/mariadb-${mariadb55_ver}/source else - DOWN_ADDR_MARIADB=https://downloads.mariadb.org/interstitial/mariadb-${mariadb55_ver}/source - MARAIDB_TAR_MD5=$(curl -s http://archive.mariadb.org/mariadb-${mariadb55_ver}/source/md5sums.txt | grep ${FILE_NAME} | awk '{print $1}') + DOWN_ADDR_MARIADB=http://ftp.osuosl.org/pub/mariadb/mariadb-${mariadb55_ver}/source + DOWN_ADDR_MARIADB_BK=http://mirror.nodesdirect.com/mariadb/mariadb-${mariadb55_ver}/source fi fi + src_url=${DOWN_ADDR_MARIADB}/${FILE_NAME} && Download_src + wget -4 --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}/${FILE_NAME};sleep 1 + wget -c --no-check-certificate ${DOWN_ADDR_MARIADB_BK}/${FILE_NAME};sleep 1 let "tryDlCount++" [ "$(md5sum ${FILE_NAME} | awk '{print $1}')" == "${MARAIDB_TAR_MD5}" -o "${tryDlCount}" == '6' ] && break || continue done @@ -395,27 +372,27 @@ checkDownload() { echo "[${CMSG}${FILE_NAME}${CEND}] found." fi ;; - 8) # Precona 5.7 if [ "${dbinstallmethod}" == '1' ]; then echo "Download Percona 5.7 binary package..." FILE_NAME=Percona-Server-${percona57_ver}-Linux.${SYS_BIT_b}.${sslLibVer}.tar.gz DOWN_ADDR_PERCONA=https://www.percona.com/downloads/Percona-Server-5.7/Percona-Server-${percona57_ver}/binary/tarball - PERCONA_TAR_MD5=$(curl -s https://www.percona.com/downloads/Percona-Server-5.7/Percona-Server-${percona57_ver}/binary/tarball/${FILE_NAME}.md5sum | grep ${FILE_NAME} | awk '{print $1}') elif [ "${dbinstallmethod}" == '2' ]; then echo "Download Percona 5.7 source package..." FILE_NAME=percona-server-${percona57_ver}.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_ver}/source/tarball - PERCONA_TAR_MD5=$(curl -s ${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 -s ${DOWN_ADDR_PERCONA_BK}/${FILE_NAME}.md5sum | grep ${FILE_NAME} | awk '{print $1}'); } else DOWN_ADDR_PERCONA=https://www.percona.com/downloads/Percona-Server-5.7/Percona-Server-${percona57_ver}/source/tarball - PERCONA_TAR_MD5=$(curl -s ${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=${DOWN_ADDR_PERCONA}/${FILE_NAME}.md5 && Download_src + # verifying download + PERCONA_TAR_MD5=$(awk '{print $1}' ${FILE_NAME}.md5) + [ -z "${PERCONA_TAR_MD5}" ] && PERCONA_TAR_MD5=$(curl -s ${DOWN_ADDR_PERCONA}/${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 @@ -429,7 +406,6 @@ checkDownload() { echo "[${CMSG}${FILE_NAME}${CEND}] found." fi ;; - 9) # Precona 5.6 if [ "${dbinstallmethod}" == '1' ]; then @@ -437,20 +413,21 @@ checkDownload() { perconaVerStr1=$(echo ${percona56_ver} | 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_ver}/binary/tarball - PERCONA_TAR_MD5=$(curl -s https://www.percona.com/downloads/Percona-Server-5.6/Percona-Server-${percona56_ver}/binary/tarball/${FILE_NAME}.md5sum | grep ${FILE_NAME} | awk '{print $1}') elif [ "${dbinstallmethod}" == '2' ]; then echo "Download Percona 5.6 source package..." FILE_NAME=percona-server-${percona56_ver}.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_ver}/source/tarball - PERCONA_TAR_MD5=$(curl -s ${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 -s ${DOWN_ADDR_PERCONA_BK}/${FILE_NAME}.md5sum | grep ${FILE_NAME} | awk '{print $1}'); } else DOWN_ADDR_PERCONA=https://www.percona.com/downloads/Percona-Server-5.6/Percona-Server-${percona56_ver}/source/tarball - PERCONA_TAR_MD5=$(curl -s ${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=${DOWN_ADDR_PERCONA}/${FILE_NAME}.md5 && Download_src + # verifying download + PERCONA_TAR_MD5=$(awk '{print $1}' ${FILE_NAME}.md5) + [ -z "${PERCONA_TAR_MD5}" ] && PERCONA_TAR_MD5=$(curl -s ${DOWN_ADDR_PERCONA}/${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 @@ -464,7 +441,6 @@ checkDownload() { echo "[${CMSG}${FILE_NAME}${CEND}] found." fi ;; - 10) # Percona 5.5 if [ "${dbinstallmethod}" == '1' ]; then @@ -472,20 +448,21 @@ checkDownload() { perconaVerStr1=$(echo ${percona55_ver} | 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_ver}/binary/tarball - PERCONA_TAR_MD5=$(curl -s https://www.percona.com/downloads/Percona-Server-5.5/Percona-Server-${percona55_ver}/binary/tarball/${FILE_NAME}.md5sum | grep ${FILE_NAME} | awk '{print $1}') elif [ "${dbinstallmethod}" == '2' ]; then echo "Download Percona 5.5 source package..." FILE_NAME=percona-server-${percona55_ver}.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_ver}/source/tarball - PERCONA_TAR_MD5=$(curl -s ${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 -s ${DOWN_ADDR_PERCONA_BK}/${FILE_NAME}.md5sum | grep ${FILE_NAME} | awk '{print $1}'); } else DOWN_ADDR_PERCONA=https://www.percona.com/downloads/Percona-Server-5.5/Percona-Server-${percona55_ver}/source/tarball - PERCONA_TAR_MD5=$(curl -s ${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=${DOWN_ADDR_PERCONA}/${FILE_NAME}.md5 && Download_src + # verifying download + PERCONA_TAR_MD5=$(awk '{print $1}' ${FILE_NAME}.md5) + [ -z "${PERCONA_TAR_MD5}" ] && PERCONA_TAR_MD5=$(curl -s ${DOWN_ADDR_PERCONA}/${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 @@ -499,37 +476,37 @@ checkDownload() { echo "[${CMSG}${FILE_NAME}${CEND}] found." fi ;; - 11) # AliSQL 5.6 DOWN_ADDR_ALISQL=$mirrorLink echo "Download AliSQL 5.6 source package..." FILE_NAME=alisql-${alisql_ver}.tar.gz - wget -4 --tries=6 -c --no-check-certificate ${DOWN_ADDR_ALISQL}/${FILE_NAME} - wget -4 --tries=6 -c --no-check-certificate ${DOWN_ADDR_ALISQL}/${FILE_NAME}.md5 + src_url=${DOWN_ADDR_ALISQL}/${FILE_NAME} && Download_src + src_url=${DOWN_ADDR_ALISQL}/${FILE_NAME}.md5 && Download_src 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 ;; - - 12) - # PostgreSQL + 12) + # PostgreSQL echo "Download PostgreSQL source package..." FILE_NAME=postgresql-${pgsql_ver}.tar.gz if [ "${IPADDR_COUNTRY}"x == "CN"x ]; then DOWN_ADDR_PGSQL=https://mirrors.tuna.tsinghua.edu.cn/postgresql/source/v${pgsql_ver} - PGSQL_TAR_MD5=$(curl -s ${DOWN_ADDR_PGSQL}/${FILE_NAME}.md5 | grep ${FILE_NAME} | awk '{print $1}') - [ -z "${PGSQL_TAR_MD5}" ] && { DOWN_ADDR_PGSQL=https://mirrors.ustc.edu.cn/postgresql/source/v${pgsql_ver}; PGSQL_TAR_MD5=$(curl -s ${DOWN_ADDR_PGSQL}/${FILE_NAME}.md5 | grep ${FILE_NAME} | awk '{print $1}'); } + DOWN_ADDR_PGSQL_BK=https://mirrors.ustc.edu.cn/postgresql/source/v${pgsql_ver} else DOWN_ADDR_PGSQL=https://ftp.postgresql.org/pub/source/v${pgsql_ver} - PGSQL_TAR_MD5=$(curl -s ${DOWN_ADDR_PGSQL}/${FILE_NAME}.md5 | grep ${FILE_NAME} | awk '{print $1}') + 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}/${FILE_NAME};sleep 1 + 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 @@ -540,7 +517,7 @@ checkDownload() { echo "[${CMSG}${FILE_NAME}${CEND}] found." fi ;; - 13) + 13) # MongoDB echo "Download MongoDB binary package..." FILE_NAME=mongodb-linux-${SYS_BIT_b}-${mongodb_ver}.tgz @@ -549,8 +526,10 @@ checkDownload() { else DOWN_ADDR_MongoDB=https://fastdl.mongodb.org/linux fi - MongoDB_TAR_MD5=$(curl -s ${DOWN_ADDR_MongoDB}/${FILE_NAME}.md5 | grep ${FILE_NAME} | awk '{print $1}') - + 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 diff --git a/include/mariadb-10.0.sh b/include/mariadb-10.0.sh index e1fbe40b..2aaa4027 100644 --- a/include/mariadb-10.0.sh +++ b/include/mariadb-10.0.sh @@ -45,6 +45,7 @@ Install_MariaDB100() { 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-${mariadb100_ver}-*-${SYS_BIT_b} diff --git a/include/mariadb-10.1.sh b/include/mariadb-10.1.sh index 4efe764d..c05d8f05 100644 --- a/include/mariadb-10.1.sh +++ b/include/mariadb-10.1.sh @@ -45,6 +45,7 @@ Install_MariaDB101() { 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-${mariadb101_ver}-*-${SYS_BIT_b} diff --git a/include/mariadb-10.2.sh b/include/mariadb-10.2.sh index 7b10f2f6..a1e12cdb 100644 --- a/include/mariadb-10.2.sh +++ b/include/mariadb-10.2.sh @@ -45,6 +45,7 @@ Install_MariaDB102() { 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-${mariadb102_ver}-*-${SYS_BIT_b} diff --git a/include/mariadb-5.5.sh b/include/mariadb-5.5.sh index 8a40bc7b..3362fc02 100644 --- a/include/mariadb-5.5.sh +++ b/include/mariadb-5.5.sh @@ -47,6 +47,7 @@ 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}-*-${SYS_BIT_b} diff --git a/include/mongodb.sh b/include/mongodb.sh index a63073e8..8f6092fb 100644 --- a/include/mongodb.sh +++ b/include/mongodb.sh @@ -62,6 +62,7 @@ EOF 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-${SYS_BIT_b}-${mongodb_ver} else diff --git a/include/mysql-5.5.sh b/include/mysql-5.5.sh index d2a44565..a59376b4 100644 --- a/include/mysql-5.5.sh +++ b/include/mysql-5.5.sh @@ -47,6 +47,7 @@ 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}-*-${SYS_BIT_b} diff --git a/include/mysql-5.6.sh b/include/mysql-5.6.sh index f522c48d..13fcf4e1 100644 --- a/include/mysql-5.6.sh +++ b/include/mysql-5.6.sh @@ -45,6 +45,7 @@ Install_MySQL56() { 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-${mysql56_ver}-*-${SYS_BIT_b} diff --git a/include/mysql-5.7.sh b/include/mysql-5.7.sh index 68fd2242..8283b8e2 100644 --- a/include/mysql-5.7.sh +++ b/include/mysql-5.7.sh @@ -45,6 +45,7 @@ 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}-*-${SYS_BIT_b} diff --git a/include/percona-5.5.sh b/include/percona-5.5.sh index 0807811e..62da759e 100644 --- a/include/percona-5.5.sh +++ b/include/percona-5.5.sh @@ -48,6 +48,7 @@ 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.${SYS_BIT_b}.${sslLibVer} diff --git a/include/percona-5.6.sh b/include/percona-5.6.sh index 8ec4ae5e..74f3afe5 100644 --- a/include/percona-5.6.sh +++ b/include/percona-5.6.sh @@ -47,6 +47,7 @@ Install_Percona56() { 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.${SYS_BIT_b}.${sslLibVer} diff --git a/include/percona-5.7.sh b/include/percona-5.7.sh index 98e1ec85..55b8fe44 100644 --- a/include/percona-5.7.sh +++ b/include/percona-5.7.sh @@ -47,6 +47,7 @@ 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.${SYS_BIT_b}.${sslLibVer} diff --git a/include/postgresql.sh b/include/postgresql.sh index 39984414..3dabb9fe 100644 --- a/include/postgresql.sh +++ b/include/postgresql.sh @@ -38,6 +38,7 @@ Install_PostgreSQL() { service postgresql reload if [ -e "${pgsql_install_dir}/bin/psql" ]; then + sed -i "s+^dbpostgrespwd.*+dbpostgrespwd='$dbpostgrespwd'+" ../options.conf echo "${CSUCCESS}PostgreSQL installed successfully! ${CEND}" rm -rf postgresql-${pgsql_ver} else diff --git a/include/upgrade_oneinstack.sh b/include/upgrade_oneinstack.sh index dc63fece..d7a92725 100644 --- a/include/upgrade_oneinstack.sh +++ b/include/upgrade_oneinstack.sh @@ -33,7 +33,7 @@ Upgrade_OneinStack() { sed -i "s@^${Key}=.*@${Key}=${Value}@" ./options.conf done rm -rf /tmp/{oneinstack.tar.gz,options.conf} - [ "$install_flag" == 'n' ] && rm -rf install.sh LICENSE README.md + [ "${install_flag}" == 'n' ] && rm -rf install.sh LICENSE README.md sed -i "s@^oneinstack_md5=.*@oneinstack_md5=${Latest_OneinStack_MD5}@" ./options.conf echo echo "${CSUCCESS}Congratulations! OneinStack upgrade successful! ${CEND}" diff --git a/include/upgrade_web.sh b/include/upgrade_web.sh index 5638275f..87308630 100644 --- a/include/upgrade_web.sh +++ b/include/upgrade_web.sh @@ -188,23 +188,23 @@ Upgrade_Apache() { pushd ${oneinstack_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="`/usr/local/apache/bin/httpd -v | grep version | awk -F'/| ' '{print $4}'`" - Apache_flag="`echo $OLD_apache_ver | awk -F. '{print $1 $2}'`" + Apache_flag="`echo ${OLD_apache_ver} | awk -F. '{print $1 $2}'`" Latest_apache_ver=`curl -s http://httpd.apache.org/download.cgi | awk "/#apache$Apache_flag/{print $2}" | head -1 | grep -oE "2\.[24]\.[0-9]+"` echo - echo "Current Apache Version: ${CMSG}$OLD_apache_ver${CEND}" + echo "Current Apache Version: ${CMSG}${OLD_apache_ver}${CEND}" while :; do echo read -p "Please input upgrade Apache Version(Default: $Latest_apache_ver): " NEW_apache_ver - [ -z "$NEW_apache_ver" ] && NEW_apache_ver=$Latest_apache_ver - if [ "$NEW_apache_ver" != "$OLD_apache_ver" ]; then + [ -z "${NEW_apache_ver}" ] && NEW_apache_ver=$Latest_apache_ver + if [ "${NEW_apache_ver}" != "${OLD_apache_ver}" ]; then if [ "$Apache_flag" == '24' ]; 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 tar xzf apr-${apr_ver}.tar.gz tar xzf apr-util-${apr_util_ver}.tar.gz fi - [ ! -e "httpd-$NEW_apache_ver.tar.gz" ] && wget --no-check-certificate -c http://mirrors.linuxeye.com/apache/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! " + [ ! -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}" @@ -214,12 +214,12 @@ Upgrade_Apache() { fi done - if [ -e "httpd-$NEW_apache_ver.tar.gz" ]; then - echo "[${CMSG}httpd-$NEW_apache_ver.tar.gz${CEND}] found" + if [ -e "httpd-${NEW_apache_ver}.tar.gz" ]; then + echo "[${CMSG}httpd-${NEW_apache_ver}.tar.gz${CEND}] found" echo "Press Ctrl+c to cancel or Press any key to continue..." char=`get_char` - tar xzf httpd-$NEW_apache_ver.tar.gz - pushd httpd-$NEW_apache_ver + tar xzf httpd-${NEW_apache_ver}.tar.gz + pushd httpd-${NEW_apache_ver} make clean if [ "$Apache_flag" == '24' ]; then /bin/cp -R ../apr-${apr_ver} ./srclib/apr @@ -239,8 +239,8 @@ Upgrade_Apache() { make install && unset LDFLAGS /etc/init.d/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 apr-${apr_ver} apr-util-${apr_util_ver} + 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} apr-${apr_ver} apr-util-${apr_util_ver} else echo "${CFAILURE}Upgrade Apache failed! ${CEND}" fi diff --git a/install.sh b/install.sh index c31283ca..1e392d19 100755 --- a/install.sh +++ b/install.sh @@ -8,7 +8,7 @@ # https://oneinstack.com # https://github.com/lj2007331/oneinstack -export PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin +export PATH=/sbin:/bin:/usr/sbin:/usr/bin:/usr/local/sbin:/usr/local/bin clear printf " ####################################################################### @@ -32,12 +32,14 @@ pushd ${oneinstack_dir} > /dev/null ssh_port=22 phpcache_option=1 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` xcachepwd=`< /dev/urandom tr -dc A-Za-z0-9 | head -c8` dbinstallmethod=1 version() { echo "version: 1.7" - echo "updated date: 2018-03-22" + echo "updated date: 2018-03-25" } showhelp() { @@ -58,7 +60,7 @@ showhelp() { --pureftpd Install Pure-Ftpd --redis Install Redis --memcached Install Memcached - --phpmyadmin Install phpMyAdmin + --phpmyadmin Install phpMyAdmin --hhvm Install HHVM --ssh_port [22] SSH port, default: 22 --iptables Enable iptables @@ -121,50 +123,43 @@ while :; do ;; --db_option) db_option=$2; shift 2 - [[ ! "${db_option}" =~ ^[1-9]$|^1[0-3]$ ]] && { echo "${CWARNING}db_option input error! Please only input number 1~13${CEND}"; exit 1; } db_yn=y - if [ "${db_option}" == '12' ]; then + if [[ "${db_option}" =~ ^[1-9]$|^1[0-1]$ ]]; then + [ -d "${db_install_dir}/support-files" ] && { echo "${CWARNING}MySQL already installed! ${CEND}"; db_yn=Other; } + elif [ "${db_option}" == '12' ]; then [ -e "${pgsql_install_dir}/bin/psql" ] && { echo "${CWARNING}PostgreSQL already installed! ${CEND}"; db_yn=Other; } elif [ "${db_option}" == '13' ]; then [ -e "${mongo_install_dir}/bin/mongo" ] && { echo "${CWARNING}MongoDB already installed! ${CEND}"; db_yn=Other; } else - [ -d "${db_install_dir}/support-files" ] && { echo "${CWARNING}MySQL already installed! ${CEND}"; db_yn=Other; } + echo "${CWARNING}db_option input error! Please only input number 1~13${CEND}" + exit 1 fi ;; --dbrootpwd) dbrootpwd=$2; shift 2 - if [ "${db_yn}" == 'y' ]; then - if [ "${db_option}" == '12' ]; then - sed -i "s+^dbpostgrespwd.*+dbpostgrespwd='$dbrootpwd'+" ./options.conf - dbpostgrespwd="$dbrootpwd" - elif [ "${db_option}" == '13' ]; then - sed -i "s+^dbmongopwd.*+dbmongopwd='$dbrootpwd'+" ./options.conf - dbmongopwd="$dbrootpwd" - else - sed -i "s+^dbrootpwd.*+dbrootpwd='$dbrootpwd'+" ./options.conf - fi - fi + 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) - ftp_yn=y; shift 1 + ftp_yn=y; shift 1 [ -e "${pureftpd_install_dir}/sbin/pure-ftpwho" ] && { echo "${CWARNING}Pure-FTPd already installed! ${CEND}"; ftp_yn=Other; } ;; --redis) - redis_yn=y; shift 1 + redis_yn=y; shift 1 ;; --memcached) - memcached_yn=y; shift 1 + memcached_yn=y; shift 1 ;; --phpmyadmin) - phpmyadmin_yn=y; shift 1 + phpmyadmin_yn=y; shift 1 [ -d "${wwwroot_dir}/default/phpMyAdmin" ] && { echo "${CWARNING}phpMyAdmin already installed! ${CEND}"; phpmyadmin_yn=Other; } ;; --hhvm) - hhvm_yn=y; shift 1 + hhvm_yn=y; shift 1 [ -e "/usr/bin/hhvm" ] && { echo "${CWARNING}HHVM already installed! ${CEND}"; hhvm_yn=Other; } ;; --ssh_port) @@ -172,10 +167,10 @@ while :; do [ ${ssh_port} -ne 22 >/dev/null 2>&1 -o ${ssh_port} -lt 1024 >/dev/null 2>&1 -a ${ssh_port} -gt 65535 >/dev/null 2>&1 ] && { echo "${CWARNING}ssh_port input error! Input range: 22,1025~65534${CEND}"; exit 1; } ;; --iptables) - iptables_yn=y; shift 1 + iptables_yn=y; shift 1 ;; --reboot) - reboot_yn=y; shift 1 + reboot_yn=y; shift 1 ;; --) shift @@ -190,7 +185,7 @@ 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 - if [ ${ARG_NUM} == 0 ]; then + if [ ${ARG_NUM} == 0 ]; then [ -z "`grep ^Port /etc/ssh/sshd_config`" ] && now_ssh_port=22 || now_ssh_port=`grep ^Port /etc/ssh/sshd_config | awk '{print $2}'` while :; do echo read -p "Please input SSH port(Default: ${now_ssh_port}): " ssh_port @@ -210,7 +205,7 @@ if [ -e "/etc/ssh/sshd_config" ]; then fi fi -if [ ${ARG_NUM} == 0 ]; then +if [ ${ARG_NUM} == 0 ]; then # check iptables while :; do echo read -p "Do you want to enable iptables? [y/n]: " iptables_yn @@ -220,7 +215,7 @@ if [ ${ARG_NUM} == 0 ]; then break fi done - + # check Web server while :; do echo read -p "Do you want to install Web server? [y/n]: " web_yn @@ -322,7 +317,7 @@ if [ ${ARG_NUM} == 0 ]; then break fi done - + # choice database while :; do echo read -p "Do you want to install Database? [y/n]: " db_yn @@ -358,27 +353,28 @@ if [ ${ARG_NUM} == 0 ]; then fi while :; do if [ "${db_option}" == '12' ]; then - read -p "Please input the postgres password of database(default: ${dbrootpwd}): " dbrootpwd + read -p "Please input the postgres password of PostgreSQL(default: ${dbpostgrespwd}): " dbpwd + [ -z "${dbpwd}" ] && dbpwd=${dbpostgrespwd} + elif [ "${db_option}" == '13' ]; then + read -p "Please input the root password of MongoDB(default: ${dbmongopwd}): " dbpwd + [ -z "${dbpwd}" ] && dbpwd=${dbmongopwd} else - read -p "Please input the root password of database(default: ${dbrootpwd}): " dbrootpwd + read -p "Please input the root password of MySQL(default: ${dbrootpwd}): " dbpwd + [ -z "${dbpwd}" ] && dbpwd=${dbrootpwd} fi - [ -z "${dbrootpwd}" ] && dbrootpwd=${dbrootpwd} - [ -n "`echo $dbrootpwd | grep '[+|&]'`" ] && { echo "${CWARNING}input error,not contain a plus sign (+) and & ${CEND}"; continue; } - if (( ${#dbrootpwd} >= 5 )); then + [ -n "`echo ${dbpwd} | grep '[+|&]'`" ] && { echo "${CWARNING}input error,not contain a plus sign (+) and & ${CEND}"; continue; } + if (( ${#dbpwd} >= 5 )); then if [ "${db_option}" == '12' ]; then - sed -i "s+^dbpostgrespwd.*+dbpostgrespwd='$dbrootpwd'+" ./options.conf - dbpostgrespwd="$dbrootpwd" + dbpostgrespwd=${dbpwd} elif [ "${db_option}" == '13' ]; then - sed -i "s+^dbmongopwd.*+dbmongopwd='$dbrootpwd'+" ./options.conf - dbmongopwd="$dbrootpwd" + dbmongopwd=${dbpwd} else - sed -i "s+^dbrootpwd.*+dbrootpwd='$dbrootpwd'+" ./options.conf + dbrootpwd=${dbpwd} fi break else echo "${CWARNING}password least 5 characters! ${CEND}" fi - done # choose install methods if [[ "${db_option}" =~ ^[1-9]$|^10$ ]]; then @@ -404,7 +400,7 @@ if [ ${ARG_NUM} == 0 ]; then break fi done - + # check PHP while :; do echo read -p "Do you want to install PHP? [y/n]: " php_yn @@ -430,7 +426,7 @@ if [ ${ARG_NUM} == 0 ]; then while :; do echo read -p "Do you want to install opcode cache of the PHP? [y/n]: " phpcache_yn if [[ ! ${phpcache_yn} =~ ^[y,n]$ ]]; then - echo "${CWARNING}input error! Please only input 'y' or 'n'${CEND}" + echo "${CWARNING}input error! Please only input 'y' or 'n'${CEND}" else if [ "${phpcache_yn}" == 'y' ]; then if [ ${php_option} == 1 ]; then @@ -495,7 +491,7 @@ if [ ${ARG_NUM} == 0 ]; then fi done fi - if [[ ${php_option} =~ ^[5-6]$ ]]; then + if [[ ${php_option} =~ ^[5-6]$ ]]; then while :; do echo 'Please select a opcode cache of the PHP:' echo -e "\t${CMSG}1${CEND}. Install Zend OPcache" @@ -516,9 +512,8 @@ if [ ${ARG_NUM} == 0 ]; then done if [ "${phpcache_option}" == '2' ]; then while :; do - read -p "Please input xcache admin password(default: ${xcachepwd}): " xcachepwd - [ -z "${xcachepwd}" ] && xcachepwd=${xcachepwd} - (( ${#xcachepwd} >= 5 )) && { xcachepwd_md5=`echo -n "${xcachepwd}" | md5sum | awk '{print $1}'` ; break ; } || echo "${CFAILURE}xcache admin password least 5 characters! ${CEND}" + read -p "Please input xcache admin password: " xcachepwd + (( ${#xcachepwd} >= 5 )) && { xcachepwd_md5=$(echo -n "${xcachepwd}" | md5sum | awk '{print $1}') ; break ; } || echo "${CFAILURE}xcache admin password least 5 characters! ${CEND}" done fi if [[ ${php_option} =~ ^[1-4]$ ]] && [ "${phpcache_option}" != '1' -a "${armplatform}" != "y" ]; then @@ -531,7 +526,7 @@ if [ ${ARG_NUM} == 0 ]; then fi done fi - + # ionCube if [ "${TARGET_ARCH}" != "arm64" ]; then while :; do echo @@ -543,7 +538,7 @@ if [ ${ARG_NUM} == 0 ]; then fi done fi - + # ImageMagick or GraphicsMagick while :; do echo read -p "Do you want to install ImageMagick or GraphicsMagick? [y/n]: " magick_yn @@ -553,7 +548,7 @@ if [ ${ARG_NUM} == 0 ]; then break fi done - + if [ "${magick_yn}" == 'y' ]; then while :; do echo 'Please select ImageMagick or GraphicsMagick:' @@ -575,7 +570,7 @@ if [ ${ARG_NUM} == 0 ]; then break fi done - + # check Pureftpd while :; do echo read -p "Do you want to install Pure-FTPd? [y/n]: " ftp_yn @@ -586,7 +581,7 @@ if [ ${ARG_NUM} == 0 ]; then break fi done - + # check phpMyAdmin if [[ ${php_option} =~ ^[1-7]$ ]] || [ -e "${php_install_dir}/bin/phpize" ]; then while :; do echo @@ -599,7 +594,7 @@ if [ ${ARG_NUM} == 0 ]; then fi done fi - + # check redis while :; do echo read -p "Do you want to install redis? [y/n]: " redis_yn @@ -609,7 +604,7 @@ if [ ${ARG_NUM} == 0 ]; then break fi done - + # check memcached while :; do echo read -p "Do you want to install memcached? [y/n]: " memcached_yn @@ -619,7 +614,7 @@ if [ ${ARG_NUM} == 0 ]; then break fi done - + while :; do echo read -p "Do you want to install HHVM? [y/n]: " hhvm_yn if [[ ! ${hhvm_yn} =~ ^[y,n]$ ]]; then @@ -696,7 +691,7 @@ if [[ ${nginx_option} =~ ^[1-3]$ ]] || [ "${db_yn}" == 'y' ]; then Install_Jemalloc | tee -a ${oneinstack_dir}/install.log fi -# openSSL +# openSSL . ./include/openssl.sh if [[ ${tomcat_option} =~ ^[1-3]$ ]] || [[ ${apache_option} =~ ^[1-2]$ ]] || [[ ${php_option} =~ ^[1-7]$ ]]; then Install_openSSL102 | tee -a ${oneinstack_dir}/install.log @@ -987,7 +982,7 @@ echo "Total OneinStack Install Time: ${CQUESTION}${installTime}${CEND} minutes" [ "${db_option}" == '13' ] && echo "$(printf "%-32s" "MongoDB user:")${CMSG}root${CEND}" [ "${db_option}" == '13' ] && echo "$(printf "%-32s" "MongoDB password:")${CMSG}${dbmongopwd}${CEND}" [ "${php_yn}" == 'y' ] && 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}" +[ "${php_yn}" == 'y' -a "${phpcache_option}" == '1' ] && echo "$(printf "%-32s" "Opcache Control Panel URL:")${CMSG}http://${IPADDR}/ocp.php${CEND}" [ "${phpcache_option}" == '2' ] && echo "$(printf "%-32s" "xcache Control Panel URL:")${CMSG}http://${IPADDR}/xcache${CEND}" [ "${phpcache_option}" == '2' ] && echo "$(printf "%-32s" "xcache user:")${CMSG}admin${CEND}" [ "${phpcache_option}" == '2' ] && echo "$(printf "%-32s" "xcache password:")${CMSG}${xcachepwd}${CEND}" @@ -1002,7 +997,7 @@ echo "Total OneinStack Install Time: ${CQUESTION}${installTime}${CEND} minutes" [ "${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}" -if [ ${ARG_NUM} == 0 ]; then +if [ ${ARG_NUM} == 0 ]; then 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 diff --git a/pureftpd_vhost.sh b/pureftpd_vhost.sh index 14d7ac2d..1408cd3f 100755 --- a/pureftpd_vhost.sh +++ b/pureftpd_vhost.sh @@ -8,7 +8,7 @@ # https://oneinstack.com # https://github.com/lj2007331/oneinstack -export PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin +export PATH=/sbin:/bin:/usr/sbin:/usr/bin:/usr/local/sbin:/usr/local/bin clear printf " ####################################################################### diff --git a/reset_db_root_password.sh b/reset_db_root_password.sh index 8903ec08..976f1f51 100755 --- a/reset_db_root_password.sh +++ b/reset_db_root_password.sh @@ -8,7 +8,7 @@ # https://oneinstack.com # https://github.com/lj2007331/oneinstack -export PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin +export PATH=/sbin:/bin:/usr/sbin:/usr/bin:/usr/local/sbin:/usr/local/bin clear printf " ####################################################################### @@ -31,7 +31,7 @@ Input_db_root_password() { (( ${#New_dbrootpwd} >= 5 )) && break || echo "${CWARNING}database root password least 5 characters! ${CEND}" done } - + Reset_db_root_password() { ${db_install_dir}/bin/mysqladmin -uroot -p"$dbrootpwd" password "$New_dbrootpwd" -h localhost > /dev/null 2>&1 status_Localhost=`echo $?` diff --git a/ss.sh b/ss.sh index 0198c315..2490f965 100755 --- a/ss.sh +++ b/ss.sh @@ -9,7 +9,7 @@ # https://oneinstack.com # https://github.com/lj2007331/oneinstack -export PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin +export PATH=/sbin:/bin:/usr/sbin:/usr/bin:/usr/local/sbin:/usr/local/bin clear printf " ####################################################################### @@ -121,7 +121,7 @@ Install_SS-python() { ${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 + 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 @@ -140,7 +140,7 @@ Install_SS-libev() { src_url=http://mirrors.linuxeye.com/oneinstack/src/mbedtls-2.7.0-apache.tgz && Download_src tar xzf shadowsocks-libev-3.1.3.tar.gz tar xzf libsodium-1.0.16.tar.gz - tar xzf mbedtls-2.7.0-apache.tgz + tar xzf mbedtls-2.7.0-apache.tgz pushd libsodium-1.0.16 ./configure make -j ${THREAD} && make install diff --git a/uninstall.sh b/uninstall.sh index f4c17604..9920c093 100755 --- a/uninstall.sh +++ b/uninstall.sh @@ -8,7 +8,7 @@ # https://oneinstack.com # https://github.com/lj2007331/oneinstack -export PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin +export PATH=/sbin:/bin:/usr/sbin:/usr/bin:/usr/local/sbin:/usr/local/bin clear printf " ####################################################################### @@ -67,11 +67,11 @@ Print_web() { [ -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" @@ -111,7 +111,7 @@ Print_MongoDB() { } Uninstall_MySQL() { - # uninstall mysql,mariadb,percona,alisql + # uninstall mysql,mariadb,percona,alisql 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,alisql}*.conf @@ -130,8 +130,8 @@ 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 "${php_install_dir}/etc/php.d/07-pgsql.ini" ] && rm -rf ${php_install_dir}/etc/php.d/07-pgsql.ini - id -u postgres >/dev/null 2>&1 ; [ $? -eq 0 ] && userdel postgres + [ -e "${php_install_dir}/etc/php.d/07-pgsql.ini" ] && rm -rf ${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 @@ -142,13 +142,13 @@ Uninstall_PostgreSQL() { } Uninstall_MongoDB() { - # 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 "${php_install_dir}/etc/php.d/07-mongo.ini" ] && rm -rf ${php_install_dir}/etc/php.d/07-mongo.ini - [ -e "${php_install_dir}/etc/php.d/07-mongodb.ini" ] && rm -rf ${php_install_dir}/etc/php.d/07-mongodb.ini - id -u mongod > /dev/null 2>&1 ; [ $? -eq 0 ] && userdel mongod + [ -e "${php_install_dir}/etc/php.d/07-mongo.ini" ] && rm -rf ${php_install_dir}/etc/php.d/07-mongo.ini + [ -e "${php_install_dir}/etc/php.d/07-mongodb.ini" ] && rm -rf ${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 @@ -205,7 +205,7 @@ Print_Redis() { 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/05-redis.ini" ] && rm -rf ${php_install_dir}/etc/php.d/05-redis.ini + [ -e "${php_install_dir}/etc/php.d/05-redis.ini" ] && rm -rf ${php_install_dir}/etc/php.d/05-redis.ini echo "${CMSG}Redis uninstall completed! ${CEND}" } @@ -217,8 +217,8 @@ Print_Memcached() { 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/05-memcache.ini" ] && rm -rf ${php_install_dir}/etc/php.d/05-memcache.ini - [ -e "${php_install_dir}/etc/php.d/05-memcached.ini" ] && rm -rf ${php_install_dir}/etc/php.d/05-memcached.ini + [ -e "${php_install_dir}/etc/php.d/05-memcache.ini" ] && rm -rf ${php_install_dir}/etc/php.d/05-memcache.ini + [ -e "${php_install_dir}/etc/php.d/05-memcached.ini" ] && rm -rf ${php_install_dir}/etc/php.d/05-memcached.ini echo "${CMSG}Memcached uninstall completed! ${CEND}" } @@ -239,8 +239,8 @@ What Are You Doing? \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 PostgreSQL -\t${CMSG}4${CEND}. Uninstall MongoDB +\t${CMSG}3${CEND}. Uninstall PostgreSQL +\t${CMSG}4${CEND}. Uninstall MongoDB \t${CMSG}5${CEND}. Uninstall PHP \t${CMSG}6${CEND}. Uninstall HHVM \t${CMSG}7${CEND}. Uninstall PureFtpd @@ -272,7 +272,7 @@ What Are You Doing? Uninstall_Web Uninstall_MySQL Uninstall_PostgreSQL - Uninstall_MongoDB + Uninstall_MongoDB Uninstall_PHP Uninstall_HHVM Uninstall_PureFtpd diff --git a/upgrade.sh b/upgrade.sh index b8a356f1..012c764f 100755 --- a/upgrade.sh +++ b/upgrade.sh @@ -8,12 +8,12 @@ # https://oneinstack.com # https://github.com/lj2007331/oneinstack -export PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin +export PATH=/sbin:/bin:/usr/sbin:/usr/bin:/usr/local/sbin:/usr/local/bin clear printf " ####################################################################### # OneinStack for CentOS/RadHat 6+ Debian 7+ and Ubuntu 12+ # -# Upgrade Software versions for OneinStack # +# Upgrade Software versions for OneinStack # # For more information please visit https://oneinstack.com # ####################################################################### " @@ -48,9 +48,9 @@ ${CMSG}web${CEND} --->Upgrade Nginx/Tengine/OpenResty/Apache ${CMSG}db${CEND} --->Upgrade MySQL/MariaDB/Percona ${CMSG}php${CEND} --->Upgrade PHP ${CMSG}redis${CEND} --->Upgrade Redis -${CMSG}memcached${CEND} --->Upgrade Memcached +${CMSG}memcached${CEND} --->Upgrade Memcached ${CMSG}phpmyadmin${CEND} --->Upgrade phpMyAdmin -${CMSG}oneinstack${CEND} --->Upgrade OneinStack +${CMSG}oneinstack${CEND} --->Upgrade OneinStack ${CMSG}acme.sh${CEND} --->Upgrade acme.sh " @@ -64,10 +64,10 @@ What Are You Doing? \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}5${CEND}. Upgrade Memcached \t${CMSG}6${CEND}. Upgrade phpMyAdmin \t${CMSG}7${CEND}. Upgrade OneinStack -\t${CMSG}8${CEND}. Upgrade acme.sh +\t${CMSG}8${CEND}. Upgrade acme.sh \t${CMSG}q${CEND}. Exit " echo @@ -84,7 +84,7 @@ What Are You Doing? elif [ -e "$openresty_install_dir/nginx/sbin/nginx" ]; then Upgrade_OpenResty elif [ -e "${apache_install_dir}/conf/httpd.conf" ]; then - Upgrade_Apache + Upgrade_Apache fi ;; 2) @@ -103,7 +103,7 @@ What Are You Doing? Upgrade_phpMyAdmin ;; 7) - Upgrade_OneinStack + Upgrade_OneinStack ;; 8) [ -e ~/.acme.sh/acme.sh ] && { ~/.acme.sh/acme.sh --upgrade; ~/.acme.sh/acme.sh --version; } @@ -128,7 +128,7 @@ elif [ $# == 1 ]; then elif [ -e "$openresty_install_dir/nginx/sbin/nginx" ]; then Upgrade_OpenResty elif [ -e "${apache_install_dir}/conf/httpd.conf" ]; then - Upgrade_Apache + Upgrade_Apache fi ;; db) @@ -147,7 +147,7 @@ elif [ $# == 1 ]; then Upgrade_phpMyAdmin ;; oneinstack) - Upgrade_OneinStack + Upgrade_OneinStack ;; acme.sh) [ -e ~/.acme.sh/acme.sh ] && { ~/.acme.sh/acme.sh --upgrade; ~/.acme.sh/acme.sh --version; } diff --git a/versions.txt b/versions.txt index f77e5c0f..6f59d237 100644 --- a/versions.txt +++ b/versions.txt @@ -9,7 +9,7 @@ tomcat8_ver=8.5.28 tomcat7_ver=7.0.85 tomcat6_ver=6.0.53 -apache24_ver=2.4.32 +apache24_ver=2.4.33 apache22_ver=2.2.34 pcre_ver=8.41 apr_ver=1.6.3 @@ -51,7 +51,7 @@ php54_ver=5.4.45 php53_ver=5.3.29 libiconv_ver=1.15 -curl_ver=7.58.0 +curl_ver=7.59.0 libmcrypt_ver=2.5.8 mcrypt_ver=2.6.8 mhash_ver=0.9.9.9 diff --git a/vhost.sh b/vhost.sh index fde8704d..d52e84b6 100755 --- a/vhost.sh +++ b/vhost.sh @@ -8,7 +8,7 @@ # https://oneinstack.com # https://github.com/lj2007331/oneinstack -export PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin +export PATH=/sbin:/bin:/usr/sbin:/usr/bin:/usr/local/sbin:/usr/local/bin clear printf " ####################################################################### @@ -140,7 +140,7 @@ Choose_env() { } Create_SSL() { - if [ "${Domian_Mode}" == '2' ]; then + if [ "${Domian_Mode}" == '2' ]; then printf " You are about to be asked to enter information that will be incorporated into your certificate request. @@ -166,10 +166,10 @@ If you enter '.', the field will be left blank. [ -z "${SELFSIGNEDSSL_OU}" ] && 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 + 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' ]; then [ "${moredomainame_flag}" == 'y' ] && moredomainame_D="$(for D in ${moredomainame}; do echo -d ${D}; done)" - if [ "${nginx_ssl_flag}" == 'y' ] && [ "${moredomain}" != "*.${domain}" ]; then + if [ "${nginx_ssl_flag}" == 'y' ] && [ "${moredomain}" != "*.${domain}" ]; then [ ! -d ${web_install_dir}/conf/vhost ] && mkdir ${web_install_dir}/conf/vhost 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 @@ -349,12 +349,14 @@ What Are You Doing? Tomcat_Domain_alias=$(for D in $(echo ${moredomainame}); do echo "${D}"; done) if [ "${Domian_Mode}" == '3' ] && [ "${moredomain}" != "*.${domain}" ]; then - PUBLIC_IPADDR=$(./include/get_public_ipaddr.py) + auth_file=${vhostdir}/"`< /dev/urandom tr -dc A-Za-z0-9 | head -c8`".html + auth_str='oneinstack'; echo ${auth_str} > ${auth_file} for D in ${domain} ${moredomainame} do - Domain_IPADDR=$(ping ${D} -c1 2> /dev/null | sed '1{s/[^(]*(//;s/).*//;q}') - [ "${PUBLIC_IPADDR%.*}" != "${Domain_IPADDR%.*}" ] && { echo; echo "${CFAILURE}DNS problem: NXDOMAIN looking up A for ${D}${CEND}"; echo; exit 1; } + curl_str=`curl --connect-timeout 10 -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}"; echo; rm -f ${auth_file}; exit 1; } done + rm -f ${auth_file} fi if [ -e "${web_install_dir}/sbin/nginx" ]; then @@ -366,7 +368,7 @@ What Are You Doing? break fi done - [ "${redirect_flag}" == 'y' ] && Nginx_redirect="if (\$host != $domain) { return 301 \$scheme://${domain}\$request_uri; }" + [ "${redirect_flag}" == 'y' ] && Nginx_redirect="if (\$host != ${domain}) { return 301 \$scheme://${domain}\$request_uri; }" fi fi @@ -617,8 +619,8 @@ 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 - + [ "${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 ${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