Advertisement
Guest User

Untitled

a guest
Feb 8th, 2016
144
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.74 KB | None | 0 0
  1. #!/bin/bash
  2. # Garry's Mod
  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.  
  12. version="271215"
  13.  
  14. #### Variables ####
  15.  
  16. # Notification Email
  17. # (on|off)
  18. emailnotification="off"
  19. email="email@example.com"
  20.  
  21. # Steam login
  22. steamuser="anonymous"
  23. steampass=""
  24.  
  25. # Workshop Variables
  26. # http://wiki.garrysmod.com/page/Workshop_for_Dedicated_Servers
  27. workshopauth=""
  28. workshopcollectionid=""
  29.  
  30. # Start Variables
  31. defaultmap="gm_construct"
  32. gamemode="sandbox"
  33. maxplayers="16"
  34. port="27015"
  35. sourcetvport="27020"
  36. clientport="27005"
  37. ip="0.0.0.0"
  38. updateonstart="off"
  39.  
  40. # Optional: Game Server Login Token
  41. # GSLT can be used for running a public server.
  42. # More info: http://gameservermanagers.com/gslt
  43. gslt=""
  44.  
  45. # https://developer.valvesoftware.com/wiki/Command_Line_Options#Source_Dedicated_Server
  46. fn_parms(){
  47. parms="-game garrysmod -strictportbind -ip ${ip} -port ${port} +host_workshop_collection ${workshopcollectionid} -authkey ${workshopauth} +clientport ${clientport} +tv_port ${sourcetvport} +gamemode ${gamemode} +map ${defaultmap} +sv_setsteamaccount ${gslt} +servercfgfile ${servercfg} -maxplayers ${maxplayers}"
  48. }
  49.  
  50. #### Advanced Variables ####
  51.  
  52. # Github Branch Select
  53. # Allows for the use of different function files
  54. # from a different repo and/or branch.
  55. githubuser="dgibbs64"
  56. githubrepo="linuxgsm"
  57. githubbranch="master"
  58.  
  59. # Steam
  60. appid="4020"
  61.  
  62. # Server Details
  63. servicename="gmod-server"
  64. gamename="Garry's Mod"
  65. engine="source"
  66.  
  67. # Directories
  68. rootdir="$(dirname $(readlink -f "${BASH_SOURCE[0]}"))"
  69. selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))"
  70. lockselfname=".${servicename}.lock"
  71. filesdir="${rootdir}/serverfiles"
  72. systemdir="${filesdir}/garrysmod"
  73. executabledir="${filesdir}"
  74. executable="./srcds_run"
  75. servercfg="${servicename}.cfg"
  76. servercfgdir="${systemdir}/cfg"
  77. servercfgfullpath="${servercfgdir}/${servercfg}"
  78. servercfgdefault="${servercfgdir}/lgsm-default.cfg"
  79. backupdir="${rootdir}/backups"
  80.  
  81. # Logging
  82. logdays="7"
  83. gamelogdir="${systemdir}/logs"
  84. scriptlogdir="${rootdir}/log/script"
  85. consolelogdir="${rootdir}/log/console"
  86.  
  87. scriptlog="${scriptlogdir}/${servicename}-script.log"
  88. consolelog="${consolelogdir}/${servicename}-console.log"
  89. emaillog="${scriptlogdir}/${servicename}-email.log"
  90.  
  91. scriptlogdate="${scriptlogdir}/${servicename}-script-$(date '+%d-%m-%Y-%H-%M-%S').log"
  92. consolelogdate="${consolelogdir}/${servicename}-console-$(date '+%d-%m-%Y-%H-%M-%S').log"
  93.  
  94. ##### Script #####
  95. # Do not edit
  96.  
  97. fn_getgithubfile(){
  98. filename=$1
  99. exec=$2
  100. fileurl=${3:-$filename}
  101. filepath="${rootdir}/${filename}"
  102. filedir=$(dirname "${filepath}")
  103. # If the function file is missing, then download
  104. if [ ! -f "${filepath}" ]; then
  105. if [ ! -d "${filedir}" ]; then
  106. mkdir "${filedir}"
  107. fi
  108. githuburl="https://raw.githubusercontent.com/${githubuser}/${githubrepo}/${githubbranch}/${fileurl}"
  109. echo -e " fetching ${filename}...\c"
  110. if [ "$(command -v curl)" ]||[ "$(which curl >/dev/null 2>&1)" ]||[ -f "/usr/bin/curl" ]||[ -f "/bin/curl" ]; then
  111. :
  112. else
  113. echo -e "\e[0;31mFAIL\e[0m\n"
  114. echo "Curl is not installed!"
  115. echo -e ""
  116. exit
  117. fi
  118. curl=$(curl --fail -o "${filepath}" "${githuburl}" 2>&1)
  119. if [ $? -ne 0 ]; then
  120. echo -e "\e[0;31mFAIL\e[0m\n"
  121. echo "${curl}"
  122. echo -e "${githuburl}\n"
  123. exit
  124. else
  125. echo -e "\e[0;32mOK\e[0m"
  126. fi
  127. if [ "${exec}" ]; then
  128. chmod +x "${filepath}"
  129. fi
  130. fi
  131. if [ "${exec}" ]; then
  132. source "${filepath}"
  133. fi
  134. }
  135.  
  136. fn_runfunction(){
  137. fn_getgithubfile "functions/${functionfile}" 1
  138. }
  139.  
  140. core_functions.sh(){
  141. # Functions are defined in core_functions.sh.
  142. functionfile="${FUNCNAME}"
  143. fn_runfunction
  144. }
  145.  
  146. core_functions.sh
  147.  
  148. getopt=$1
  149. core_getopt.sh
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement