Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
76 changes: 46 additions & 30 deletions functions/check.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,40 +7,56 @@ lgsm_version="271215"
# Description: Overall function for managing checks.
# Runs checks that will either halt on or fix an issue.

fn_module_compare() {
local e
for e in "${@:2}"; do [[ "$e" == "$1" ]] && return 0; done
return 1
array_contains () {
local seeking=$1; shift
local in=1
for element; do
if [ ${element} == ${seeking} ]; then
in=0
break
fi
done
return $in
}


check_root.sh

if [ "${cmd}" != "install" ]; then
if [ "${function_selfname}" != "command_install.sh" ]; then
check_systemdir.sh
fi

no_check_logs=( debug details install map-compressor )
fn_module_compare "${cmd}" "${no_check_logs[@]}"
if [ $? != 0 ]; then
check_logs.sh
fi

check_ip=( debug )
fn_module_compare "${cmd}" "${no_check_logs[@]}"
if [ $? != 0 ]; then
check_ip.sh
fi

check_ip=( debug )
fn_module_compare "${cmd}" "${no_check_logs[@]}"
if [ $? != 0 ]; then
check_steamuser.sh
check_steamcmd.sh
fi

check_ip=( start )
fn_module_compare "${cmd}" "${no_check_logs[@]}"
if [ $? != 0 ]; then
check_tmux.sh
fi
local allowed_commands_array=( command_backup.sh command_console.sh command_debug.sh command_details.sh command_unreal2_maps.sh command_ut99_maps.sh command_monitor.sh command_start.sh command_stop.sh update_check.sh command_validate.sh update_functions.sh command_email_test.sh )
for allowed_command in "${allowed_commands_array[@]}"
do
if [ "${allowed_command}" == "${function_selfname}" ]; then
check_logs.sh
fi
done

local allowed_commands_array=( command_debug.sh command_details.sh command_monitor.sh command_start.sh command_stop.sh )
for allowed_command in "${allowed_commands_array[@]}"
do
if [ "${allowed_command}" == "${function_selfname}" ]; then
check_ip.sh
fi
done

local allowed_commands_array=( command_debug.sh command_start.sh command_stop.sh update_check.sh command_validate.sh )
for allowed_command in "${allowed_commands_array[@]}"
do
if [ "${allowed_command}" == "${function_selfname}" ]; then
if [ "${gamename}" == "Unreal Tournament 99" ]||[ "${gamename}" == "Unreal Tournament 2004" ]||[ "${gamename}" == "Mumble" ]||[ "${gamename}" == "Teamspeak 3" ]; then
: # These servers do not require SteamCMD. Check is skipped.
else
check_steamcmd.sh
fi
fi
done

local allowed_commands_array=( command_console.sh command_start.sh command_stop.sh )
for allowed_command in "${allowed_commands_array[@]}"
do
if [ "${allowed_command}" == "${function_selfname}" ]; then
check_tmux.sh
fi
done
42 changes: 23 additions & 19 deletions functions/check_ip.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,25 +7,29 @@ lgsm_version="271215"
# 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".

if [ ! -f "/bin/ip" ]; then
ipcommand="/sbin/ip"
if [ "${gamename}" == "Teamspeak 3" ]; then
:
else
ipcommand="ip"
fi
getip=$(${ipcommand} -o -4 addr|awk '{print $4}'|grep -oe '\([0-9]\{1,3\}\.\?\)\{4\}'|grep -v 127.0.0)
getipwc=$(${ipcommand} -o -4 addr|awk '{print $4}'|grep -oe '\([0-9]\{1,3\}\.\?\)\{4\}'|grep -vc 127.0.0)

if [ "${ip}" == "0.0.0.0" ]||[ "${ip}" == "" ]; then
if [ "${getipwc}" -ge "2" ]; then
fn_printwarn "Multiple active network interfaces found.\n\n"
echo -en "Manually specify the IP you want to use within the ${selfname} script.\n"
echo -en "Set ip=\"0.0.0.0\" to one of the following:\n"
echo -en "${getip}\n"
echo -en ""
echo -en "http://gameservermanagers.com/network-interfaces"
echo -en ""
exit 1
if [ ! -f "/bin/ip" ]; then
ipcommand="/sbin/ip"
else
ip=${getip}
ipcommand="ip"
fi
getip=$(${ipcommand} -o -4 addr|awk '{print $4}'|grep -oe '\([0-9]\{1,3\}\.\?\)\{4\}'|grep -v 127.0.0)
getipwc=$(${ipcommand} -o -4 addr|awk '{print $4}'|grep -oe '\([0-9]\{1,3\}\.\?\)\{4\}'|grep -vc 127.0.0)

if [ "${ip}" == "0.0.0.0" ]||[ "${ip}" == "" ]; then
if [ "${getipwc}" -ge "2" ]; then
fn_printwarn "Multiple active network interfaces found.\n\n"
echo -en "Manually specify the IP you want to use within the ${selfname} script.\n"
echo -en "Set ip=\"0.0.0.0\" to one of the following:\n"
echo -en "${getip}\n"
echo -en ""
echo -en "http://gameservermanagers.com/network-interfaces"
echo -en ""
exit 1
else
ip=${getip}
fi
fi
fi
fi
3 changes: 3 additions & 0 deletions functions/check_root.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,8 @@ lgsm_version="271215"

if [ $(whoami) = "root" ]; then
fn_printfailnl "Do NOT run this script as root!"
if [ -d "${scriptlogdir}" ]; then
fn_scriptlog "${selfname} attempted to run as root."
fi
exit 1
fi
24 changes: 21 additions & 3 deletions functions/check_steamcmd.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,32 @@
# LGSM check_steamcmd.sh function
# Author: Daniel Gibbs
# Website: http://gameservermanagers.com
lgsm_version="271215"
lgsm_version="281215"

# Description: Downloads SteamCMD on install and checks if missing before running functions that require SteamCMD


if [ "${gamename}" == "Unreal Tournament 99" ]||[ "${gamename}" == "Unreal Tournament 2004" ]; then
if [ "${gamename}" == "Unreal Tournament 99" ]||[ "${gamename}" == "Unreal Tournament 2004" ]||[ "${gamename}" == "Mumble" ]||[ "${gamename}" == "Teamspeak 3" ]; then
: # These servers do not require SteamCMD. Check is skipped.
elif [ "${modulename}" == "Starting" ]||[ "${modulename}" == "Update" ]||[ "${modulename}" == "Validate" ]; then
else
# Checks steamuser is setup.
if [ "${steamuser}" == "username" ]; then
fn_printfailnl "Steam login not set. Update steamuser."
echo " * Change steamuser=\"username\" to a valid steam login."
if [ -d ${scriptlogdir} ]; then
fn_scriptlog "edit ${selfname}. change steamuser=\"username\" to a valid steam login."
exit 1
fi
fi
if [ -z "${steamuser}" ]; then
fn_printwarnnl "Steam login not set. Using anonymous login."
if [ -d "${scriptlogdir}" ]; then
fn_scriptlog "Steam login not set. Using anonymous login."
fi
steamuser="anonymous"
steampass=""
sleep 2
fi
# Checks if SteamCMD exists when starting or updating a server.
# Re-installs if missing.
steamcmddir="${rootdir}/steamcmd"
Expand Down
3 changes: 3 additions & 0 deletions functions/check_systemdir.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,8 @@ lgsm_version="271215"

if [ ! -d "${systemdir}" ]; then
fn_printfailnl "Cannot access ${systemdir}: No such directory"
if [ -d "${scriptlogdir}" ]; then
fn_scriptlog "Cannot access ${systemdir}: No such directory."
fi
exit 1
fi
5 changes: 3 additions & 2 deletions functions/command_backup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,9 @@ lgsm_version="271215"
# Description: Creates a .tar.gz file in the backup directory.

local modulename="Backup"
check_root.sh
check_systemdir.sh
function_selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))"

check.sh
backupname="${servicename}-$(date '+%Y-%m-%d-%H%M%S')"
echo ""
echo "${gamename} Backup"
Expand Down
6 changes: 3 additions & 3 deletions functions/command_console.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,9 @@ lgsm_version="271215"
# Description: Gives access to the server tmux console.

local modulename="Console"
check_root.sh
check_systemdir.sh
function_selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))"

check.sh
echo ""
echo "${gamename} Console"
echo "============================"
Expand All @@ -26,7 +27,6 @@ esac
done
fn_printdots "Starting"
sleep 1
check_tmux.sh
tmuxwc=$(tmux list-sessions 2>&1|awk '{print $1}'|grep -v failed|grep -Ec "^${servicename}:")
if [ "${tmuxwc}" -eq 1 ]; then
fn_printoknl "Starting"
Expand Down
7 changes: 3 additions & 4 deletions functions/command_debug.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,9 @@ lgsm_version="271215"
# Description: Runs the server without tmux. Runs direct from the terminal.

local modulename="Debug"
check_root.sh
check_systemdir.sh
check_ip.sh
check_logs.sh
function_selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))"

check.sh
info_distro.sh
fn_parms
echo ""
Expand Down
Loading