Guest User

Untitled

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