ut2k4server 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120
  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. :
  71. else
  72. echo -e "\e[0;31mFAIL\e[0m\n"
  73. echo "Curl is not installed!"
  74. echo -e ""
  75. exit
  76. fi
  77. curl=$(curl --fail -o "${filepath}" "${githuburl}" 2>&1)
  78. if [ $? -ne 0 ]; then
  79. echo -e "\e[0;31mFAIL\e[0m\n"
  80. echo " ${curl}"|grep "curl:"
  81. echo -e "${githuburl}\n"
  82. exit
  83. else
  84. echo -e "\e[0;32mOK\e[0m"
  85. fi
  86. if [ "${exec}" ]; then
  87. chmod +x "${filepath}"
  88. fi
  89. fi
  90. if [ "${exec}" ]; then
  91. source "${filepath}"
  92. fi
  93. }
  94. fn_runfunction(){
  95. fn_getgithubfile "functions/${functionfile}" 1
  96. }
  97. fn_functions(){
  98. # Functions are defined in fn_functions.
  99. functionfile="${FUNCNAME}"
  100. fn_runfunction
  101. }
  102. fn_functions
  103. getopt=$1
  104. fn_getopt