-
Notifications
You must be signed in to change notification settings - Fork 1
/
TS3Update.sh
50 lines (42 loc) · 1.99 KB
/
TS3Update.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
#!/usr/bin/env bash
#
# TeamSpeak3 Update Script
#
# get home folder
TMP_LIST_PASSWD=( $(getent passwd `/usr/bin/id -un` | sed 's/:/ /g' ))
HOMEDIR=${TMP_LIST_PASSWD[5]}
unset TMP_LIST_PASSWD
# FILESERVER
TS3FILESERVER="https://files.teamspeak-services.com/releases/server/"
# needed file (Server Plattform Version)
TS3FILE="teamspeak3-server_linux_amd64"
# get latest Version
TS3LATEST=`curl --silent https://teamspeak.com/de/downloads/ | grep input | grep -o "http[^ ]*" | grep server | head -n 1 | sed -nre 's/^[^0-9]*(([0-9]+\.)*[0-9]+).*/\1/p'`
# prevent non-version given
if [ -z "$TS3LATEST" ]; then
TS3LATEST="0"
fi
# get local Version
TS3LOCAL=`ls -1rv $HOMEDIR | sed 's/ts3server*//g' | head -n 1`
if dpkg --compare-versions $TS3LATEST gt $TS3LOCAL ; then
echo "TS3: newer Version ($TS3LATEST) found, downloading..."
wget –q --no-cache --https-only -A "tar.bz2" –O "$HOMEDIR/$TS3FILE-$TS3LATEST.tar.bz2" "$TS3FILESERVER$TS3LATEST/$TS3FILE-$TS3LATEST.tar.bz2" &> /dev/null
if [ -f "$HOMEDIR/$TS3FILE-$TS3LATEST.tar.bz2" ]; then
echo "extracting..."
tar -xf "$HOMEDIR/$TS3FILE-$TS3LATEST.tar.bz2"
rm "$HOMEDIR/$TS3FILE-$TS3LATEST.tar.bz2"
echo "prepare update..."
mv "$TS3FILE" "ts3server$TS3LATEST"
TARGET=`ls -1rv $HOMEDIR | grep ts3server | head -n 1`
echo "updating symlinks..."
ln -sfn $HOMEDIR/$TARGET $HOMEDIR/ts3server
ln -s $HOMEDIR/server.ini $HOMEDIR/ts3server/ts3server.ini
if [ -f "$HOMEDIR/licensekey.dat" ]; then
ln -s $HOMEDIR/licensekey.dat $HOMEDIR/ts3server/licensekey.dat
fi
ln -sfn $HOMEDIR/ts3files $HOMEDIR/ts3server/files
ln -s $HOMEDIR/ts3server/redist/libmariadb.so.2 $HOMEDIR/ts3server/libmariadb.so.2
echo "initiate server restart..."
$TS3LOCAL/ts3server/ts3server_startscript.sh stop
fi
fi