Browse Source

Updated script to have central github fetch function, added lgsm_version variable to each function file to keep up to date

pull/548/head
Jared Ballou 10 years ago
parent
commit
809d7bcb63
  1. 2
      Insurgency/cfg/servers/_default.cfg
  2. 143
      Insurgency/insserver
  3. 4
      functions/fn_backup
  4. 2
      functions/fn_check_ip
  5. 4
      functions/fn_check_logs
  6. 4
      functions/fn_check_root
  7. 2
      functions/fn_check_steamcmd
  8. 2
      functions/fn_check_steamuser
  9. 4
      functions/fn_check_systemdir
  10. 4
      functions/fn_check_tmux
  11. 4
      functions/fn_check_ts3status
  12. 2
      functions/fn_compress_unreal2maps
  13. 2
      functions/fn_compress_ut99maps
  14. 2
      functions/fn_console
  15. 2
      functions/fn_csgofix
  16. 2
      functions/fn_debug
  17. 2
      functions/fn_deps_detect
  18. 2
      functions/fn_details
  19. 2
      functions/fn_details_config
  20. 2
      functions/fn_details_distro
  21. 2
      functions/fn_details_glibc
  22. 2
      functions/fn_email
  23. 2
      functions/fn_email_test
  24. 2
      functions/fn_functions
  25. 2
      functions/fn_getopt
  26. 2
      functions/fn_insfix
  27. 2
      functions/fn_install
  28. 2
      functions/fn_install_complete
  29. 2
      functions/fn_install_config
  30. 2
      functions/fn_install_glibcfix
  31. 2
      functions/fn_install_gsquery
  32. 2
      functions/fn_install_header
  33. 2
      functions/fn_install_kffix
  34. 2
      functions/fn_install_logs
  35. 2
      functions/fn_install_retry
  36. 2
      functions/fn_install_rofix
  37. 2
      functions/fn_install_serverdir
  38. 2
      functions/fn_install_serverfiles
  39. 2
      functions/fn_install_steamcmd
  40. 2
      functions/fn_install_steamfix
  41. 2
      functions/fn_install_ts3
  42. 2
      functions/fn_install_ut2k4
  43. 2
      functions/fn_install_ut2k4filesdl
  44. 2
      functions/fn_install_ut2k4fix
  45. 2
      functions/fn_install_ut2k4key
  46. 2
      functions/fn_install_ut99
  47. 2
      functions/fn_install_ut99filesdl
  48. 2
      functions/fn_install_ut99fix
  49. 2
      functions/fn_logs
  50. 2
      functions/fn_messages
  51. 2
      functions/fn_monitor
  52. 2
      functions/fn_monitor_query
  53. 2
      functions/fn_start
  54. 2
      functions/fn_stop
  55. 2
      functions/fn_update_check
  56. 2
      functions/fn_update_dl
  57. 2
      functions/fn_update_functions
  58. 2
      functions/fn_validate

2
Insurgency/cfg/servers/_default.cfg

@ -9,7 +9,7 @@ defaultmode="checkpoint"
email="[email protected]"
emailnotification="off" # (on|off)
ip="0.0.0.0"
lgsm_version="031115"
lgsm_version="061115"
logdays="7"
mapcyclefile="mapcycle.txt"
maxplayers="16"

143
Insurgency/insserver

