arma3server 3.4 KB

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