utserver 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192
  1. #!/bin/bash
  2. # Unreal Tournament
  3. # Project: Game Server Managers - LinuxGSM
  4. # Author: Daniel Gibbs
  5. # License: MIT License, Copyright (c) 2016 Daniel Gibbs
  6. # Purpose: Unreal Tournament | 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. # Debugging
  11. if [ -f ".dev-debug" ]; then
  12. exec 5>dev-debug.log
  13. BASH_XTRACEFD="5"
  14. set -x
  15. fi
  16. version="161113"
  17. ##########################
  18. ######## Settings ########
  19. ##########################
  20. #### Server Settings ####
  21. ## Server Start Settings | https://github.com/GameServerManagers/LinuxGSM/wiki/Start-Parameters
  22. # For CTF: defaultmap="CTF-Face" gametype="CTF"
  23. defaultmap="DM-Underland"
  24. gametype="DM"
  25. timelimit="10"
  26. ip="0.0.0.0"
  27. port="7777"
  28. ## Server Start Command | https://github.com/GameServerManagers/LinuxGSM/wiki/Start-Parameters#additional-parameters
  29. # Edit with care
  30. fn_parms(){
  31. parms="UnrealTournament ${defaultmap}?Game=${gametype}?TimeLimit=${timelimit} -port=${port}"
  32. }
  33. #### LinuxGSM Settings ####
  34. ## Notification Alerts
  35. # (on|off)
  36. # Email Alerts | https://github.com/GameServerManagers/LinuxGSM/wiki/Email
  37. emailalert="off"
  38. email="email@example.com"
  39. emailfrom=""
  40. # Pushbullet Alerts | https://github.com/GameServerManagers/LinuxGSM/wiki/Pushbullet
  41. pushbulletalert="off"
  42. pushbullettoken="accesstoken"
  43. # Pushbullet Channel | Do not set unless the channel exists on the
  44. # account associated with the access token. Set without using the '#'
  45. # E.g: "thisisachanneltag" would push to #thisisachanneltag
  46. channeltag=""
  47. ## Backup | https://github.com/GameServerManagers/LinuxGSM/wiki/Backup
  48. maxbackups="4"
  49. maxbackupdays="30"
  50. stoponbackup="on"
  51. ## Logging | https://github.com/GameServerManagers/LinuxGSM/wiki/Logging
  52. consolelogging="on"
  53. logdays="7"
  54. #### LinuxGSM Advanced Settings ####
  55. ## Github Branch Select
  56. # Allows for the use of different function files
  57. # from a different repo and/or branch.
  58. githubuser="GameServerManagers"
  59. githubrepo="LinuxGSM"
  60. githubbranch="master"
  61. ## LinuxGSM Server Details
  62. # Do not edit
  63. gamename="Unreal Tournament"
  64. engine="unreal4"
  65. ## Service Name | https://github.com/GameServerManagers/LinuxGSM/wiki/Multiple-Servers
  66. servicename="ut-server"
  67. #### Directories ####
  68. # Edit with care
  69. ## Work Directories
  70. rootdir="$(dirname $(readlink -f "${BASH_SOURCE[0]}"))"
  71. selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))"
  72. lockselfname=".${servicename}.lock"
  73. lgsmdir="${rootdir}/lgsm"
  74. functionsdir="${lgsmdir}/functions"
  75. libdir="${lgsmdir}/lib"
  76. tmpdir="${lgsmdir}/tmp"
  77. filesdir="${rootdir}/serverfiles"
  78. ## Server Specific Directories
  79. systemdir="${filesdir}/LinuxServer"
  80. executabledir="${systemdir}/Engine/Binaries/Linux"
  81. executable="./UE4Server-Linux-Shipping"
  82. servercfg="Game.ini"
  83. servercfgdir="${systemdir}/UnrealTournament/Saved/Config/LinuxServer"
  84. servercfgfullpath="${servercfgdir}/${servercfg}"
  85. ## Backup Directory
  86. backupdir="${rootdir}/backups"
  87. ## Logging Directories
  88. gamelogdir="${filesdir}/Logs"
  89. scriptlogdir="${rootdir}/log/script"
  90. consolelogdir="${rootdir}/log/console"
  91. scriptlog="${scriptlogdir}/${servicename}-script.log"
  92. consolelog="${consolelogdir}/${servicename}-console.log"
  93. emaillog="${scriptlogdir}/${servicename}-email.log"
  94. ## Logs Naming
  95. scriptlogdate="${scriptlogdir}/${servicename}-script-$(date '+%Y-%m-%d-%H:%M:%S').log"
  96. consolelogdate="${consolelogdir}/${servicename}-console-$(date '+%Y-%m-%d-%H:%M:%S').log"
  97. ########################
  98. ######## Script ########
  99. ###### Do not edit #####
  100. ########################
  101. # Fetches core_dl for file downloads
  102. fn_fetch_core_dl(){
  103. github_file_url_dir="lgsm/functions"
  104. github_file_url_name="${functionfile}"
  105. filedir="${functionsdir}"
  106. filename="${github_file_url_name}"
  107. githuburl="https://raw.githubusercontent.com/${githubuser}/${githubrepo}/${githubbranch}/${github_file_url_dir}/${github_file_url_name}"
  108. # If the file is missing, then download
  109. if [ ! -f "${filedir}/${filename}" ]; then
  110. if [ ! -d "${filedir}" ]; then
  111. mkdir -p "${filedir}"
  112. fi
  113. echo -e " fetching ${filename}...\c"
  114. # Check curl exists and use available path
  115. curlpaths="$(command -v curl 2>/dev/null) $(which curl >/dev/null 2>&1) /usr/bin/curl /bin/curl /usr/sbin/curl /sbin/curl)"
  116. for curlcmd in ${curlpaths}
  117. do
  118. if [ -x "${curlcmd}" ]; then
  119. break
  120. fi
  121. done
  122. # If curl exists download file
  123. if [ "$(basename ${curlcmd})" == "curl" ]; then
  124. curlfetch=$(${curlcmd} -s --fail -o "${filedir}/${filename}" "${githuburl}" 2>&1)
  125. if [ $? -ne 0 ]; then
  126. echo -e "\e[0;31mFAIL\e[0m\n"
  127. echo "${curlfetch}"
  128. echo -e "${githuburl}\n"
  129. exit 1
  130. else
  131. echo -e "\e[0;32mOK\e[0m"
  132. fi
  133. else
  134. echo -e "\e[0;31mFAIL\e[0m\n"
  135. echo "Curl is not installed!"
  136. echo -e ""
  137. exit 1
  138. fi
  139. chmod +x "${filedir}/${filename}"
  140. fi
  141. source "${filedir}/${filename}"
  142. }
  143. core_dl.sh(){
  144. # Functions are defined in core_functions.sh.
  145. functionfile="${FUNCNAME}"
  146. fn_fetch_core_dl
  147. }
  148. core_functions.sh(){
  149. # Functions are defined in core_functions.sh.
  150. functionfile="${FUNCNAME}"
  151. fn_fetch_core_dl
  152. }
  153. # Prevent from running this script as root.
  154. if [ "$(whoami)" = "root" ]; then
  155. if [ ! -f "${functionsdir}/core_functions.sh" ]||[ ! -f "${functionsdir}/check_root.sh" ]||[ ! -f "${functionsdir}/core_messages.sh" ]||[ ! -f "${functionsdir}/core_exit.sh" ]; then
  156. echo "[ FAIL ] Do NOT run this script as root!"
  157. exit 1
  158. else
  159. core_functions.sh
  160. check_root.sh
  161. fi
  162. fi
  163. core_dl.sh
  164. core_functions.sh
  165. getopt=$1
  166. core_getopt.sh