-
Notifications
You must be signed in to change notification settings - Fork 124
/
snell.centos.sh
49 lines (49 loc) · 1.52 KB
/
snell.centos.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
#!/usr/bin/env bash
PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin:~/bin
export PATH
CONF="/etc/snell/snell-server.conf"
SYSTEMD="/etc/systemd/system/snell.service"
yum install unzip -y
cd ~/
wget --no-check-certificate -O snell.zip https://github.com/surge-networks/snell/releases/download/v3.0.1/snell-server-v3.0.1-linux-amd64.zip
unzip -o snell.zip
rm -f snell.zip
chmod +x snell-server
mv -f snell-server /usr/local/bin/
if [ -f ${CONF} ]; then
echo "Found existing config..."
else
if [ -z ${PSK} ]; then
PSK=$(tr -dc A-Za-z0-9 </dev/urandom | head -c 16)
echo "Using generated PSK: ${PSK}"
else
echo "Using predefined PSK: ${PSK}"
fi
mkdir /etc/snell/
echo "Generating new config..."
echo "[snell-server]" >>${CONF}
echo "listen = 0.0.0.0:13254" >>${CONF}
echo "psk = ${PSK}" >>${CONF}
echo "obfs = tls" >>${CONF}
fi
if [ -f ${SYSTEMD} ]; then
echo "Found existing service..."
systemctl daemon-reload
systemctl restart snell
else
echo "Generating new service..."
echo "[Unit]" >>${SYSTEMD}
echo "Description=Snell Proxy Service" >>${SYSTEMD}
echo "After=network.target" >>${SYSTEMD}
echo "" >>${SYSTEMD}
echo "[Service]" >>${SYSTEMD}
echo "Type=simple" >>${SYSTEMD}
echo "LimitNOFILE=32768" >>${SYSTEMD}
echo "ExecStart=/usr/local/bin/snell-server -c /etc/snell/snell-server.conf" >>${SYSTEMD}
echo "" >>${SYSTEMD}
echo "[Install]" >>${SYSTEMD}
echo "WantedBy=multi-user.target" >>${SYSTEMD}
systemctl daemon-reload
systemctl enable snell
systemctl start snell
fi