ut99server 5.0 KB

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