kfserver 3.2 KB

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