roserver 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136
  1. #!/bin/bash
  2. # Red Orchestra: Ostfront 41-45
  3. # Server Management Script
  4. # Author: Daniel Gibbs
  5. # Website: http://gameservermanagers.com
  6. if [ -f ".dev-debug" ]; then
  7. exec 5>dev-debug.log
  8. BASH_XTRACEFD="5"
  9. set -x
  10. fi
  11. version="271215"
  12. #### Variables ####
  13. # Notification Email
  14. # (on|off)
  15. emailnotification="off"
  16. email="email@example.com"
  17. # Steam login
  18. steamuser="username"
  19. steampass="password"
  20. # Start Variables
  21. defaultmap="RO-Arad.rom"
  22. ip="0.0.0.0"
  23. updateonstart="off"
  24. fn_parms(){
  25. parms="server ${defaultmap}?game=ROGame.ROTeamGame?VACSecured=true -nohomedir ini=${servercfg} log=${gamelog}"
  26. }
  27. #### Advanced Variables ####
  28. # Github Branch Select
  29. # Allows for the use of different function files
  30. # from a different repo and/or branch.
  31. githubuser="dgibbs64"
  32. githubrepo="linuxgsm"
  33. githubbranch="master"
  34. # Server Details
  35. servicename="ro-server"
  36. gamename="Red Orchestra: Ostfront 41-45"
  37. engine="unreal2"
  38. # Steam
  39. appid="223250"
  40. # Directories
  41. rootdir="$(dirname $(readlink -f "${BASH_SOURCE[0]}"))"
  42. selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))"
  43. lockselfname=".${servicename}.lock"
  44. filesdir="${rootdir}/serverfiles"
  45. systemdir="${filesdir}/system"
  46. executabledir="${systemdir}"
  47. executable="./ucc-bin"
  48. servercfg="${servicename}.ini"
  49. servercfgdir="${systemdir}"
  50. servercfgfullpath="${servercfgdir}/${servercfg}"
  51. servercfgdefault="${servercfgdir}/default.ini"
  52. compressedmapsdir="${rootdir}/Maps-Compressed"
  53. backupdir="${rootdir}/backups"
  54. # Logging
  55. logdays="7"
  56. gamelogdir="${rootdir}/log/server"
  57. scriptlogdir="${rootdir}/log/script"
  58. consolelogdir="${rootdir}/log/console"
  59. gamelog="${gamelogdir}/${servicename}-game.log"
  60. scriptlog="${scriptlogdir}/${servicename}-script.log"
  61. consolelog="${consolelogdir}/${servicename}-console.log"
  62. emaillog="${scriptlogdir}/${servicename}-email.log"
  63. gamelogdate="${gamelogdir}/${servicename}-game-$(date '+%d-%m-%Y-%H-%M-%S').log"
  64. scriptlogdate="${scriptlogdir}/${servicename}-script-$(date '+%d-%m-%Y-%H-%M-%S').log"
  65. consolelogdate="${consolelogdir}/${servicename}-console-$(date '+%d-%m-%Y-%H-%M-%S').log"
  66. ##### Script #####
  67. # Do not edit
  68. fn_getgithubfile(){
  69. filename=$1
  70. exec=$2
  71. fileurl=${3:-$filename}
  72. filepath="${rootdir}/${filename}"
  73. filedir=$(dirname "${filepath}")
  74. # If the function file is missing, then download
  75. if [ ! -f "${filepath}" ]; then
  76. if [ ! -d "${filedir}" ]; then
  77. mkdir "${filedir}"
  78. fi
  79. githuburl="https://raw.githubusercontent.com/${githubuser}/${githubrepo}/${githubbranch}/${fileurl}"
  80. echo -e " fetching ${filename}...\c"
  81. if [ "$(command -v curl)" ]||[ "$(which curl >/dev/null 2>&1)" ]||[ -f "/usr/bin/curl" ]||[ -f "/bin/curl" ]; then
  82. :
  83. else
  84. echo -e "\e[0;31mFAIL\e[0m\n"
  85. echo "Curl is not installed!"
  86. echo -e ""
  87. exit
  88. fi
  89. curl=$(curl --fail -o "${filepath}" "${githuburl}" 2>&1)
  90. if [ $? -ne 0 ]; then
  91. echo -e "\e[0;31mFAIL\e[0m\n"
  92. echo "${curl}"
  93. echo -e "${githuburl}\n"
  94. exit
  95. else
  96. echo -e "\e[0;32mOK\e[0m"
  97. fi
  98. if [ "${exec}" ]; then
  99. chmod +x "${filepath}"
  100. fi
  101. fi
  102. if [ "${exec}" ]; then
  103. source "${filepath}"
  104. fi
  105. }
  106. fn_runfunction(){
  107. fn_getgithubfile "functions/${functionfile}" 1
  108. }
  109. core_functions.sh(){
  110. # Functions are defined in core_functions.sh.
  111. functionfile="${FUNCNAME}"
  112. fn_runfunction
  113. }
  114. core_functions.sh
  115. getopt=$1
  116. core_getopt.sh