|
| 1 | +#!/bin/bash |
| 2 | +# Project: Game Server Managers - LinuxGSM |
| 3 | +# Author: Daniel Gibbs |
| 4 | +# License: MIT License, Copyright (c) 2017 Daniel Gibbs |
| 5 | +# Purpose: Tower Unite | Server Management Script |
| 6 | +# Contributors: https://github.com/GameServerManagers/LinuxGSM/graphs/contributors |
| 7 | +# Documentation: https://github.com/GameServerManagers/LinuxGSM/wiki |
| 8 | +# Website: https://gameservermanagers.com |
| 9 | + |
| 10 | +# Debugging |
| 11 | +if [ -f ".dev-debug" ]; then |
| 12 | + exec 5>dev-debug.log |
| 13 | + BASH_XTRACEFD="5" |
| 14 | + set -x |
| 15 | +fi |
| 16 | + |
| 17 | +version="170128" |
| 18 | + |
| 19 | +########################## |
| 20 | +######## Settings ######## |
| 21 | +########################## |
| 22 | + |
| 23 | +#### Server Settings #### |
| 24 | + |
| 25 | +## Server Start Settings | https://github.com/GameServerManagers/LinuxGSM/wiki/Start-Parameters |
| 26 | +port="7777" |
| 27 | +queryport="27015" |
| 28 | +ip="0.0.0.0" |
| 29 | + |
| 30 | +## Server Start Command | https://github.com/GameServerManagers/LinuxGSM/wiki/Start-Parameters#additional-parameters |
| 31 | +fn_parms(){ |
| 32 | +parms="-log -MultiHome=${ip} -Port=${port} -QueryPort=${queryport} -TowerServerINI=${servicename}.ini" |
| 33 | +} |
| 34 | + |
| 35 | +#### LinuxGSM Settings #### |
| 36 | + |
| 37 | +## Notification Alerts |
| 38 | +# (on|off) |
| 39 | +# Email Alerts | https://github.com/GameServerManagers/LinuxGSM/wiki/Email |
| 40 | +emailalert="off" |
| 41 | + |
| 42 | +emailfrom="" |
| 43 | + |
| 44 | +# Pushbullet Alerts | https://github.com/GameServerManagers/LinuxGSM/wiki/Pushbullet |
| 45 | +pushbulletalert="off" |
| 46 | +pushbullettoken="accesstoken" |
| 47 | +channeltag="" |
| 48 | + |
| 49 | +## Updating | https://github.com/GameServerManagers/LinuxGSM/wiki/Update |
| 50 | +updateonstart="off" |
| 51 | + |
| 52 | +## Backup | https://github.com/GameServerManagers/LinuxGSM/wiki/Backup |
| 53 | +maxbackups="4" |
| 54 | +maxbackupdays="30" |
| 55 | +stoponbackup="on" |
| 56 | + |
| 57 | +## Logging | https://github.com/GameServerManagers/LinuxGSM/wiki/Logging |
| 58 | +consolelogging="on" |
| 59 | +logdays="7" |
| 60 | + |
| 61 | +#### LinuxGSM Advanced Settings #### |
| 62 | + |
| 63 | +## SteamCMD Settings |
| 64 | +# Server appid |
| 65 | +appid="439660" |
| 66 | +# Steam App Branch Select |
| 67 | +# Allows to opt into the various Steam app branches. Default branch is "". |
| 68 | +# Example: "-beta latest_experimental" |
| 69 | +branch="" |
| 70 | + |
| 71 | +## Github Branch Select |
| 72 | +# Allows for the use of different function files |
| 73 | +# from a different repo and/or branch. |
| 74 | +githubuser="GameServerManagers" |
| 75 | +githubrepo="LinuxGSM" |
| 76 | +githubbranch="master" |
| 77 | + |
| 78 | +## LinuxGSM Server Details |
| 79 | +# Do not edit |
| 80 | +gamename="Tower Unite" |
| 81 | +engine="unreal4" |
| 82 | + |
| 83 | +## Service Name | https://github.com/GameServerManagers/LinuxGSM/wiki/Multiple-Servers |
| 84 | +servicename="tu-server" |
| 85 | + |
| 86 | +#### Directories #### |
| 87 | +# Edit with care |
| 88 | + |
| 89 | +## Work Directories |
| 90 | +rootdir="$(dirname $(readlink -f "${BASH_SOURCE[0]}"))" |
| 91 | +selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))" |
| 92 | +lockselfname=".${servicename}.lock" |
| 93 | +lgsmdir="${rootdir}/lgsm" |
| 94 | +functionsdir="${lgsmdir}/functions" |
| 95 | +libdir="${lgsmdir}/lib" |
| 96 | +tmpdir="${lgsmdir}/tmp" |
| 97 | +filesdir="${rootdir}/serverfiles" |
| 98 | + |
| 99 | +## Server Specific Directories |
| 100 | +systemdir="${filesdir}/Tower" |
| 101 | +executabledir="${systemdir}/Binaries/Linux" |
| 102 | +executable="./TowerServer-Linux-Shipping" |
| 103 | +servercfgdir="${systemdir}/Binaries/Linux" |
| 104 | +servercfg="${servicename}.ini" |
| 105 | +servercfgfullpath="${servercfgdir}/${servercfg}" |
| 106 | +servercfgdefault="TowerServer.ini" |
| 107 | + |
| 108 | +## Backup Directory |
| 109 | +backupdir="${rootdir}/backups" |
| 110 | + |
| 111 | +## Logging Directories |
| 112 | +gamelogdir="${systemdir}/Saved/Logs" |
| 113 | +scriptlogdir="${rootdir}/log/script" |
| 114 | +consolelogdir="${rootdir}/log/console" |
| 115 | +scriptlog="${scriptlogdir}/${servicename}-script.log" |
| 116 | +consolelog="${consolelogdir}/${servicename}-console.log" |
| 117 | +emaillog="${scriptlogdir}/${servicename}-email.log" |
| 118 | + |
| 119 | +## Logs Naming |
| 120 | +scriptlogdate="${scriptlogdir}/${servicename}-script-$(date '+%Y-%m-%d-%H:%M:%S').log" |
| 121 | +consolelogdate="${consolelogdir}/${servicename}-console-$(date '+%Y-%m-%d-%H:%M:%S').log" |
| 122 | + |
| 123 | +######################## |
| 124 | +######## Script ######## |
| 125 | +###### Do not edit ##### |
| 126 | +######################## |
| 127 | + |
| 128 | +# Fetches core_dl for file downloads |
| 129 | +fn_fetch_core_dl(){ |
| 130 | +github_file_url_dir="lgsm/functions" |
| 131 | +github_file_url_name="${functionfile}" |
| 132 | +filedir="${functionsdir}" |
| 133 | +filename="${github_file_url_name}" |
| 134 | +githuburl="https://raw.githubusercontent.com/${githubuser}/${githubrepo}/${githubbranch}/${github_file_url_dir}/${github_file_url_name}" |
| 135 | +# If the file is missing, then download |
| 136 | +if [ ! -f "${filedir}/${filename}" ]; then |
| 137 | + if [ ! -d "${filedir}" ]; then |
| 138 | + mkdir -p "${filedir}" |
| 139 | + fi |
| 140 | + echo -e " fetching ${filename}...\c" |
| 141 | + # Check curl exists and use available path |
| 142 | + curlpaths="$(command -v curl 2>/dev/null) $(which curl >/dev/null 2>&1) /usr/bin/curl /bin/curl /usr/sbin/curl /sbin/curl)" |
| 143 | + for curlcmd in ${curlpaths} |
| 144 | + do |
| 145 | + if [ -x "${curlcmd}" ]; then |
| 146 | + break |
| 147 | + fi |
| 148 | + done |
| 149 | + # If curl exists download file |
| 150 | + if [ "$(basename ${curlcmd})" == "curl" ]; then |
| 151 | + curlfetch=$(${curlcmd} -s --fail -o "${filedir}/${filename}" "${githuburl}" 2>&1) |
| 152 | + if [ $? -ne 0 ]; then |
| 153 | + echo -e "\e[0;31mFAIL\e[0m\n" |
| 154 | + echo "${curlfetch}" |
| 155 | + echo -e "${githuburl}\n" |
| 156 | + exit 1 |
| 157 | + else |
| 158 | + echo -e "\e[0;32mOK\e[0m" |
| 159 | + fi |
| 160 | + else |
| 161 | + echo -e "\e[0;31mFAIL\e[0m\n" |
| 162 | + echo "Curl is not installed!" |
| 163 | + echo -e "" |
| 164 | + exit 1 |
| 165 | + fi |
| 166 | + chmod +x "${filedir}/${filename}" |
| 167 | +fi |
| 168 | +source "${filedir}/${filename}" |
| 169 | +} |
| 170 | + |
| 171 | +core_dl.sh(){ |
| 172 | +# Functions are defined in core_functions.sh. |
| 173 | +functionfile="${FUNCNAME}" |
| 174 | +fn_fetch_core_dl |
| 175 | +} |
| 176 | + |
| 177 | +core_functions.sh(){ |
| 178 | +# Functions are defined in core_functions.sh. |
| 179 | +functionfile="${FUNCNAME}" |
| 180 | +fn_fetch_core_dl |
| 181 | +} |
| 182 | + |
| 183 | +# Prevent from running this script as root. |
| 184 | +if [ "$(whoami)" = "root" ]; then |
| 185 | + if [ ! -f "${functionsdir}/core_functions.sh" ]||[ ! -f "${functionsdir}/check_root.sh" ]||[ ! -f "${functionsdir}/core_messages.sh" ]||[ ! -f "${functionsdir}/core_exit.sh" ]; then |
| 186 | + echo "[ FAIL ] Do NOT run this script as root!" |
| 187 | + exit 1 |
| 188 | + else |
| 189 | + core_functions.sh |
| 190 | + check_root.sh |
| 191 | + fi |
| 192 | +fi |
| 193 | + |
| 194 | +core_dl.sh |
| 195 | +core_functions.sh |
| 196 | +getopt=$1 |
| 197 | +core_getopt.sh |
0 commit comments