-
Notifications
You must be signed in to change notification settings - Fork 0
/
setup.sh
45 lines (36 loc) · 1016 Bytes
/
setup.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
#!/bin/bash
# Update system
sudo apt update
# Install goproxy
curl -L https://raw.githubusercontent.com/snail007/goproxy/master/install_auto.sh | sudo bash
# Define settings variables
USER_NAME=$1
PROXY_TYPE=$2
PROXY_PORT=$3
PROXY_USER=$4
PROXY_PASSWORD=$5
# Define service command
if [ -n "$PROXY_USER" ] && [ -n "$PROXY_PASSWORD" ]; then
COMMAND="${PROXY_TYPE} -t tcp -p '0.0.0.0:${PROXY_PORT}' -a '${PROXY_USER}:${PROXY_PASSWORD}'"
else
COMMAND="${PROXY_TYPE} -t tcp -p '0.0.0.0:${PROXY_PORT}'"
fi
# Create systemd service
sudo echo "[Unit]
Description=Proxy server
Requires=network.target
[Service]
Type=simple
User=${USER_NAME}
WorkingDirectory=/home/${USER_NAME}
ExecStart=/bin/bash -lc '/usr/bin/proxy ${COMMAND}'
TimeoutSec=15
Restart=always
[Install]
WantedBy=multi-user.target" > /etc/systemd/system/proxy.service
# Enable service
sudo systemctl daemon-reload
sudo systemctl enable proxy.service
sudo systemctl start proxy.service
# Print status
sudo systemctl status proxy.service --no-pager