-
Notifications
You must be signed in to change notification settings - Fork 1
/
ss-libev.sh
100 lines (91 loc) · 3.7 KB
/
ss-libev.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
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
#!/usr/bin/env bash
PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin:~/bin
export PATH
#
# Auto install Shadowsocks Server
# Copyright (C) 2016-2021
# System Required: CentOS 6+, Debian7+, Ubuntu12+
# Reference URL:
# https://github.com/shadowsocks/shadowsocks
# https://github.com/shadowsocks/shadowsocks-libev
# https://github.com/shadowsocks/shadowsocks-windows
echo -e "\033[33mBegin to install shadowsocks-libev...\033[0m"
echo -e "\033[33mPlease excute this by root user!\033[0m"
echo -e "\033[33mElse it will be faild!\033[0m"
echo
sudo apt update
sudo apt upgrade -y
sudo apt install shadowsocks-libev
read -p "Input your server port: " server_port
read -s -p "Input your passwd: " passwd
echo
echo "Method: "
echo " 1) aes-256-gcm"
echo " 2) chacha20-ietf-poly1305"
echo " 3) aes-128-gcm"
echo " 4) aes-192-gcm"
echo " 5) other"
read -p "Select a method: " selec
case $selec in
1) method="aes-256-gcm";;
2) method="chacha20-ietf-poly1305";;
3) method="aes-128-gcm";;
4) method="aes-192-gcm";;
5) read -p "Input your method: " method;;
esac
echo -e "\033[33mYour method is $method, now write it to config.json...\033[0m"
cd /etc/shadowsocks-libev/
echo "{" > config.json
echo " \"server\":[\"::0\", \"0.0.0.0\"]," >> config.json
echo " \"server_port\":$server_port," >> config.json
echo " \"local_port\":1080," >> config.json
echo " \"password\":\"$passwd\"," >> config.json
echo " \"timeout\":300," >> config.json
echo " \"method\":\"$method\"," >> config.json
read -p "Install simple-obfs(y/n)? " if_simple_obfs
case $if_simple_obfs in
Y) if_simple_obfs="y";;
N) if_simple_obfs="n";;
esac
case $if_simple_obfs in
y) sudo apt install --no-install-recommends -y build-essential git autoconf libtool libssl-dev libpcre3-dev libev-dev asciidoc xmlto automake
cd /opt
git clone https://github.com/shadowsocks/simple-obfs.git
cd simple-obfs
git submodule update --init --recursive
./autogen.sh
./configure && make
sudo make install
cd /etc/shadowsocks-libev/
echo " \"fast_open\": false," >> config.json
echo " \"plugin\":\"obfs-server\"," >> config.json
echo " \"plugin_opts\":\"obfs=http\"" >> config.json;;
n) echo " \"fast_open\": false" >> config.json;;
esac
echo "}" >> config.json
echo -e "\033[33mThe config has been writen:\033[0m"
echo
echo -e "\033[32m--------------config.json--------------\033[0m"
cat config.json
echo -e "\033[32m--------------config.json--------------\033[0m"
echo
echo -e "\033[33mSystemd:\033[0m"
echo "[Unit]" > /etc/systemd/system/shadowsocks-server.service
echo "Description=Shadowsocks Server" >> /etc/systemd/system/shadowsocks-server.service
echo "After=network.target" >> /etc/systemd/system/shadowsocks-server.service
echo "" >> /etc/systemd/system/shadowsocks-server.service
echo "[Service]" >> /etc/systemd/system/shadowsocks-server.service
echo "ExecStart=/usr/local/bin/ss-server -c /etc/shadowsocks-libev/config.json" >> /etc/systemd/system/shadowsocks-server.service
echo "Restart=on-abort" >> /etc/systemd/system/shadowsocks-server.service
echo "" >> /etc/systemd/system/shadowsocks-server.service
echo "[Install]" >> /etc/systemd/system/shadowsocks-server.service
echo "WantedBy=multi-user.target" >> /etc/systemd/system/shadowsocks-server.service
echo -e "\033[33mThe config has been writen:\033[0m"
echo
echo -e "\033[32m--------------shadowsocks-server.service--------------\033[0m"
cat /etc/systemd/system/shadowsocks-server.service
echo -e "\033[32m--------------shadowsocks-server.service--------------\033[0m"
echo
echo -e "\033[33mStart the ss...\033[0m"
sudo systemctl start shadowsocks-server
sudo systemctl enable shadowsocks-server