@ -3,22 +3,27 @@
# Server Management Script
# Author: Daniel Gibbs
# Website: http://gameservermanagers.com
version="031115"
version="061115"
#### Variables ####
engine="source"
game="insurgency"
gamename="Insurgency"
#File fetching settings
githubuser="jballou"
githubrepo="linuxgsm"
githubbranch="master"
# The name of this script file, used to show the LGSM link properly
selfname=$(basename $(readlink -f "${BASH_SOURCE[0]}"))
servicename="$(basename $0)"
# Directories
rootdir="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
rootdir="$(dirname "${selfname}")"
scriptcfgdir="${rootdir}/cfg/servers"
# Settings to get before config parsing begins
engine="source"
game="insurgency"
gamename="Insurgency"
servicename="$(basename $0)"
#ipaddr=$(ip addr | grep 'state UP' -A2 | tail -n1 | awk '{print $2}' | cut -f1 -d'/')
@ -30,58 +35,6 @@ cfg_instance="${scriptcfgdir}/${servicename}.cfg"
#If config directory does not exist, create it
if [ ! -e $scriptcfgdir ]; then mkdir -p "$scriptcfgdir"; fi
# If default config does not exist, create it. This should come from Git, and will be overwritten by updates.
# Rather than try to wget it from Github or other fancy ways to get it, the simplest way to ensure it works is to simply create it here.
fn_create_default_config(){
cat <<'EOF' >> $cfg_default
# Default config - Changes will be overwritten by updates.
# Your settings for all servers go in _common.cfg
# Server-specific settings go into $SERVER.cfg
appid="237410"
beta="" #To enable beta, use " -beta beta"
clientport="27005"
defaultmap="ministry"
defaultmode="checkpoint"
email="[email protected]"
emailnotification="off" # (on|off)
ip="0.0.0.0"
lgsm_version="031115"
logdays="7"
mapcyclefile="mapcycle.txt"
maxplayers="16"
playlist="custom"
port="27015"
sourcetvport="27020"
srcds_parms=""
steampass=""
steamuser="anonymous"
updateonstart="off"
EOF
}
if [ ! -f $cfg_default ]
then
fn_create_default_config
fi
# Load defaults
source $cfg_default
#If defaults are from an older version, overwrite the file
if [ "${lgsm_version}" != "${version}" ]; then fn_create_default_config; fi
# Load sitewide common settings (so that Git updates can safely overwrite default.cfg)
if [ ! -f $cfg_common ]; then touch $cfg_common; else source $cfg_common; fi
# Load instance specific settings
if [ ! -f $cfg_instance ]; then touch $cfg_instance; else source $cfg_instance; fi
# Set the paramaters to send to srcds
# https://developer.valvesoftware.com/wiki/Command_Line_Options#Source_Dedicated_Server
fn_parms(){
#TODO: Put in some conditional logic to handle generating the parm string so we can make this a little less game specific
parms="-game ${game} -strictportbind -ip ${ip} -port ${port} +clientport ${clientport} +tv_port ${sourcetvport} +sv_playlist ${playlist} +mapcyclefile ${mapcyclefile}+servercfgfile ${servercfg} +map ${defaultmap} ${defaultmode} -maxplayers ${maxplayers} ${srcds_parms}"
}
#### Advanced Variables ####
# Directories
lockselfname=".${servicename}.lock"
@ -110,29 +63,71 @@ emaillog="${scriptlogdir}/${servicename}-email.log"
scriptlogdate="${scriptlogdir}/${servicename}-script-$(date '+%d-%m-%Y-%H-%M-%S').log"
consolelogdate="${consolelogdir}/${servicename}-console-$(date '+%d-%m-%Y-%H-%M-%S').log"
# Set the paramaters to send to srcds
# https://developer.valvesoftware.com/wiki/Command_Line_Options#Source_Dedicated_Server
fn_parms(){
#TODO: Put in some conditional logic to handle generating the parm string so we can make this a little less game specific
parms="-game ${game} -strictportbind -ip ${ip} -port ${port} -maxplayers ${maxplayers} ${srcds_parms} +clientport ${clientport} +tv_port ${sourcetvport} +sv_playlist ${playlist} +mapcyclefile ${mapcyclefile} +servercfgfile ${servercfg} +map ${defaultmap} ${defaultmode}"
}
##### Script #####
# Do not edit
fn_runfunction(){
functiondir="${rootdir}/functions"
functionpath="${functiondir}/${functionfile}"
# Functions are downloaded and run with this function
if [ ! -f "${functionpath}" ]; then
# cd "${rootdir}"
if [ ! -d "${functiondir}" ]; then
mkdir -p "${functiondir}"
fn_getgithubfile() {
filename=$1
exec=$2
url=${3:-$filename}
filepath="${rootdir}/${filename}"
filedir=$(dirname "${filepath}")
# If file is missing, then download
if [ ! -f "${filepath}" ]
then
download=1
else
# Get the lgsm_version from the file, and download if out of date
script_version=$(grep lgsm_version "${filepath}" 2>&1 | cut -d'=' -f2 | sed -e 's/"//g')
if [ "${script_version}" != "" ] && [ "${script_version}" != "${version}" ]
then
echo $script_version
download=1
fi
fi
if [ "$download" ]
then
if [ ! -d "${filedir}" ]; then
mkdir -p "${filedir}"
fi
echo -e " fetching ${filename}...\c"
wget -N /dev/null "https://raw.githubusercontent.com/${githubuser}/${githubrepo}/${githubbranch}/${url}" -O "${filepath}" 2>&1 | grep -F HTTP | cut -c45-
if [ "$exec" ]
then
chmod +x "${functionpath}"
fi
fi
echo -e " loading ${functionfile}...\c"
wget -N /dev/null "https://raw.githubusercontent.com/dgibbs64/linuxgsm/master/functions/${functionfile}" -O "${functionpath}" 2>&1 | grep -F HTTP | cut -c45-
chmod +x "${functionpath}"
fi
source "${functionpath}"
if [ "$exec" ]
then
source "${filepath}"
fi
}
# If default config does not exist, create it. This should come from Git, and will be overwritten by updates.
fn_getgithubfile "cfg/servers/_default.cfg" 1 "${gamename}/cfg/servers/_default.cfg"
# Load sitewide common settings (so that Git updates can safely overwrite default.cfg)
if [ ! -f $cfg_common ]; then touch $cfg_common; else source $cfg_common; fi
# Load instance specific settings
if [ ! -f $cfg_instance ]; then touch $cfg_instance; else source $cfg_instance; fi
fn_runfunction(){
fn_getgithubfile "functions/${functionfile}" 1
}
fn_functions(){
# Functions are defined in fn_functions.
functionfile="${FUNCNAME}"
fn_runfunction
# Functions are defined in fn_functions.
functionfile="${FUNCNAME}"
fn_runfunction
}
fn_functions

4
functions/fn_backup

@ -3,6 +3,8 @@
# Author: Daniel Gibbs
# Website: http://gameservermanagers.com
# Version: 311015
lgsm_version="061115"
# Description: Creates a .tar.gz file in the backup directory.
@ -58,4 +60,4 @@ sleep 1
echo ""
fn_printcompletenl "Complete."
fn_scriptlog "Complete"
echo ""
echo ""

2
functions/fn_check_ip

@ -3,6 +3,8 @@
# Author: Daniel Gibbs
# Website: http://gameservermanagers.com
# Version: 311015
lgsm_version="061115"
# Description: Automatically identifies the server interface IP.
# If multiple interfaces are detected the user will need to manualy set using ip="0.0.0.0".

4
functions/fn_check_logs

@ -3,6 +3,8 @@
# Author: Daniel Gibbs
# Website: http://gameservermanagers.com
# Version: 190515
lgsm_version="061115"
# Description: Checks that log files exist on server start
# Create dir's for the script and console logs
@ -13,4 +15,4 @@ if [ ! -d "${scriptlogdir}" ]; then
echo -en "\n"
checklogs=1
fn_install_logs
fi
fi

4
functions/fn_check_root

@ -3,8 +3,10 @@
# Author: Daniel Gibbs
# Website: http://gameservermanagers.com
# Version: 311015
lgsm_version="061115"
if [ $(whoami) = "root" ]; then
fn_printfailnl "Do NOT run this script as root!"
exit 1
fi
fi

2
functions/fn_check_steamcmd

@ -3,6 +3,8 @@
# Author: Daniel Gibbs
# Website: http://gameservermanagers.com
# Version: 210115
lgsm_version="061115"
# Description: Downloads SteamCMD on install and checks if missing before running functions that require SteamCMD

2
functions/fn_check_steamuser

@ -3,6 +3,8 @@
# Author: Daniel Gibbs
# Website: http://gameservermanagers.com
# Version: 040715
lgsm_version="061115"
if [ "${steamuser}" == "username" ]; then
fn_printfailnl "Steam login not set. Update steamuser."

4
functions/fn_check_systemdir

@ -3,8 +3,10 @@
# Author: Daniel Gibbs
# Website: http://gameservermanagers.com
# Version: 311015
lgsm_version="061115"
if [ ! -e "${systemdir}" ]; then
fn_printfailnl "Cannot access ${systemdir}: No such directory"
exit 1
fi
fi

4
functions/fn_check_tmux

@ -3,6 +3,8 @@
# Author: Daniel Gibbs
# Website: http://gameservermanagers.com
# Version: 311015
lgsm_version="061115"
# Checks if tmux is installed as too many users do not RTFM or know how to use Google.
@ -17,4 +19,4 @@ else
echo " * Please see the the following link."
echo " * http://gameservermanagers.com/tmux-not-found"
exit 127
fi
fi

4
functions/fn_check_ts3status

@ -3,8 +3,10 @@
# Author: Daniel Gibbs
# Website: http://gameservermanagers.com
# Version: 070215
lgsm_version="061115"
# Checks the status of Teamspeak 3.
cd "${executabledir}"
ts3status=$(./ts3server_startscript.sh status servercfgfullpathfile=${servercfgfullpath})
ts3status=$(./ts3server_startscript.sh status servercfgfullpathfile=${servercfgfullpath})

2
functions/fn_compress_unreal2maps

@ -3,6 +3,8 @@
# Author: Daniel Gibbs
# Website: http://gameservermanagers.com
# Version: 311015
lgsm_version="061115"
fn_check_root
clear

2
functions/fn_compress_ut99maps

@ -3,6 +3,8 @@
# Author: Daniel Gibbs
# Website: http://gameservermanagers.com
# Version: 311015
lgsm_version="061115"
fn_check_root
clear

2
functions/fn_console

@ -3,6 +3,8 @@
# Author: Daniel Gibbs
# Website: http://gameservermanagers.com
# Version: 311015
lgsm_version="061115"
# Description: Gives access to the server tmux console.

2
functions/fn_csgofix

@ -3,6 +3,8 @@
# Author: Daniel Gibbs
# Website: http://gameservermanagers.com
# Version: 210115
lgsm_version="061115"
# Description: Resolves various issues with csgo.

2
functions/fn_debug

@ -3,6 +3,8 @@
# Author: Daniel Gibbs
# Website: http://gameservermanagers.com
# Version: 311015
lgsm_version="061115"
# Description: Runs the server without tmux. Runs direct from the terminal.

2
functions/fn_deps_detect

@ -3,6 +3,8 @@
# Author: Daniel Gibbs
# Website: http://gameservermanagers.com
# Version: 290615
lgsm_version="061115"
# Description: Detects dependencies the server binary requires.

2
functions/fn_details

@ -3,6 +3,8 @@
# Author: Daniel Gibbs
# Website: http://gameservermanagers.com
# Version: 301015
lgsm_version="061115"
# Description: Displays server infomation.

2
functions/fn_details_config

@ -3,6 +3,8 @@
# Author: Daniel Gibbs
# Website: http://gameservermanagers.com
# Version: 301015
lgsm_version="061115"
# Description: Gets specific details from config files.

2
functions/fn_details_distro

@ -3,6 +3,8 @@
# Author: Daniel Gibbs
# Website: http://gameservermanagers.com
# Version: 301015
lgsm_version="061115"
# Description: Variables providing useful info on the Operating System such as disk and performace info.
# Used for fn_details, fn_debug and fn_email.

2
functions/fn_details_glibc

@ -3,6 +3,8 @@
# Author: Daniel Gibbs
# Website: http://gameservermanagers.com
# Version: 180715
lgsm_version="061115"
# Description: stores details on servers Glibc requirements.

2
functions/fn_email

@ -3,6 +3,8 @@
# Author: Daniel Gibbs
# Website: http://gameservermanagers.com
# Version: 290815
lgsm_version="061115"
# Description: Sends email notification if monitor picks up a failure.

2
functions/fn_email_test

@ -3,6 +3,8 @@
# Author: Daniel Gibbs
# Website: http://gameservermanagers.com
# Version: 210115
lgsm_version="061115"
# Description: Sends a test email notification.

2
functions/fn_functions

@ -3,6 +3,8 @@
# Author: Daniel Gibbs
# Website: http://gameservermanagers.com
# Version: 150715
lgsm_version="061115"
# Description: Defines all functions to allow download and execution of functions using fn_runfunction.
# This function is called first before any other function. Without this file other functions would not load.

2
functions/fn_getopt

@ -3,6 +3,8 @@
# Author: Daniel Gibbs
# Website: http://gameservermanagers.com
# Version: 011115
lgsm_version="061115"
# Description: getopt arguments.

2
functions/fn_insfix

@ -3,6 +3,8 @@
# Author: Daniel Gibbs
# Website: http://gameservermanagers.com
# Version: 110415
lgsm_version="061115"
# Description: Resolves ./srcds_linux: error while loading shared libraries: libtier0.so: cannot open shared object file: No such file or directory

2
functions/fn_install

@ -3,6 +3,8 @@
# Author: Daniel Gibbs
# Website: http://gameservermanagers.com
# Version: 190515
lgsm_version="061115"
fn_check_root
fn_install_header

2
functions/fn_install_complete

@ -3,6 +3,8 @@
# Author: Daniel Gibbs
# Website: http://gameservermanagers.com
# Version: 070715
lgsm_version="061115"
if [ "${gamename}" == "Dont Starve Together" ]; then
echo ""

2
functions/fn_install_config

@ -3,6 +3,8 @@
# Author: Daniel Gibbs
# Website: http://gameservermanagers.com
# Version: 291015
lgsm_version="061115"
fn_defaultconfig(){
echo "creating ${servercfg} config file."

2
functions/fn_install_glibcfix

@ -3,6 +3,8 @@
# Author: Daniel Gibbs
# Website: http://gameservermanagers.com
# Version: 301015
lgsm_version="061115"
fn_glibcfixmsg(){
echo ""

2
functions/fn_install_gsquery

@ -3,6 +3,8 @@
# Author: Daniel Gibbs
# Website: http://gameservermanagers.com
# Version: 070715
lgsm_version="061115"
fn_dlgsquery(){
cd "${rootdir}"

2
functions/fn_install_header

@ -3,6 +3,8 @@
# Author: Daniel Gibbs
# Website: http://gameservermanagers.com
# Version: 210115
lgsm_version="061115"
clear
echo "================================="

2
functions/fn_install_kffix

@ -3,6 +3,8 @@
# Author: Daniel Gibbs
# Website: http://gameservermanagers.com
# Version: 150515
lgsm_version="061115"
echo "Applying ${gamename} Server Fixes"
echo "================================="

2
functions/fn_install_logs

@ -3,6 +3,8 @@
# Author: Daniel Gibbs
# Website: http://gameservermanagers.com
# Version: 281015
lgsm_version="061115"
if [ "${checklogs}" != "1" ]; then
echo ""

2
functions/fn_install_retry

@ -3,6 +3,8 @@
# Author: Daniel Gibbs
# Website: http://gameservermanagers.com
# Version: 210115
lgsm_version="061115"
while true; do
read -p "Retry install? [y/N]" yn

2
functions/fn_install_rofix

@ -3,6 +3,8 @@
# Author: Daniel Gibbs
# Website: http://gameservermanagers.com
# Version: 150515
lgsm_version="061115"
echo "Applying ${gamename} Server Fixes"
echo "================================="

2
functions/fn_install_serverdir

@ -3,6 +3,8 @@
# Author: Daniel Gibbs
# Website: http://gameservermanagers.com
# Version: 240515
lgsm_version="061115"
echo ""
echo "Server Directory"

2
functions/fn_install_serverfiles

@ -3,6 +3,8 @@
# Author: Daniel Gibbs
# Website: http://gameservermanagers.com
# Version: 040715
lgsm_version="061115"
fn_steaminstallcommand(){
fn_check_steamuser

2
functions/fn_install_steamcmd

@ -3,6 +3,8 @@
# Author: Daniel Gibbs
# Website: http://gameservermanagers.com
# Version: 210115
lgsm_version="061115"
# Description: Downloads SteamCMD on install and checks if missing before running functions that require SteamCMD

2
functions/fn_install_steamfix

@ -3,6 +3,8 @@
# Author: Daniel Gibbs
# Website: http://gameservermanagers.com
# Version: 210115
lgsm_version="061115"
fn_steamclientfix(){
echo ""

2
functions/fn_install_ts3

@ -3,6 +3,8 @@
# Author: Daniel Gibbs
# Website: http://gameservermanagers.com
# Version: 311015
lgsm_version="061115"
fn_details_distro
# Gets the teamspeak server architecture

2
functions/fn_install_ut2k4

@ -3,6 +3,8 @@
# Author: Daniel Gibbs
# Website: http://gameservermanagers.com
# Version: 210115
lgsm_version="061115"
echo "Installing ${gamename} Server"
echo "================================="

2
functions/fn_install_ut2k4filesdl

@ -3,6 +3,8 @@
# Author: Daniel Gibbs
# Website: http://gameservermanagers.com
# Version: 210115
lgsm_version="061115"
echo "Downloading Server Files"
echo "================================="

2
functions/fn_install_ut2k4fix

@ -3,6 +3,8 @@
# Author: Daniel Gibbs
# Website: http://gameservermanagers.com
# Version: 150515
lgsm_version="061115"
echo "Applying ${gamename} Server Fixes"
echo "================================="

2
functions/fn_install_ut2k4key

@ -3,6 +3,8 @@
# Author: Daniel Gibbs
# Website: http://gameservermanagers.com
# Version: 210115
lgsm_version="061115"
echo "Enter ${gamename} CD Key"
echo "================================="

2
functions/fn_install_ut99

@ -3,6 +3,8 @@
# Author: Daniel Gibbs
# Website: http://gameservermanagers.com
# Version: 210115
lgsm_version="061115"
echo "Installing ${gamename} Server"
echo "================================="

2
functions/fn_install_ut99filesdl

@ -3,6 +3,8 @@
# Author: Daniel Gibbs
# Website: http://gameservermanagers.com
# Version: 210115
lgsm_version="061115"
echo "Downloading Server Files"
echo "================================="

2
functions/fn_install_ut99fix

@ -3,6 +3,8 @@
# Author: Daniel Gibbs
# Website: http://gameservermanagers.com
# Version: 070215
lgsm_version="061115"
echo "Applying ${gamename} Server Fixes"
echo "================================="

2
functions/fn_logs

@ -3,6 +3,8 @@
# Author: Daniel Gibbs
# Website: http://gameservermanagers.com
# Version: 030715
lgsm_version="061115"
# Description: Acts as a log rotater, removing old logs.

2
functions/fn_messages

@ -3,6 +3,8 @@
# Author: Daniel Gibbs
# Website: http://gameservermanagers.com
# Version: 260115
lgsm_version="061115"
# Description: Defines on-screen messages such as [ OK ] and how script logs look.

2
functions/fn_monitor

@ -3,6 +3,8 @@
# Author: Daniel Gibbs
# Website: http://gameservermanagers.com
# Version: 311015
lgsm_version="061115"
# Description: Monitors server by checking for running proccesses
# then passes to fn_monitor_query.

2
functions/fn_monitor_query

@ -3,6 +3,8 @@
# Author: Daniel Gibbs
# Website: http://gameservermanagers.com
# Version: 311015
lgsm_version="061115"
# Description: uses gsquery.py to directly query the server.
# Detects if the server has frozen.

2
functions/fn_start

@ -3,6 +3,8 @@
# Author: Daniel Gibbs
# Website: http://gameservermanagers.com
# Version: 301015
lgsm_version="061115"
# Description: Starts the server.

2
functions/fn_stop

@ -3,6 +3,8 @@
# Author: Daniel Gibbs
# Website: http://gameservermanagers.com
# Version: 261015
lgsm_version="061115"
# Description: Stops the server.

2
functions/fn_update_check

@ -3,6 +3,8 @@
# Author: Daniel Gibbs
# Website: http://gameservermanagers.com
# Version: 011115
lgsm_version="061115"
# Description: Checks if a server update is available.

2
functions/fn_update_dl

@ -3,6 +3,8 @@
# Author: Daniel Gibbs
# Website: http://gameservermanagers.com
# Version: 311015
lgsm_version="061115"
# Description: Runs a server update.

2
functions/fn_update_functions

@ -3,6 +3,8 @@
# Author: Daniel Gibbs
# Website: http://gameservermanagers.com
# Version: 190515
lgsm_version="061115"
# Description: Deletes the functions dir to allow re-downloading of functions from GitHub.

2
functions/fn_validate

@ -3,6 +3,8 @@
# Author: Daniel Gibbs
# Website: http://gameservermanagers.com
# Version: 040715
lgsm_version="061115"
# Description: Runs a server validation.

Loading…
Cancel
Save