Browse Source

Fix backup_setup.sh and Update iptables

lj2007331@gmail.com 6 years ago
parent
commit
c09ebc0f79
13 changed files with 170 additions and 95 deletions
  1. 2 0
      addons.sh
  2. 13 13
      backup_setup.sh
  3. 2 6
      include/panel.sh
  4. 4 6
      include/pureftpd.sh
  5. 2 6
      include/tomcat-6.sh
  6. 2 6
      include/tomcat-7.sh
  7. 2 6
      include/tomcat-8.sh
  8. 2 6
      include/tomcat-9.sh
  9. 15 0
      init.d/SS-libev.service
  10. 15 0
      init.d/SS-python.service
  11. 2 2
      install.sh
  12. 107 42
      ss.sh
  13. 2 2
      versions.txt

+ 2 - 0
addons.sh

@@ -137,6 +137,7 @@ What Are You Doing?
         2)
           ACTION_FUN
           if [ "${install_yn}" = 'y' ]; then
+            Install_Python
             Install_fail2ban
           elif [ "${uninstall_yn}" = 'y' ]; then
             Uninstall_fail2ban
@@ -189,6 +190,7 @@ else
   fi
   if [ "${fail2ban_yn}" == 'y' ]; then
     if [ "${install_yn}" = 'y' ]; then
+      Install_Python
       Install_fail2ban
     elif [ "${uninstall_yn}" = 'y' ]; then
       Uninstall_fail2ban

+ 13 - 13
backup_setup.sh

@@ -56,12 +56,12 @@ while :; do echo
 done
 
 sed -i 's@^backup_destination=.*@backup_destination=@' ./options.conf
-[ `echo ${desc_bk} | grep -w 1` ] && sed -i 's@^backup_destination=.*@backup_destination=local@' ./options.conf
-[ `echo ${desc_bk} | grep -w 2` ] && sed -i 's@^backup_destination=.*@&,remote@' ./options.conf
-[ `echo ${desc_bk} | grep -w 3` ] && sed -i 's@^backup_destination=.*@&,oss@' ./options.conf
-[ `echo ${desc_bk} | grep -w 4` ] && sed -i 's@^backup_destination=.*@&,cos@' ./options.conf
-[ `echo ${desc_bk} | grep -w 5` ] && sed -i 's@^backup_destination=.*@&,upyun@' ./options.conf
-[ `echo ${desc_bk} | grep -w 6` ] && sed -i 's@^backup_destination=.*@&,qiniu@' ./options.conf
+[ -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
 sed -i 's@^backup_destination=,@backup_destination=@' ./options.conf
 
 while :; do echo
@@ -143,7 +143,7 @@ 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}"
 
-if [ `echo ${desc_bk} | grep -e 2` ]; then
+if [ -n `echo ${desc_bk} | grep -w 2` ]; then
   > tools/iplist.txt
   while :; do echo
     read -e -p "Please enter the remote host ip: " remote_ip
@@ -176,7 +176,7 @@ if [ `echo ${desc_bk} | grep -e 2` ]; then
   done
 fi
 
-if [ `echo ${desc_bk} | grep -e 3` ]; then
+if [ -n `echo ${desc_bk} | grep -w 3` ]; then
   if [ ! -e "/usr/local/bin/ossutil" ]; then
     wget -qc http://gosspublic.alicdn.com/ossutil/1.4.2/ossutil${OS_BIT} -O /usr/local/bin/ossutil
     chmod +x /usr/local/bin/ossutil
@@ -239,7 +239,7 @@ if [ `echo ${desc_bk} | grep -e 3` ]; then
   done
 fi
 
-if [ `echo ${desc_bk} | grep -e 4` ]; then
+if [ -n `echo ${desc_bk} | grep -w 4` ]; then
   Install_Python
   [ ! -e "${python_install_dir}/lib/coscmd" ] && ${python_install_dir}/bin/pip install coscmd >/dev/null 2>&1
   while :; do echo
