-
Notifications
You must be signed in to change notification settings - Fork 0
/
update.bash
executable file
·40 lines (33 loc) · 959 Bytes
/
update.bash
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
#!/usr/bin/env bash
source config.bash
source api.bash
update_msg() {
echo "This server will go down for updating in $1!"
}
current_build="$(< "$current_version_file")"
latest_build="$(get_latest_build)"
# check if server is up to date
! (( latest_build > current_build )) && exit 0
echo "Server is out of date! Updating..."
if systemctl --user -q is-active "$service"; then
echo "Stopping server in 5 minutes..."
global_chat_message "$(update_msg "5 minutes")"
sleep 4m
global_chat_message "$(update_msg "1 minute")"
sleep 30s
global_chat_message "$(update_msg "30 seconds")"
sleep 20s
global_chat_message "$(update_msg "10 seconds")"
sleep 7s
global_chat_message "3..."
sleep 1s
global_chat_message "2..."
sleep 1s
global_chat_message "1..."
sleep 1s
global_chat_message "RIP"
update_server true
else
update_server false
fi
echo -n "$latest_build" > "$current_version_file"