gesserver 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140
  1. #!/bin/bash
  2. # GoldenEye: Source
  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. export MALLOC_CHECK_=0
  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. defaultmap="ge_archives"
  23. maxplayers="16"
  24. port="27015"
  25. sourcetvport="27020"
  26. clientport="27005"
  27. ip="0.0.0.0"
  28. updateonstart="off"
  29. # https://developer.valvesoftware.com/wiki/Command_Line_Options#Source_Dedicated_Server
  30. fn_parms(){
  31. parms="-game gesource -strictportbind -ip ${ip} -port ${port} +clientport ${clientport} +tv_port ${sourcetvport} +map ${defaultmap} +servercfgfile ${servercfg} -maxplayers ${maxplayers}"
  32. }
  33. #### Advanced Variables ####
  34. # Github Branch Select
  35. # Allows for the use of different function files
  36. # from a different repo and/or branch.
  37. githubuser="dgibbs64"
  38. githubrepo="linuxgsm"
  39. githubbranch="master"
  40. # Steam - 2007 SDK
  41. appid="310"
  42. # Server Details
  43. servicename="ges-server"
  44. gamename="GoldenEye: Source"
  45. engine="source"
  46. # Directories
  47. rootdir="$(dirname $(readlink -f "${BASH_SOURCE[0]}"))"
  48. selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))"
  49. lockselfname=".${servicename}.lock"
  50. filesdir="${rootdir}/serverfiles"
  51. systemdir="${filesdir}/gesource"
  52. executabledir="${filesdir}"
  53. executable="./srcds_run"
  54. servercfg="${servicename}.cfg"
  55. servercfgdir="${systemdir}/cfg"
  56. servercfgfullpath="${servercfgdir}/${servercfg}"
  57. servercfgdefault="${servercfgdir}/lgsm-default.cfg"
  58. backupdir="${rootdir}/backups"
  59. # Logging
  60. logdays="7"
  61. gamelogdir="${systemdir}/logs"
  62. scriptlogdir="${rootdir}/log/script"
  63. consolelogdir="${rootdir}/log/console"
  64. scriptlog="${scriptlogdir}/${servicename}-script.log"
  65. consolelog="${consolelogdir}/${servicename}-console.log"
  66. emaillog="${scriptlogdir}/${servicename}-email.log"
  67. scriptlogdate="${scriptlogdir}/${servicename}-script-$(date '+%d-%m-%Y-%H-%M-%S').log"
  68. consolelogdate="${consolelogdir}/${servicename}-console-$(date '+%d-%m-%Y-%H-%M-%S').log"
  69. ##### Script #####
  70. # Do not edit
  71. fn_getgithubfile(){
  72. filename=$1
  73. exec=$2
  74. fileurl=${3:-$filename}
  75. filepath="${rootdir}/${filename}"
  76. filedir=$(dirname "${filepath}")
  77. # If the function file is missing, then download
  78. if [ ! -f "${filepath}" ]; then
  79. if [ ! -d "${filedir}" ]; then
  80. mkdir "${filedir}"
  81. fi
  82. githuburl="https://raw.githubusercontent.com/${githubuser}/${githubrepo}/${githubbranch}/${fileurl}"
  83. echo -e " fetching ${filename}...\c"
  84. if [ "$(command -v curl)" ]||[ "$(which curl >/dev/null 2>&1)" ]||[ -f "/usr/bin/curl" ]||[ -f "/bin/curl" ]; then
  85. :
  86. else
  87. echo -e "\e[0;31mFAIL\e[0m\n"
  88. echo "Curl is not installed!"
  89. echo -e ""
  90. exit
  91. fi
  92. curl=$(curl --fail -o "${filepath}" "${githuburl}" 2>&1)
  93. if [ $? -ne 0 ]; then
  94. echo -e "\e[0;31mFAIL\e[0m\n"
  95. echo "${curl}"
  96. echo -e "${githuburl}\n"
  97. exit
  98. else
  99. echo -e "\e[0;32mOK\e[0m"
  100. fi
  101. if [ "${exec}" ]; then
  102. chmod +x "${filepath}"
  103. fi
  104. fi
  105. if [ "${exec}" ]; then
  106. source "${filepath}"
  107. fi
  108. }
  109. fn_runfunction(){
  110. fn_getgithubfile "functions/${functionfile}" 1
  111. }
  112. core_functions.sh(){
  113. # Functions are defined in core_functions.sh.
  114. functionfile="${FUNCNAME}"
  115. fn_runfunction
  116. }
  117. core_functions.sh
  118. getopt=$1
  119. core_getopt.sh