forked from jordan-bentley97/mc-backup.sh
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmc-update-geyser.sh
executable file
·42 lines (31 loc) · 1.21 KB
/
mc-update-geyser.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
pathFile=$(readlink -f "$BASH_SOURCE")
dirname=${pathFile%/*}
required_files=(constants.sh lib.sh)
for v in ${required_files[*]}; { [[ -r "$dirname"/${v} ]] || { echo "File ${v} not found. Exiting..."; $exit; }; }
source "$dirname"/constants.sh
source "$dirname"/lib.sh
stopGeyser(){
sudo systemctl stop "$geyser_service"
log "[$(currentDay)] Stopped Service $geyser_service"
}
startGeyser(){
sudo systemctl start "$geyser_service"
log "[$(currentDay)] Started Service $geyser_service"
}
if ! sudo -n true; then
log "[$(currentDay)] Please use user with sudo privileges."
$exit 1
fi
stopGeyser
if [ -f "$geyser_path" ]; then
log "[$(currentDay)] Geyser found. Checking for updates..."
geyser_folder=$(dirname "$geyser_path")
sudo -u "$geyser_user" mv "$geyser_folder"/Geyser.jar "$geyser_folder"/Geyser.jar.old
log "[$(currentDay)] Geyser backup made. Creating old file..."
geyser_link="https://ci.opencollab.dev/job/GeyserMC/job/Geyser/job/master/lastSuccessfulBuild/artifact/bootstrap/standalone/build/libs/Geyser-Standalone.jar"
sudo -u "$geyser_user" wget -O "$geyser_folder/Geyser.jar" "$geyser_link"
log "[$(currentDay)] Geyser updated."
fi
startGeyser
$exit 0