emserver 5.1 KB

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