@@ -316,7 +316,7 @@ if [ `echo ${desc_bk} | grep -e 4` ]; then
   done
 fi
 
-if [ `echo ${desc_bk} | grep -e 5` ]; then
+if [ -n `echo ${desc_bk} | grep -w 5` ]; then
   if [ ! -e "/usr/local/bin/upx" ]; then
     if [ "${OS_BIT}" == '64' ]; then
       wget -qc http://collection.b0.upaiyun.com/softwares/upx/upx-linux-amd64-v0.2.3 -O /usr/local/bin/upx
@@ -346,7 +346,7 @@ if [ `echo ${desc_bk} | grep -e 5` ]; then
   done
 fi
 
-if [ `echo ${desc_bk} | grep -e 6` ]; then
+if [ -n `echo ${desc_bk} | grep -w 6` ]; then
   if [ ! -e "/usr/local/bin/qrsctl" ]; then
     if [ "${OS_BIT}" == '64' ]; then
       wget -qc http://devtools.qiniu.com/linux/amd64/qrsctl -O /usr/local/bin/qrsctl
@@ -356,8 +356,8 @@ if [ `echo ${desc_bk} | grep -e 6` ]; then
     chmod +x /usr/local/bin/qrsctl
   fi
   if [ ! -e "/usr/local/bin/qshell" ]; then
-    wget -qc http://devtools.qiniu.com/qshell-v2.1.8.zip -O /tmp/qshell-v2.1.8.zip
-    unzip -q /tmp/qshell-v2.1.8.zip -d /tmp/
+    wget -qc http://devtools.qiniu.com/qshell-v2.3.5.zip -O /tmp/qshell-v2.3.5.zip
+    unzip -q /tmp/qshell-v2.3.5.zip -d /tmp/
     if [ "${OS_BIT}" == '64' ]; then
       /bin/cp /tmp/qshell-linux-x64 /usr/local/bin/qshell
     elif [ "${OS_BIT}" == '32' ]; then

+ 2 - 6
include/panel.sh

