forked from Panther-X/PantherDashboard
-
Notifications
You must be signed in to change notification settings - Fork 0
/
install.sh
77 lines (64 loc) · 2.65 KB
/
install.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
#!/bin/bash
rm /tmp/latest.tar.gz
if test -d /var/dashboard; then
echo 'Dashboard already installed, running an update...'
wget https://raw.githubusercontent.com/Panther-X/PantherDashboard/main/update.sh -O - | sudo bash
else
if id -nG admin | grep -qw "sudo"; then
wget https://raw.githubusercontent.com/Panther-X/PantherDashboard/main/version -O /tmp/dashboard_latest_ver
VER=`cat /tmp/dashboard_latest_ver`
wget https://codeload.github.com/Panther-X/PantherDashboard/tar.gz/refs/tags/${VER} -O /tmp/latest.tar.gz
cd /tmp
if test -f latest.tar.gz; then
rm -rf /tmp/PantherDashboard-*
tar -xzf latest.tar.gz
cd PantherDashboard-${VER}
apt-get update
apt-get --assume-yes install nginx php-fpm php7.3-fpm
mkdir /var/dashboard
mkdir /etc/monitor-scripts
cp -r dashboard/* /var/dashboard/
cp version /var/dashboard/
cp monitor-scripts/* /etc/monitor-scripts/
cp nginx/snippets/* /etc/nginx/snippets/
cp nginx/default /etc/nginx/sites-enabled
if ! test -f /var/dashboard/.htpasswd; then
cp nginx/.htpasswd /var/dashboard/.htpasswd
fi
if ! test -f /etc/ssl/certs/dhparam.pem; then
openssl dhparam -out /etc/ssl/certs/dhparam.pem 2048
fi
openssl req -new -newkey rsa:2048 -days 365 -nodes -x509 -subj "/C=CN/ST=Panther/L=Panther/O=Panther/CN=localhost" -keyout /etc/ssl/private/nginx-selfsigned.key -out /etc/ssl/certs/nginx-selfsigned.crt
cp systemd/* /etc/systemd/system/
chmod 755 /etc/monitor-scripts/*
chown root:www-data /var/dashboard/services/*
chown root:www-data /var/dashboard/statuses/*
chmod 775 /var/dashboard/services/*
chmod 775 /var/dashboard/statuses/*
chown root:root /etc/ssl/private/nginx-selfsigned.key
chmod 600 /etc/ssl/private/nginx-selfsigned.key
chown root:root /etc/ssl/certs/nginx-selfsigned.crt
chmod 777 /etc/ssl/certs/nginx-selfsigned.crt
chown root:www-data /var/dashboard/.htpasswd
chmod 775 /var/dashboard/.htpasswd
chown root:www-data /var/dashboard
chmod 775 /var/dashboard
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
done
systemctl enable nginx
systemctl restart nginx
bash /etc/monitor-scripts/pubkeys.sh
echo 'Success.'
else
echo 'No installation archive found. No changes made.'
fi
else
echo 'Error checking if admin user exists. No changes made.';
fi
fi