From 98fced6ab7a0b1160d86f2f78e54f952bc4a0a39 Mon Sep 17 00:00:00 2001 From: Jerry Date: Fri, 3 Feb 2017 15:32:49 +0800 Subject: [PATCH] Synchronized automatically. --- .../backupfiles/chinadns.service.logging | 16 ++++++++++++++ .../shadowsocks-libev-redir@.service.logging} | 5 ++++- .../files/etc/systemd/system/chinadns.service | 6 ++--- .../systemd/system/chinadns.service.nologging | 14 ------------ .../system/shadowsocks-libev-redir@.service | 5 +---- shadowsocks/ss-iptables.sh | 22 +++++++++---------- 6 files changed, 34 insertions(+), 34 deletions(-) create mode 100644 shadowsocks/files/etc/systemd/system/backupfiles/chinadns.service.logging rename shadowsocks/files/etc/systemd/system/{shadowsocks-libev-redir@.service.nologging => backupfiles/shadowsocks-libev-redir@.service.logging} (86%) delete mode 100644 shadowsocks/files/etc/systemd/system/chinadns.service.nologging diff --git a/shadowsocks/files/etc/systemd/system/backupfiles/chinadns.service.logging b/shadowsocks/files/etc/systemd/system/backupfiles/chinadns.service.logging new file mode 100644 index 0000000..1dd1fe6 --- /dev/null +++ b/shadowsocks/files/etc/systemd/system/backupfiles/chinadns.service.logging @@ -0,0 +1,16 @@ +[Unit] +Description=Chinadns +After=network.target + +[Service] +Type=simple +User=root +ExecStart=/bin/sh -c '/usr/bin/chinadns \ + -m \ + -b 127.0.0.2 \ + -c /usr/share/chnroute.txt \ + 1> /var/log/chinadns.log \ + 2> /var/log/chinadns.err.log' + +[Install] +WantedBy=multi-user.target diff --git a/shadowsocks/files/etc/systemd/system/shadowsocks-libev-redir@.service.nologging b/shadowsocks/files/etc/systemd/system/backupfiles/shadowsocks-libev-redir@.service.logging similarity index 86% rename from shadowsocks/files/etc/systemd/system/shadowsocks-libev-redir@.service.nologging rename to shadowsocks/files/etc/systemd/system/backupfiles/shadowsocks-libev-redir@.service.logging index 420f194..f1905e7 100644 --- a/shadowsocks/files/etc/systemd/system/shadowsocks-libev-redir@.service.nologging +++ b/shadowsocks/files/etc/systemd/system/backupfiles/shadowsocks-libev-redir@.service.logging @@ -17,7 +17,10 @@ After=network.target [Service] Type=simple CapabilityBoundingSet=CAP_NET_ADMIN CAP_NET_BIND_SERVICE -ExecStart=/usr/bin/ss-redir -c /etc/shadowsocks-libev/%i.json +ExecStart=/bin/sh -c '/usr/bin/ss-redir \ + -c /etc/shadowsocks-libev/%i.json \ + > /var/log/ss-redir.log \ + 2>&1' [Install] WantedBy=multi-user.target diff --git a/shadowsocks/files/etc/systemd/system/chinadns.service b/shadowsocks/files/etc/systemd/system/chinadns.service index 1dd1fe6..e386e73 100644 --- a/shadowsocks/files/etc/systemd/system/chinadns.service +++ b/shadowsocks/files/etc/systemd/system/chinadns.service @@ -5,12 +5,10 @@ After=network.target [Service] Type=simple User=root -ExecStart=/bin/sh -c '/usr/bin/chinadns \ +ExecStart=/usr/bin/chinadns \ -m \ -b 127.0.0.2 \ - -c /usr/share/chnroute.txt \ - 1> /var/log/chinadns.log \ - 2> /var/log/chinadns.err.log' + -c /usr/share/chnroute.txt [Install] WantedBy=multi-user.target diff --git a/shadowsocks/files/etc/systemd/system/chinadns.service.nologging b/shadowsocks/files/etc/systemd/system/chinadns.service.nologging deleted file mode 100644 index e386e73..0000000 --- a/shadowsocks/files/etc/systemd/system/chinadns.service.nologging +++ /dev/null @@ -1,14 +0,0 @@ -[Unit] -Description=Chinadns -After=network.target - -[Service] -Type=simple -User=root -ExecStart=/usr/bin/chinadns \ - -m \ - -b 127.0.0.2 \ - -c /usr/share/chnroute.txt - -[Install] -WantedBy=multi-user.target diff --git a/shadowsocks/files/etc/systemd/system/shadowsocks-libev-redir@.service b/shadowsocks/files/etc/systemd/system/shadowsocks-libev-redir@.service index f1905e7..420f194 100644 --- a/shadowsocks/files/etc/systemd/system/shadowsocks-libev-redir@.service +++ b/shadowsocks/files/etc/systemd/system/shadowsocks-libev-redir@.service @@ -17,10 +17,7 @@ After=network.target [Service] Type=simple CapabilityBoundingSet=CAP_NET_ADMIN CAP_NET_BIND_SERVICE -ExecStart=/bin/sh -c '/usr/bin/ss-redir \ - -c /etc/shadowsocks-libev/%i.json \ - > /var/log/ss-redir.log \ - 2>&1' +ExecStart=/usr/bin/ss-redir -c /etc/shadowsocks-libev/%i.json [Install] WantedBy=multi-user.target diff --git a/shadowsocks/ss-iptables.sh b/shadowsocks/ss-iptables.sh index 91ab31c..0b48cfb 100755 --- a/shadowsocks/ss-iptables.sh +++ b/shadowsocks/ss-iptables.sh @@ -4,11 +4,11 @@ localport="1080" ssdomain="ipv4.jerry981028.ml" ssconfig="config-client" #完整路径为/etc/shadowsocks-libev/config-client.json sstool="ss-nat" -USE_CHINADNS=0 -FANCYDISPLAY=1 #用于在终端中画出一个小飞机图标 +USE_CHINADNS=false #使用true,false或/bin/true,/bin/false +FANCYDISPLAY=true #用于在终端中画出一个小飞机图标 ############################# function ErrorSolve(){ -if [ $IS_TERMINAL == 1 ] ; then +if [ "$IS_TERMINAL" == "true" ] ; then read -n 1 -t 5 -p "发生错误,等待5秒或任意键退出" fi exit 1 @@ -35,7 +35,7 @@ fi if [ ! -f chnroute.txt ] ; then Update fi -if [ $USE_CHINADNS == 1 ] ; then +if $USE_CHINADNS ; then echo -e "\e[1;32m● \e[0m使用chinadns \c" else echo -e "\e[1;31m● \e[0m不使用chinadns \c" @@ -43,9 +43,9 @@ fi } function Start(){ #Get ip from domain -serverip=`ping ${ssdomain} -s 1 -c 1 -W 2 | grep ${ssdomain} | head -n 1` -serverip=`echo ${serverip} | cut -d'(' -f 2 | cut -d')' -f 1` -if [ "$serverip" == "" ] ; then +serverip=$(ping ${ssdomain} -s 1 -c 1 -W 2 | grep ${ssdomain} | head -n 1) +serverip=$(echo ${serverip} | cut -d '(' -f 2 | cut -d ')' -f 1) +if [ -z "$serverip" ] ; then echo "错误:查找服务器ip失败,检查网络连接" ErrorSolve fi @@ -54,14 +54,14 @@ touch /run/ss-iptables.lock systemctl start shadowsocks-libev-redir@"$ssconfig".service $sstool -s $serverip -l $localport -i chnroute.txt -o #Start chinadns if necessary -if [ $USE_CHINADNS == 1 ] ; then +if $USE_CHINADNS ; then systemctl start chinadns.service fi } function Stop(){ $sstool -f systemctl stop shadowsocks-libev-redir@"$ssconfig".service -if [ $USE_CHINADNS == 1 ] ; then +if $USE_CHINADNS ; then systemctl stop chinadns.service fi rm /run/ss-iptables.lock @@ -90,7 +90,7 @@ systemctl restart networking Start ;; "") -IS_TERMINAL=1 +IS_TERMINAL="true" Checkenv if [ -f /run/ss-iptables.lock ] ; then echo -e "\e[41;30m关闭中...\e[0m" @@ -99,7 +99,7 @@ else echo -e "\e[42;30m启动中...\e[0m" Start fi -if [ $FANCYDISPLAY == 1 ] ; then +if $FANCYDISPLAY ; then echo -e "\e[1;34m CO Ls40a