-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathupdate.sh
executable file
·42 lines (34 loc) · 970 Bytes
/
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
#!/bin/bash
# Check if the user is root
if [ "$EUID" -ne 0 ]
then echo "Please run as root"
exit 1
fi
echo "Reading existing Client ID..."
if ! CLIENT_ID=$(cat /etc/opt/bakupagent/CLIENT_ID)
then
echo "Client ID is missing, exiting"
exit 1
fi
echo "Reading existing API Token..."
if ! API_TOKEN=$(cat /etc/opt/bakupagent/API_TOKEN)
then
echo "API Token is missing, exiting"
exit 1
fi
echo "Reading existing User ID..."
if ! USER_ID=$(cat /etc/opt/bakupagent/USER_ID)
then
echo "USER_ID is missing, exiting"
exit 1
fi
echo "Uninstalling current agent..."
/opt/bakupagent/uninstall.sh --local-uninstall
# This cd takes the script out of the deleted directory before running the install script. This stops getcwd() errors
# saying it can't find the directory
cd ..
echo "Installing the agent..."
wget -qO - https://agent.bakup.io/latest/install | sudo bash -s $CLIENT_ID $API_TOKEN $USER_ID
echo "Update completed"
PID=$$
kill $PID