codwawserver 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188
  1. #!/bin/bash
  2. # Project: Game Server Managers - LinuxGSM
  3. # Author: Daniel Gibbs
  4. # License: MIT License, Copyright (c) 2016 Daniel Gibbs
  5. # Purpose: Call of Duty: World at War | Server Management Script
  6. # Contributors: https://github.com/GameServerManagers/LinuxGSM/graphs/contributors
  7. # Documentation: https://github.com/GameServerManagers/LinuxGSM/wiki
  8. # Website: https://gameservermanagers.com
  9. # Debugging
  10. if [ -f ".dev-debug" ]; then
  11. exec 5>dev-debug.log
  12. BASH_XTRACEFD="5"
  13. set -x
  14. fi
  15. version="161224"
  16. ##########################
  17. ######## Settings ########
  18. ##########################
  19. #### Server Settings ####
  20. ## Server Start Settings | https://github.com/GameServerManagers/LinuxGSM/wiki/Start-Parameters
  21. defaultmap="mp_castle"
  22. maxclients="20"
  23. port="28960"
  24. ip="0.0.0.0"
  25. ## Server Start Command | https://github.com/GameServerManagers/LinuxGSM/wiki/Start-Parameters#additional-parameters
  26. fn_parms(){
  27. parms="+set sv_punkbuster 0 +set fs_basepath ${filesdir} +set dedicated 1 +set net_ip ${ip} +set net_port ${port} +set sv_maxclients ${maxclients} +exec ${servercfg} +map ${defaultmap}"
  28. }
  29. #### LinuxGSM Settings ####
  30. ## Notification Alerts
  31. # (on|off)
  32. # Email Alerts | https://github.com/GameServerManagers/LinuxGSM/wiki/Email
  33. emailalert="off"
  34. email="email@example.com"
  35. emailfrom=""
  36. # Pushbullet Alerts | https://github.com/GameServerManagers/LinuxGSM/wiki/Pushbullet
  37. pushbulletalert="off"
  38. pushbullettoken="accesstoken"
  39. channeltag=""
  40. ## Backup | https://github.com/GameServerManagers/LinuxGSM/wiki/Backup
  41. maxbackups="4"
  42. maxbackupdays="30"
  43. stoponbackup="on"
  44. ## Logging | https://github.com/GameServerManagers/LinuxGSM/wiki/Logging
  45. consolelogging="on"
  46. logdays="7"
  47. #### Advanced Variables ####
  48. ## Github Branch Select
  49. # Allows for the use of different function files
  50. # from a different repo and/or branch.
  51. githubuser="GameServerManagers"
  52. githubrepo="LinuxGSM"
  53. githubbranch="master"
  54. ## LinuxGSM Server Details
  55. # Do not edit
  56. gamename="Call of Duty: World at War"
  57. engine="iw3.0"
  58. ## Service Name | https://github.com/GameServerManagers/LinuxGSM/wiki/Multiple-Servers
  59. servicename="codwaw-server"
  60. #### Directories ####
  61. # Edit with care
  62. ## Work Directories
  63. rootdir="$(dirname $(readlink -f "${BASH_SOURCE[0]}"))"
  64. selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))"
  65. lockselfname=".${servicename}.lock"
  66. lgsmdir="${rootdir}/lgsm"
  67. functionsdir="${lgsmdir}/functions"
  68. libdir="${lgsmdir}/lib"
  69. tmpdir="${lgsmdir}/tmp"
  70. filesdir="${rootdir}/serverfiles"
  71. ## Server Specific Directories
  72. systemdir="${filesdir}"
  73. executabledir="${filesdir}"
  74. executable="./codwaw_lnxded"
  75. servercfg="${servicename}.cfg"
  76. servercfgdefault="server.cfg"
  77. servercfgdir="${systemdir}/main"
  78. servercfgfullpath="${servercfgdir}/${servercfg}"
  79. ## Backup Directory
  80. backupdir="${rootdir}/backups"
  81. ## Logging Directories
  82. gamelogdir="${filesdir}/Logs"
  83. scriptlogdir="${rootdir}/log/script"
  84. consolelogdir="${rootdir}/log/console"
  85. scriptlog="${scriptlogdir}/${servicename}-script.log"
  86. consolelog="${consolelogdir}/${servicename}-console.log"
  87. emaillog="${scriptlogdir}/${servicename}-email.log"
  88. ## Logs Naming
  89. scriptlogdate="${scriptlogdir}/${servicename}-script-$(date '+%Y-%m-%d-%H:%M:%S').log"
  90. consolelogdate="${consolelogdir}/${servicename}-console-$(date '+%Y-%m-%d-%H:%M:%S').log"
  91. ########################
  92. ######## Script ########
  93. ###### Do not edit #####
  94. ########################
  95. # Fetches core_dl for file downloads
  96. fn_fetch_core_dl(){
  97. github_file_url_dir="lgsm/functions"
  98. github_file_url_name="${functionfile}"
  99. filedir="${functionsdir}"
  100. filename="${github_file_url_name}"
  101. githuburl="https://raw.githubusercontent.com/${githubuser}/${githubrepo}/${githubbranch}/${github_file_url_dir}/${github_file_url_name}"
  102. # If the file is missing, then download
  103. if [ ! -f "${filedir}/${filename}" ]; then
  104. if [ ! -d "${filedir}" ]; then
  105. mkdir -p "${filedir}"
  106. fi
  107. echo -e " fetching ${filename}...\c"
  108. # Check curl exists and use available path
  109. curlpaths="$(command -v curl 2>/dev/null) $(which curl >/dev/null 2>&1) /usr/bin/curl /bin/curl /usr/sbin/curl /sbin/curl)"
  110. for curlcmd in ${curlpaths}
  111. do
  112. if [ -x "${curlcmd}" ]; then
  113. break
  114. fi
  115. done
  116. # If curl exists download file
  117. if [ "$(basename ${curlcmd})" == "curl" ]; then
  118. curlfetch=$(${curlcmd} -s --fail -o "${filedir}/${filename}" "${githuburl}" 2>&1)
  119. if [ $? -ne 0 ]; then
  120. echo -e "\e[0;31mFAIL\e[0m\n"
  121. echo "${curlfetch}"
  122. echo -e "${githuburl}\n"
  123. exit 1
  124. else
  125. echo -e "\e[0;32mOK\e[0m"
  126. fi
  127. else
  128. echo -e "\e[0;31mFAIL\e[0m\n"
  129. echo "Curl is not installed!"
  130. echo -e ""
  131. exit 1
  132. fi
  133. chmod +x "${filedir}/${filename}"
  134. fi
  135. source "${filedir}/${filename}"
  136. }
  137. core_dl.sh(){
  138. # Functions are defined in core_functions.sh.
  139. functionfile="${FUNCNAME}"
  140. fn_fetch_core_dl
  141. }
  142. core_functions.sh(){
  143. # Functions are defined in core_functions.sh.
  144. functionfile="${FUNCNAME}"
  145. fn_fetch_core_dl
  146. }
  147. # Prevent from running this script as root.
  148. if [ "$(whoami)" = "root" ]; then
  149. if [ ! -f "${functionsdir}/core_functions.sh" ]||[ ! -f "${functionsdir}/check_root.sh" ]||[ ! -f "${functionsdir}/core_messages.sh" ]||[ ! -f "${functionsdir}/core_exit.sh" ]; then
  150. echo "[ FAIL ] Do NOT run this script as root!"
  151. exit 1
  152. else
  153. core_functions.sh
  154. check_root.sh
  155. fi
  156. fi
  157. core_dl.sh
  158. core_functions.sh
  159. getopt=$1
  160. core_getopt.sh