-
Notifications
You must be signed in to change notification settings - Fork 0
/
uesp-update-teamspeak
executable file
·85 lines (62 loc) · 1.88 KB
/
uesp-update-teamspeak
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
74
75
76
77
78
79
80
81
82
83
84
85
#!/bin/sh
#
# Basic concept copied from https://github.com/eminga/ts3updater/blob/master/ts3updater.sh
#
INSTALLPATH="/home/uesp/teamspeak"
BACKUPROOTPATH="/home/backup/teamspeak"
JQ_INSTALLED=$(yum list installed | grep jq.x86_64)
if [ -z "$JQ_INSTALLED" ]
then
echo " Installing JQ..."
yum install jq
fi
SERVER=$(curl -Ls 'https://www.teamspeak.com/versions/server.json' | jq ".linux.x86_64")
LINKS=$(printf '%s' "$SERVER" | jq -r '.mirrors | values[]')
LINK=$(printf '%s' "$LINKS" | sed -n "1"p)
echo $SERVER
echo $LINK
if [ -z "$LINK" ]
then
echo " No version of TeamSpeak found to install!"
exit
fi
echo " Downloading $LINK"
TMPFILE=$(mktemp "/tmp/ts3updater.XXXXXXXXXX")
curl --fail -Lo "$TMPFILE" "$LINK"
if [ $? == 0 ]; then
echo " Successfully downloaded file!"
else
echo " Error: Curl failed to download file!"
exit
fi
echo " Stopping teamspeak..."
service teamspeak stop
BACKUPDATE=$(date +"%Y-%m-%d-%H%M%S")
BACKUPPATH="$BACKUPROOTPATH/$BACKUPDATE"
echo " Creating backup at '$BACKUPPATH'..."
mv "$INSTALLPATH" "$BACKUPPATH"
if [ $? -ne 0 ]; then
echo " Error: Failed to move old files to backup!"
exit
fi
mkdir -p "$INSTALLPATH"
if [ $? -ne 0 ]; then
echo " Error: Failed to make new directory '$INSTALLPATH'!"
exit
fi
tar --strip-component 1 -xf "$TMPFILE" -C "$INSTALLPATH"
if [ $? -ne 0 ]; then
echo " Error: Failed to make new directory '$INSTALLPATH'!"
exit
fi
chown teamspeak:teamspeak -R "$INSTALLPATH"
chmod o-w -R "$INSTALLPATH"
echo " Installed new TeamSpeak version at '$INSTALLPATH'..."
echo " Copying old data to new path..."
cp -Rp $BACKUPPATH/logs $INSTALLPATH/
cp -Rp $BACKUPPATH/query* $INSTALLPATH/
cp -Rp $BACKUPPATH/ssh* $INSTALLPATH/
cp -Rp $BACKUPPATH/.ts3server_license_accepted $INSTALLPATH/
cp -Rp $BACKUPPATH/ts3server.sqlitedb* $INSTALLPATH/
echo " Starting teamspeak..."
service teamspeak start