arma3server 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165
  1. #!/bin/bash
  2. # ARMA 3
  3. # Server Management Script
  4. # Author: Daniel Gibbs
  5. # Contributor: Scarsz
  6. # Website: http://gameservermanagers.com
  7. if [ -f ".dev-debug" ]; then
  8. exec 5>dev-debug.log
  9. BASH_XTRACEFD="5"
  10. set -x
  11. fi
  12. version="150316"
  13. #### Variables ####
  14. # Notification Email
  15. # (on|off)
  16. emailnotification="off"
  17. email="email@example.com"
  18. # Steam login
  19. steamuser="username"
  20. steampass="password"
  21. # Start Variables
  22. ip="0.0.0.0"
  23. port="2302"
  24. updateonstart="off"
  25. consolelogging="on"
  26. fn_parms(){
  27. parms="-netlog -ip=${ip} -port=${port} -cfg=${networkcfgfullpath} -config=${servercfgfullpath} -mod=${mods} -servermod=${servermods} -bepath=${bepath} -autoinit -loadmissiontomemory"
  28. }
  29. # ARMA 3 Modules
  30. # add mods with relative paths:
  31. # mods/\@CBA_A3\;
  32. # or several mods as:
  33. # mods/\@CBA_A3\;mods/\@task_force_radio
  34. # and chmod modules directories to 775
  35. mods=""
  36. # Server-side Mods
  37. servermods=""
  38. # Path to BattlEye
  39. # leave empty for default
  40. bepath=""
  41. #### Advanced Variables ####
  42. # Github Branch Select
  43. # Allows for the use of different function files
  44. # from a different repo and/or branch.
  45. githubuser="dgibbs64"
  46. githubrepo="linuxgsm"
  47. githubbranch="master"
  48. # Steam
  49. # Stable
  50. appid="233780"
  51. # Development
  52. # appid="233780 -beta development"
  53. # Server Details
  54. servicename="arma3-server"
  55. gamename="ARMA 3"
  56. engine="realvirtuality"
  57. # Directories
  58. rootdir="$(dirname $(readlink -f "${BASH_SOURCE[0]}"))"
  59. selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))"
  60. lockselfname=".${servicename}.lock"
  61. lgsmdir="${rootdir}/lgsm"
  62. functionsdir="${lgsmdir}/functions"
  63. filesdir="${rootdir}/serverfiles"
  64. systemdir="${filesdir}"
  65. executabledir="${filesdir}"
  66. executable="./arma3server"
  67. servercfg="${servicename}.server.cfg"
  68. networkcfg="${servicename}.network.cfg"
  69. servercfgdir="${systemdir}/cfg"
  70. servercfgfullpath="${servercfgdir}/${servercfg}"
  71. networkcfgfullpath="${servercfgdir}/${networkcfg}"
  72. servercfgdefault="${servercfgdir}/lgsm-default.server.cfg"
  73. networkcfgdefault="${servercfgdir}/lgsm-default.network.cfg"
  74. backupdir="${rootdir}/backups"
  75. # Logging
  76. logdays="7"
  77. #gamelogdir="" # No server logs available
  78. scriptlogdir="${rootdir}/log/script"
  79. consolelogdir="${rootdir}/log/console"
  80. scriptlog="${scriptlogdir}/${servicename}-script.log"
  81. consolelog="${consolelogdir}/${servicename}-console.log"
  82. emaillog="${scriptlogdir}/${servicename}-email.log"
  83. scriptlogdate="${scriptlogdir}/${servicename}-script-$(date '+%d-%m-%Y-%H-%M-%S').log"
  84. consolelogdate="${consolelogdir}/${servicename}-console-$(date '+%d-%m-%Y-%H-%M-%S').log"
  85. ##### Script #####
  86. # Do not edit
  87. # Fetches core_dl for file downloads
  88. fn_fetch_core_dl(){
  89. github_file_url_dir="lgsm/functions"
  90. github_file_url_name="${functionfile}"
  91. filedir="${functionsdir}"
  92. filename="${github_file_url_name}"
  93. githuburl="https://raw.githubusercontent.com/${githubuser}/${githubrepo}/${githubbranch}/${github_file_url_dir}/${github_file_url_name}"
  94. # If the file is missing, then download
  95. if [ ! -f "${filedir}/${filename}" ]; then
  96. if [ ! -d "${filedir}" ]; then
  97. mkdir -p "${filedir}"
  98. fi
  99. echo -e " fetching ${filename}...\c"
  100. # Check curl exists and use available path
  101. curlpaths="$(command -v curl 2>/dev/null) $(which curl >/dev/null 2>&1) /usr/bin/curl /bin/curl /usr/sbin/curl /sbin/curl)"
  102. for curlcmd in ${curlpaths}
  103. do
  104. if [ -x "${curlcmd}" ]; then
  105. break
  106. fi
  107. done
  108. # If curl exists download file
  109. if [ "$(basename ${curlcmd})" == "curl" ]; then
  110. curlfetch=$(${curlcmd} -s --fail -o "${filedir}/${filename}" "${githuburl}" 2>&1)
  111. if [ $? -ne 0 ]; then
  112. echo -e "\e[0;31mFAIL\e[0m\n"
  113. echo "${curlfetch}"
  114. echo -e "${githuburl}\n"
  115. exit 1
  116. else
  117. echo -e "\e[0;32mOK\e[0m"
  118. fi
  119. else
  120. echo -e "\e[0;31mFAIL\e[0m\n"
  121. echo "Curl is not installed!"
  122. echo -e ""
  123. exit 1
  124. fi
  125. chmod +x "${filedir}/${filename}"
  126. fi
  127. source "${filedir}/${filename}"
  128. }
  129. core_dl.sh(){
  130. # Functions are defined in core_functions.sh.
  131. functionfile="${FUNCNAME}"
  132. fn_fetch_core_dl
  133. }
  134. core_functions.sh(){
  135. # Functions are defined in core_functions.sh.
  136. functionfile="${FUNCNAME}"
  137. fn_fetch_core_dl
  138. }
  139. core_dl.sh
  140. core_functions.sh
  141. getopt=$1
  142. core_getopt.sh