ut99server 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136
  1. #!/bin/bash
  2. # Unreal Tournament 99
  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-Deck16]["
  19. ip="0.0.0.0"
  20. fn_parms(){
  21. parms="server ${defaultmap}.unr ini=${servercfgfullpath}"
  22. }
  23. #### Advanced Variables ####
  24. # Github Branch Select
  25. # Allows for the use of different function files
  26. # from a different repo and/or branch.
  27. githubuser="dgibbs64"
  28. githubrepo="linuxgsm"
  29. githubbranch="master"
  30. # Server Details
  31. servicename="ut99-server"
  32. gamename="Unreal Tournament 99"
  33. engine="unreal"
  34. # Directories
  35. rootdir="$(dirname $(readlink -f "${BASH_SOURCE[0]}"))"
  36. selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))"
  37. lockselfname=".${servicename}.lock"
  38. lgsmdir="${rootdir}/lgsm"
  39. functionsdir="${lgsmdir}/functions"
  40. filesdir="${rootdir}/serverfiles"
  41. systemdir="${filesdir}/System"
  42. executabledir="${systemdir}"
  43. executable="./ucc-bin"
  44. servercfg="${servicename}.ini"
  45. servercfgdir="${systemdir}"
  46. servercfgfullpath="${servercfgdir}/${servercfg}"
  47. servercfgdefault="${servercfgdir}/Default.ini"
  48. compressedmapsdir="${rootdir}/Maps-Compressed"
  49. backupdir="${rootdir}/backups"
  50. # Logging
  51. logdays="7"
  52. gamelogdir="${systemdir}/Logs/"
  53. scriptlogdir="${rootdir}/log/script"
  54. consolelogdir="${rootdir}/log/console"
  55. consolelogging="on"
  56. scriptlog="${scriptlogdir}/${servicename}-script.log"
  57. consolelog="${consolelogdir}/${servicename}-console.log"
  58. emaillog="${scriptlogdir}/${servicename}-email.log"
  59. scriptlogdate="${scriptlogdir}/${servicename}-script-$(date '+%d-%m-%Y-%H-%M-%S').log"
  60. consolelogdate="${consolelogdir}/${servicename}-console-$(date '+%d-%m-%Y-%H-%M-%S').log"
  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