forked from sirzdy/shadowsocks
-
Notifications
You must be signed in to change notification settings - Fork 0
/
ss.sh
78 lines (73 loc) · 2.02 KB
/
ss.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
#! /bin/bash
# log路径
export log_path=/etc/ss.log
# 设置端口号
echo -n -e '\033[36mPlease enter PORT(1225 default): \033[0m'
# echo -n "please enter port(1225 default):"
read port
if [ ! -n "$port" ];then
echo "port will be set to 1225"
port=1225
else
echo "port will be set to $port"
fi
# 设置密码
echo -n -e '\033[36mPlease enter PASSWORD(123456 default): \033[0m'
# echo -n "please enter password(123456 default):"
read pwd
if [ ! -n "$pwd" ];then
echo "password will be set to 123456"
pwd=123456
else
echo "password will be set to $pwd"
fi
# 写shadowsocks.json配置文件
cat>/etc/shadowsocks.json<<EOF
{
"server":"0.0.0.0",
"server_port":$port,
"local_address": "127.0.0.1",
"local_port":1080,
"password":"$pwd",
"timeout":300,
"method":"aes-256-cfb",
"fast_open": false
}
EOF
# 安装 shadowsocks 防火墙等
ret=`yum install -y m2crypto python-setuptools >> ${log_path} 2>&1`
ret=`easy_install pip >> ${log_path} 2>&1`
ret=`pip install shadowsocks >> ${log_path} 2>&1`
ret=`yum install -y firewalld >> ${log_path} 2>&1`
ret=`systemctl start firewalld >> ${log_path} 2>&1`
# 开启端口
ret=`firewall-cmd --permanent --zone=public --add-port=22/tcp >> ${log_path} 2>&1`
ret=`firewall-cmd --permanent --zone=public --add-port=$port/tcp >> ${log_path} 2>&1`
ret=`firewall-cmd --reload >> ${log_path} 2>&1`
# 如果有相同功能的进程则杀死
ps -ef|grep ssserver|grep shadowsocks|grep -v grep
if [ $? -eq 0 ];then
ps -ef|grep ssserver|grep shadowsocks|awk '{ print $2 }'|xargs kill -9
fi
# 后台运行
/usr/bin/ssserver -c /etc/shadowsocks.json -d start
# 成功
if [ $? -eq 0 ];then
clear
cat<<EOF
***************Congratulation!*************
Shadowsocks installed successfully!
PORT: $port
PASSWORD: $pwd
METHOD: aes-256-cfb
***************JUST ENJOY IT!**************
EOF
# 失败
else
clear
cat<<EOF
************Failed,retry please!***********
cat /etc/ss.log to get something you need…
************Failed,retry please!***********
EOF
fi