@@ -33,9 +33,7 @@ Install_Panel() {
     if [ -n "`grep 'dport 80 ' /etc/sysconfig/iptables`" ] && [ -z "$(grep -w ${Panel_port} /etc/sysconfig/iptables)" ]; then
       iptables -I INPUT 5 -p tcp -m state --state NEW -m tcp --dport ${Panel_port} -j ACCEPT
       service iptables save
-      /bin/cp /etc/sysconfig/{iptables,ip6tables}
-      sed -i 's@icmp@icmpv6@g' /etc/sysconfig/ip6tables
-      ip6tables-restore < /etc/sysconfig/ip6tables
+      ip6tables -I INPUT 5 -p tcp -m state --state NEW -m tcp --dport ${Panel_port} -j ACCEPT
       service ip6tables save
     fi
   elif [ "${PM}" == 'apt-get' ]; then
@@ -43,9 +41,7 @@ Install_Panel() {
       if [ -n "`grep 'dport 80 ' /etc/iptables/rules.v4`" ] && [ -z "$(grep -w ${Panel_port} /etc/iptables/rules.v4)" ]; then
         iptables -I INPUT 5 -p tcp -m state --state NEW -m tcp --dport ${Panel_port} -j ACCEPT
         iptables-save > /etc/iptables/rules.v4
-        /bin/cp /etc/iptables/rules.v{4,6}
-        sed -i 's@icmp@icmpv6@g' /etc/iptables/rules.v6
-        ip6tables-restore < /etc/iptables/rules.v6
+        ip6tables -I INPUT 5 -p tcp -m state --state NEW -m tcp --dport ${Panel_port} -j ACCEPT
         ip6tables-save > /etc/iptables/rules.v6
       fi
     elif [ -e '/etc/iptables.up.rules' ]; then

+ 4 - 6
include/pureftpd.sh

@@ -54,9 +54,8 @@ Install_PureFTPd() {
         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
-        /bin/cp /etc/sysconfig/{iptables,ip6tables}
-        sed -i 's@icmp@icmpv6@g' /etc/sysconfig/ip6tables
-        ip6tables-restore < /etc/sysconfig/ip6tables
+        ip6tables -I INPUT 5 -p tcp -m state --state NEW -m tcp --dport 21 -j ACCEPT
+        ip6tables -I INPUT 6 -p tcp -m state --state NEW -m tcp --dport 20000:30000 -j ACCEPT
         service ip6tables save
       fi
     elif [ "${PM}" == 'apt-get' ]; then
@@ -65,9 +64,8 @@ Install_PureFTPd() {
           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/rules.v4
-          /bin/cp /etc/iptables/rules.v{4,6}
-          sed -i 's@icmp@icmpv6@g' /etc/iptables/rules.v6
-          ip6tables-restore < /etc/iptables/rules.v6
+          ip6tables -I INPUT 5 -p tcp -m state --state NEW -m tcp --dport 21 -j ACCEPT
+          ip6tables -I INPUT 6 -p tcp -m state --state NEW -m tcp --dport 20000:30000 -j ACCEPT
           ip6tables-save > /etc/iptables/rules.v6
         fi
       elif [ -e '/etc/iptables.up.rules' ]; then

+ 2 - 6
include/tomcat-6.sh

@@ -75,9 +75,7 @@ EOF
         if [ -n "`grep 'dport 80 ' /etc/sysconfig/iptables`" ] && [ -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
-          /bin/cp /etc/sysconfig/{iptables,ip6tables}
-          sed -i 's@icmp@icmpv6@g' /etc/sysconfig/ip6tables
-          ip6tables-restore < /etc/sysconfig/ip6tables
+          ip6tables -I INPUT 5 -p tcp -m state --state NEW -m tcp --dport 8080 -j ACCEPT
           service ip6tables save
         fi
       elif [ "${PM}" == 'apt-get' ]; then
@@ -85,9 +83,7 @@ EOF
           if [ -n "`grep 'dport 80 ' /etc/iptables/rules.v4`" ] && [ -z "$(grep -w '8080' /etc/iptables/rules.v4)" ]; then
             iptables -I INPUT 5 -p tcp -m state --state NEW -m tcp --dport 8080 -j ACCEPT
             iptables-save > /etc/iptables/rules.v4
-            /bin/cp /etc/iptables/rules.v{4,6}
-            sed -i 's@icmp@icmpv6@g' /etc/iptables/rules.v6
-            ip6tables-restore < /etc/iptables/rules.v6
+            ip6tables -I INPUT 5 -p tcp -m state --state NEW -m tcp --dport 8080 -j ACCEPT
             ip6tables-save > /etc/iptables/rules.v6
           fi
         elif [ -e '/etc/iptables.up.rules' ]; then

+ 2 - 6
include/tomcat-7.sh

@@ -75,9 +75,7 @@ EOF
         if [ -n "`grep 'dport 80 ' /etc/sysconfig/iptables`" ] && [ -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
-          /bin/cp /etc/sysconfig/{iptables,ip6tables}
-          sed -i 's@icmp@icmpv6@g' /etc/sysconfig/ip6tables
-          ip6tables-restore < /etc/sysconfig/ip6tables
+          ip6tables -I INPUT 5 -p tcp -m state --state NEW -m tcp --dport 8080 -j ACCEPT
           service ip6tables save
         fi
       elif [ "${PM}" == 'apt-get' ]; then
@@ -85,9 +83,7 @@ EOF
           if [ -n "`grep 'dport 80 ' /etc/iptables/rules.v4`" ] && [ -z "$(grep -w '8080' /etc/iptables/rules.v4)" ]; then
             iptables -I INPUT 5 -p tcp -m state --state NEW -m tcp --dport 8080 -j ACCEPT
             iptables-save > /etc/iptables/rules.v4
-            /bin/cp /etc/iptables/rules.v{4,6}
-            sed -i 's@icmp@icmpv6@g' /etc/iptables/rules.v6
-            ip6tables-restore < /etc/iptables/rules.v6
+            ip6tables -I INPUT 5 -p tcp -m state --state NEW -m tcp --dport 8080 -j ACCEPT
             ip6tables-save > /etc/iptables/rules.v6
           fi
         elif [ -e '/etc/iptables.up.rules' ]; then

+ 2 - 6
include/tomcat-8.sh

@@ -75,9 +75,7 @@ EOF
         if [ -n "`grep 'dport 80 ' /etc/sysconfig/iptables`" ] && [ -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
-          /bin/cp /etc/sysconfig/{iptables,ip6tables}
-          sed -i 's@icmp@icmpv6@g' /etc/sysconfig/ip6tables
-          ip6tables-restore < /etc/sysconfig/ip6tables
+          ip6tables -I INPUT 5 -p tcp -m state --state NEW -m tcp --dport 8080 -j ACCEPT
           service ip6tables save
         fi
       elif [ "${PM}" == 'apt-get' ]; then
@@ -85,9 +83,7 @@ EOF
           if [ -n "`grep 'dport 80 ' /etc/iptables/rules.v4`" ] && [ -z "$(grep -w '8080' /etc/iptables/rules.v4)" ]; then
             iptables -I INPUT 5 -p tcp -m state --state NEW -m tcp --dport 8080 -j ACCEPT
             iptables-save > /etc/iptables/rules.v4
-            /bin/cp /etc/iptables/rules.v{4,6}
-            sed -i 's@icmp@icmpv6@g' /etc/iptables/rules.v6
-            ip6tables-restore < /etc/iptables/rules.v6
+            ip6tables -I INPUT 5 -p tcp -m state --state NEW -m tcp --dport 8080 -j ACCEPT
             ip6tables-save > /etc/iptables/rules.v6
           fi
         elif [ -e '/etc/iptables.up.rules' ]; then

+ 2 - 6
include/tomcat-9.sh

@@ -75,9 +75,7 @@ EOF
         if [ -n "`grep 'dport 80 ' /etc/sysconfig/iptables`" ] && [ -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
-          /bin/cp /etc/sysconfig/{iptables,ip6tables}
-          sed -i 's@icmp@icmpv6@g' /etc/sysconfig/ip6tables
-          ip6tables-restore < /etc/sysconfig/ip6tables
+          ip6tables -I INPUT 5 -p tcp -m state --state NEW -m tcp --dport 8080 -j ACCEPT
           service ip6tables save
         fi
       elif [ "${PM}" == 'apt-get' ]; then
@@ -85,9 +83,7 @@ EOF
           if [ -n "`grep 'dport 80 ' /etc/iptables/rules.v4`" ] && [ -z "$(grep -w '8080' /etc/iptables/rules.v4)" ]; then
             iptables -I INPUT 5 -p tcp -m state --state NEW -m tcp --dport 8080 -j ACCEPT
             iptables-save > /etc/iptables/rules.v4
-            /bin/cp /etc/iptables/rules.v{4,6}
-            sed -i 's@icmp@icmpv6@g' /etc/iptables/rules.v6
-            ip6tables-restore < /etc/iptables/rules.v6
+            ip6tables -I INPUT 5 -p tcp -m state --state NEW -m tcp --dport 8080 -j ACCEPT
             ip6tables-save > /etc/iptables/rules.v6
           fi
         elif [ -e '/etc/iptables.up.rules' ]; then

+ 15 - 0
init.d/SS-libev.service

@@ -0,0 +1,15 @@
+[Unit]
+Description=Shadowsocks-libev Default Server Service
+After=network.target
+
+[Service]
+Type=simple
+CapabilityBoundingSet=CAP_NET_BIND_SERVICE
+AmbientCapabilities=CAP_NET_BIND_SERVICE
+ExecStart=/usr/local/bin/ss-server -c /etc/shadowsocks/config.json
+User=nobody
+Group=nogroup
+LimitNOFILE=32768
+
+[Install]
+WantedBy=multi-user.target

+ 15 - 0
init.d/SS-python.service

@@ -0,0 +1,15 @@
+[Unit]
+Description=Shadowsocks Default Server Service
+After=network.target
+
+[Service]
+Type=simple
+CapabilityBoundingSet=CAP_NET_BIND_SERVICE
+AmbientCapabilities=CAP_NET_BIND_SERVICE
+ExecStart=/usr/local/python/bin/ssserver -c /etc/shadowsocks/config.json
+User=nobody
+Group=nogroup
+LimitNOFILE=32768
+
+[Install]
+WantedBy=multi-user.target

+ 2 - 2
install.sh

@@ -37,8 +37,8 @@ xcachepwd=`< /dev/urandom tr -dc A-Za-z0-9 | head -c8`
 dbinstallmethod=1
 
 version() {
-  echo "version: 1.7"
-  echo "updated date: 2018-04-20"
+  echo "version: 2.0"
+  echo "updated date: 2019-01-04"
 }
 
 showhelp() {

+ 107 - 42
ss.sh

@@ -32,6 +32,63 @@ pushd ${oneinstack_dir}/src > /dev/null
 
 PUBLIC_IPADDR=$(../include/get_public_ipaddr.py)
 
+showhelp() {
+  echo
+  echo "Usage: $0  command ...[parameters]....
+  --help, -h                  Show this help message
+  --quiet, -q                 quiet operation
+  --install, -i               Install
+  --uninstall, -u             Uninstall
+  --libev                     shadowsocks-libev
+  --python                    shadowsocks-python
+  --adduser                   Add shadowsocks account
+  --password [password]       shadowsocks password
+  --port [port]               shadowsocks port
+  "
+}
+ARG_NUM=$#
+TEMP=`getopt -o hqiu --long help,quiet,install,uninstall,libev,python,adduser,password:,port: -- "$@" 2>/dev/null`
+[ $? != 0 ] && echo "${CWARNING}ERROR: unknown argument! ${CEND}" && showhelp && exit 1
+eval set -- "${TEMP}"
+while :; do
+  [ -z "$1" ] && break;
+  case "$1" in
+    -h|--help)
+      showhelp; exit 0
+      ;;
+    -q|--quiet)
+      quiet_yn=y; shift 1
+      ;;
+    -i|--install)
+      install_yn=y; shift 1
+      ;;
+    -u|--uninstall)
+      uninstall_yn=y; shift 1
+      ;;
+    --libev)
+      libev_queit=y; ss_option=1; shift 1
+      ;;
+    --python)
+      python_queit=y; ss_option=2; shift 1
+      ;;
+    --adduser)
+      adduser_yn=y; shift 1
+      ;;
+    --password)
+      password_queit=y; SS_password=$2; shift 2
+      ;;
+    --port)
+      port_queit=y; SS_port=$2; shift 2
+      ;;
+    --)
+      shift
+      ;;
+    *)
+      echo "${CWARNING}ERROR: unknown argument! ${CEND}" && showhelp && exit 1
+      ;;
+  esac
+done
+
 [ "${CentOS_ver}" == '5' ] && { echo "${CWARNING}SS only support CentOS6,7 or Debian or Ubuntu! ${CEND}"; exit 1; }
 
 Check_SS() {
@@ -41,7 +98,7 @@ Check_SS() {
 
 AddUser_SS() {
   while :; do echo
-    read -e -p "Please input password for SS: " SS_password
+    [ ${password_queit} != 'y' ] && read -e -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
@@ -63,7 +120,7 @@ Iptables_set() {
   fi
 
   while :; do echo
-    read -e -p "Please input SS port(Default: ${SS_Default_port}): " SS_port
+    [ ${port_queit} != 'y' ] && read -e -p "Please input SS port(Default: ${SS_Default_port}): " SS_port
     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}"
@@ -77,9 +134,8 @@ Iptables_set() {
       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
-      /bin/cp /etc/sysconfig/{iptables,ip6tables}
-      sed -i 's@icmp@icmpv6@g' /etc/sysconfig/ip6tables
-      ip6tables-restore < /etc/sysconfig/ip6tables
+      ip6tables -I INPUT 4 -p udp -m state --state NEW -m udp --dport ${SS_port} -j ACCEPT
+      ip6tables -I INPUT 4 -p tcp -m state --state NEW -m tcp --dport ${SS_port} -j ACCEPT
       service ip6tables save
     fi
   elif [ "${PM}" == 'apt-get' ]; then
@@ -88,9 +144,8 @@ Iptables_set() {
         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/rules.v4
-        /bin/cp /etc/iptables/rules.v{4,6}
-        sed -i 's@icmp@icmpv6@g' /etc/iptables/rules.v6
-        ip6tables-restore < /etc/iptables/rules.v6
+        ip6tables -I INPUT 4 -p udp -m state --state NEW -m udp --dport ${SS_port} -j ACCEPT
+        ip6tables -I INPUT 4 -p tcp -m state --state NEW -m tcp --dport ${SS_port} -j ACCEPT
         ip6tables-save > /etc/iptables/rules.v6
       fi
     elif [ -e '/etc/iptables.up.rules' ]; then
@@ -105,10 +160,12 @@ Iptables_set() {
 
 Def_parameter() {
   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 -e -p "Please input a number:(Default 1 press Enter) " ss_option
+    if [ "${libev_queit}" != 'y' -a "${python_queit}" != 'y' ]; then
+      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 -e -p "Please input a number:(Default 1 press Enter) " ss_option
+    fi
     ss_option=${ss_option:-1}
     if [[ ! "${ss_option}" =~ ^[1-2]$ ]]; then
       echo "${CWARNING}input error! Please only input number 1~2${CEND}"
@@ -139,11 +196,18 @@ Install_SS-python() {
   ${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
-    [ "${PM}" == 'yum' ] && { chkconfig --add shadowsocks; chkconfig shadowsocks on; }
-    [ "${PM}" == 'apt-get' ] && update-rc.d shadowsocks defaults
+    sed -i 's@libcrypto.EVP_CIPHER_CTX_cleanup@libcrypto.EVP_CIPHER_CTX_reset@g' ${python_install_dir}/lib/python3.6/site-packages/shadowsocks/crypto/openssl.py
+    if [ -e /bin/systemctl ]; then
+      /bin/cp ../init.d/SS-python.service /lib/systemd/system/shadowsocks.service
+      sed -i "s@/usr/local/python@${python_install_dir}@g" /lib/systemd/system/shadowsocks.service
+      systemctl enable shadowsocks
+    else
+      /bin/cp ../init.d/SS-python-init /etc/init.d/shadowsocks
+      sed -i "s@SS_bin=.*@SS_bin=${python_install_dir}/bin/ssserver@" /etc/init.d/shadowsocks
+      chmod +x /etc/init.d/shadowsocks
+      [ "${PM}" == 'yum' ] && { chkconfig --add shadowsocks; chkconfig shadowsocks on; }
+      [ "${PM}" == 'apt-get' ] && update-rc.d shadowsocks defaults
+    fi
   else
     echo
     echo "${CQUESTION}SS-python install failed! Please visit https://oneinstack.com${CEND}"
@@ -177,13 +241,18 @@ Install_SS-libev() {
   [ -z "`grep /usr/local/lib /etc/ld.so.conf.d/*.conf`" ] && echo '/usr/local/lib' > /etc/ld.so.conf.d/local.conf
   ldconfig
   if [ -f /usr/local/bin/ss-server ]; then
-    if [ "${PM}" == 'yum' ]; then
-      /bin/cp ../init.d/SS-libev-init-CentOS /etc/init.d/shadowsocks
-      chkconfig --add shadowsocks
-      chkconfig shadowsocks on
-    elif [ "${PM}" == 'apt-get' ]; then
-      /bin/cp ../init.d/SS-libev-init-Ubuntu /etc/init.d/shadowsocks
-      update-rc.d shadowsocks defaults
+    if [ -e /bin/systemctl ]; then
+      /bin/cp ../init.d/SS-libev.service /lib/systemd/system/shadowsocks.service
+      systemctl enable shadowsocks
+    else
+      if [ "${PM}" == 'yum' ]; then
+        /bin/cp ../init.d/SS-libev-init-CentOS /etc/init.d/shadowsocks
+        chkconfig --add shadowsocks
+        chkconfig shadowsocks on
+      elif [ "${PM}" == 'apt-get' ]; then
+        /bin/cp ../init.d/SS-libev-init-Ubuntu /etc/init.d/shadowsocks
+        update-rc.d shadowsocks defaults
+      fi
     fi
   else
     echo
@@ -194,16 +263,17 @@ Install_SS-libev() {
 
 Uninstall_SS() {
   while :; do echo
-    read -e -p "Do you want to uninstall SS? [y/n]: " SS_yn
-    if [[ ! "${SS_yn}" =~ ^[y,n]$ ]]; then
+    [ "${quiet_yn}" != 'y' ] && read -e -p "Do you want to uninstall SS? [y/n]: " uninstall_yn
+    if [[ ! "${uninstall_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
+  if [ "${uninstall_yn}" == 'y' ]; then
+    [ -n "$(ps -ef | grep -v grep | grep -iE "ssserver|ss-server")" ] && service shadowsocks stop
+    [ -e /lib/systemd/system/shadowsocks.service ] && { systemctl disable shadowsocks; rm -f /lib/systemd/system/shadowsocks.service; }
     [ "${PM}" == 'yum' ] && chkconfig --del shadowsocks
     [ "${PM}" == 'apt-get' ] && update-rc.d -f shadowsocks remove
     rm -rf /etc/shadowsocks /var/run/shadowsocks.pid /etc/init.d/shadowsocks
@@ -273,16 +343,16 @@ Your Encryption Method: ${CMSG}aes-256-cfb${CEND}
 "
 }
 
-case "$1" in
-install)
+if [ "${install_yn}" == 'y' -o "${ARG_NUM}" == '0' ]; then
   Def_parameter
   [ "${ss_option}" == '1' ] && Install_SS-libev
   [ "${ss_option}" == '2' ] && Install_SS-python
   Config_SS
   service shadowsocks start
   Print_User_SS
-  ;;
-adduser)
+fi
+
+if [ "${adduser_yn}" == 'y' ]; then
   Check_SS
   if [ "${ss_option}" == '2' ]; then
     AddUser_SS
@@ -290,21 +360,16 @@ adduser)
     AddUser_Config_SS
     service shadowsocks restart
     Print_User_SS
-  else
+  elif [ "${ss_option}" == '2' ]; then
     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)
+fi
+
+if [ "${uninstall_yn}" == 'y' ]; then
   Check_SS
   Uninstall_SS
-  ;;
-*)
-  echo
-  echo "Usage: ${CMSG}$0${CEND} { ${CMSG}install${CEND} | ${CMSG}adduser${CEND} | ${CMSG}uninstall${CEND} }"
-  echo
-  exit 1
-esac
+fi

+ 2 - 2
versions.txt

@@ -25,7 +25,7 @@ mysql56_ver=5.6.42
 mysql55_ver=5.5.62
 
 mariadb103_ver=10.3.11
-mariadb102_ver=10.2.20
+mariadb102_ver=10.2.21
 mariadb101_ver=10.1.37
 mariadb100_ver=10.0.37
 mariadb55_ver=5.5.62
@@ -63,7 +63,7 @@ mcrypt_ver=2.6.8
 mhash_ver=0.9.9.9
 libsodium_ver=1.0.16
 argon2_ver=20171227
-imagemagick_ver=6.9.10-22
+imagemagick_ver=6.9.10-23
 imagick_ver=3.4.3
 graphicsmagick_ver=1.3.30
 gmagick_ver=2.0.5RC1