arma3server 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148
  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="201215"
  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. updateonstart="off"
  24. fn_parms(){
  25. parms="-netlog -ip=${ip} -cfg=${networkcfgfullpath} -config=${servercfgfullpath} -mod=${mods} -servermod=${servermods} -autoinit -loadmissiontomemory"
  26. }
  27. # ARMA 3 Modules
  28. # add mods with relative paths:
  29. # mods/\@CBA_A3\;
  30. # or several mods as:
  31. # mods/\@CBA_A3\;mods/\@task_force_radio
  32. # and chmod modules directories to 775
  33. mods=""
  34. servermods=""
  35. #### Advanced Variables ####
  36. # Github Branch Select
  37. # Allows for the use of different function files
  38. # from a different repo and/or branch.
  39. githubuser="dgibbs64"
  40. githubrepo="linuxgsm"
  41. githubbranch="master"
  42. # Steam
  43. # Stable
  44. appid="233780"
  45. # Development
  46. # appid="233780 -beta development"
  47. # Server Details
  48. servicename="arma3-server"
  49. gamename="ARMA 3"
  50. engine="realvirtuality"
  51. # Directories
  52. rootdir="$(dirname $(readlink -f "${BASH_SOURCE[0]}"))"
  53. selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))"
  54. lockselfname=".${servicename}.lock"
  55. filesdir="${rootdir}/serverfiles"
  56. systemdir="${filesdir}"
  57. executabledir="${filesdir}"
  58. executable="./arma3server"
  59. servercfg="${servicename}.server.cfg"
  60. networkcfg="${servicename}.network.cfg"
  61. servercfgdir="${systemdir}/cfg"
  62. servercfgfullpath="${servercfgdir}/${servercfg}"
  63. networkcfgfullpath="${servercfgdir}/${networkcfg}"
  64. servercfgdefault="${servercfgdir}/lgsm-default.server.cfg"
  65. networkcfgdefault="${servercfgdir}/lgsm-default.network.cfg"
  66. backupdir="${rootdir}/backups"
  67. # Logging
  68. logdays="7"
  69. #gamelogdir="" # No server logs available
  70. scriptlogdir="${rootdir}/log/script"
  71. consolelogdir="${rootdir}/log/console"
  72. scriptlog="${scriptlogdir}/${servicename}-script.log"
  73. consolelog="${consolelogdir}/${servicename}-console.log"
  74. emaillog="${scriptlogdir}/${servicename}-email.log"
  75. scriptlogdate="${scriptlogdir}/${servicename}-script-$(date '+%d-%m-%Y-%H-%M-%S').log"
  76. consolelogdate="${consolelogdir}/${servicename}-console-$(date '+%d-%m-%Y-%H-%M-%S').log"
  77. ##### Script #####
  78. # Do not edit
  79. fn_getgithubfile(){
  80. filename=$1
  81. exec=$2
  82. fileurl=${3:-$filename}
  83. filepath="${rootdir}/${filename}"
  84. filedir=$(dirname "${filepath}")
  85. # If the function file is missing, then download
  86. if [ ! -f "${filepath}" ]; then
  87. if [ ! -d "${filedir}" ]; then
  88. mkdir "${filedir}"
  89. fi
  90. githuburl="https://raw.githubusercontent.com/${githubuser}/${githubrepo}/${githubbranch}/${fileurl}"
  91. echo -e " fetching ${filename}...\c"
  92. if [ "$(command -v curl)" ]||[ "$(which curl >/dev/null 2>&1)" ]||[ -f "/usr/bin/curl" ]||[ -f "/bin/curl" ]; then
  93. :
  94. else
  95. echo -e "\e[0;31mFAIL\e[0m\n"
  96. echo "Curl is not installed!"
  97. echo -e ""
  98. exit
  99. fi
  100. curl=$(curl --fail -o "${filepath}" "${githuburl}" 2>&1)
  101. if [ $? -ne 0 ]; then
  102. echo -e "\e[0;31mFAIL\e[0m\n"
  103. echo "${curl}"
  104. echo -e "${githuburl}\n"
  105. exit
  106. else
  107. echo -e "\e[0;32mOK\e[0m"
  108. fi
  109. if [ "${exec}" ]; then
  110. chmod +x "${filepath}"
  111. fi
  112. fi
  113. if [ "${exec}" ]; then
  114. source "${filepath}"
  115. fi
  116. }
  117. fn_runfunction(){
  118. fn_getgithubfile "functions/${functionfile}" 1
  119. }
  120. fn_functions(){
  121. # Functions are defined in fn_functions.
  122. functionfile="${FUNCNAME}"
  123. fn_runfunction
  124. }
  125. fn_functions
  126. getopt=$1
  127. fn_getopt