forked from swizzin/swizzin_dashboard
-
Notifications
You must be signed in to change notification settings - Fork 0
/
setup.sh
71 lines (57 loc) · 1.65 KB
/
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
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
#!/bin/bash
master=$(cut -d: -f1 < /root/.master.info)
apt-get -y -q install python3-venv git
mkdir -p /opt/swizzin/
python3 -m venv /opt/swizzin/venv
git clone https://github.com/liaralabs/swizzin_dashboard.git /opt/swizzin/swizzin
/opt/swizzin/venv/bin/pip install -r /opt/swizzin/swizzin/requirements.txt
useradd -r swizzin
chown -R swizzin: /opt/swizzin
mkdir -p /etc/nginx/apps
if [[ -f /install/.deluge.lock ]]; then
touch /install/.delugeweb.lock
fi
if [[ $master == $(id -nu 1000) ]]; then
:
else
echo "ADMIN_USER = '$master'" >> /opt/swizzin/swizzin/swizzin.cfg
fi
cat > /etc/nginx/apps/panel.conf <<'EON'
location / {
#rewrite ^/panel/(.*) /$1 break;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Host $host;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_set_header Origin "";
proxy_pass http://127.0.0.1:8333;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "Upgrade";
}
EON
cat > /etc/systemd/system/panel.service <<EOS
[Unit]
Description=swizzin panel service
After=nginx.service
[Service]
Type=simple
User=swizzin
ExecStart=/opt/swizzin/venv/bin/python swizzin.py
WorkingDirectory=/opt/swizzin/swizzin
Restart=on-failure
TimeoutStopSec=300
[Install]
WantedBy=multi-user.target
EOS
cat > /etc/sudoers.d/panel <<EOSUD
#Defaults env_keep -="HOME"
Defaults:swizzin !logfile
Defaults:swizzin !syslog
Defaults:swizzin !pam_session
Cmnd_Alias CMNDS = /usr/bin/quota, /bin/systemctl
swizzin ALL = (ALL) NOPASSWD: CMNDS
EOSUD
systemctl reload nginx
systemctl enable --now panel