csczserver 3.8 KB

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