qlserver 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141
  1. #!/bin/bash
  2. # Quake Live
  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="271215"
  12. #### Variables ####
  13. arch="x64"
  14. # Notification Email
  15. # (on|off)
  16. emailnotification="off"
  17. email="email@example.com"
  18. # Steam login
  19. steamuser="anonymous"
  20. steampass=""
  21. # Start Variables
  22. gameport="27960"
  23. rconport="28960"
  24. rcon_password='ch@ng3me'
  25. stats_password='ch@ng3me'
  26. mappool='mappool.txt'
  27. ip="0.0.0.0"
  28. updateonstart="off"
  29. # Install/Config Guide : https://steamcommunity.com/sharedfiles/filedetails/?id=542966946
  30. # Console Commands : http://www.regurge.at/ql/
  31. fn_parms(){
  32. parms="+set net_strict 1 +set net_ip 0.0.0.0 +set net_port ${gameport} +set fs_homepath ${filesdir}/${gameport} +set zmq_rcon_enable 1 +set zmq_rcon_port ${rconport} +set zmq_rcon_password ${rcon_password} +set zmq_stats_enable 1 +set zmq_stats_password ${stats_password} +set zmq_stats_port ${gameport} +set sv_mapPoolFile ${mappool} +exec ${servercfg} "
  33. }
  34. #### Advanced Variables ####
  35. # Github Branch Select
  36. # Allows for the use of different function files
  37. # from a different repo and/or branch.
  38. githubuser="dgibbs64"
  39. githubrepo="linuxgsm"
  40. githubbranch="master"
  41. # Steam
  42. appid="349090"
  43. # Server Details
  44. servicename="ql-server"
  45. gamename="Quake Live"
  46. engine="idtech3"
  47. # Directories
  48. rootdir="$(dirname $(readlink -f "${BASH_SOURCE[0]}"))"
  49. selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))"
  50. lockselfname=".${servicename}.lock"
  51. filesdir="${rootdir}/serverfiles"
  52. systemdir="${filesdir}"
  53. executabledir="${filesdir}"
  54. executable=$([ "$arch" == 'x64' ] && echo "./run_server_x64.sh" || echo "./run_server_x86.sh")
  55. servercfg="${servicename}.cfg"
  56. servercfgdir="${filesdir}/baseq3"
  57. servercfgfullpath="${servercfgdir}/${servercfg}"
  58. servercfgdefault="${servercfgdir}/lgsm-default.cfg"
  59. backupdir="${rootdir}/backups"
  60. # Logging
  61. logdays="7"
  62. gamelogdir="${rootdir}/log/server"
  63. scriptlogdir="${rootdir}/log/script"
  64. consolelogdir="${rootdir}/log/console"
  65. gamelog="${gamelogdir}/${servicename}-game.log"
  66. scriptlog="${scriptlogdir}/${servicename}-script.log"
  67. consolelog="${consolelogdir}/${servicename}-console.log"
  68. emaillog="${scriptlogdir}/${servicename}-email.log"
  69. scriptlogdate="${scriptlogdir}/${servicename}-script-$(date '+%d-%m-%Y-%H-%M-%S').log"
  70. consolelogdate="${consolelogdir}/${servicename}-console-$(date '+%d-%m-%Y-%H-%M-%S').log"
  71. ##### Script #####
  72. # Do not edit
  73. fn_getgithubfile(){
  74. filename=$1
  75. exec=$2
  76. fileurl=${3:-$filename}
  77. filepath="${rootdir}/${filename}"
  78. filedir=$(dirname "${filepath}")
  79. # If the function file is missing, then download
  80. if [ ! -f "${filepath}" ]; then
  81. if [ ! -d "${filedir}" ]; then
  82. mkdir "${filedir}"
  83. fi
  84. githuburl="https://raw.githubusercontent.com/${githubuser}/${githubrepo}/${githubbranch}/${fileurl}"
  85. echo -e " fetching ${filename}...\c"
  86. if [ "$(command -v curl)" ]||[ "$(which curl >/dev/null 2>&1)" ]||[ -f "/usr/bin/curl" ]||[ -f "/bin/curl" ]; then
  87. :
  88. else
  89. echo -e "\e[0;31mFAIL\e[0m\n"
  90. echo "Curl is not installed!"
  91. echo -e ""
  92. exit
  93. fi
  94. curl=$(curl --fail -o "${filepath}" "${githuburl}" 2>&1)
  95. if [ $? -ne 0 ]; then
  96. echo -e "\e[0;31mFAIL\e[0m\n"
  97. echo "${curl}"
  98. echo -e "${githuburl}\n"
  99. exit
  100. else
  101. echo -e "\e[0;32mOK\e[0m"
  102. fi
  103. if [ "${exec}" ]; then
  104. chmod +x "${filepath}"
  105. fi
  106. fi
  107. if [ "${exec}" ]; then
  108. source "${filepath}"
  109. fi
  110. }
  111. fn_runfunction(){
  112. fn_getgithubfile "functions/${functionfile}" 1
  113. }
  114. core_functions.sh(){
  115. # Functions are defined in core_functions.sh.
  116. functionfile="${FUNCNAME}"
  117. fn_runfunction
  118. }
  119. core_functions.sh
  120. getopt=$1
  121. core_getopt.sh