diff --git a/.gitignore b/.gitignore
index 2b0bcabc1..59c91bc99 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,2 +1,6 @@
*.db
-.idea
\ No newline at end of file
+.idea
+*/functions/*
+*/cfg/servers/*
+*/lgsm/*
+
diff --git a/GarrysMod/addons.sh b/GarrysMod/addons.sh
new file mode 100755
index 000000000..8eb0888ec
--- /dev/null
+++ b/GarrysMod/addons.sh
@@ -0,0 +1,125 @@
+#!/bin/bash
+#
+# This is a temporary tool which I am using to look into Git cloning of addons.
+# The list lives in this script for the time being, and this is not ready for production!
+
+# Root directory where addons live. Create it if missing.
+addons_root=~/serverfiles/garrysmod/addons
+if [ ! -e $addons_root ]
+then
+ mkdir -p $addons_root
+fi
+
+# Git protocol to use for fetching repos, options are "ssh" and "https"
+git_protocol="ssh"
+
+# List of addons to manage, an array of comma-delimted strings. Format is user,repo,branch,method
+addons_list=(
+ "nrlulz,ACF,master,zip",
+ "wiremod,advdupe2,master,tarball",
+ "wiremod,wire,master,clone"
+)
+
+# Program flow
+
+for addon_data in ${addons_list[@]}
+do
+ # Split addon data into separate fields
+ IFS=, read githubuser githubrepo githubbranch gitmethod <<< "${addon_data}"
+ echo "Managing ${githubuser}/${githubrepo}..."
+
+ # Get current release
+ current_release_url="https://api.github.com/repos/${githubuser}/${githubrepo}/git/refs/heads/${githubbranch}"
+ current_release=$(curl -s -L $current_release_url | grep '"sha"' | cut -d'"' -f4)
+
+ # Addon path has the repo name in lower-case for gmod linux weirdness
+ addon_lcase=$(echo $githubrepo | tr '[:upper:]' '[:lower:]')
+ addon_path="${addons_root}/${addon_lcase}"
+
+ # Archive type to download
+ # Do the update/install
+ case "${gitmethod}" in
+ # Allow archive download/deployment as one method of installation
+ tar|tarball|archive|download|zip|zipfile|zipball)
+ if [ "${gitmethod}" == "zip" ] || [ "${gitmethod}" == "zipfile" ] || [ "${gitmethod}" == "zipball" ]
+ then
+ archive_format="zipball"
+ else
+ archive_format="tarball"
+ fi
+
+ echo "Using archive (${archive_format})"
+ # Download archive if it's not present. This will require we leave the archives in place, so we need to think about that
+ archive_url="https://github.com/${githubuser}/${githubrepo}/${archive_format}/${githubbranch}"
+
+ # Get filename of latest archive, this includes the commit hash
+ archive_file="${addons_root}/$(curl -sLI $archive_url | grep -o -E '^Content-Disp.*filename=.*$' | sed -e 's/.*filename=//' -e 's/[\x01-\x1F\x7F]//g')"
+ archive_unpack=$(echo $archive_file | sed -e 's/\.\(tar\.gz\|tar\|zip\)$//g')
+ archive_linktarget=$(basename $archive_unpack)
+ # If the unpacked directory isn't there, download and deploy
+ # FIXME: There needs to be a better way of tracking installs that doesn't require leaving archives lying around. Cleanup would be good.
+ if [ ! -e $archive_unpack ]
+ then
+ # TODO: Should we uninstall or delete the old addon? Any configs or other data that need to be retained?
+ # TODO: Checksum the downloaded files and remove/retry if corrupt
+ echo "Fetching ${githubrepo} ($(basename $archive_file))..."
+ curl -s -L -o $archive_file $archive_url
+ if [ "${archive_format}" == "zipfile" ]
+ then
+ # Unzip file
+ unzip $archive_file -d $addons_path
+ else
+ # Untar. FIXME: Assuming gzip, should probably have a little logic here.
+ # This descends one directory so we get rid of the directory with the same name as the archive
+ tar xzvpf $archive_file -C $addons_path
+ fi
+ fi
+
+ # Update symlink. This will BLOW AWAY a real directory, may want to adjust that behavior.
+ if [ "$(basename $(readlink -f $addon_path))" != "${archive_linktarget}" ]
+ then
+ echo "Pointing ${addon_lcase} to ${archive_linktarget}"
+ ln -nsf $archive_linktarget "${addon_path}"
+ fi
+ ;;
+ # Otherwise, use Git natively
+ *)
+ echo "Using Native Git"
+ # Get repo URL based upon our protocol
+ if [ "${git_protocol}" == "ssh" ]
+ then
+ repo_url="git@github.com:${githubuser}/${githubrepo}.git"
+ else
+ repo_url="https://github.com/${githubuser}/${githubrepo}.git"
+ fi
+
+ # Clone repo if it does not exist
+ if [ ! -e $addon_path ]
+ then
+ cd $addons_root && git clone $repo_url $addon_lcase
+ fi
+
+ # Init repo if directory has no .git subdirectory
+ if [ ! -e $addon_path ]
+ then
+ cd $addons_root && git init
+ fi
+
+ # Check to make sure we have the right remote
+ repo_remote=$(cd $addon_path && git remote -v | grep '^origin' | grep '\(fetch\)' | awk '{print $2}')
+ if [ "${repo_remote}" != "${repo_url}" ]
+ then
+ # TODO: Possibly delete incorrect remotes?
+ cd $addon_path && git remote add -f -t $githubbranch -m $githubbranch origin $repo_url
+ fi
+
+ # Check to make sure we are on the latest commit
+ repo_commit=$(cd $addon_path && git show | head -n1 | awk '{print $2}')
+ if [ "${repo_commit}" != "${current_release}" ]
+ then
+ cd $addon_path && git pull origin $githubbranch
+ fi
+ ;;
+ esac
+ echo "Up to date"
+done
diff --git a/Insurgency/insserver b/Insurgency/insserver
old mode 100644
new mode 100755
index e43d5e752..4254ce3c6
--- a/Insurgency/insserver
+++ b/Insurgency/insserver
@@ -3,137 +3,163 @@
# Server Management Script
# Author: Daniel Gibbs
# Website: http://gameservermanagers.com
-if [ -f ".dev-debug" ]; then
- exec 5>dev-debug.log
- BASH_XTRACEFD="5"
- set -x
-fi
-
-version="271215"
-#### Variables ####
-
-# Notification Email
-# (on|off)
-emailnotification="off"
-email="email@example.com"
-
-# Steam login
-steamuser="anonymous"
-steampass=""
-
-# Start Variables
-defaultmap="ministry"
-maxplayers="16"
-tickrate="64"
-port="27015"
-sourcetvport="27020"
-clientport="27005"
-ip="0.0.0.0"
-updateonstart="off"
-
-# https://developer.valvesoftware.com/wiki/Command_Line_Options#Source_Dedicated_Server
-fn_parms(){
-parms="-game insurgency -strictportbind -ip ${ip} -port ${port} +clientport ${clientport} +tv_port ${sourcetvport} -tickrate ${tickrate} +map ${defaultmap} +servercfgfile ${servercfg} -maxplayers ${maxplayers}"
-}
-
-#### Advanced Variables ####
+version="190116"
+# File fetching settings
# Github Branch Select
# Allows for the use of different function files
# from a different repo and/or branch.
-githubuser="dgibbs64"
+githubuser="jaredballou"
githubrepo="linuxgsm"
githubbranch="master"
-# Steam
-appid="237410"
+# Update stale files on the fly using Git
+git_update=0
+
+#### Variables ####
+
+# The name of this script file, used to show the LGSM link properly
+selfname=$(basename $(readlink -f "${BASH_SOURCE[0]}"))
-# Server Details
-servicename="ins-server"
-gamename="Insurgency"
-engine="source"
+# Name of this service (for symlinked instances)
+servicename="$(basename $0)"
# Directories
-rootdir="$(dirname $(readlink -f "${BASH_SOURCE[0]}"))"
-selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))"
-lockselfname=".${servicename}.lock"
-filesdir="${rootdir}/serverfiles"
-systemdir="${filesdir}/insurgency"
-executabledir="${filesdir}"
-executable="./srcds_linux"
-servercfg="${servicename}.cfg"
-servercfgdir="${systemdir}/cfg"
-servercfgfullpath="${servercfgdir}/${servercfg}"
-servercfgdefault="${servercfgdir}/lgsm-default.cfg"
-backupdir="${rootdir}/backups"
-
-# Logging
-logdays="7"
-gamelogdir="${systemdir}/logs"
-scriptlogdir="${rootdir}/log/script"
-consolelogdir="${rootdir}/log/console"
-
-scriptlog="${scriptlogdir}/${servicename}-script.log"
-consolelog="${consolelogdir}/${servicename}-console.log"
-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"
+
+# Script root
+rootdir="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
+# LGSM Support Files - set ro rootdir for old behavior
+lgsmdir="${rootdir}/lgsm"
+# Temporary path to store and manipulate settings
+settingsdir="${lgsmdir}/settings.tmp"
+# Supported Game Data
+gamedatadir="${lgsmdir}/cfg/gamedata"
+# Config path for local instances
+scriptcfgdir="${lgsmdir}/cfg/servers"
+# Temporary cache location
+cachedir="${lgsmdir}/tmp"
+
+# Git last commit file (for tracking updates)
+lastcommit_file="${cachedir}/lastcommit"
+
+
+# Debugging, if debugflag exists send output to $debuglog
+debugflag="${lgsmdir}/.dev-debug"
+debuglog="${lgsmdir}/dev-debug.log"
+if [ -f "${debugflag}" ]; then
+ exec 5>${debuglog}
+ BASH_XTRACEFD="5"
+ set -x
+fi
+
+#ipaddr=$(ip addr show $(ip route | grep '^default' | awk '{print $NF}') | grep 'inet ' | awk '{print $2}' | cut -f1 -d'/')
##### Script #####
# Do not edit
+# fn_colortext color msg
+# Display a message with a color code
+# Paremeters:
+# color: Numeric color code
+# msg: Message. This includes all further paremeters, so there is no need to quote a message with spaces in it.
+fn_colortext(){
+#Black 0;30 Dark Gray 1;30
+#Red 0;31 Light Red 1;31
+#Green 0;32 Light Green 1;32
+#Brown/Orange 0;33 Yellow 1;33
+#Blue 0;34 Light Blue 1;34
+#Purple 0;35 Light Purple 1;35
+#Cyan 0;36 Light Cyan 1;36
+#Light Gray 0;37 White 1;37
+ case "${1}" in
+ green)
+ color="\033[0;32m";;
+ yellow)
+ color="\033[0;33m";;
+ reset)
+ color="\033[0m";;
+ red)
+ color="\033[0;31m";;
+ *)
+ color="\033[0;${1}m";;
+ esac
+ echo -e "[${color}${@:2}\e[0m]"
+}
+
+# Set fetchcmd to the full path of whatever command we can to fetch files
+for fetchcmd in curl wget
+do
+ paths="$(command -v ${fetchcmd} 2>/dev/null) $(which ${fetchcmd} >/dev/null 2>&1) /usr/bin/${fetchcmd} /bin/${fetchcmd} /usr/sbin/${fetchcmd} /sbin/${fetchcmd} $(echo $PATH | sed "s/\([:]\|\$\)/\/${fetchcmd} /g")"
+ for tp in $paths
+ do
+ if [ -x $tp ]; then
+ fetchcmd=$tp
+ break 2
+ fi
+ done
+done
+# If we have no executable fetchcmd, fail script execution
+if [ ! -x "${fetchcmd}" ]; then
+ fn_colortext 31 FAIL
+ echo "Cannot find curl or wget!"
+ exit 1
+fi
+
+# fn_getgithubfile filename [exec] [url]
+# Download file from Github
+# Parameters:
+# filename: The path of the file in reference to the repository root
+# exec: Optional, set to 1 to make file executable
+# url: Optional, set to full path under repository root if different than filename
fn_getgithubfile(){
-filename=$1
-exec=$2
-fileurl=${3:-$filename}
-filepath="${rootdir}/${filename}"
-filedir=$(dirname "${filepath}")
-# If the function file is missing, then download
-if [ ! -f "${filepath}" ]; then
- if [ ! -d "${filedir}" ]; then
- mkdir "${filedir}"
- fi
- githuburl="https://raw.githubusercontent.com/${githubuser}/${githubrepo}/${githubbranch}/${fileurl}"
- echo -e " fetching ${filename}...\c"
- if [ "$(command -v curl)" ]||[ "$(which curl >/dev/null 2>&1)" ]||[ -f "/usr/bin/curl" ]||[ -f "/bin/curl" ]; then
- :
- else
- echo -e "\e[0;31mFAIL\e[0m\n"
- echo "Curl is not installed!"
- echo -e ""
- exit
+ filename=$1
+ exec=$2
+ fileurl=${3:-$filename}
+ force=$4
+ filepath="${lgsmdir}/${filename}"
+ filedir=$(dirname "${filepath}")
+
+ # If the function file is missing, then download
+ if [ ! -f "${filepath}" ] || [ "${force}" != "" ]; then
+ if [ ! -d "${filedir}" ]; then
+ mkdir -p "${filedir}"
+ fi
+ githuburl="https://raw.githubusercontent.com/${githubuser}/${githubrepo}/${githubbranch}/${fileurl}"
+ echo -ne " fetching ${filename} (${githuburl})... "
+ if [ "$(basename ${fetchcmd})" == "curl" ]; then
+ cmd="$fetchcmd -s --fail -o"
+ elif [ "$(basename ${fetchcmd})" == "wget" ]; then
+ cmd="$fetchcmd -O"
+ fi
+ fetch=$($cmd "${filepath}" "${githuburl}" 2>&1)
+ if [ "${exec}" != "" ]; then
+ chmod +x "${filepath}"
+ fi
+ fn_colortext 32 "DONE"
fi
- curl=$(curl --fail -o "${filepath}" "${githuburl}" 2>&1)
- if [ $? -ne 0 ]; then
- echo -e "\e[0;31mFAIL\e[0m\n"
- echo "${curl}"
- echo -e "${githuburl}\n"
- exit
- else
- echo -e "\e[0;32mOK\e[0m"
- fi
- if [ "${exec}" ]; then
- chmod +x "${filepath}"
+ if [ "${exec}" == "1" ]; then
+ source "${filepath}"
fi
-fi
-if [ "${exec}" ]; then
- source "${filepath}"
-fi
}
+# fn_runfunction
fn_runfunction(){
+ scriptfile=${1:-$functionfile}
+ functionfile=$scriptfile
fn_getgithubfile "functions/${functionfile}" 1
+ fn_check_github_files "${lgsmdir}" "${lgsmdir}/functions/${functionfile}"
}
-core_functions.sh(){
-# Functions are defined in core_functions.sh.
-functionfile="${FUNCNAME}"
-fn_runfunction
-}
+# Load GitHub hashing and updating functions
+fn_runfunction github_hash.sh
+
+# Process game configs and load variables needed to run script
+fn_runfunction game_settings.sh
-core_functions.sh
+# Load core functions
+fn_runfunction core_functions.sh
+# Get option from command line and run option parser
getopt=$1
core_getopt.sh
diff --git a/Insurgency/cfg/lgsm-default.cfg b/Insurgency/lgsm/cfg/lgsm-default.cfg
similarity index 100%
rename from Insurgency/cfg/lgsm-default.cfg
rename to Insurgency/lgsm/cfg/lgsm-default.cfg
diff --git a/Insurgency/dependencies/libc.so.6 b/Insurgency/lgsm/dependencies/libc.so.6
similarity index 100%
rename from Insurgency/dependencies/libc.so.6
rename to Insurgency/lgsm/dependencies/libc.so.6
diff --git a/Insurgency/dependencies/libm.so.6 b/Insurgency/lgsm/dependencies/libm.so.6
similarity index 100%
rename from Insurgency/dependencies/libm.so.6
rename to Insurgency/lgsm/dependencies/libm.so.6
diff --git a/Insurgency/dependencies/libpthread.so.0 b/Insurgency/lgsm/dependencies/libpthread.so.0
similarity index 100%
rename from Insurgency/dependencies/libpthread.so.0
rename to Insurgency/lgsm/dependencies/libpthread.so.0
diff --git a/Insurgency/dependencies/librt.so.1 b/Insurgency/lgsm/dependencies/librt.so.1
similarity index 100%
rename from Insurgency/dependencies/librt.so.1
rename to Insurgency/lgsm/dependencies/librt.so.1
diff --git a/Insurgency/manifest.sh b/Insurgency/manifest.sh
new file mode 100755
index 000000000..82b0864e9
--- /dev/null
+++ b/Insurgency/manifest.sh
@@ -0,0 +1,91 @@
+#!/bin/bash
+# LGSM git manifest functions
+# Author: Jared Ballou
+# Website: http://gameservermanagers.com
+#
+# This is another one of my POC tools. Eventually I want to have a pretty robust update/download system here
+# Goals:
+# * Keep function files up to date on client machines
+# * Deploy other programs or support tools
+# * Learn more about GitHub API
+# * Parse JSON in Bash
+
+# fn_getgithash filename
+# Calculate the Git hash for a file
+function fn_get_git_hash(){
+ filename=$1
+ if [ -e $filename ]
+ then
+ filesize=$(stat --format='%s' $filename)
+ if [ "$(tail -c1 $filename)" == "" ]; then
+ printf "blob %d\0%s\n" "${filesize}" "$(cat $filename)" | sha1sum | awk '{print $1}'
+ else
+ printf "blob %d\0%s" "${filesize}" "$(cat $filename)" | sha1sum | awk '{print $1}'
+ fi
+# printf "blob %d\0%s" "$(stat --format='%s' $filename)" "$(awk '{print $0}' $filename)" | sha1sum | awk '{print $1}'
+ fi
+}
+
+
+fn_githget_ub_manifest(){
+ # Create cache directory if missing
+ if [ ! -e "${cachedir}" ]
+ then
+ mkdir -p "${cachedir}"
+ fi
+ # Get latest commit from GitHub. Cache file for 60 minutes
+ if [ -e $lastcommit_file ]; then
+ if [ $(($(date +%s) - $(date -r ${lastcommit_file} +%s))) -gt 3600 ]; then
+ fetch=1
+ else
+ fetch=0
+ fi
+ else
+ fetch=1
+ fi
+ if [ $fetch -eq 1 ]; then
+ echo "Fetching ${lastcommit_file}"
+ curl -s "https://api.github.com/repos/${githubuser}/${githubrepo}/git/refs/heads/${githubbranch}" -o "${lastcommit_file}.json"
+ ${lgsmdir}/functions/jq-linux64 -r '.object.sha' "${lastcommit_file}.json" > "${lastcommit_file}"
+ fi
+ # Get manifest of all files at this revision in GitHub. These hashes are what we use to compare and select files that need to be updated.
+ manifest="${cachedir}/$(cat "${lastcommit_file}").manifest"
+ if [ ! -e "${manifest}.json" ]; then
+ curl -Ls "https://api.github.com/repos/${githubuser}/${githubrepo}/git/trees/${githubbranch}?recursive=1" -o "${manifest}.json"
+ fi
+ if [ ! -e "${manifest}" ]; then
+ ${lgsmdir}/functions/jq-linux64 -r '.tree[] | .path + " " + .sha' "${manifest}.json" > "${manifest}"
+ fi
+}
+# Check files against manifest
+fn_github_checkfiles(){
+ prefix=$1
+ files=${@:2}
+ fn_github_manifest
+ manifest="${cachedir}/$(cat "${lastcommit_file}").manifest"
+ # Check all files in functions for updates
+ for file in $files
+ do
+ if [ -d $file ]; then
+ echo "Descending into ${file}..."
+ fn_github_checkfiles "${prefix}" ${file}/*
+ else
+ myhash=$(fn_getgithash $file)
+ repofile=$(echo $file | sed -e "s|${1}[/]*||g")
+ githash=$(grep "^$repofile " $manifest 2>/dev/null| cut -d" " -f2)
+ if [ "${githash}" == "" ]
+ then
+ echo "Can't find ${repofile} in git!"
+ elif [ "${myhash}" != "${githash}" ]
+ then
+ echo "Would fetch ${repofile}: have ${myhash}, expected ${githash}"
+ else
+ echo "${repofile} is OK"
+ fi
+ fi
+ done
+}
+lgsmdir="./lgsm"
+cachedir="${lgsmdir}/tmp"
+lastcommit_file="${cachedir}/lastcommit"
+fn_github_checkfiles $lgsmdir ${lgsmdir}/functions
diff --git a/PiratesVikingandKnightsII/cfg/lgsm-default.cfg b/PiratesVikingsandKnightsII/cfg/lgsm-default.cfg
similarity index 100%
rename from PiratesVikingandKnightsII/cfg/lgsm-default.cfg
rename to PiratesVikingsandKnightsII/cfg/lgsm-default.cfg
diff --git a/PiratesVikingandKnightsII/pvkiiserver b/PiratesVikingsandKnightsII/pvkiiserver
similarity index 100%
rename from PiratesVikingandKnightsII/pvkiiserver
rename to PiratesVikingsandKnightsII/pvkiiserver
diff --git a/_MasterScript/lgsm-core b/_MasterScript/lgsm-core
new file mode 100755
index 000000000..4b8059683
--- /dev/null
+++ b/_MasterScript/lgsm-core
@@ -0,0 +1,177 @@
+#!/bin/bash
+# Insurgency
+# Server Management Script
+# Author: Daniel Gibbs
+# Website: http://gameservermanagers.com
+
+version="200116"
+
+# File fetching settings
+# Github Branch Select
+# Allows for the use of different function files
+# from a different repo and/or branch.
+githubuser="jaredballou"
+githubrepo="linuxgsm"
+githubbranch="master"
+
+# Update stale files on the fly using Git
+git_update=0
+
+#### Variables ####
+
+# The name of this script file, used to show the LGSM link properly
+selfname=$(basename $(readlink -f "${BASH_SOURCE[0]}"))
+
+# Name of this service (for symlinked instances)
+servicename="$(basename $0)"
+
+# Directories
+
+# Script root
+rootdir="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
+# LGSM Support Files - set ro rootdir for old behavior
+lgsmdir="${rootdir}/lgsm"
+# Temporary path to store and manipulate settings
+settingsdir="${lgsmdir}/settings.tmp"
+# Supported Game Data
+gamedatadir="${lgsmdir}/gamedata"
+# Config path for local instances
+scriptcfgdir="${lgsmdir}/cfg/servers"
+# Temporary cache location
+cachedir="${lgsmdir}/tmp"
+
+# Create all the directories we need
+for dir in $(grep '^[a-zA-Z0-9]*dir=' $0 | cut -d'=' -f1); do
+ if [ ! -e "${!dir}" ]; then
+ echo "Creating ${dir} at ${!dir}"
+ mkdir -p "${!dir}"
+ fi
+done
+# Git last commit file (for tracking updates)
+lastcommit_file="${cachedir}/lastcommit"
+
+
+# Debugging, if debugflag exists send output to $debuglog
+debugflag="${lgsmdir}/.dev-debug"
+debuglog="${lgsmdir}/dev-debug.log"
+if [ -f "${debugflag}" ]; then
+ exec 5>${debuglog}
+ BASH_XTRACEFD="5"
+ set -x
+fi
+
+#ipaddr=$(ip addr show $(ip route | grep '^default' | awk '{print $NF}') | grep 'inet ' | awk '{print $2}' | cut -f1 -d'/')
+
+##### Script #####
+# Do not edit
+
+# fn_colortext color msg
+# Display a message with a color code
+# Paremeters:
+# color: Numeric color code
+# msg: Message. This includes all further paremeters, so there is no need to quote a message with spaces in it.
+fn_colortext(){
+#Black 0;30 Dark Gray 1;30
+#Red 0;31 Light Red 1;31
+#Green 0;32 Light Green 1;32
+#Brown/Orange 0;33 Yellow 1;33
+#Blue 0;34 Light Blue 1;34
+#Purple 0;35 Light Purple 1;35
+#Cyan 0;36 Light Cyan 1;36
+#Light Gray 0;37 White 1;37
+ case "${1}" in
+ green)
+ color="\033[0;32m";;
+ yellow)
+ color="\033[0;33m";;
+ reset)
+ color="\033[0m";;
+ red)
+ color="\033[0;31m";;
+ *)
+ color="\033[0;${1}m";;
+ esac
+ echo -e "[${color}${@:2}\e[0m]"
+}
+
+# Set fetchcmd to the full path of whatever command we can to fetch files
+for fetchcmd in curl wget
+do
+ paths="$(command -v ${fetchcmd} 2>/dev/null) $(which ${fetchcmd} >/dev/null 2>&1) /usr/bin/${fetchcmd} /bin/${fetchcmd} /usr/sbin/${fetchcmd} /sbin/${fetchcmd} $(echo $PATH | sed "s/\([:]\|\$\)/\/${fetchcmd} /g")"
+ for tp in $paths
+ do
+ if [ -x $tp ]; then
+ fetchcmd=$tp
+ break 2
+ fi
+ done
+done
+# If we have no executable fetchcmd, fail script execution
+if [ ! -x "${fetchcmd}" ]; then
+ fn_colortext 31 FAIL
+ echo "Cannot find curl or wget!"
+ exit 1
+fi
+
+# fn_getgithubfile filename [exec] [url]
+# Download file from Github
+# Parameters:
+# filename: The path of the file in reference to the repository root
+# exec: Optional, set to 1 to make file executable
+# url: Optional, set to full path under repository root if different than filename
+fn_getgithubfile(){
+ filename=$1
+ exec=$2
+ fileurl=${3:-$filename}
+ force=$4
+ filepath="${lgsmdir}/${filename}"
+ filedir=$(dirname "${filepath}")
+
+ # If the function file is missing, then download
+ if [ ! -f "${filepath}" ] || [ "${force}" != "" ]; then
+ if [ ! -d "${filedir}" ]; then
+ mkdir -p "${filedir}"
+ fi
+ githuburl="https://raw.githubusercontent.com/${githubuser}/${githubrepo}/${githubbranch}/${fileurl}"
+ echo -ne " fetching ${filename} (${githuburl})... "
+ if [ "$(basename ${fetchcmd})" == "curl" ]; then
+ cmd="$fetchcmd -s --fail -o"
+ elif [ "$(basename ${fetchcmd})" == "wget" ]; then
+ cmd="$fetchcmd -O"
+ fi
+ fetch=$($cmd "${filepath}" "${githuburl}" 2>&1)
+ if [ "${exec}" != "" ]; then
+ chmod +x "${filepath}"
+ fi
+ fn_colortext 32 "DONE"
+ fi
+ if [ "${exec}" == "1" ]; then
+ source "${filepath}"
+ fi
+}
+
+# fn_runfunction
+fn_runfunction(){
+ scriptfile=${1:-$functionfile}
+ functionfile=$scriptfile
+ fn_getgithubfile "functions/${functionfile}" 1
+ fn_check_github_files "${lgsmdir}" "${lgsmdir}/functions/${functionfile}"
+}
+
+# Load GitHub hashing and updating functions
+fn_runfunction github_hash.sh
+
+# Load core functions
+fn_runfunction core_functions.sh
+
+if [ "${selfname}" == "lgsm-core" ];
+then
+ fn_runfunction install_lgsm.sh
+else
+ # Process game configs and load variables needed to run script
+ fn_runfunction game_settings.sh
+
+ # Get option from command line and run option parser
+ getopt=$1
+ core_getopt.sh
+fi
diff --git a/functions/check_root.sh b/functions/check_root.sh
index 8f2e5ed54..148ecb30b 100644
--- a/functions/check_root.sh
+++ b/functions/check_root.sh
@@ -4,7 +4,10 @@
# Website: http://gameservermanagers.com
lgsm_version="271215"
-if [ $(whoami) = "root" ]; then
+# If you want to run as root (i.e. in Docker, or just because you hate security)
+# set the following variable in your environment or config scripts.
+#I_KNOW_THIS_IS_A_BAD_IDEA=YES
+if [ $(whoami) = "root" ] && [ "${I_KNOW_THIS_IS_A_BAD_IDEA}" != "YES" ]; then
fn_printfailnl "Do NOT run this script as root!"
if [ -d "${scriptlogdir}" ]; then
fn_scriptlog "${selfname} attempted to run as root."
diff --git a/functions/command_backup.sh b/functions/command_backup.sh
index 5f923ad07..1f3baf924 100644
--- a/functions/command_backup.sh
+++ b/functions/command_backup.sh
@@ -49,7 +49,7 @@ sleep 1
echo -en "starting backup...\r"
sleep 1
echo -en "\n"
-cd "${rootdir}"
+cd "${lgsmdir}"
if [ ! -d "${backupdir}" ]; then
mkdir -v "${backupdir}"
fi
diff --git a/functions/command_dev_detect_deps.sh b/functions/command_dev_detect_deps.sh
index 30f89157d..e33fcbd1c 100644
--- a/functions/command_dev_detect_deps.sh
+++ b/functions/command_dev_detect_deps.sh
@@ -41,62 +41,62 @@ else
readelf=readelf
fi
-${readelf} -d ${executable} |grep NEEDED|awk '{ print $5 }'|sed 's/\[//g'|sed 's/\]//g' > "${rootdir}/.depdetect_readelf"
+${readelf} -d ${executable} |grep NEEDED|awk '{ print $5 }'|sed 's/\[//g'|sed 's/\]//g' > "${lgsmdir}/.depdetect_readelf"
-echo "yum install " > "${rootdir}/.depdetect_centos_list_uniq"
-echo "apt-get install " > "${rootdir}/.depdetect_ubuntu_list_uniq"
-echo "apt-get install " > "${rootdir}/.depdetect_debian_list_uniq"
+echo "yum install " > "${lgsmdir}/.depdetect_centos_list_uniq"
+echo "apt-get install " > "${lgsmdir}/.depdetect_ubuntu_list_uniq"
+echo "apt-get install " > "${lgsmdir}/.depdetect_debian_list_uniq"
while read lib; do
sharedlib=${lib}
if [ "${lib}" == "libm.so.6" ]||[ "${lib}" == "libc.so.6" ]||[ "${lib}" == "libpthread.so.0" ]||[ "${lib}" == "libdl.so.2" ]||[ "${lib}" == "libnsl.so.1" ]||[ "${lib}" == "libgcc_s.so.1" ]||[ "${lib}" == "librt.so.1" ]||[ "${lib}" == "ld-linux.so.2" ]; then
- echo "glibc.i686" >> "${rootdir}/.depdetect_centos_list"
- echo "lib32gcc1" >> "${rootdir}/.depdetect_ubuntu_list"
- echo "lib32gcc1" >> "${rootdir}/.depdetect_debian_list"
+ echo "glibc.i686" >> "${lgsmdir}/.depdetect_centos_list"
+ echo "lib32gcc1" >> "${lgsmdir}/.depdetect_ubuntu_list"
+ echo "lib32gcc1" >> "${lgsmdir}/.depdetect_debian_list"
elif [ "${lib}" == "libstdc++.so.6" ]; then
- echo "libstdc++.i686" >> "${rootdir}/.depdetect_centos_list"
- echo "libstdc++6:i386" >> "${rootdir}/.depdetect_ubuntu_list"
- echo "libstdc++6:i386" >> "${rootdir}/.depdetect_debian_list"
+ echo "libstdc++.i686" >> "${lgsmdir}/.depdetect_centos_list"
+ echo "libstdc++6:i386" >> "${lgsmdir}/.depdetect_ubuntu_list"
+ echo "libstdc++6:i386" >> "${lgsmdir}/.depdetect_debian_list"
elif [ "${lib}" == "libstdc++.so.5" ]; then
- echo "compat-libstdc++-33.i686" >> "${rootdir}/.depdetect_centos_list"
- echo "libstdc++5:i386" >> "${rootdir}/.depdetect_ubuntu_list"
- echo "libstdc++5:i386" >> "${rootdir}/.depdetect_debian_list"
+ echo "compat-libstdc++-33.i686" >> "${lgsmdir}/.depdetect_centos_list"
+ echo "libstdc++5:i386" >> "${lgsmdir}/.depdetect_ubuntu_list"
+ echo "libstdc++5:i386" >> "${lgsmdir}/.depdetect_debian_list"
elif [ "${lib}" == "libspeex.so.1" ]||[ "${lib}" == "libspeexdsp.so.1" ]; then
- echo "speex.i686" >> "${rootdir}/.depdetect_centos_list"
- echo "speex:i386" >> "${rootdir}/.depdetect_ubuntu_list"
- echo "speex:i386" >> "${rootdir}/.depdetect_debian_list"
+ echo "speex.i686" >> "${lgsmdir}/.depdetect_centos_list"
+ echo "speex:i386" >> "${lgsmdir}/.depdetect_ubuntu_list"
+ echo "speex:i386" >> "${lgsmdir}/.depdetect_debian_list"
elif [ "${lib}" == "./libSDL-1.2.so.0" ]||[ "${lib}" == "libSDL-1.2.so.0" ]; then
- echo "SDL.i686" >> "${rootdir}/.depdetect_centos_list"
- echo "libsdl1.2debian" >> "${rootdir}/.depdetect_ubuntu_list"
- echo "libsdl1.2debian" >> "${rootdir}/.depdetect_debian_list"
+ echo "SDL.i686" >> "${lgsmdir}/.depdetect_centos_list"
+ echo "libsdl1.2debian" >> "${lgsmdir}/.depdetect_ubuntu_list"
+ echo "libsdl1.2debian" >> "${lgsmdir}/.depdetect_debian_list"
elif [ "${lib}" == "libtbb.so.2" ]; then
- echo "tbb.i686" >> "${rootdir}/.depdetect_centos_list"
- echo "libtbb2" >> "${rootdir}/.depdetect_ubuntu_list"
- echo "libtbb2" >> "${rootdir}/.depdetect_debian_list"
+ echo "tbb.i686" >> "${lgsmdir}/.depdetect_centos_list"
+ echo "libtbb2" >> "${lgsmdir}/.depdetect_ubuntu_list"
+ echo "libtbb2" >> "${lgsmdir}/.depdetect_debian_list"
elif [ "${lib}" == "libtier0.so" ]||[ "${lib}" == "Core.so" ]||[ "${lib}" == "Editor.so" ]||[ "${lib}" == "Engine.so" ]||[ "${lib}" == "liblua.so" ]||[ "${lib}" == "libsteam_api.so" ]||[ "${lib}" == "ld-linux-x86-64.so.2" ]||[ "${lib}" == "libPhysX3_x86.so" ]||[ "${lib}" == "libPhysX3Common_x86.so" ]||[ "${lib}" == "libPhysX3Cooking_x86.so" ]; then
# Known shared libs what dont requires dependencies
:
else
unknownlib=1
- echo "${lib}" >> "${rootdir}/.depdetect_unknown"
+ echo "${lib}" >> "${lgsmdir}/.depdetect_unknown"
fi
-done < "${rootdir}/.depdetect_readelf"
-sort "${rootdir}/.depdetect_centos_list" | uniq >> "${rootdir}/.depdetect_centos_list_uniq"
-sort "${rootdir}/.depdetect_ubuntu_list" | uniq >> "${rootdir}/.depdetect_ubuntu_list_uniq"
-sort "${rootdir}/.depdetect_debian_list" | uniq >> "${rootdir}/.depdetect_debian_list_uniq"
+done < "${lgsmdir}/.depdetect_readelf"
+sort "${lgsmdir}/.depdetect_centos_list" | uniq >> "${lgsmdir}/.depdetect_centos_list_uniq"
+sort "${lgsmdir}/.depdetect_ubuntu_list" | uniq >> "${lgsmdir}/.depdetect_ubuntu_list_uniq"
+sort "${lgsmdir}/.depdetect_debian_list" | uniq >> "${lgsmdir}/.depdetect_debian_list_uniq"
if [ "${unknownlib}" == "1" ]; then
- sort "${rootdir}/.depdetect_unknown" | uniq >> "${rootdir}/.depdetect_unknown_uniq"
+ sort "${lgsmdir}/.depdetect_unknown" | uniq >> "${lgsmdir}/.depdetect_unknown_uniq"
fi
-awk -vORS=' ' '{ print $1, $2 }' "${rootdir}/.depdetect_centos_list_uniq" > "${rootdir}/.depdetect_centos_line"
-awk -vORS=' ' '{ print $1, $2 }' "${rootdir}/.depdetect_ubuntu_list_uniq" > "${rootdir}/.depdetect_ubuntu_line"
-awk -vORS=' ' '{ print $1, $2 }' "${rootdir}/.depdetect_debian_list_uniq" > "${rootdir}/.depdetect_debian_line"
+awk -vORS=' ' '{ print $1, $2 }' "${lgsmdir}/.depdetect_centos_list_uniq" > "${lgsmdir}/.depdetect_centos_line"
+awk -vORS=' ' '{ print $1, $2 }' "${lgsmdir}/.depdetect_ubuntu_list_uniq" > "${lgsmdir}/.depdetect_ubuntu_line"
+awk -vORS=' ' '{ print $1, $2 }' "${lgsmdir}/.depdetect_debian_list_uniq" > "${lgsmdir}/.depdetect_debian_line"
echo ""
echo "Required Dependencies"
@@ -105,46 +105,46 @@ echo "${executable}"
echo ""
echo "CentOS"
echo "================================="
-cat "${rootdir}/.depdetect_centos_line"
+cat "${lgsmdir}/.depdetect_centos_line"
echo ""
echo ""
echo "Ubuntu"
echo "================================="
-cat "${rootdir}/.depdetect_ubuntu_line"
+cat "${lgsmdir}/.depdetect_ubuntu_line"
echo ""
echo ""
echo "Debian"
echo "================================="
-cat "${rootdir}/.depdetect_debian_line"
+cat "${lgsmdir}/.depdetect_debian_line"
echo ""
if [ "${unknownlib}" == "1" ]; then
echo ""
echo "Unknown shared Library"
echo "================================="
- cat "${rootdir}/.depdetect_unknown"
+ cat "${lgsmdir}/.depdetect_unknown"
fi
echo ""
echo "Required Librarys"
echo "================================="
-sort "${rootdir}/.depdetect_readelf" |uniq
+sort "${lgsmdir}/.depdetect_readelf" |uniq
echo ""
echo "ldd"
echo "================================="
ldd ${executable}
echo -en "\n"
-rm -f "${rootdir}/.depdetect_centos_line"
-rm -f "${rootdir}/.depdetect_centos_list"
-rm -f "${rootdir}/.depdetect_centos_list_uniq"
+rm -f "${lgsmdir}/.depdetect_centos_line"
+rm -f "${lgsmdir}/.depdetect_centos_list"
+rm -f "${lgsmdir}/.depdetect_centos_list_uniq"
-rm -f "${rootdir}/.depdetect_debian_line"
-rm -f "${rootdir}/.depdetect_debian_list"
-rm -f "${rootdir}/.depdetect_debian_list_uniq"
+rm -f "${lgsmdir}/.depdetect_debian_line"
+rm -f "${lgsmdir}/.depdetect_debian_list"
+rm -f "${lgsmdir}/.depdetect_debian_list_uniq"
-rm -f "${rootdir}/.depdetect_ubuntu_line"
-rm -f "${rootdir}/.depdetect_ubuntu_list"
-rm -f "${rootdir}/.depdetect_ubuntu_list_uniq"
+rm -f "${lgsmdir}/.depdetect_ubuntu_line"
+rm -f "${lgsmdir}/.depdetect_ubuntu_list"
+rm -f "${lgsmdir}/.depdetect_ubuntu_list_uniq"
-rm -f "${rootdir}/.depdetect_readelf"
+rm -f "${lgsmdir}/.depdetect_readelf"
-rm -f "${rootdir}/.depdetect_unknown"
-rm -f "${rootdir}/.depdetect_unknown_uniq"
\ No newline at end of file
+rm -f "${lgsmdir}/.depdetect_unknown"
+rm -f "${lgsmdir}/.depdetect_unknown_uniq"
diff --git a/functions/command_monitor.sh b/functions/command_monitor.sh
index f253abc54..0a691866b 100644
--- a/functions/command_monitor.sh
+++ b/functions/command_monitor.sh
@@ -16,7 +16,7 @@ logs.sh
fn_printdots "${servername}"
fn_scriptlog "${servername}"
sleep 1
-if [ ! -f "${rootdir}/${lockselfname}" ]; then
+if [ ! -f "${lgsmdir}/${lockselfname}" ]; then
fn_printinfo "Disabled: No lock file found"
fn_scriptlog "Disabled: No lock file found"
sleep 1
@@ -59,7 +59,7 @@ info_config.sh
fn_printdots "${servername}"
fn_scriptlog "${servername}"
sleep 1
-if [ ! -f "${rootdir}/${lockselfname}" ]; then
+if [ ! -f "${lgsmdir}/${lockselfname}" ]; then
fn_printinfo "Disabled: No lock file found"
fn_scriptlog "Disabled: No lock file found"
sleep 1
diff --git a/functions/command_start.sh b/functions/command_start.sh
index 309a8078f..ebd38b76b 100644
--- a/functions/command_start.sh
+++ b/functions/command_start.sh
@@ -53,7 +53,7 @@ fi
mv "${scriptlog}" "${scriptlogdate}"
# Create lock file
-date > "${rootdir}/${lockselfname}"
+date > "${lgsmdir}/${lockselfname}"
cd "${executabledir}"
if [ "${ts3serverpass}" == "1" ];then
./ts3server_startscript.sh start serveradmin_password="${newpassword}"
@@ -65,7 +65,7 @@ info_ts3status.sh
if [ "${ts3status}" = "Server seems to have died" ]||[ "${ts3status}" = "No server running (ts3server.pid is missing)" ]; then
fn_printfailnl "Unable to start ${servername}"
fn_scriptlog "Unable to start ${servername}"
- echo -e " Check log files: ${rootdir}/log"
+ echo -e " Check log files: ${lgsmdir}/log"
exit 1
else
fn_printok "${servername}"
@@ -112,7 +112,7 @@ if [ "${tmuxwc}" -eq 1 ]; then
fi
# Create lock file
-date > "${rootdir}/${lockselfname}"
+date > "${lgsmdir}/${lockselfname}"
cd "${executabledir}"
tmux new-session -d -s "${servicename}" "${executable} ${parms}" 2> "${scriptlogdir}/.${servicename}-tmux-error.tmp"
# tmux pipe-pane not supported in tmux versions < 1.6
diff --git a/functions/command_stop.sh b/functions/command_stop.sh
index 98d21c9a5..1c4304be0 100644
--- a/functions/command_stop.sh
+++ b/functions/command_stop.sh
@@ -44,7 +44,7 @@ else
fn_scriptlog "Stopped ${servername}"
fi
# Remove lock file
-rm -f "${rootdir}/${lockselfname}"
+rm -f "${lgsmdir}/${lockselfname}"
sleep 1
echo -en "\n"
}
@@ -147,7 +147,7 @@ else
fi
fi
# Remove lock file
- rm -f "${rootdir}/${lockselfname}"
+ rm -f "${lgsmdir}/${lockselfname}"
sleep 1
echo -en "\n"
}
@@ -156,4 +156,4 @@ if [ "${gamename}" == "Teamspeak 3" ]; then
fn_stop_teamspeak3
else
fn_stop_tmux
-fi
\ No newline at end of file
+fi
diff --git a/functions/core_functions.sh b/functions/core_functions.sh
index 560a2ee26..e8d522175 100644
--- a/functions/core_functions.sh
+++ b/functions/core_functions.sh
@@ -10,84 +10,84 @@ lgsm_version="060116"
#Legacy functions
fn_functions(){
-functionfile="${FUNCNAME}"
-fn_runfunction
+fn_runfunction "${FUNCNAME}"
+
}
fn_getopt(){
-functionfile="${FUNCNAME}"
-fn_runfunction
+fn_runfunction "${FUNCNAME}"
+
}
# Core
core_getopt.sh(){
-functionfile="${FUNCNAME}"
-fn_runfunction
+fn_runfunction "${FUNCNAME}"
+
}
core_messages.sh(){
-functionfile="${FUNCNAME}"
-fn_runfunction
+fn_runfunction "${FUNCNAME}"
+
}
# Command
command_console.sh(){
-functionfile="${FUNCNAME}"
-fn_runfunction
+fn_runfunction "${FUNCNAME}"
+
}
command_debug.sh(){
-functionfile="${FUNCNAME}"
-fn_runfunction
+fn_runfunction "${FUNCNAME}"
+
}
command_details.sh(){
-functionfile="${FUNCNAME}"
-fn_runfunction
+fn_runfunction "${FUNCNAME}"
+
}
command_email_test.sh(){
-functionfile="${FUNCNAME}"
-fn_runfunction
+fn_runfunction "${FUNCNAME}"
+
}
command_backup.sh(){
-functionfile="${FUNCNAME}"
-fn_runfunction
+fn_runfunction "${FUNCNAME}"
+
}
command_monitor.sh(){
-functionfile="${FUNCNAME}"
-fn_runfunction
+fn_runfunction "${FUNCNAME}"
+
}
command_start.sh(){
-functionfile="${FUNCNAME}"
-fn_runfunction
+fn_runfunction "${FUNCNAME}"
+
}
command_stop.sh(){
-functionfile="${FUNCNAME}"
-fn_runfunction
+fn_runfunction "${FUNCNAME}"
+
}
command_validate.sh(){
-functionfile="${FUNCNAME}"
-fn_runfunction
+fn_runfunction "${FUNCNAME}"
+
}
command_install.sh(){
-functionfile="${FUNCNAME}"
-fn_runfunction
+fn_runfunction "${FUNCNAME}"
+
}
command_ts3_server_pass.sh(){
-functionfile="${FUNCNAME}"
-fn_runfunction
+fn_runfunction "${FUNCNAME}"
+
}
fn_restart(){
@@ -102,196 +102,196 @@ command_start.sh
# Checks
check.sh(){
-functionfile="${FUNCNAME}"
-fn_runfunction
+fn_runfunction "${FUNCNAME}"
+
}
check_config.sh(){
-functionfile="${FUNCNAME}"
-fn_runfunction
+fn_runfunction "${FUNCNAME}"
+
}
check_ip.sh(){
-functionfile="${FUNCNAME}"
-fn_runfunction
+fn_runfunction "${FUNCNAME}"
+
}
check_logs.sh(){
-functionfile="${FUNCNAME}"
-fn_runfunction
+fn_runfunction "${FUNCNAME}"
+
}
check_root.sh(){
-functionfile="${FUNCNAME}"
-fn_runfunction
+fn_runfunction "${FUNCNAME}"
+
}
check_steamcmd.sh(){
-functionfile="${FUNCNAME}"
-fn_runfunction
+fn_runfunction "${FUNCNAME}"
+
}
check_steamuser.sh(){
-functionfile="${FUNCNAME}"
-fn_runfunction
+fn_runfunction "${FUNCNAME}"
+
}
check_systemdir.sh(){
-functionfile="${FUNCNAME}"
-fn_runfunction
+fn_runfunction "${FUNCNAME}"
+
}
check_tmux.sh(){
-functionfile="${FUNCNAME}"
-fn_runfunction
+fn_runfunction "${FUNCNAME}"
+
}
# Compress
compress_unreal2_maps.sh(){
-functionfile="${FUNCNAME}"
-fn_runfunction
+fn_runfunction "${FUNCNAME}"
+
}
compress_ut99_maps.sh(){
-functionfile="${FUNCNAME}"
-fn_runfunction
+fn_runfunction "${FUNCNAME}"
+
}
# Dev
command_dev_debug.sh(){
-functionfile="${FUNCNAME}"
-fn_runfunction
+fn_runfunction "${FUNCNAME}"
+
}
command_dev_detect_deps.sh(){
-functionfile="${FUNCNAME}"
-fn_runfunction
+fn_runfunction "${FUNCNAME}"
+
}
# Fix
fix.sh(){
-functionfile="${FUNCNAME}"
-fn_runfunction
+fn_runfunction "${FUNCNAME}"
+
}
fix_arma3.sh(){
-functionfile="${FUNCNAME}"
-fn_runfunction
+fn_runfunction "${FUNCNAME}"
+
}
fix_csgo.sh(){
-functionfile="${FUNCNAME}"
-fn_runfunction
+fn_runfunction "${FUNCNAME}"
+
}
fix_dst.sh(){
-functionfile="${FUNCNAME}"
-fn_runfunction
+fn_runfunction "${FUNCNAME}"
+
}
fix_ins.sh(){
-functionfile="${FUNCNAME}"
-fn_runfunction
+fn_runfunction "${FUNCNAME}"
+
}
fix_steamcmd.sh(){
-functionfile="${FUNCNAME}"
-fn_runfunction
+fn_runfunction "${FUNCNAME}"
+
}
fix_glibc.sh(){
-functionfile="${FUNCNAME}"
-fn_runfunction
+fn_runfunction "${FUNCNAME}"
+
}
fix_ro.sh(){
-functionfile="${FUNCNAME}"
-fn_runfunction
+fn_runfunction "${FUNCNAME}"
+
}
fix_kf.sh(){
-functionfile="${FUNCNAME}"
-fn_runfunction
+fn_runfunction "${FUNCNAME}"
+
}
fix_ut2k4.sh(){
-functionfile="${FUNCNAME}"
-fn_runfunction
+fn_runfunction "${FUNCNAME}"
+
}
# Info
info_config.sh(){
-functionfile="${FUNCNAME}"
-fn_runfunction
+fn_runfunction "${FUNCNAME}"
+
}
info_distro.sh(){
-functionfile="${FUNCNAME}"
-fn_runfunction
+fn_runfunction "${FUNCNAME}"
+
}
info_glibc.sh(){
-functionfile="${FUNCNAME}"
-fn_runfunction
+fn_runfunction "${FUNCNAME}"
+
}
info_ts3status.sh(){
-functionfile="${FUNCNAME}"
-fn_runfunction
+fn_runfunction "${FUNCNAME}"
+
}
# Email
email.sh(){
-functionfile="${FUNCNAME}"
-fn_runfunction
+fn_runfunction "${FUNCNAME}"
+
}
# Logs
logs.sh(){
-functionfile="${FUNCNAME}"
-fn_runfunction
+fn_runfunction "${FUNCNAME}"
+
}
# Monitor
monitor_gsquery.sh(){
-functionfile="${FUNCNAME}"
-fn_runfunction
+fn_runfunction "${FUNCNAME}"
+
}
# Update
update_check.sh(){
-functionfile="${FUNCNAME}"
-fn_runfunction
+fn_runfunction "${FUNCNAME}"
+
}
update_functions.sh(){
-functionfile="${FUNCNAME}"
-fn_runfunction
+fn_runfunction "${FUNCNAME}"
+
}
update_dl.sh(){
-functionfile="${FUNCNAME}"
-fn_runfunction
+fn_runfunction "${FUNCNAME}"
+
}
update_functions.sh(){
-functionfile="${FUNCNAME}"
-fn_runfunction
+fn_runfunction "${FUNCNAME}"
+
}
@@ -305,92 +305,94 @@ command_install.sh
}
install_complete.sh(){
-functionfile="${FUNCNAME}"
-fn_runfunction
+fn_runfunction "${FUNCNAME}"
+
}
install_config.sh(){
-functionfile="${FUNCNAME}"
-fn_runfunction
+fn_runfunction "${FUNCNAME}"
+
}
install_gsquery.sh(){
-functionfile="${FUNCNAME}"
-fn_runfunction
+fn_runfunction "${FUNCNAME}"
+
}
install_gslt.sh(){
-functionfile="${FUNCNAME}"
-fn_runfunction
+fn_runfunction "${FUNCNAME}"
+
}
install_header.sh(){
-functionfile="${FUNCNAME}"
-fn_runfunction
+fn_runfunction "${FUNCNAME}"
+
}
install_logs.sh(){
-functionfile="${FUNCNAME}"
-fn_runfunction
+fn_runfunction "${FUNCNAME}"
+
}
install_retry.sh(){
-functionfile="${FUNCNAME}"
-fn_runfunction
+fn_runfunction "${FUNCNAME}"
+
}
install_serverdir.sh(){
-functionfile="${FUNCNAME}"
-fn_runfunction
+fn_runfunction "${FUNCNAME}"
+
}
install_serverfiles.sh(){
-functionfile="${FUNCNAME}"
-fn_runfunction
+fn_runfunction "${FUNCNAME}"
+}
+install_sourcemod.sh(){
+fn_runfunction "${FUNCNAME}"
}
install_steamcmd.sh(){
-functionfile="${FUNCNAME}"
-fn_runfunction
+fn_runfunction "${FUNCNAME}"
+
}
install_ts3.sh(){
-functionfile="${FUNCNAME}"
-fn_runfunction
+fn_runfunction "${FUNCNAME}"
+
}
install_ts3db.sh(){
-functionfile="${FUNCNAME}"
-fn_runfunction
+fn_runfunction "${FUNCNAME}"
+
}
install_ut2k4.sh(){
-functionfile="${FUNCNAME}"
-fn_runfunction
+fn_runfunction "${FUNCNAME}"
+
}
install_dl_ut2k4.sh(){
-functionfile="${FUNCNAME}"
-fn_runfunction
+fn_runfunction "${FUNCNAME}"
+
}
install_ut2k4_key.sh(){
-functionfile="${FUNCNAME}"
-fn_runfunction
+fn_runfunction "${FUNCNAME}"
+
}
install_ut99.sh(){
-functionfile="${FUNCNAME}"
-fn_runfunction
+fn_runfunction "${FUNCNAME}"
+
}
install_dl_ut99.sh(){
-functionfile="${FUNCNAME}"
-fn_runfunction
+fn_runfunction "${FUNCNAME}"
+
}
fix_ut99.sh(){
-functionfile="${FUNCNAME}"
-fn_runfunction
+fn_runfunction "${FUNCNAME}"
+
}
# Calls on-screen messages
diff --git a/functions/core_getopt.sh b/functions/core_getopt.sh
index 95196d0ef..7bf402b33 100644
--- a/functions/core_getopt.sh
+++ b/functions/core_getopt.sh
@@ -41,6 +41,8 @@ case "$getopt" in
command_install.sh;;
ai|auto-install)
fn_autoinstall;;
+ sm|sourcemod)
+ install_sourcemod.sh;;
dd|depsdetect)
command_dev_detect_deps.sh;;
*)
@@ -65,6 +67,7 @@ case "$getopt" in
echo -e "\e[34mdebug\t\e[0mSee the output of the server directly to your terminal."
echo -e "\e[34minstall\t\e[0mInstall the server."
echo -e "\e[34mauto-install\t\e[0mInstall the server, without prompts."
+ echo -e "\e[34msourcemod\t\e[0mInstall SourceMod."
} | column -s $'\t' -t
esac
exit
@@ -424,4 +427,4 @@ elif [ "${engine}" == "unreal" ]; then
fn_getopt_unreal
else
fn_getopt_generic
-fi
\ No newline at end of file
+fi
diff --git a/functions/core_messages.sh b/functions/core_messages.sh
index 939e73889..d92228ec4 100644
--- a/functions/core_messages.sh
+++ b/functions/core_messages.sh
@@ -6,6 +6,18 @@ lgsm_version="271215"
# Description: Defines on-screen messages such as [ OK ] and how script logs look.
+# Print text center-aligned
+fn_print_center() {
+ columns="$(tput cols)"
+ line="$@"
+ printf "%*s\n" $(( (${#line} + columns) / 2)) "$line"
+}
+# Print horizontal line
+fn_print_horizontal(){
+ char="${1:-=}"
+ printf '%*s\n' "${COLUMNS:-$(tput cols)}" '' | tr ' ' "${char}"
+}
+
# Date and servicename for log files.
fn_scriptlog(){
if [ -n "${modulename}" ]; then
@@ -145,4 +157,4 @@ fn_printokeol(){
# FAIL for end of line
fn_printfaileol(){
echo -e "\e[0;31mFAIL\e[0m\n"
-}
\ No newline at end of file
+}
diff --git a/functions/fn_update_functions b/functions/fn_update_functions
index 185f44f5e..51964e14f 100644
--- a/functions/fn_update_functions
+++ b/functions/fn_update_functions
@@ -10,7 +10,7 @@ fn_printdots "Updating functions"
fn_scriptlog "Updating functions"
sleep 1
echo -ne "\n"
-rm -rfv "${rootdir}/functions/"*
+rm -rfv "${lgsmdir}/functions/"*
exitcode=$?
if [ "${exitcode}" == "0" ]; then
fn_printok "Updating functions"
@@ -19,4 +19,4 @@ else
fn_printokfail "Updating functions"
fn_scriptlog "Failure! Updating functions"
fi
-echo -ne "\n"
\ No newline at end of file
+echo -ne "\n"
diff --git a/functions/game_settings.sh b/functions/game_settings.sh
new file mode 100644
index 000000000..74af87f93
--- /dev/null
+++ b/functions/game_settings.sh
@@ -0,0 +1,146 @@
+#!/bin/bash
+# LGSM game_settings.sh function
+# Author: Jared Ballou
+# Website: http://gameservermanagers.com
+lgsm_version="180116"
+
+function_selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))"
+local modulename="Settings"
+
+# Config files
+cfg_file_default="${scriptcfgdir}/_default.cfg"
+cfg_file_common="${scriptcfgdir}/_common.cfg"
+cfg_file_instance="${scriptcfgdir}/${servicename}.cfg"
+
+# Config file headers
+cfg_header_all="# Your settings for all servers go in _common.cfg\n# Server-specific settings go into \$SERVER.cfg"
+cfg_header_default="# Default config - Changes will be overwritten by updates.\n${cfg_header_all}"
+cfg_header_common="# Common config - Will not be overwritten by script.\n${cfg_header_all}"
+cfg_header_instance="# Instance Config for ${servicename} - Will not be overwritten by script.\n${cfg_header_all}"
+
+
+# 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_update_config()
+{
+ key=$1
+ val=$2
+ cfg_file=${3:-$cfg_file_default}
+ comment=${4:-""}
+
+ # Get current key/value pair from file
+ exists=$(grep "^${key}=" $cfg_file 2>/dev/null)
+ exists_comment=$(echo $(echo $exists | cut -d'#' -f2-))
+ case "${val}" in
+ ""|"--UNSET--")
+ if [ "${exists}" != "" ]; then
+ echo "Removing ${key} from ${cfg_file}"
+ sed "/${key}=.*/d" -i $cfg_file
+ fi
+ return
+ ;;
+ "--EMPTY--")
+ val=""
+ ;;
+ esac
+ # Put " # " at beginning of comment if not empty
+ if [ "${comment}" != "" ]
+ then
+ comment=" # ${comment}"
+ else
+ if [ "${exists_comment}" != "" ]; then
+ comment=" # ${exists_comment}"
+ fi
+ fi
+
+ # Line to be put in
+ data="${key}=\"${val}\"${comment}"
+
+ # Check if key exists in config
+ if [ "${exists}" != "" ]; then
+ # If the line isn't the same as the parsed data line, replace it
+ if [ "${exists}" != "${data}" ]; then
+ #echo "Updating ${data} in ${cfg_file}"
+ sed -e "s%^${key}=.*\$%${data}%g" -i $cfg_file
+ #sed "/${key}=.*/${data}/" -i $cfg_file
+ fi
+ else
+ # If value does not exist, append to file
+ #echo "Adding ${data} to ${cfg_file}"
+ echo -ne "${data}\n" >> $cfg_file
+ fi
+}
+
+fn_create_config(){
+ cfg_type=${1:-default}
+ cfg_force=$2
+ cfg_file="cfg_file_${cfg_type}"
+ cfg_header="cfg_header_${cfg_type}"
+
+ cfg_dir=$(dirname ${!cfg_file})
+ #If config directory does not exist, create it
+ if [ ! -e $cfg_dir ]; then mkdir -p $cfg_dir; fi
+
+ # Create file header if needed
+ if [ ! -e ${!cfg_file} ] || [ "${cfg_force}" != "" ]; then
+ echo "Creating ${cfg_type} config at ${!cfg_file}"
+ echo -ne "${!cfg_header}\n\n" > ${!cfg_file}
+ # Dump in defaults for this game
+ if [ "${cfg_type}" == "default" ]; then
+ cat ${settingsdir}/settings >> ${!cfg_file}
+ fi
+ fi
+}
+
+fn_flush_game_settings(){
+ if [ -e $settingsdir ]; then
+ rm -rf $settingsdir > /dev/null
+ fi
+ mkdir -p $settingsdir
+}
+
+fn_import_game_settings(){
+ import="${gamedatadir}/${1}"
+ importdir=$(echo "${gamedatadir}" | sed -e "s|${lgsmdir}/||g")
+ #echo $importdir
+ if [ ! -e $import ]; then
+ fn_getgithubfile "${importdir}/${1}" 1 "gamedata/${1}"
+ fi
+ source $import
+}
+
+fn_set_game_params(){
+ param_set=$1
+ param_name=$2
+ param_value=$3
+ param_comment=$4
+ fn_update_config "${param_name}" "${param_value}" "${settingsdir}/${param_set}" "${param_comment}"
+}
+
+
+fn_get_game_params(){
+ param_set=$1
+ param_name=$2
+ param_default=$3
+}
+
+# Flush old setings buffer
+fn_flush_game_settings
+
+# Import this game's settings
+fn_import_game_settings $selfname
+
+# New method is to always run this function, it will overwrite defaults with whatever the new script values are
+cfg_version_default=$(grep '^lgsm_version="' "${cfg_file_default}" 2>&1 | cut -d'"' -f2)
+if [ "${cfg_version_default}" != "${version}" ]; then
+ fn_create_config default 1
+fi
+
+# Load defaults
+source $cfg_file_default
+
+# Load sitewide common settings (so that Git updates can safely overwrite default.cfg)
+if [ ! -f $cfg_file_common ]; then fn_create_config common; else source $cfg_file_common; fi
+
+# Load instance specific settings
+if [ ! -f $cfg_file_instance ]; then fn_create_config instance; else source $cfg_file_instance; fi
diff --git a/functions/github_hash.sh b/functions/github_hash.sh
new file mode 100755
index 000000000..e78450d58
--- /dev/null
+++ b/functions/github_hash.sh
@@ -0,0 +1,91 @@
+#!/bin/bash
+# LGSM git manifest functions
+# Author: Jared Ballou
+# Website: http://gameservermanagers.com
+#
+# This is another one of my POC tools. Eventually I want to have a pretty robust update/download system here
+# Goals:
+# * Keep function files up to date on client machines
+# * Deploy other programs or support tools
+# * Learn more about GitHub API
+# * Parse JSON in Bash
+
+# fn_get_git_hash $filename
+# Calculate the Git hash for a file
+function fn_get_git_hash(){
+ filename=$1
+ if [ -e $filename ]; then
+ gitcmd="$(which git)"
+ if [ -x "${gitcmd}" ]; then
+ $gitcmd hash-object "${filename}"
+ else
+ filesize=$(stat --format='%s' $filename)
+ if [ "$(tail -c1 $filename)" == "" ]; then
+ printf "blob %d\0%s\n" "${filesize}" "$(cat $filename)" | sha1sum | awk '{print $1}'
+ else
+ printf "blob %d\0%s" "${filesize}" "$(cat $filename)" | sha1sum | awk '{print $1}'
+ fi
+ fi
+ fi
+}
+
+fn_get_github_manifest(){
+ # Create cache directory if missing
+ if [ ! -e "${cachedir}" ]; then
+ mkdir -p "${cachedir}"
+ fi
+ fn_getgithubfile "functions/jq-linux64"
+ jq_path="${lgsmdir}/functions/jq-linux64"
+ chmod +x "${jq_path}"
+ # Get latest commit from GitHub. Cache file for 60 minutes
+ if [ -e $lastcommit_file ]; then
+ if [ $(($(date +%s) - $(date -r ${lastcommit_file} +%s))) -gt 3600 ]; then
+ fetch=1
+ else
+ fetch=0
+ fi
+ else
+ fetch=1
+ fi
+ if [ $fetch -eq 1 ]; then
+ echo "Fetching ${lastcommit_file}"
+ curl -s "https://api.github.com/repos/${githubuser}/${githubrepo}/git/refs/heads/${githubbranch}" -o "${lastcommit_file}.json"
+ "${jq_path}" -r '.object.sha' "${lastcommit_file}.json" > "${lastcommit_file}"
+ fi
+ # Get manifest of all files at this revision in GitHub. These hashes are what we use to compare and select files that need to be updated.
+ manifest="${cachedir}/$(cat "${lastcommit_file}").manifest"
+ if [ ! -e "${manifest}.json" ]; then
+ curl -Ls "https://api.github.com/repos/${githubuser}/${githubrepo}/git/trees/${githubbranch}?recursive=1" -o "${manifest}.json"
+ fi
+ if [ ! -e "${manifest}" ]; then
+ "${jq_path}" -r '.tree[] | .path + " " + .sha' "${manifest}.json" > "${manifest}"
+ fi
+}
+
+# Check files against manifest
+fn_check_github_files(){
+ # Return unless turned on
+ if [ "${git_update}" != "1" ]; then return; fi
+
+ prefix=$1
+ files=${@:2}
+ fn_get_github_manifest
+ manifest="${cachedir}/$(cat "${lastcommit_file}").manifest"
+ # Check all files in functions for updates
+ for file in $files; do
+ if [ -d $file ]; then
+ #echo "Descending into ${file}..."
+ fn_check_github_files "${prefix}" ${file}/*
+ else
+ myhash=$(fn_get_git_hash $file)
+ repofile=$(echo $file | sed -e "s|${1}[/]*||g")
+ githash=$(grep "^$repofile " $manifest 2>/dev/null| cut -d" " -f2)
+ if [ "${githash}" == "" ]; then
+ echo "Can't find ${repofile} in git!"
+ elif [ "${myhash}" != "${githash}" ]; then
+ #echo "Would fetch ${repofile}: have ${myhash}, expected ${githash}"
+ fn_getgithubfile "${repofile}" 0 "${repofile}" 1
+ fi
+ fi
+ done
+}
diff --git a/functions/install_gsquery.sh b/functions/install_gsquery.sh
index a113ea829..143357553 100644
--- a/functions/install_gsquery.sh
+++ b/functions/install_gsquery.sh
@@ -5,7 +5,7 @@
lgsm_version="271215"
fn_dlgsquery(){
-cd "${rootdir}"
+cd "${lgsmdir}"
echo -e "downloading gsquery.py...\c"
wget -N /dev/null "http://gameservermanagers.com/dl/gsquery.py" 2>&1 | grep -F "HTTP" | grep -v "Moved Permanently" | cut -c45- | uniq
chmod +x gsquery.py
diff --git a/functions/install_lgsm.sh b/functions/install_lgsm.sh
new file mode 100644
index 000000000..0eb1ee111
--- /dev/null
+++ b/functions/install_lgsm.sh
@@ -0,0 +1,45 @@
+#!/bin/bash
+# LGSM install_lgsm function
+# Author: Jared Ballou
+# Website: http://gameservermanagers.com
+lgsm_version="200116"
+
+# Description: Display menu of available games and install the one selected
+
+# Perform installation
+fn_runfunction menu.sh
+# Listing of available games
+gamelist="gamedata/__game_list"
+# Installation path
+installpath=$(cd ~ && pwd)
+# Get game list
+fn_getgithubfile $gamelist
+# Display installer menu
+fn_menu result "Linux Game Server Manager" "Select game to install" "${lgsmdir}/${gamelist}"
+# If we have a selection, do the install
+if [ -n "${result}" ]; then
+ # Confirm path for installation
+ read -p "Select path to install ${result} [${installpath}]: " input
+ installpath=${input:-$installpath}
+ scriptpath="${installpath}/${result}"
+ # If file exists, confirm overwrite
+ if [ -e "${scriptpath}" ]; then
+ read -p "WARNING! ${scriptpath} already exists! OVERWRITE!? [y/N]: " input
+ if [ "${input}" != "y" ] && [ "${input}" != "Y" ]; then exit; fi
+ fi
+ # Install script
+ echo -ne "Installing to ${scriptpath}... \c"
+ # Create directory if missing. TODO: Gravefully handle errors like giving a file as the install dir
+ if [ ! -e $(dirname "${scriptpath}") ]; then
+ mkdir -p $(dirname "${scriptpath}")
+ fi
+ # Copy script and set executable
+ cp "${0}" "${scriptpath}"
+ chmod 0755 "${scriptpath}"
+ if [ $? ]; then
+ fn_colortext green "Done"
+ echo "Script deployed to ${scriptpath}"
+ else
+ fn_colortext red "FAIL"
+ fi
+fi
diff --git a/functions/install_logs.sh b/functions/install_logs.sh
index 6496ad647..9d4dcaca2 100644
--- a/functions/install_logs.sh
+++ b/functions/install_logs.sh
@@ -11,7 +11,7 @@ if [ "${checklogs}" != "1" ]; then
fi
sleep 1
# Create dir's for the script and console logs
-mkdir -v "${rootdir}/log"
+mkdir -v "${lgsmdir}/log"
mkdir -v "${scriptlogdir}"
touch "${scriptlog}"
if [ -n "${consolelogdir}" ]; then
@@ -21,8 +21,8 @@ fi
# If a server is source or goldsource, Teamspeak 3, Starbound, Project Zomhoid create a symbolic link to the game server logs.
if [ "${engine}" == "source" ]||[ "${engine}" == "goldsource" ]||[ "${gamename}" == "Teamspeak 3" ]||[ "${engine}" == "starbound" ]||[ "${engine}" == "projectzomboid" ]; then
- if [ ! -h "${rootdir}/log/server" ]; then
- ln -nfsv "${gamelogdir}" "${rootdir}/log/server"
+ if [ ! -h "${lgsmdir}/log/server" ]; then
+ ln -nfsv "${gamelogdir}" "${lgsmdir}/log/server"
fi
fi
@@ -40,8 +40,8 @@ fi
# If server uses SteamCMD create a symbolic link to the Steam logs.
if [ -d "${rootdir}/Steam/logs" ]; then
- if [ ! -h "${rootdir}/log/steamcmd" ]; then
- ln -nfsv "${rootdir}/Steam/logs" "${rootdir}/log/steamcmd"
+ if [ ! -h "${lgsmdir}/log/steamcmd" ]; then
+ ln -nfsv "${rootdir}/Steam/logs" "${lgsmdir}/log/steamcmd"
fi
fi
-sleep 1
\ No newline at end of file
+sleep 1
diff --git a/functions/install_sourcemod.sh b/functions/install_sourcemod.sh
new file mode 100755
index 000000000..f6f7095b2
--- /dev/null
+++ b/functions/install_sourcemod.sh
@@ -0,0 +1,77 @@
+#!/bin/bash
+# LGSM install_sourcemod.sh
+# Author: Jared Ballou
+# Website: http://gameservermanagers.com
+
+# This downloads and installs the latest stable versions of MetaMod and SourceMod
+
+lgsm_version="200116"
+
+
+# MetaMod
+fn_install_metamod(){
+ # Get installation path for MetaMod
+ mm_path="${1:-"${systemdir}/addons/metamod"}"
+ mm_root=$(cd "$(dirname $(dirname "${mm_path}"))" && pwd)
+ if [ -e "${mm_path}" ]; then
+ read -p "WARNING! MetaMod exists at ${mm_path}! OVERWRITE!? [y/N]: " input
+ if [ "${input}" != "y" ] && [ "${input}" != "Y" ]; then return; fi
+ fi
+ # Download URL base
+ mm_url_base="http://www.sourcemm.net/downloads/"
+ # Get latest release file name
+ echo "Getting latest MetaMod version..."
+ mm_file_latest="$(curl -sL "${mm_url_base}" | grep -m1 -o "mmsource-[0-9\.a-zA-Z]*-linux\.tar\.gz")"
+ mm_file="${cachedir}/${mm_file_latest}"
+ # If file is not here, download it
+ if [ ! -e "${mm_file}" ]; then
+ echo -ne "Downloading ${mm_file_latest}... \c"
+ # Get mirror URLs
+ mm_file_urls="$(curl -sL "${mm_url_base}${mm_file_latest}" | grep -o -E 'href="http([^"#]+)mmsource-1.10.6-linux.tar.gz"' | cut -d'"' -f2)"
+ # Try each mirror
+ for url in $mm_file_urls; do
+ # Download file
+ curl -sL "${url}" -o "${mm_file}"
+ # If file downloaded, exit loop
+ if [ -e "${mm_file}" ]; then break; fi
+ done
+ if [ ! -e "${mm_file}" ]; then
+ fn_colortext red FAILED
+ exit 1
+ else
+ fn_colortext green DONE
+ fi
+ fi
+ # Unzip MetaMod to addons
+ tar -xzvpf "${mm_file}" -C "${mm_root}"
+}
+fn_install_sourcemod(){
+ # Get installation path for SourceMod
+ sm_path="${1:-"${systemdir}/addons/sourcemod"}"
+ sm_root=$(cd "$(dirname $(dirname "${sm_path}"))" && pwd)
+ if [ -e "${sm_path}" ]; then
+ read -p "WARNING! SourceMod exists at ${sm_path}! OVERWRITE!? [y/N]: " input
+ if [ "${input}" != "y" ] && [ "${input}" != "Y" ]; then return; fi
+ fi
+ # Install SourceMod to game server
+ sm_major_version="1.7"
+ sm_url_base="http://www.sourcemod.net/smdrop/${sm_major_version}/"
+ sm_url_latest="${sm_url_base}sourcemod-latest-linux"
+ sm_file_latest="$(curl -sL "${sm_url_latest}")"
+ sm_url_file="${sm_url_base}${sm_file_latest}"
+ sm_file="${cachedir}/${sm_file_latest}"
+ if [ ! -e "${sm_file}" ]; then
+ echo -ne "Downloading ${sm_file_latest}... \c"
+ curl -sL "${sm_url_file}" -o "${sm_file}"
+ if [ ! -e "${sm_file}" ]; then
+ fn_colortext red FAILED
+ exit 1
+ else
+ fn_colortext green DONE
+ fi
+ fi
+ # Unzip SourceMod to addons
+ tar -xzvpf "${sm_file}" -C "${sm_root}"
+}
+fn_install_metamod
+fn_install_sourcemod
diff --git a/functions/install_ts3.sh b/functions/install_ts3.sh
index 3860fbc50..252a4a4bc 100644
--- a/functions/install_ts3.sh
+++ b/functions/install_ts3.sh
@@ -48,7 +48,7 @@ if [ -z "${availablebuild}" ]; then
exit 1
fi
-cd "${rootdir}"
+cd "${lgsmdir}"
echo -e "downloading teamspeak3-server_linux-${ts3arch}-${availablebuild}.tar.gz...\c"
wget -N /dev/null http://dl.4players.de/ts/releases/${ts3_version_number}/teamspeak3-server_linux-${ts3arch}-${ts3_version_number}.tar.gz 2>&1 | grep -F HTTP | cut -c45-| uniq
sleep 1
@@ -65,7 +65,7 @@ else
exit $?
fi
echo -e "copying to ${filesdir}...\c"
-cp -R "${rootdir}/teamspeak3-server_linux-${ts3arch}/"* "${filesdir}" 2> ".${servicename}-cp-error.tmp"
+cp -R "${lgsmdir}/teamspeak3-server_linux-${ts3arch}/"* "${filesdir}" 2> ".${servicename}-cp-error.tmp"
local status=$?
if [ ${status} -eq 0 ]; then
echo "OK"
@@ -77,4 +77,4 @@ else
exit $?
fi
rm -f teamspeak3-server_linux-${ts3arch}-${availablebuild}.tar.gz
-rm -rf "${rootdir}/teamspeak3-server_linux-${ts3arch}"
+rm -rf "${lgsmdir}/teamspeak3-server_linux-${ts3arch}"
diff --git a/functions/jq-linux64 b/functions/jq-linux64
new file mode 100755
index 000000000..939227e58
Binary files /dev/null and b/functions/jq-linux64 differ
diff --git a/functions/menu.sh b/functions/menu.sh
new file mode 100644
index 000000000..0e7dce75a
--- /dev/null
+++ b/functions/menu.sh
@@ -0,0 +1,90 @@
+#!/bin/bash
+# LGSM fn_messages function
+# Author: Jared Ballou
+# Website: http://gameservermanagers.com
+lgsm_version="200116"
+
+# Description: Display menus and return selection
+
+# Display simple Bash menu
+fn_menu_bash() {
+ local resultvar=$1
+ title=$2
+ caption=$3
+ options=$4
+ fn_print_horizontal
+ fn_print_center $title
+ fn_print_center $caption
+ fn_print_horizontal
+ menu_options=()
+ while IFS='' read -r line || [[ -n "$line" ]]; do
+ menu_options+=( "${line}" )
+ done < $options
+ menu_options+=( "Cancel" )
+ select option in "${menu_options[@]}"; do
+ if [ -n "${option}" ] && [ "${option}" != "Cancel" ]; then
+ eval "$resultvar=\"${option/%\ */}\""
+ fi
+ break
+ done
+}
+
+# Draw menu using Whiptail
+fn_menu_whiptail() {
+ local menucmd=$1
+ local resultvar=$2
+ title=$3
+ caption=$4
+ options=$5
+ height=${6:-40}
+ width=${7:-80}
+ menuheight=${8:-30}
+ #whiptail --title "