Skip to content

Commit

Permalink
Synchronized automatically.
Browse files Browse the repository at this point in the history
  • Loading branch information
Jerry authored and Jerry committed Feb 3, 2017
1 parent 0c28a45 commit 98fced6
Show file tree
Hide file tree
Showing 6 changed files with 34 additions and 34 deletions.
Original file line number Diff line number Diff line change
@@ -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
5 changes: 4 additions & 1 deletion [email protected] → .../[email protected]
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 2 additions & 4 deletions shadowsocks/files/etc/systemd/system/chinadns.service
Original file line number Diff line number Diff line change
Expand Up @@ -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
14 changes: 0 additions & 14 deletions shadowsocks/files/etc/systemd/system/chinadns.service.nologging

This file was deleted.

5 changes: 1 addition & 4 deletions shadowsocks/files/etc/systemd/system/[email protected]
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
22 changes: 11 additions & 11 deletions shadowsocks/ss-iptables.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -35,17 +35,17 @@ 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"
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
Expand All @@ -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
Expand Down Expand Up @@ -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"
Expand All @@ -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
Expand Down

0 comments on commit 98fced6

Please sign in to comment.