insserver 3.3 KB

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