4
0

kfserver 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149
  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="150316"
  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. lgsmdir="${rootdir}/lgsm"
  48. functionsdir="${lgsmdir}/functions"
  49. filesdir="${rootdir}/serverfiles"
  50. systemdir="${filesdir}/System"
  51. executabledir="${systemdir}"
  52. executable="./ucc-bin"
  53. servercfg="${servicename}.ini"
  54. servercfgdir="${systemdir}"
  55. servercfgfullpath="${servercfgdir}/${servercfg}"
  56. servercfgdefault="${servercfgdir}/Default.ini"
  57. compressedmapsdir="${rootdir}/Maps-Compressed"
  58. backupdir="${rootdir}/backups"
  59. # Logging
  60. logdays="7"
  61. gamelogdir="${rootdir}/log/server"
  62. scriptlogdir="${rootdir}/log/script"
  63. consolelogdir="${rootdir}/log/console"
  64. gamelog="${gamelogdir}/${servicename}-game.log"
  65. scriptlog="${scriptlogdir}/${servicename}-script.log"
  66. consolelog="${consolelogdir}/${servicename}-console.log"
  67. emaillog="${scriptlogdir}/${servicename}-email.log"
  68. gamelogdate="${gamelogdir}/${servicename}-game-$(date '+%d-%m-%Y-%H-%M-%S').log"
  69. scriptlogdate="${scriptlogdir}/${servicename}-script-$(date '+%d-%m-%Y-%H-%M-%S').log"
  70. consolelogdate="${consolelogdir}/${servicename}-console-$(date '+%d-%m-%Y-%H-%M-%S').log"
  71. ##### Script #####
  72. # Do not edit
  73. # Fetches core_dl for file downloads
  74. fn_fetch_core_dl(){
  75. github_file_url_dir="lgsm/functions"
  76. github_file_url_name="${functionfile}"
  77. filedir="${functionsdir}"
  78. filename="${github_file_url_name}"
  79. githuburl="https://raw.githubusercontent.com/${githubuser}/${githubrepo}/${githubbranch}/${github_file_url_dir}/${github_file_url_name}"
  80. # If the file is missing, then download
  81. if [ ! -f "${filedir}/${filename}" ]; then
  82. if [ ! -d "${filedir}" ]; then
  83. mkdir -p "${filedir}"
  84. fi
  85. echo -e " fetching ${filename}...\c"
  86. # Check curl exists and use available path
  87. curlpaths="$(command -v curl 2>/dev/null) $(which curl >/dev/null 2>&1) /usr/bin/curl /bin/curl /usr/sbin/curl /sbin/curl)"
  88. for curlcmd in ${curlpaths}
  89. do
  90. if [ -x "${curlcmd}" ]; then
  91. break
  92. fi
  93. done
  94. # If curl exists download file
  95. if [ "$(basename ${curlcmd})" == "curl" ]; then
  96. curlfetch=$(${curlcmd} -s --fail -o "${filedir}/${filename}" "${githuburl}" 2>&1)
  97. if [ $? -ne 0 ]; then
  98. echo -e "\e[0;31mFAIL\e[0m\n"
  99. echo "${curlfetch}"
  100. echo -e "${githuburl}\n"
  101. exit 1
  102. else
  103. echo -e "\e[0;32mOK\e[0m"
  104. fi
  105. else
  106. echo -e "\e[0;31mFAIL\e[0m\n"
  107. echo "Curl is not installed!"
  108. echo -e ""
  109. exit 1
  110. fi
  111. chmod +x "${filedir}/${filename}"
  112. fi
  113. source "${filedir}/${filename}"
  114. }
  115. core_dl.sh(){
  116. # Functions are defined in core_functions.sh.
  117. functionfile="${FUNCNAME}"
  118. fn_fetch_core_dl
  119. }
  120. core_functions.sh(){
  121. # Functions are defined in core_functions.sh.
  122. functionfile="${FUNCNAME}"
  123. fn_fetch_core_dl
  124. }
  125. core_dl.sh
  126. core_functions.sh
  127. getopt=$1
  128. core_getopt.sh