ut2k4server 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135
  1. #!/bin/bash
  2. # Unreal Tournament 2004
  3. # Server Management Script
  4. # Author: Daniel Gibbs
  5. # Website: http://gameservermanagers.com
  6. if [ -f ".dev-debug" ]; then
  7. exec 5>dev-debug.log
  8. BASH_XTRACEFD="5"
  9. set -x
  10. fi
  11. version="150316"
  12. #### Variables ####
  13. # Notification Email
  14. # (on|off)
  15. emailnotification="off"
  16. email="email@example.com"
  17. # Start Variables
  18. defaultmap="DM-Rankin"
  19. ip="0.0.0.0"
  20. fn_parms(){
  21. parms="server ${defaultmap}?game=XGame.xDeathMatch -nohomedir ini=${servercfg} log=${gamelog}"
  22. }
  23. # Server Details
  24. servicename="ut2k4-server"
  25. gamename="Unreal Tournament 2004"
  26. engine="unreal2"
  27. # Directories
  28. rootdir="$(dirname $(readlink -f "${BASH_SOURCE[0]}"))"
  29. selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))"
  30. lockselfname=".${servicename}.lock"
  31. lgsmdir="${rootdir}/lgsm"
  32. functionsdir="${lgsmdir}/functions"
  33. filesdir="${rootdir}/serverfiles"
  34. systemdir="${filesdir}/System"
  35. executabledir="${systemdir}"
  36. executable="./ucc-bin"
  37. servercfg="${servicename}.ini"
  38. servercfgdir="${systemdir}"
  39. servercfgfullpath="${servercfgdir}/${servercfg}"
  40. servercfgdefault="${servercfgdir}/UT2004.ini"
  41. compressedmapsdir="${rootdir}/Maps-Compressed"
  42. backupdir="${rootdir}/backups"
  43. # Logging
  44. logdays="7"
  45. gamelogdir="${rootdir}/log/server"
  46. scriptlogdir="${rootdir}/log/script"
  47. consolelogdir="${rootdir}/log/console"
  48. gamelog="${gamelogdir}/${servicename}-game.log"
  49. scriptlog="${scriptlogdir}/${servicename}-script.log"
  50. consolelog="${consolelogdir}/${servicename}-console.log"
  51. emaillog="${scriptlogdir}/${servicename}-email.log"
  52. gamelogdate="${gamelogdir}/${servicename}-game-$(date '+%d-%m-%Y-%H-%M-%S').log"
  53. scriptlogdate="${scriptlogdir}/${servicename}-script-$(date '+%d-%m-%Y-%H-%M-%S').log"
  54. consolelogdate="${consolelogdir}/${servicename}-console-$(date '+%d-%m-%Y-%H-%M-%S').log"
  55. # Github Branch Select
  56. # Allows for the use of different function files
  57. # from a different repo and/or branch.
  58. githubuser="dgibbs64"
  59. githubrepo="linuxgsm"
  60. githubbranch="master"
  61. ##### Script #####
  62. # Do not edit
  63. # Fetches core_dl for file downloads
  64. fn_fetch_core_dl(){
  65. github_file_url_dir="lgsm/functions"
  66. github_file_url_name="${functionfile}"
  67. filedir="${functionsdir}"
  68. filename="${github_file_url_name}"
  69. githuburl="https://raw.githubusercontent.com/${githubuser}/${githubrepo}/${githubbranch}/${github_file_url_dir}/${github_file_url_name}"
  70. # If the file is missing, then download
  71. if [ ! -f "${filedir}/${filename}" ]; then
  72. if [ ! -d "${filedir}" ]; then
  73. mkdir -p "${filedir}"
  74. fi
  75. echo -e " fetching ${filename}...\c"
  76. # Check curl exists and use available path
  77. curlpaths="$(command -v curl 2>/dev/null) $(which curl >/dev/null 2>&1) /usr/bin/curl /bin/curl /usr/sbin/curl /sbin/curl)"
  78. for curlcmd in ${curlpaths}
  79. do
  80. if [ -x "${curlcmd}" ]; then
  81. break
  82. fi
  83. done
  84. # If curl exists download file
  85. if [ "$(basename ${curlcmd})" == "curl" ]; then
  86. curlfetch=$(${curlcmd} -s --fail -o "${filedir}/${filename}" "${githuburl}" 2>&1)
  87. if [ $? -ne 0 ]; then
  88. echo -e "\e[0;31mFAIL\e[0m\n"
  89. echo "${curlfetch}"
  90. echo -e "${githuburl}\n"
  91. exit 1
  92. else
  93. echo -e "\e[0;32mOK\e[0m"
  94. fi
  95. else
  96. echo -e "\e[0;31mFAIL\e[0m\n"
  97. echo "Curl is not installed!"
  98. echo -e ""
  99. exit 1
  100. fi
  101. chmod +x "${filedir}/${filename}"
  102. fi
  103. source "${filedir}/${filename}"
  104. }
  105. core_dl.sh(){
  106. # Functions are defined in core_functions.sh.
  107. functionfile="${FUNCNAME}"
  108. fn_fetch_core_dl
  109. }
  110. core_functions.sh(){
  111. # Functions are defined in core_functions.sh.
  112. functionfile="${FUNCNAME}"
  113. fn_fetch_core_dl
  114. }
  115. core_dl.sh
  116. core_functions.sh
  117. getopt=$1
  118. core_getopt.sh