forked from wg-dashboard/wg-dashboard
-
Notifications
You must be signed in to change notification settings - Fork 0
/
update_script.sh
38 lines (33 loc) · 1.16 KB
/
update_script.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
#!/bin/bash
set -e
if [[ "$EUID" -ne 0 ]]; then
echo "Sorry, this script must be ran as root"
echo "Maybe try this:"
echo "curl https://raw.githubusercontent.com/wg-dashboard/wg-dashboard/master/update_script.sh | sudo bash"
exit
fi
# go into home folder
cd /opt
# test for existing install
if [ ! -d wg-dashboard ]; then
echo "You do not appear to have wg-dashboard installed."
echo "Try running this instead:"
echo "curl https://raw.githubusercontent.com/wg-dashboard/wg-dashboard/master/install_script.sh | sudo bash"
exit
fi
# backup existing config
cp wg-dashboard/server_config.json wg-dashboard/server_config.bak
# download latest release
curl -L https://github.com/$(wget https://github.com/wg-dashboard/wg-dashboard/releases/latest -O - | egrep '/.*/.*/.*tar.gz' -o) --output wg-dashboard.tar.gz
# untar latest release into existing install
tar -xzf wg-dashboard.tar.gz --strip-components=1 -C wg-dashboard
# delete unpacked .tar.gz
rm -f wg-dashboard.tar.gz
# go into wg-dashboard folder
cd wg-dashboard
# install node modules
npm i --production --unsafe-perm
# restore config
mv server_config.bak server_config.json
# restart service
systemctl restart wg-dashboard