Advertisement
Guest User

Untitled

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