arma3server 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218
  1. #!/bin/bash
  2. # Project: Game Server Managers - LinuxGSM
  3. # Author: Daniel Gibbs
  4. # License: MIT License, Copyright (c) 2017 Daniel Gibbs
  5. # Purpose: ARMA 3 | 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="170501"
  16. ##########################
  17. ######## Settings ########
  18. ##########################
  19. #### Server Settings ####
  20. ## SteamCMD Login | https://github.com/GameServerManagers/LinuxGSM/wiki/SteamCMD#steamcmd-login
  21. steamuser="username"
  22. steampass='password'
  23. ## Server Start Settings | https://github.com/GameServerManagers/LinuxGSM/wiki/Start-Parameters
  24. ip="0.0.0.0"
  25. port="2302"
  26. ## ARMA 3 Modules
  27. # Add mods with relative paths:
  28. # mods/@cba_a3
  29. # To load the "Community Base Addons v3" module found in the
  30. # directory serverfiles/mods/@cba_a3. Load several mods as:
  31. # mods="mods/@ace\;mods/@acex\;mods/@cba_a3"
  32. mods=""
  33. ## Server-side Mods
  34. servermods=""
  35. ## Path to BattlEye
  36. # Leave empty for default
  37. bepath=""
  38. ## Server Start Command | https://github.com/GameServerManagers/LinuxGSM/wiki/Start-Parameters#additional-parameters
  39. fn_parms(){
  40. parms="-netlog -ip=${ip} -port=${port} -cfg=${networkcfgfullpath} -config=${servercfgfullpath} -mod=${mods} -servermod=${servermods} -bepath=${bepath} -autoinit -loadmissiontomemory"
  41. }
  42. #### LinuxGSM Settings ####
  43. ## Notification Alerts
  44. # (on|off)
  45. # Email Alerts | https://github.com/GameServerManagers/LinuxGSM/wiki/Email
  46. emailalert="off"
  47. email="email@example.com"
  48. emailfrom=""
  49. # Pushbullet Alerts | https://github.com/GameServerManagers/LinuxGSM/wiki/Pushbullet
  50. pushbulletalert="off"
  51. pushbullettoken="accesstoken"
  52. channeltag=""
  53. ## Updating | https://github.com/GameServerManagers/LinuxGSM/wiki/Update
  54. updateonstart="off"
  55. ## Backup | https://github.com/GameServerManagers/LinuxGSM/wiki/Backup
  56. maxbackups="4"
  57. maxbackupdays="30"
  58. stoponbackup="on"
  59. ## Logging | https://github.com/GameServerManagers/LinuxGSM/wiki/Logging
  60. consolelogging="on"
  61. logdays="7"
  62. #### LinuxGSM Advanced Settings ####
  63. ## SteamCMD Settings
  64. # Server appid
  65. appid="233780"
  66. # Steam App Branch Select
  67. # Allows to opt into the various Steam app branches. Default branch is "".
  68. # Example: "-beta latest_experimental"
  69. branch=""
  70. ## Github Branch Select
  71. # Allows for the use of different function files
  72. # from a different repo and/or branch.
  73. githubuser="GameServerManagers"
  74. githubrepo="LinuxGSM"
  75. githubbranch="master"
  76. ## LinuxGSM Server Details
  77. # Do not edit
  78. gamename="ARMA 3"
  79. engine="realvirtuality"
  80. ## Service Name | https://github.com/GameServerManagers/LinuxGSM/wiki/Multiple-Servers
  81. servicename="arma3-server"
  82. #### Directories ####
  83. # Edit with care
  84. ## Work Directories
  85. rootdir="$(dirname $(readlink -f "${BASH_SOURCE[0]}"))"
  86. selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))"
  87. lockselfname=".${servicename}.lock"
  88. lgsmdir="${rootdir}/lgsm"
  89. functionsdir="${lgsmdir}/functions"
  90. libdir="${lgsmdir}/lib"
  91. tmpdir="${lgsmdir}/tmp"
  92. filesdir="${rootdir}/serverfiles"
  93. ## Server Specific Directories
  94. systemdir="${filesdir}"
  95. executabledir="${filesdir}"
  96. executable="./arma3server"
  97. servercfg="${servicename}.server.cfg"
  98. networkcfg="${servicename}.network.cfg"
  99. servercfgdefault="server.cfg"
  100. networkcfgdefault="network.cfg"
  101. servercfgdir="${systemdir}/cfg"
  102. servercfgfullpath="${servercfgdir}/${servercfg}"
  103. networkcfgfullpath="${servercfgdir}/${networkcfg}"
  104. ## Backup Directory
  105. backupdir="${rootdir}/backups"
  106. ## Logging Directories
  107. #gamelogdir="" # No server logs available
  108. scriptlogdir="${rootdir}/log/script"
  109. consolelogdir="${rootdir}/log/console"
  110. scriptlog="${scriptlogdir}/${servicename}-script.log"
  111. consolelog="${consolelogdir}/${servicename}-console.log"
  112. emaillog="${scriptlogdir}/${servicename}-email.log"
  113. ## Logs Naming
  114. scriptlogdate="${scriptlogdir}/${servicename}-script-$(date '+%Y-%m-%d-%H:%M:%S').log"
  115. consolelogdate="${consolelogdir}/${servicename}-console-$(date '+%Y-%m-%d-%H:%M:%S').log"
  116. ########################
  117. ######## Script ########
  118. ###### Do not edit #####
  119. ########################
  120. # Fetches core_dl for file downloads
  121. fn_fetch_core_dl(){
  122. github_file_url_dir="lgsm/functions"
  123. github_file_url_name="${functionfile}"
  124. filedir="${functionsdir}"
  125. filename="${github_file_url_name}"
  126. githuburl="https://raw.githubusercontent.com/${githubuser}/${githubrepo}/${githubbranch}/${github_file_url_dir}/${github_file_url_name}"
  127. # If the file is missing, then download
  128. if [ ! -f "${filedir}/${filename}" ]; then
  129. if [ ! -d "${filedir}" ]; then
  130. mkdir -p "${filedir}"
  131. fi
  132. echo -e " fetching ${filename}...\c"
  133. # Check curl exists and use available path
  134. curlpaths="$(command -v curl 2>/dev/null) $(which curl >/dev/null 2>&1) /usr/bin/curl /bin/curl /usr/sbin/curl /sbin/curl)"
  135. for curlcmd in ${curlpaths}
  136. do
  137. if [ -x "${curlcmd}" ]; then
  138. break
  139. fi
  140. done
  141. # If curl exists download file
  142. if [ "$(basename ${curlcmd})" == "curl" ]; then
  143. curlfetch=$(${curlcmd} -s --fail -o "${filedir}/${filename}" "${githuburl}" 2>&1)
  144. if [ $? -ne 0 ]; then
  145. echo -e "\e[0;31mFAIL\e[0m\n"
  146. echo "${curlfetch}"
  147. echo -e "${githuburl}\n"
  148. exit 1
  149. else
  150. echo -e "\e[0;32mOK\e[0m"
  151. fi
  152. else
  153. echo -e "\e[0;31mFAIL\e[0m\n"
  154. echo "Curl is not installed!"
  155. echo -e ""
  156. exit 1
  157. fi
  158. chmod +x "${filedir}/${filename}"
  159. fi
  160. source "${filedir}/${filename}"
  161. }
  162. core_dl.sh(){
  163. # Functions are defined in core_functions.sh.
  164. functionfile="${FUNCNAME}"
  165. fn_fetch_core_dl
  166. }
  167. core_functions.sh(){
  168. # Functions are defined in core_functions.sh.
  169. functionfile="${FUNCNAME}"
  170. fn_fetch_core_dl
  171. }
  172. # Prevent from running this script as root.
  173. if [ "$(whoami)" = "root" ]; then
  174. if [ ! -f "${functionsdir}/core_functions.sh" ]||[ ! -f "${functionsdir}/check_root.sh" ]||[ ! -f "${functionsdir}/core_messages.sh" ]||[ ! -f "${functionsdir}/core_exit.sh" ]; then
  175. echo "[ FAIL ] Do NOT run this script as root!"
  176. exit 1
  177. else
  178. core_functions.sh
  179. check_root.sh
  180. fi
  181. fi
  182. core_dl.sh
  183. core_functions.sh
  184. getopt=$1
  185. core_getopt.sh