-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathupdateServer.sh
More file actions
54 lines (42 loc) · 1.43 KB
/
updateServer.sh
File metadata and controls
54 lines (42 loc) · 1.43 KB
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
#!/bin/bash
# Server variables
HOMEDIRECTORY="/home/michaelsanttos12"
UNTURNEDDIRECTORY=$HOMEDIRECTORY/unturned
NEWERVERSIONFILE=$HOMEDIRECTORY/newerversion.txt
CURRENTVERSIONFILE=$HOMEDIRECTORY/currentversion.txt
STEAMDIR=$HOMEDIRECTORY/SteamCMD
stopServer() {
$HOMEDIRECTORY/stopServer.sh
}
startServer() {
$HOMEDIRECTORY/startServer.sh
}
updateServer() {
$STEAMDIR/steamcmd.sh +login anonymous +force_install_dir $UNTURNEDDIRECTORY +app_update 1110390 +quit
}
updateVersionFiles() {
cat $NEWERVERSIONFILE > $CURRENTVERSIONFILE
}
fetchLastVersion() {
$STEAMDIR/steamcmd.sh +login anonymous +app_info_update 1 +app_info_print "1110390" +quit | grep -EA 1000 "^\s+\"branches\"$" | grep -EA 5 "^\s+\"public\"$" | grep -m 1 -EB 10 "^\s+}$" | grep -E "^\s+\"buildid\"\s+" | tr '[:blank:]"' ' ' | tr -s ' ' | cut -d ' ' -f3 > $NEWERVERSIONFILE
}
[[ ! -f $NEWERVERSIONFILE ]] && touch $NEWERVERSIONFILE
[[ ! -f $CURRENTVERSIONFILE ]] && touch $CURRENTVERSIONFILE
USER=$LOGNAME
echo "User: "$LOGNAME
echo "Seach for newer version of the game..."
fetchLastVersion
echo "Newer version: ["`cat $NEWERVERSIONFILE`"]"
echo "Current version: ["`cat $CURRENTVERSIONFILE`"]"
# Check if there are game updates
if [ `cat $NEWERVERSIONFILE` -eq `cat $CURRENTVERSIONFILE` ]; then
echo "Game is already up to date"
else
stopServer
echo "Updating server..."
updateServer
startServer
updateVersionFiles
echo "Update finished!"
fi
echo "Date:"`date`