roserver 3.1 KB

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