ut2k4server 2.9 KB

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