Advertisement
Guest User

Untitled

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