ts3-server-updater/update

60 lines
1.8 KiB
Bash
Executable File

#!/bin/bash
VERSION=$(curl http://files.teamspeak-services.com/releases/server/ | egrep -o '[0-9]+\.[0-9]+\.[0-9]+' | sort | uniq | sort --version-sort --field-separator=. | tail -n1)
LINK="http://files.teamspeak-services.com/releases/server/$VERSION/teamspeak3-server_linux_amd64-$VERSION.tar.bz2"
service_ts3="ts3server serveradmin"
ts3local="/opt/teamspeak/"
mkdir -p $ts3local
if (( $(ps -ef | grep -v grep | grep "$service_ts3" | wc -l) > 0))
then
alive_ts3=1
else
alive_ts3=0
fi
if (alive_ts3=1)
then
systemctl stop teamspeak
fi
if (alive_ts3=0)
then
#CREATE BACKUP
sudo mkdir -p /BACKUP/
cp -rp /opt/ /BACKUP/opt-$(date +"%d-%m-%Y")/
#DOWNLOAD NEWER VERSION OF TEAMSPEAK
wget $LINK --quiet
#UNTAR AND COPY FILES
tar -jxf teamspeak3-server_linux_amd*.tar.bz2
cp -rp /opt/teamspeak3-server_linux_amd64/CHANGELOG $ts3local
cp -rp /opt/teamspeak3-server_linux_amd64/doc $ts3local
cp -rp /opt/teamspeak3-server_linux_amd64/ts3server $ts3local
cp -rp /opt/teamspeak3-server_linux_amd64/ts3server_minimal_runscript.sh $ts3local
cp -rp /opt/teamspeak3-server_linux_amd64/ts3server_startscript.sh $ts3local
cp -rp /opt/teamspeak3-server_linux_amd64/sql $ts3local
cp -rp /opt/teamspeak3-server_linux_amd64/redist $ts3local
cp -rp /opt/teamspeak3-server_linux_amd64/serverquerydocs $ts3local
cp -rp /opt/teamspeak3-server_linux_amd64/libts3_ssh.so $ts3local
#REMOVE FILES
rm -rf teamspeak3-server_linux_amd*.tar.bz2 teamspeak3-server_linux_amd64*
#START TEAMSPEAK
systemctl start teamspeak
if (( $(ps -ef | grep -v grep | grep "$service_ts3" | wc -l) > 0))
then
echo -e "\e[32m$service_ts3 is running!!!\e[0m"
else
echo -e "\e[31m$service_ts3 is not running!!!\e[0m"
sleep 5
systemctl start teamspeak
fi
fi