forked from briffy/PiscesQoLDashboard
-
Notifications
You must be signed in to change notification settings - Fork 0
/
update.sh
93 lines (81 loc) · 2.85 KB
/
update.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
#!/bin/bash
apt-get update
apt-get -f install --assume-yes pptp-linux openvpn
if ! id "admin" &> /dev/null; then
delgroup admin
adduser --disabled-password --gecos "" admin
echo admin:admin | chpasswd
usermod admin -g sudo
fi
if ! test -d /home/admin; then
mkhomedir_helper admin
fi
if id -nG admin | grep -qw "sudo"; then
rm -rf /tmp/latest.tar.gz
rm -rf /tmp/dashboardinstall
echo 'Downloading latest release...' > /var/dashboard/logs/dashboard-update.log
wget --no-cache https://raw.githubusercontent.com/briffy/PiscesQoLDashboard/main/latest.tar.gz -O /tmp/latest.tar.gz
cd /tmp
if test -f latest.tar.gz; then
echo 'Extracting contents...' >> /var/dashboard/logs/dashboard-update.log
tar -xzf latest.tar.gz
cd dashboardinstall
rm dashboard/logs/dashboard-update.log
for f in dashboard/services/*; do
if ! test -f /var/$f; then
cp $f /var/dashboard/services
fi
done
for f in dashboard/statuses/*; do
if ! test -f /var/$f; then
cp $f /var/dashboard/statuses
fi
done
for f in dashboard/logs/*; do
if ! test -f /var/$f; then
cp $f /var/dashboard/logs
fi
done
for f in dashboard/vpn/*; do
if ! test -f /var/$f; then
cp $f /var/dashboard/logs
fi
done
rm -rf dashboard/services/*
rm -rf dashboard/statuses/*
rm -rf dashboard/logs/*
rm nginx/.htpasswd
cp -r monitor-scripts/* /etc/monitor-scripts/
cp -r dashboard/* /var/dashboard/
cp -r systemd/* /etc/systemd/system/
chown root:www-data /var/dashboard/vpn/*
chmod 755 /etc/monitor-scripts/*
chown root:www-data /var/dashboard/services/*
chown root:www-data /var/dashboard/statuses/*
chmod 775 /var/dashboard/vpn/*
chmod 775 /var/dashboard/services/*
chmod 775 /var/dashboard/statuses/*
chown root:www-data /var/dashboard
chmod 775 /var/dashboard
echo 'Starting and enabling services...' >> /var/dashboard/logs/dashboard-update.log
FILES="systemd/*.timer"
for f in $FILES;
do
name=$(echo $f | sed 's/.timer//' | sed 's/systemd\///')
systemctl start $name.timer
systemctl enable $name.timer
systemctl start $name.service
echo "$name enabled" >> /var/dashboard/logs/dashboard-update.log
done
systemctl daemon-reload
bash /etc/monitor-scripts/pubkeys.sh
echo 'Success.' >> /var/dashboard/logs/dashboard-update.log
echo 'stopped' > /var/dashboard/services/dashboard-update
else
echo 'No installation archive found. No changes made.' >> /var/dashboard/logs/dashboard-update.log
echo 'stopped' > /var/dashboard/services/dashboard-update
fi
else
echo 'Error checking if admin user exists. No changes made.' >> /var/dashboard/logs/dashboard-update.log
echo 'stopped' > /var/dashboard/services/dashboard-update
fi