kfserver 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140
  1. #!/bin/bash
  2. # Killing Floor
  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="KF-BioticsLab.rom"
  22. ip="0.0.0.0"
  23. updateonstart="off"
  24. fn_parms(){
  25. parms="server ${defaultmap}?game=KFmod.KFGameType?VACSecured=true -nohomedir ini=${servercfg} log=${gamelog}"
  26. # Start Variables for Objective mode
  27. #defaultmap="KFO-Steamland"
  28. #parms="server ${defaultmap}?Game=KFStoryGame.KFStoryGame?VACSecured=true -nohomedir ini=${servercfg} log=${gamelog}"
  29. }
  30. #### Advanced Variables ####
  31. # Github Branch Select
  32. # Allows for the use of different function files
  33. # from a different repo and/or branch.
  34. githubuser="dgibbs64"
  35. githubrepo="linuxgsm"
  36. githubbranch="master"
  37. # Steam
  38. appid="215360"
  39. # Server Details
  40. servicename="kf-server"
  41. gamename="Killing Floor"
  42. engine="unreal2"
  43. # Directories
  44. rootdir="$(dirname $(readlink -f "${BASH_SOURCE[0]}"))"
  45. selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))"
  46. lockselfname=".${servicename}.lock"
  47. filesdir="${rootdir}/serverfiles"
  48. systemdir="${filesdir}/System"
  49. executabledir="${systemdir}"
  50. executable="./ucc-bin"
  51. servercfg="${servicename}.ini"
  52. servercfgdir="${systemdir}"
  53. servercfgfullpath="${servercfgdir}/${servercfg}"
  54. servercfgdefault="${servercfgdir}/Default.ini"
  55. compressedmapsdir="${rootdir}/Maps-Compressed"
  56. backupdir="${rootdir}/backups"
  57. # Logging
  58. logdays="7"
  59. gamelogdir="${rootdir}/log/server"
  60. scriptlogdir="${rootdir}/log/script"
  61. consolelogdir="${rootdir}/log/console"
  62. gamelog="${gamelogdir}/${servicename}-game.log"
  63. scriptlog="${scriptlogdir}/${servicename}-script.log"
  64. consolelog="${consolelogdir}/${servicename}-console.log"
  65. emaillog="${scriptlogdir}/${servicename}-email.log"
  66. gamelogdate="${gamelogdir}/${servicename}-game-$(date '+%d-%m-%Y-%H-%M-%S').log"
  67. scriptlogdate="${scriptlogdir}/${servicename}-script-$(date '+%d-%m-%Y-%H-%M-%S').log"
  68. consolelogdate="${consolelogdir}/${servicename}-console-$(date '+%d-%m-%Y-%H-%M-%S').log"
  69. ##### Script #####
  70. # Do not edit
  71. fn_getgithubfile(){
  72. filename=$1
  73. exec=$2
  74. fileurl=${3:-$filename}
  75. filepath="${rootdir}/${filename}"
  76. filedir=$(dirname "${filepath}")
  77. # If the function file is missing, then download
  78. if [ ! -f "${filepath}" ]; then
  79. if [ ! -d "${filedir}" ]; then
  80. mkdir "${filedir}"
  81. fi
  82. githuburl="https://raw.githubusercontent.com/${githubuser}/${githubrepo}/${githubbranch}/${fileurl}"
  83. echo -e " fetching ${filename}...\c"
  84. if [ "$(command -v curl)" ]||[ "$(which curl >/dev/null 2>&1)" ]||[ -f "/usr/bin/curl" ]||[ -f "/bin/curl" ]; then
  85. :
  86. else
  87. echo -e "\e[0;31mFAIL\e[0m\n"
  88. echo "Curl is not installed!"
  89. echo -e ""
  90. exit
  91. fi
  92. curl=$(curl --fail -o "${filepath}" "${githuburl}" 2>&1)
  93. if [ $? -ne 0 ]; then
  94. echo -e "\e[0;31mFAIL\e[0m\n"
  95. echo "${curl}"
  96. echo -e "${githuburl}\n"
  97. exit
  98. else
  99. echo -e "\e[0;32mOK\e[0m"
  100. fi
  101. if [ "${exec}" ]; then
  102. chmod +x "${filepath}"
  103. fi
  104. fi
  105. if [ "${exec}" ]; then
  106. source "${filepath}"
  107. fi
  108. }
  109. fn_runfunction(){
  110. fn_getgithubfile "functions/${functionfile}" 1
  111. }
  112. core_functions.sh(){
  113. # Functions are defined in core_functions.sh.
  114. functionfile="${FUNCNAME}"
  115. fn_runfunction
  116. }
  117. core_functions.sh
  118. getopt=$1
  119. core_getopt.sh