Advertisement
Guest User

Untitled

a guest
Feb 20th, 2017
113
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 6.17 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="170219"
  18.  
  19. ##########################
  20. ######## Settings ########
  21. ##########################
  22.  
  23. #### Server Settings ####
  24.  
  25. ## SteamCMD Login | https://github.com/GameServerManagers/LinuxGSM/wiki/SteamCMD#steamcmd-login
  26. steamuser="username"
  27. steampass='password'
  28.  
  29. ## Server Start Settings | https://github.com/GameServerManagers/LinuxGSM/wiki/Start-Parameters
  30. ip="0.0.0.0"
  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=""
  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"
  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. email="email@example.com"
  60. emailfrom=""
  61.  
  62. # Pushbullet Alerts | https://github.com/GameServerManagers/LinuxGSM/wiki/Pushbullet
  63. pushbulletalert="off"
  64. pushbullettoken="accesstoken"
  65. channeltag=""
  66.  
  67. ## Updating | https://github.com/GameServerManagers/LinuxGSM/wiki/Update
  68. updateonstart="off"
  69.  
  70. ## Backup | https://github.com/GameServerManagers/LinuxGSM/wiki/Backup
  71. maxbackups="4"
  72. maxbackupdays="30"
  73. stoponbackup="on"
  74.  
  75. ## Logging | https://github.com/GameServerManagers/LinuxGSM/wiki/Logging
  76. consolelogging="on"
  77. logdays="7"
  78.  
  79. #### LinuxGSM Advanced Settings ####
  80.  
  81. ## SteamCMD Settings
  82. # Server appid
  83. appid="233780"
  84. # Steam App Branch Select
  85. # Allows to opt into the various Steam app branches. Default branch is "".
  86. # Example: "-beta latest_experimental"
  87. branch=""
  88.  
  89. ## Github Branch Select
  90. # Allows for the use of different function files
  91. # from a different repo and/or branch.
  92. githubuser="GameServerManagers"
  93. githubrepo="LinuxGSM"
  94. githubbranch="master"
  95.  
  96. ## LinuxGSM Server Details
  97. # Do not edit
  98. gamename="ARMA 3"
  99. engine="realvirtuality"
  100.  
  101. ## Service Name | https://github.com/GameServerManagers/LinuxGSM/wiki/Multiple-Servers
  102. servicename="arma3-server"
  103.  
  104. #### Directories ####
  105. # Edit with care
  106.  
  107. ## Work Directories
  108. rootdir="$(dirname $(readlink -f "${BASH_SOURCE[0]}"))"
  109. selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))"
  110. lockselfname=".${servicename}.lock"
  111. lgsmdir="${rootdir}/lgsm"
  112. functionsdir="${lgsmdir}/functions"
  113. libdir="${lgsmdir}/lib"
  114. tmpdir="${lgsmdir}/tmp"
  115. filesdir="${rootdir}/serverfiles"
  116.  
  117. ## Server Specific Directories
  118. systemdir="${filesdir}"
  119. executabledir="${filesdir}"
  120. executable="./arma3server"
  121. servercfg="${servicename}.server.cfg"
  122. networkcfg="${servicename}.network.cfg"
  123. servercfgdefault="server.cfg"
  124. networkcfgdefault="network.cfg"
  125. servercfgdir="${systemdir}/cfg"
  126. servercfgfullpath="${servercfgdir}/${servercfg}"
  127. networkcfgfullpath="${servercfgdir}/${networkcfg}"
  128.  
  129. ## Backup Directory
  130. backupdir="${rootdir}/backups"
  131.  
  132. ## Logging Directories
  133. #gamelogdir="" # No server logs available
  134. scriptlogdir="${rootdir}/log/script"
  135. consolelogdir="${rootdir}/log/console"
  136. scriptlog="${scriptlogdir}/${servicename}-script.log"
  137. consolelog="${consolelogdir}/${servicename}-console.log"
  138. emaillog="${scriptlogdir}/${servicename}-email.log"
  139.  
  140. ## Logs Naming
  141. scriptlogdate="${scriptlogdir}/${servicename}-script-$(date '+%Y-%m-%d-%H:%M:%S').log"
  142. consolelogdate="${consolelogdir}/${servicename}-console-$(date '+%Y-%m-%d-%H:%M:%S').log"
  143.  
  144. ########################
  145. ######## Script ########
  146. ###### Do not edit #####
  147. ########################
  148.  
  149. # Fetches core_dl for file downloads
  150. fn_fetch_core_dl(){
  151. github_file_url_dir="lgsm/functions"
  152. github_file_url_name="${functionfile}"
  153. filedir="${functionsdir}"
  154. filename="${github_file_url_name}"
  155. githuburl="https://raw.githubusercontent.com/${githubuser}/${githubrepo}/${githubbranch}/${github_file_url_dir}/${github_file_url_name}"
  156. # If the file is missing, then download
  157. if [ ! -f "${filedir}/${filename}" ]; then
  158. if [ ! -d "${filedir}" ]; then
  159. mkdir -p "${filedir}"
  160. fi
  161. echo -e " fetching ${filename}...\c"
  162. # Check curl exists and use available path
  163. curlpaths="$(command -v curl 2>/dev/null) $(which curl >/dev/null 2>&1) /usr/bin/curl /bin/curl /usr/sbin/curl /sbin/curl)"
  164. for curlcmd in ${curlpaths}
  165. do
  166. if [ -x "${curlcmd}" ]; then
  167. break
  168. fi
  169. done
  170. # If curl exists download file
  171. if [ "$(basename ${curlcmd})" == "curl" ]; then
  172. curlfetch=$(${curlcmd} -s --fail -o "${filedir}/${filename}" "${githuburl}" 2>&1)
  173. if [ $? -ne 0 ]; then
  174. echo -e "\e[0;31mFAIL\e[0m\n"
  175. echo "${curlfetch}"
  176. echo -e "${githuburl}\n"
  177. exit 1
  178. else
  179. echo -e "\e[0;32mOK\e[0m"
  180. fi
  181. else
  182. echo -e "\e[0;31mFAIL\e[0m\n"
  183. echo "Curl is not installed!"
  184. echo -e ""
  185. exit 1
  186. fi
  187. chmod +x "${filedir}/${filename}"
  188. fi
  189. source "${filedir}/${filename}"
  190. }
  191.  
  192. core_dl.sh(){
  193. # Functions are defined in core_functions.sh.
  194. functionfile="${FUNCNAME}"
  195. fn_fetch_core_dl
  196. }
  197.  
  198. core_functions.sh(){
  199. # Functions are defined in core_functions.sh.
  200. functionfile="${FUNCNAME}"
  201. fn_fetch_core_dl
  202. }
  203.  
  204. # Prevent from running this script as root.
  205. if [ "$(whoami)" = "root" ]; then
  206. if [ ! -f "${functionsdir}/core_functions.sh" ]||[ ! -f "${functionsdir}/check_root.sh" ]||[ ! -f "${functionsdir}/core_messages.sh" ]||[ ! -f "${functionsdir}/core_exit.sh" ]; then
  207. echo "[ FAIL ] Do NOT run this script as root!"
  208. exit 1
  209. else
  210. core_functions.sh
  211. check_root.sh
  212. fi
  213. fi
  214.  
  215. core_dl.sh
  216. core_functions.sh
  217. getopt=$1
  218. core_getopt.sh
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement