arma3server 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152
  1. #!/bin/bash
  2. # ARMA 3
  3. # Server Management Script
  4. # Author: Daniel Gibbs
  5. # Contributor: Scarsz
  6. # Website: http://danielgibbs.co.uk
  7. # Version: 010115
  8. #### Variables ####
  9. # Notification Email
  10. # (on|off)
  11. emailnotification="off"
  12. email="email@example.com"
  13. # Steam login
  14. steamuser="username"
  15. steampass="password"
  16. # Server IP
  17. ip="0.0.0.0"
  18. fn_parms(){
  19. parms="-netlog -ip=${ip} -config=${servercfg}"
  20. }
  21. #### Advanced Variables ####
  22. # Steam
  23. appid="233780"
  24. # Server Details
  25. servicename="arma3-server"
  26. gamename="ARMA 3"
  27. engine="realvirtuality"
  28. # Directories
  29. rootdir="$(cd "$(dirname "${BASH_SOURCE[0]}" )" && pwd )"
  30. selfname="$0"
  31. lockselfname=$(echo ".${servicename}.lock")
  32. filesdir="${rootdir}/serverfiles"
  33. systemdir="${filesdir}"
  34. executabledir="${filesdir}"
  35. executable="./arma3server"
  36. servercfgdir="${systemdir}"
  37. servercfg="${servicename}.cfg"
  38. servercfgfullpath="${servercfgdir}/${servercfg}"
  39. backupdir="backups"
  40. # Server Details
  41. servername=$(grep -s hostname "${servercfgfullpath}"| grep -v //|sed -e 's/\<hostname\>//g'| tr -d '=\"; ')
  42. # Logging
  43. logdays="7"
  44. #gamelogdir="" # No server logs available
  45. scriptlogdir="${rootdir}/log/script"
  46. consolelogdir="${rootdir}/log/console"
  47. scriptlog="${scriptlogdir}/${servicename}-script.log"
  48. consolelog="${consolelogdir}/${servicename}-console.log"
  49. emaillog="${scriptlogdir}/${servicename}-email.log"
  50. scriptlogdate="${scriptlogdir}/${servicename}-script-$(date '+%d-%m-%Y-%H-%M-%S').log"
  51. consolelogdate="${consolelogdir}/${servicename}-console-$(date '+%d-%m-%Y-%H-%M-%S').log"
  52. ##### Script #####
  53. # Do not edit
  54. fn_install(){
  55. fn_rootcheck
  56. fn_header
  57. if [ -z "${autoinstall}" ]; then
  58. fn_serverdirectory
  59. fn_header
  60. fi
  61. fn_steamdl
  62. fn_steaminstall
  63. fn_steamfix
  64. fn_glibcfix
  65. fn_loginstall
  66. fn_getquery
  67. fn_serverconfig
  68. fn_header
  69. fn_details
  70. fn_installcomplete
  71. }
  72. fn_functions(){
  73. # Functions are defines in fn_functions.
  74. functionfile="${FUNCNAME}"
  75. fn_runfunction
  76. }
  77. fn_runfunction(){
  78. # Functions are downloaded and run with this function
  79. if [ ! -f "${rootdir}/functions/${functionfile}" ]; then
  80. cd "${rootdir}"
  81. if [ ! -d "functions" ]; then
  82. mkdir functions
  83. fi
  84. cd functions
  85. echo -e "loading ${functionfile}...\c"
  86. wget -N --no-check-certificate /dev/null https://raw.githubusercontent.com/dgibbs64/linuxgameservers/master/functions/${functionfile} 2>&1 | grep -F HTTP | cut -c45-
  87. chmod +x "${functionfile}"
  88. cd "${rootdir}"
  89. sleep 1
  90. fi
  91. source "${rootdir}/functions/${functionfile}"
  92. }
  93. fn_functions
  94. case "$1" in
  95. start)
  96. fn_startserver;;
  97. stop)
  98. fn_stopserver;;
  99. restart)
  100. fn_restartserver;;
  101. update)
  102. norestart=1;
  103. fn_versioncheck;;
  104. update-restart)
  105. fn_versioncheck;;
  106. validate)
  107. fn_validateserver;;
  108. validate-restart)
  109. fn_stopserver
  110. fn_validateserver
  111. fn_startserver;;
  112. monitor)
  113. fn_monitorserver;;
  114. email-test)
  115. fn_emailtest;;
  116. details)
  117. fn_details;;
  118. backup)
  119. fn_backupserver;;
  120. console)
  121. fn_console;;
  122. debug)
  123. fn_debugserver;;
  124. install)
  125. fn_install;;
  126. auto-install)
  127. fn_autoinstall;;
  128. *)
  129. echo "Usage: $0 {start|stop|restart|update|update-restart|validate|validate-restart|monitor|email-test|details|backup|console|debug|install|auto-install}"
  130. exit 1;;
  131. esac
  132. exit