-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathnetclient_linux_upg.sh
52 lines (41 loc) · 1.21 KB
/
netclient_linux_upg.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
#!/bin/sh
# upgrade netclient on linux clients
# Find the current netclient version
netclient_tag=$(curl -sL https://api.github.com/repos/gravitl/netmaker/releases/latest | jq -r ".tag_name")
echo -----------------------------------------
echo current version of netclient is $netclient_tag
echo -----------------------------------------
read -p "Do you wish to install this version?" -n 1 -r
if [[ ! $REPLY =~ ^[Yy]$ ]]
then
exit 1
fi
echo exited user input
# stop service
systemctl stop netclient.service
echo stopped netclient
# move to netclient directory
cd /sbin
echo moved to netclient directory
# if there's an old backup, remove it
FILE=/sbin/netclient.bak
if [[ -f "$FILE" ]]; then
rm $FILE
fi
echo finished backup removal
# back up current binary
mv netclient netclient.bak
echo renamed netclient backup
# download the new version into correct directory
curl -L https://github.com/gravitl/netmaker/releases/download/$netclient_tag/netclient --output /sbin/netclient
echo downloaded new netclient
# make new binary executable
chmod 755 netclient
echo made executable
# restart service
systemctl start netclient.service
echo restarted service
# get new config
sudo netclient pull
echo completed netclient pull
exit 0