-
Notifications
You must be signed in to change notification settings - Fork 0
/
update.sh
executable file
·73 lines (53 loc) · 1.72 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
#!/bin/sh
RED='\e[1;31m'
YELLOW='\e[1;33m'
GREEN='\e[1;32m'
NC='\e[0m' # No Color
BOT_LOCATION="/home/bot/app"
function info {
printf "${GREEN}INFO${NC}> $1\n"
}
function warn {
printf "${YELLOW}WARN${NC}> $1\n"
}
function error {
printf "${RED}ERROR${NC}> $1\n"
}
function checkResult {
if [ $1 -ne 0 ]; then
error "$2";
rm -rf botner.tar.gz
rm -rf botner-linux-musl-x64
/etc/init.d/botner start # try it...
error "Aborting."
exit 1
fi
}
info "Starting updating Honza Botner..."
version="${1:-"latest"}"
if [ "latest" == "$version" ]; then
info "Downloading latest version of Botner"
wget https://github.com/fit-ctu-discord/honza-botner/releases/latest/download/botner-linux-musl-x64.tar.gz -O "botner.tar.gz" 1&>/dev/null 2&>/dev/null
else
info "Downloading version $version of Botner"
wget https://github.coam/fit-ctu-discord/honza-botner/releases/download/v2022.2/botner-linux-musl-x64.tar.gz -O "botner.tar.gz" 1&>/dev/null 2&>/dev/null
fi
checkResult $? "Couldnt download Botner (version: $version)";
info "Binaries downloaded"
mkdir -p "bot_binaries"
tar xzf "botner.tar.gz" -C "bot_binaries"
checkResult $? "Couldnt extract binaries"
/etc/init.d/botner stop
checkResult $? "Couldnt stop service"
info "Stoped bot service"
rm -rf "$BOT_LOCATION.bkp"
checkResult $? "Couldnt remove old backup"
mv "$BOT_LOCATION" "$BOT_LOCATION.bkp" # backup old version
checkResult $? "Couldnt make new backup"
info "Backuped old files"
cp -R "./bot_binaries/botner-linux-musl-x64" "$BOT_LOCATION"
checkResult $? "Couldnt move binnaries"
info "Copied over new binnaries"
/etc/init.d/botner start
checkResult $? "Couldnt start service"
info "Started service"