Skip to content

Instantly share code, notes, and snippets.

@serial
Last active November 4, 2022 22:17
Show Gist options
  • Save serial/911dfdd3e14da4d2394e655b6bf989a4 to your computer and use it in GitHub Desktop.
Save serial/911dfdd3e14da4d2394e655b6bf989a4 to your computer and use it in GitHub Desktop.
ts3-server-updater

TS3-Update

Script will easily download latest ts3server files and update the server automatically.

Requirements

  • Server running a linux amd64 TS3 Server
  • Server Directory Named "teamspeak3-server_linux_amd64"
  • Run the script from within the directory where the server files are located.

Put in this directory

/home/teamspeak/teamspeak3-server_linux_amd64/{TS3 server files}
/home/teamspeak/ts3update.sh (the script)

Install

save or wget the ts3update.sh

chmod +x ts3update.sh
./ts3update.sh

Oneliner - download script via wget (-N timestamp, -no-verbose), chmod +x and execute

wget -Nnv https://gist.githubusercontent.com/serial/911dfdd3e14da4d2394e655b6bf989a4/raw/b900d103501f9b101c93d4292e448e5dd4c7c86a/ts3update.sh && chmod +x ts3update.sh; ./ts3update.sh

Cron

$crontab -e
@reboot bash ts3update.sh

or execute every month the 3rd at 5.30 am

30 5 3 * * bash ts3update.sh

See wiki.ubuntuusers.de/cron

#!/usr/bin/env bash
VERSION="version.txt"
function getLatestTS3Version() {
TS3_SERVER_VERSION="";
if [[ -z "${TS3_SERVER_VERSION}" ]]; then
wget -t 1 -T 3 'https://files.teamspeak-services.com/releases/server/' -q -O - | grep -Ei 'a href="[0-9]+' | grep -Eo ">(.*)<" | tr -d ">" | tr -d "<" | uniq | sort -V -r > RELEASES.txt
if [[ $? -ne 0 ]]; then
return 1;
fi
while read release; do
wget -t 1 -T 1 --spider -q "https://files.teamspeak-services.com/releases/server/${release}/teamspeak3-server_linux_amd64-${release}.tar.bz2"
if [[ $? == 0 ]]; then
TS3_SERVER_VERSION="$release"
# Found
break
fi
done < RELEASES.txt
rm RELEASES.txt
fi
if [[ -n "$TS3_SERVER_VERSION" ]]; then
echo -n "$TS3_SERVER_VERSION";
else
return 1;
fi
}
TS3_SERVER_VERSION="$(getLatestTS3Version)";
if [[ -n "$TS3_SERVER_VERSION" ]] && [[ "$TS3_SERVER_VERSION" != "0" ]]; then
#echo -n "$TS3_SERVER_VERSION";
if [ "$TS3_SERVER_VERSION" == "$(cat $VERSION)" ] ;then
echo "No Update"
else
echo "New Version $TS3_SERVER_VERSION"
wget -O ts3.tar.bz2 "https://files.teamspeak-services.com/releases/server/${TS3_SERVER_VERSION}/teamspeak3-server_linux_amd64-${TS3_SERVER_VERSION}.tar.bz2"
if [ $? -eq 0 ]; then
echo "Stop TS3"
./teamspeak3-server_linux_amd64/ts3server_startscript.sh stop
echo "Entpacke"
tar -xjf ts3.tar.bz2
echo "Start TS3"
./teamspeak3-server_linux_amd64/ts3server_startscript.sh start
#Save Version
echo "$TS3_SERVER_VERSION" > $VERSION
else
echo "Downlod failed. Please check version"
fi
fi
else
return "Can not detect Version";
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment