2013-08-11 19:03:31 +08:00
|
|
|
#!/bin/bash
|
|
|
|
# Teamspeak 3
|
|
|
|
# Server Management Script
|
|
|
|
# Author: Daniel Gibbs
|
2015-05-03 19:29:24 +08:00
|
|
|
# Website: http://gameservermanagers.com
|
2015-12-21 05:22:56 +08:00
|
|
|
if [ -f ".dev-debug" ]; then
|
|
|
|
exec 5>dev-debug.log
|
|
|
|
BASH_XTRACEFD="5"
|
|
|
|
set -x
|
|
|
|
fi
|
|
|
|
|
2015-12-25 18:18:06 +08:00
|
|
|
version="251215"
|
2015-05-03 19:29:24 +08:00
|
|
|
|
2013-08-11 19:03:31 +08:00
|
|
|
#### Variables ####
|
|
|
|
|
|
|
|
# Notification Email
|
|
|
|
# (on|off)
|
|
|
|
emailnotification="off"
|
|
|
|
email="email@example.com"
|
|
|
|
|
2015-05-10 03:49:00 +08:00
|
|
|
# Start Variables
|
2015-08-16 05:50:59 +08:00
|
|
|
updateonstart="off"
|
2015-05-10 03:49:00 +08:00
|
|
|
|
2013-11-18 04:07:40 +08:00
|
|
|
# Server Details
|
2013-10-04 07:27:34 +08:00
|
|
|
gamename="Teamspeak 3"
|
2013-08-11 19:03:31 +08:00
|
|
|
servername="Teamspeak 3 Server"
|
|
|
|
servicename="ts3-server"
|
|
|
|
|
2015-02-08 22:51:13 +08:00
|
|
|
# Directories
|
2015-12-13 03:55:57 +08:00
|
|
|
rootdir="$(dirname $(readlink -f "${BASH_SOURCE[0]}"))"
|
2015-12-21 01:05:29 +08:00
|
|
|
selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))"
|
2015-02-08 22:51:13 +08:00
|
|
|
lockselfname=".${servicename}.lock"
|
2013-10-04 07:27:34 +08:00
|
|
|
filesdir="${rootdir}/serverfiles"
|
2015-02-08 22:51:13 +08:00
|
|
|
systemdir="${filesdir}"
|
|
|
|
executabledir="${filesdir}"
|
|
|
|
executable="./ts3server_startscript.sh"
|
|
|
|
servercfg="${servicename}.ini"
|
2015-07-04 05:31:09 +08:00
|
|
|
servercfgdir="${filesdir}"
|
2015-02-08 22:51:13 +08:00
|
|
|
servercfgfullpath="${servercfgdir}/${servercfg}"
|
2015-12-25 17:29:42 +08:00
|
|
|
servercfgdefault="${servercfgdir}/lgsm-default.ini"
|
2015-02-08 22:51:13 +08:00
|
|
|
backupdir="${rootdir}/backups"
|
2013-08-11 19:03:31 +08:00
|
|
|
|
|
|
|
# Logging
|
|
|
|
logdays="7"
|
2013-10-04 07:27:34 +08:00
|
|
|
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
|
|
|
|
2015-12-13 03:55:57 +08:00
|
|
|
# Github Branch Select
|
|
|
|
# Allows for the use of different function files
|
|
|
|
# from a different repo and/or branch.
|
|
|
|
githubuser="dgibbs64"
|
|
|
|
githubrepo="linuxgsm"
|
|
|
|
githubbranch="master"
|
|
|
|
|
2013-08-11 19:03:31 +08:00
|
|
|
##### Script #####
|
|
|
|
# Do not edit
|
|
|
|
|
2015-12-13 03:55:57 +08:00
|
|
|
fn_getgithubfile(){
|
|
|
|
filename=$1
|
|
|
|
exec=$2
|
|
|
|
fileurl=${3:-$filename}
|
|
|
|
filepath="${rootdir}/${filename}"
|
|
|
|
filedir=$(dirname "${filepath}")
|
|
|
|
# If the function file is missing, then download
|
|
|
|
if [ ! -f "${filepath}" ]; then
|
|
|
|
if [ ! -d "${filedir}" ]; then
|
|
|
|
mkdir "${filedir}"
|
2015-02-08 22:51:13 +08:00
|
|
|
fi
|
2015-12-13 03:55:57 +08:00
|
|
|
githuburl="https://raw.githubusercontent.com/${githubuser}/${githubrepo}/${githubbranch}/${fileurl}"
|
|
|
|
echo -e " fetching ${filename}...\c"
|
2015-12-13 05:55:08 +08:00
|
|
|
if [ "$(command -v curl)" ]||[ "$(which curl >/dev/null 2>&1)" ]||[ -f "/usr/bin/curl" ]||[ -f "/bin/curl" ]; then
|
|
|
|
:
|
|
|
|
else
|
|
|
|
echo -e "\e[0;31mFAIL\e[0m\n"
|
2015-12-13 03:55:57 +08:00
|
|
|
echo "Curl is not installed!"
|
|
|
|
echo -e ""
|
2015-12-13 05:55:08 +08:00
|
|
|
exit
|
|
|
|
fi
|
|
|
|
curl=$(curl --fail -o "${filepath}" "${githuburl}" 2>&1)
|
2015-12-13 03:55:57 +08:00
|
|
|
if [ $? -ne 0 ]; then
|
|
|
|
echo -e "\e[0;31mFAIL\e[0m\n"
|
2015-12-21 01:05:29 +08:00
|
|
|
echo "${curl}"
|
2015-12-13 03:55:57 +08:00
|
|
|
echo -e "${githuburl}\n"
|
|
|
|
exit
|
|
|
|
else
|
|
|
|
echo -e "\e[0;32mOK\e[0m"
|
|
|
|
fi
|
|
|
|
if [ "${exec}" ]; then
|
|
|
|
chmod +x "${filepath}"
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
if [ "${exec}" ]; then
|
|
|
|
source "${filepath}"
|
2013-08-11 19:03:31 +08:00
|
|
|
fi
|
2015-12-13 03:55:57 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
fn_runfunction(){
|
|
|
|
fn_getgithubfile "functions/${functionfile}" 1
|
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.
|
2015-02-08 22:51:13 +08:00
|
|
|
functionfile="${FUNCNAME}"
|
|
|
|
fn_runfunction
|
2013-08-11 19:03:31 +08:00
|
|
|
}
|
|
|
|
|
2015-12-28 04:07:30 +08:00
|
|
|
core_functions.sh
|
2013-08-11 19:03:31 +08:00
|
|
|
|
2015-02-08 22:51:13 +08:00
|
|
|
getopt=$1
|
2015-12-28 04:07:30 +08:00
|
|
|
core_getopt.sh
|