LinuxGSM/TeamSpeak3/ts3server

135 lines
3.1 KiB
Plaintext
Raw Normal View History

2013-08-11 19:03:31 +08:00
#!/bin/bash
# TeamSpeak 3
2013-08-11 19:03:31 +08:00
# Server Management Script
# Author: Daniel Gibbs
2016-05-09 01:17:34 +08:00
# Website: https://gameservermanagers.com
if [ -f ".dev-debug" ]; then
exec 5>dev-debug.log
BASH_XTRACEFD="5"
set -x
fi
2016-10-21 22:30:26 +08:00
version="211016"
2013-08-11 19:03:31 +08:00
#### Variables ####
# Notification Alerts
2013-08-11 19:03:31 +08:00
# (on|off)
# Email
emailalert="off"
2013-08-11 19:03:31 +08:00
email="email@example.com"
2016-09-15 05:45:26 +08:00
#emailfrom="email@example.com"
2013-08-11 19:03:31 +08:00
# Pushbullet
# https://www.pushbullet.com/#settings
2016-05-22 06:29:03 +08:00
pushbulletalert="off"
pushbullettoken="accesstoken"
# Start Variables
updateonstart="off"
# Server Details
gamename="TeamSpeak 3"
servername="TeamSpeak 3 Server"
2013-08-11 19:03:31 +08:00
servicename="ts3-server"
# Directories
rootdir="$(dirname $(readlink -f "${BASH_SOURCE[0]}"))"
selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))"
lockselfname=".${servicename}.lock"
lgsmdir="${rootdir}/lgsm"
functionsdir="${lgsmdir}/functions"
2016-08-09 18:16:32 +08:00
libdir="${lgsmdir}/lib"
2016-09-15 06:07:28 +08:00
tmpdir="${lgsmdir}/tmp"
filesdir="${rootdir}/serverfiles"
systemdir="${filesdir}"
executabledir="${filesdir}"
executable="./ts3server_startscript.sh"
servercfg="${servicename}.ini"
2016-10-10 03:05:18 +08:00
servercfgdefault="ts3server.ini"
servercfgdir="${filesdir}"
servercfgfullpath="${servercfgdir}/${servercfg}"
backupdir="${rootdir}/backups"
2013-08-11 19:03:31 +08:00
# Logging
logdays="7"
gamelogdir="${filesdir}/logs"
scriptlogdir="${rootdir}/log/script"
scriptlog="${scriptlogdir}/${servicename}-script.log"
emaillog="${scriptlogdir}/${servicename}-email.log"
scriptlogdate="${scriptlogdir}/${servicename}-script-$(date '+%d-%m-%Y-%H-%M-%S').log"
2013-08-11 19:03:31 +08:00
# Github Branch Select
# Allows for the use of different function files
# from a different repo and/or branch.
githubuser="GameServerManagers"
githubrepo="LinuxGSM"
githubbranch="master"
2013-08-11 19:03:31 +08:00
##### Script #####
# Do not edit
2016-03-15 08:25:56 +08:00
# Fetches core_dl for file downloads
fn_fetch_core_dl(){
github_file_url_dir="lgsm/functions"
github_file_url_name="${functionfile}"
filedir="${functionsdir}"
filename="${github_file_url_name}"
githuburl="https://raw.githubusercontent.com/${githubuser}/${githubrepo}/${githubbranch}/${github_file_url_dir}/${github_file_url_name}"
# If the file is missing, then download
if [ ! -f "${filedir}/${filename}" ]; then
if [ ! -d "${filedir}" ]; then
2016-03-15 08:25:56 +08:00
mkdir -p "${filedir}"
fi
echo -e " fetching ${filename}...\c"
2016-03-15 08:25:56 +08:00
# Check curl exists and use available path
curlpaths="$(command -v curl 2>/dev/null) $(which curl >/dev/null 2>&1) /usr/bin/curl /bin/curl /usr/sbin/curl /sbin/curl)"
for curlcmd in ${curlpaths}
do
if [ -x "${curlcmd}" ]; then
break
fi
done
# If curl exists download file
if [ "$(basename ${curlcmd})" == "curl" ]; then
curlfetch=$(${curlcmd} -s --fail -o "${filedir}/${filename}" "${githuburl}" 2>&1)
if [ $? -ne 0 ]; then
echo -e "\e[0;31mFAIL\e[0m\n"
echo "${curlfetch}"
echo -e "${githuburl}\n"
exit 1
else
echo -e "\e[0;32mOK\e[0m"
fi
2016-03-15 08:25:56 +08:00
else
2015-12-13 05:55:08 +08:00
echo -e "\e[0;31mFAIL\e[0m\n"
echo "Curl is not installed!"
echo -e ""
2016-03-15 08:25:56 +08:00
exit 1
fi
2016-03-15 08:25:56 +08:00
chmod +x "${filedir}/${filename}"
fi
2016-03-15 08:25:56 +08:00
source "${filedir}/${filename}"
}
2016-03-15 08:25:56 +08:00
core_dl.sh(){
# Functions are defined in core_functions.sh.
functionfile="${FUNCNAME}"
fn_fetch_core_dl
2013-08-11 19:03:31 +08:00
}
2015-12-28 04:07:30 +08:00
core_functions.sh(){
# Functions are defined in core_functions.sh.
functionfile="${FUNCNAME}"
2016-03-15 08:25:56 +08:00
fn_fetch_core_dl
2013-08-11 19:03:31 +08:00
}
2016-03-15 08:25:56 +08:00
core_dl.sh
2015-12-28 04:07:30 +08:00
core_functions.sh
2013-08-11 19:03:31 +08:00
getopt=$1
2015-12-28 04:07:30 +08:00
core_getopt.sh