q2server 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145
  1. #!/bin/bash
  2. # Quake 2
  3. # Server Management Script
  4. # Author: Daniel Gibbs
  5. # Website: https://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="210516"
  12. #### Variables ####
  13. # Notification Alerts
  14. # (on|off)
  15. # Email
  16. emailalert="off"
  17. email="email@example.com"
  18. # Pushbullet
  19. # https://www.pushbullet.com/#settings
  20. pushbulletalert="off"
  21. pushbullettoken="accesstoken"
  22. # Start Variables
  23. defaultmap="q2dm1"
  24. ip="0.0.0.0"
  25. port="27910"
  26. fn_parms(){
  27. parms="+set dedicated 1 +set ip ${ip} +set port ${port} +exec ${servercfg} +set deathmatch 1 +map ${defaultmap}"
  28. }
  29. #### Advanced Variables ####
  30. # Github Branch Select
  31. # Allows for the use of different function files
  32. # from a different repo and/or branch.
  33. githubuser="GameServerManagers"
  34. githubrepo="LinuxGSM"
  35. githubbranch="master"
  36. # Server Details
  37. servicename="quake2server"
  38. gamename="Quake 2"
  39. engine="idtech2"
  40. # Directories
  41. rootdir="$(dirname $(readlink -f "${BASH_SOURCE[0]}"))"
  42. selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))"
  43. lockselfname=".${servicename}.lock"
  44. lgsmdir="${rootdir}/lgsm"
  45. functionsdir="${lgsmdir}/functions"
  46. libdir="${lgsmdir}/lib"
  47. tmpdir="${lgsmdir}/tmp"
  48. filesdir="${rootdir}/serverfiles"
  49. systemdir="${filesdir}/baseq2"
  50. executabledir="${filesdir}"
  51. executable="./quake2"
  52. servercfg="${servicename}.cfg"
  53. servercfgdefault="server.cfg"
  54. servercfgdir="${systemdir}"
  55. servercfgfullpath="${servercfgdir}/${servercfg}"
  56. backupdir="${rootdir}/backups"
  57. # Logging
  58. logdays="7"
  59. gamelogdir="${filesdir}/Logs"
  60. scriptlogdir="${rootdir}/log/script"
  61. consolelogdir="${rootdir}/log/console"
  62. consolelogging="on"
  63. scriptlog="${scriptlogdir}/${servicename}-script.log"
  64. consolelog="${consolelogdir}/${servicename}-console.log"
  65. emaillog="${scriptlogdir}/${servicename}-email.log"
  66. scriptlogdate="${scriptlogdir}/${servicename}-script-$(date '+%d-%m-%Y-%H-%M-%S').log"
  67. consolelogdate="${consolelogdir}/${servicename}-console-$(date '+%d-%m-%Y-%H-%M-%S').log"
  68. ##### Script #####
  69. # Do not edit
  70. # Fetches core_dl for file downloads
  71. fn_fetch_core_dl(){
  72. github_file_url_dir="lgsm/functions"
  73. github_file_url_name="${functionfile}"
  74. filedir="${functionsdir}"
  75. filename="${github_file_url_name}"
  76. githuburl="https://raw.githubusercontent.com/${githubuser}/${githubrepo}/${githubbranch}/${github_file_url_dir}/${github_file_url_name}"
  77. # If the file is missing, then download
  78. if [ ! -f "${filedir}/${filename}" ]; then
  79. if [ ! -d "${filedir}" ]; then
  80. mkdir -p "${filedir}"
  81. fi
  82. echo -e " fetching ${filename}...\c"
  83. # Check curl exists and use available path
  84. curlpaths="$(command -v curl 2>/dev/null) $(which curl >/dev/null 2>&1) /usr/bin/curl /bin/curl /usr/sbin/curl /sbin/curl)"
  85. for curlcmd in ${curlpaths}
  86. do
  87. if [ -x "${curlcmd}" ]; then
  88. break
  89. fi
  90. done
  91. # If curl exists download file
  92. if [ "$(basename ${curlcmd})" == "curl" ]; then
  93. curlfetch=$(${curlcmd} -s --fail -o "${filedir}/${filename}" "${githuburl}" 2>&1)
  94. if [ $? -ne 0 ]; then
  95. echo -e "\e[0;31mFAIL\e[0m\n"
  96. echo "${curlfetch}"
  97. echo -e "${githuburl}\n"
  98. exit 1
  99. else
  100. echo -e "\e[0;32mOK\e[0m"
  101. fi
  102. else
  103. echo -e "\e[0;31mFAIL\e[0m\n"
  104. echo "Curl is not installed!"
  105. echo -e ""
  106. exit 1
  107. fi
  108. chmod +x "${filedir}/${filename}"
  109. fi
  110. source "${filedir}/${filename}"
  111. }
  112. core_dl.sh(){
  113. # Functions are defined in core_functions.sh.
  114. functionfile="${FUNCNAME}"
  115. fn_fetch_core_dl
  116. }
  117. core_functions.sh(){
  118. # Functions are defined in core_functions.sh.
  119. functionfile="${FUNCNAME}"
  120. fn_fetch_core_dl
  121. }
  122. core_dl.sh
  123. core_functions.sh
  124. getopt=$1
  125. core_getopt.sh