arma3server 6.0 KB

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