From ff3017fd97aff1e5bf2c4e7cd99ef95054b43948 Mon Sep 17 00:00:00 2001 From: Daniel Gibbs Date: Mon, 28 Dec 2015 15:46:11 +0000 Subject: [PATCH 01/25] removed spaces --- functions/command_start.sh | 2 +- functions/info_config.sh | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/functions/command_start.sh b/functions/command_start.sh index 9c72ae108..424c69e4c 100644 --- a/functions/command_start.sh +++ b/functions/command_start.sh @@ -59,7 +59,7 @@ cd "${executabledir}" ./ts3server_startscript.sh start inifile="${servercfgfullpath}" > /dev/null 2>&1 sleep 1 info_ts3status.sh -if [ "${ts3status}" = "Server seems to have died" ] || [ "${ts3status}" = "No server running (ts3server.pid is missing)" ]; then +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" diff --git a/functions/info_config.sh b/functions/info_config.sh index a342e2a52..0af342894 100644 --- a/functions/info_config.sh +++ b/functions/info_config.sh @@ -297,7 +297,7 @@ elif [ "${engine}" == "seriousengine35" ]; then fn_servercfgfullpath # Source Engine Games -elif [ "${engine}" == "source" ] || [ "${engine}" == "goldsource" ]; then +elif [ "${engine}" == "source" ]||[ "${engine}" == "goldsource" ]; then # server name if [ -f "${servercfgfullpath}" ]; then @@ -635,7 +635,7 @@ elif [ "${gamename}" == "Hurtworld" ]; then fi # Unreal Tournament -elif [ "${engine}" == "unreal" ] || [ "${engine}" == "unreal2" ]; then +elif [ "${engine}" == "unreal" ]||[ "${engine}" == "unreal2" ]; then # server name if [ -f "${servercfgfullpath}" ]; then From c2c5693047138c932c27b7dbb3820c86261eac51 Mon Sep 17 00:00:00 2001 From: Daniel Gibbs Date: Mon, 28 Dec 2015 16:36:01 +0000 Subject: [PATCH 02/25] Moving checks to start of commands --- functions/check.sh | 73 +++++--- functions/check_ip.sh | 44 +++-- functions/command_backup.sh | 3 +- functions/command_console.sh | 4 +- functions/command_debug.sh | 5 +- functions/command_details.sh | 171 +++--------------- .../{dev_debug.sh => command_dev_debug.sh} | 0 ...ect_deps.sh => command_dev_detect_deps.sh} | 3 +- functions/command_install.sh | 2 +- functions/command_monitor.sh | 7 +- functions/command_start.sh | 4 +- functions/command_stop.sh | 8 +- functions/command_validate.sh | 5 +- functions/compress_unreal2_maps.sh | 2 +- functions/compress_ut99_maps.sh | 2 +- functions/install_serverfiles.sh | 2 +- functions/update_check.sh | 3 +- functions/update_dl.sh | 6 +- 18 files changed, 108 insertions(+), 236 deletions(-) rename functions/{dev_debug.sh => command_dev_debug.sh} (100%) rename functions/{dev_detect_deps.sh => command_dev_detect_deps.sh} (98%) diff --git a/functions/check.sh b/functions/check.sh index 61c8083ce..d8924df0c 100644 --- a/functions/check.sh +++ b/functions/check.sh @@ -7,40 +7,55 @@ 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 [ "${getopt}" != "install" ]||[ "${getopt}" != "auto-install" ]; 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 \ No newline at end of file +local allowed_commands_array=( backup console debug details map-compressor monitor start stop update validate ) +for allowed_command in "${allowed_commands_array[@]}" +do + if [ "${allowed_command}" == "${getopt}" ]; then + echo "OK logs" + check_logs.sh + fi +done + +local allowed_commands_array=( debug details monitor start stop ) +for allowed_command in "${allowed_commands_array[@]}" +do + if [ "${allowed_command}" == "${getopt}" ]; then + check_ip.sh + fi +done + +local allowed_commands_array=( debug install start stop update validate ) +for allowed_command in "${allowed_commands_array[@]}" +do + if [ "${allowed_command}" == "${getopt}" ]; then + check_steamuser.sh + check_steamcmd.sh + fi +done + +local allowed_commands_array=( console start stop ) +for allowed_command in "${allowed_commands_array[@]}" +do + if [ "${allowed_command}" == "${getopt}" ]; then + check_tmux.sh + fi +done \ No newline at end of file diff --git a/functions/check_ip.sh b/functions/check_ip.sh index 1a877c12a..2d162fbb5 100644 --- a/functions/check_ip.sh +++ b/functions/check_ip.sh @@ -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" -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 [ "${gamename}" == "Teamspeak 3" ]; then + : +elif + 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 \ No newline at end of file diff --git a/functions/command_backup.sh b/functions/command_backup.sh index 6a2f9d301..65a88508c 100644 --- a/functions/command_backup.sh +++ b/functions/command_backup.sh @@ -7,8 +7,7 @@ lgsm_version="271215" # Description: Creates a .tar.gz file in the backup directory. local modulename="Backup" -check_root.sh -check_systemdir.sh +check.sh backupname="${servicename}-$(date '+%Y-%m-%d-%H%M%S')" echo "" echo "${gamename} Backup" diff --git a/functions/command_console.sh b/functions/command_console.sh index 9f3476d1c..4386cc770 100644 --- a/functions/command_console.sh +++ b/functions/command_console.sh @@ -7,8 +7,7 @@ lgsm_version="271215" # Description: Gives access to the server tmux console. local modulename="Console" -check_root.sh -check_systemdir.sh +check.sh echo "" echo "${gamename} Console" echo "============================" @@ -26,7 +25,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" diff --git a/functions/command_debug.sh b/functions/command_debug.sh index e58fe0ab4..5cf2f5138 100644 --- a/functions/command_debug.sh +++ b/functions/command_debug.sh @@ -7,10 +7,7 @@ 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 +check.sh info_distro.sh fn_parms echo "" diff --git a/functions/command_details.sh b/functions/command_details.sh index 927f0beb7..aca698dbc 100644 --- a/functions/command_details.sh +++ b/functions/command_details.sh @@ -106,7 +106,7 @@ printf '%*s\n' "${COLUMNS:-$(tput cols)}" '' | tr ' ' = # online status if [ "${gamename}" == "Teamspeak 3" ]; then info_ts3status.sh - if [ "${ts3status}" = "Server seems to have died" ] || [ "${ts3status}" = "No server running (ts3server.pid is missing)" ]; then + if [ "${ts3status}" = "Server seems to have died" ]||[ "${ts3status}" = "No server running (ts3server.pid is missing)" ]; then echo -e "\e[34mStatus:\t\e[0;31mOFFLINE\e[0m" else echo -e "\e[34mStatus:\t\e[0;32mONLINE\e[0m" @@ -184,7 +184,7 @@ fn_details_backup(){ echo -e "" echo -e "\e[92mBackups\e[0m" printf '%*s\n' "${COLUMNS:-$(tput cols)}" '' | tr ' ' = -if [ ! -d "${backupdir}" ] || [ "${backupcount}" == "0" ]; then +if [ ! -d "${backupdir}" ]||[ "${backupcount}" == "0" ]; then echo -e "No Backups created" else { @@ -207,7 +207,7 @@ echo -e "${executable} ${parms}" fn_details_statusbottom(){ echo -e "" if [ "${gamename}" == "Teamspeak 3" ]; then - if [ "${ts3status}" = "Server seems to have died" ] || [ "${ts3status}" = "No server running (ts3server.pid is missing)" ]; then + if [ "${ts3status}" = "Server seems to have died" ]||[ "${ts3status}" = "No server running (ts3server.pid is missing)" ]; then echo -e "\e[34mStatus: \e[0;31mOFFLINE\e[0m" else echo -e "\e[34mStatus: \e[0;32mONLINE\e[0m" @@ -226,14 +226,6 @@ echo -e "" # Engine Specific details fn_details_avalanche(){ -check_ip.sh -info_config.sh -info_distro.sh -fn_details_os -fn_details_performance -fn_details_disk -fn_details_gameserver -fn_details_backup echo -e "" echo -e "\e[92mPorts\e[0m" printf '%*s\n' "${COLUMNS:-$(tput cols)}" '' | tr ' ' = @@ -252,14 +244,6 @@ fn_details_statusbottom } fn_details_dontstarve(){ -check_ip.sh -info_config.sh -info_distro.sh -fn_details_os -fn_details_performance -fn_details_disk -fn_details_gameserver -fn_details_backup echo -e "" echo -e "\e[92mPorts\e[0m" printf '%*s\n' "${COLUMNS:-$(tput cols)}" '' | tr ' ' = @@ -278,14 +262,6 @@ fn_details_statusbottom } fn_details_projectzomboid(){ -check_ip.sh -info_config.sh -info_distro.sh -fn_details_os -fn_details_performance -fn_details_disk -fn_details_gameserver -fn_details_backup echo -e "" echo -e "\e[92mPorts\e[0m" printf '%*s\n' "${COLUMNS:-$(tput cols)}" '' | tr ' ' = @@ -305,16 +281,6 @@ fn_details_statusbottom fn_details_realvirtuality(){ -check_ip.sh -fn_parms -info_config.sh -info_distro.sh -fn_details_os -fn_details_performance -fn_details_disk -fn_details_gameserver -fn_details_backup -fn_details_commandlineparms echo -e "" echo -e "\e[92mPorts\e[0m" printf '%*s\n' "${COLUMNS:-$(tput cols)}" '' | tr ' ' = @@ -324,7 +290,7 @@ echo -e "" echo -e "Useful port diagnostic command:" echo -e "netstat -atunp | grep arma3server" echo -e "" -if [ -z "${port}" ] || [ -z "${queryport}" ] || [ -z "${masterport}" ]; then +if [ -z "${port}" ]||[ -z "${queryport}" ]||[ -z "${masterport}" ]; then echo -e "\e[0;31mERROR!\e[0m Missing/commented ports in ${servercfg}." echo -e "" fi @@ -339,16 +305,6 @@ fn_details_statusbottom } fn_details_seriousengine35(){ -check_ip.sh -fn_parms -info_config.sh -info_distro.sh -fn_details_os -fn_details_performance -fn_details_disk -fn_details_gameserver -fn_details_backup -fn_details_commandlineparms echo -e "" echo -e "\e[92mPorts\e[0m" printf '%*s\n' "${COLUMNS:-$(tput cols)}" '' | tr ' ' = @@ -368,16 +324,6 @@ fn_details_statusbottom } fn_details_source(){ -check_ip.sh -fn_parms -info_config.sh -info_distro.sh -fn_details_os -fn_details_performance -fn_details_disk -fn_details_gameserver -fn_details_backup -fn_details_commandlineparms echo -e "" echo -e "\e[92mPorts\e[0m" printf '%*s\n' "${COLUMNS:-$(tput cols)}" '' | tr ' ' = @@ -400,16 +346,6 @@ fn_details_statusbottom } fn_details_spark(){ -check_ip.sh -fn_parms -info_config.sh -info_distro.sh -fn_details_os -fn_details_performance -fn_details_disk -fn_details_gameserver -fn_details_backup -fn_details_commandlineparms echo -e "" echo -e "\e[92mPorts\e[0m" printf '%*s\n' "${COLUMNS:-$(tput cols)}" '' | tr ' ' = @@ -438,16 +374,6 @@ fn_details_statusbottom } fn_details_starbound(){ -check_ip.sh -fn_parms -info_config.sh -info_distro.sh -fn_details_os -fn_details_performance -fn_details_disk -fn_details_gameserver -fn_details_backup -fn_details_commandlineparms echo -e "" echo -e "\e[92mPorts\e[0m" printf '%*s\n' "${COLUMNS:-$(tput cols)}" '' | tr ' ' = @@ -469,14 +395,6 @@ fn_details_statusbottom } fn_details_teamspeak3(){ -info_config.sh -info_distro.sh -fn_details_os -fn_details_performance -fn_details_disk -fn_details_gameserver -fn_details_backup -fn_details_commandlineparms echo -e "" echo -e "\e[92mPorts\e[0m" printf '%*s\n' "${COLUMNS:-$(tput cols)}" '' | tr ' ' = @@ -497,16 +415,6 @@ fn_details_statusbottom } fn_details_teeworlds(){ -check_ip.sh -fn_parms -info_config.sh -info_distro.sh -fn_details_os -fn_details_performance -fn_details_disk -fn_details_gameserver -fn_details_backup -fn_details_commandlineparms echo -e "" echo -e "\e[92mPorts\e[0m" printf '%*s\n' "${COLUMNS:-$(tput cols)}" '' | tr ' ' = @@ -525,16 +433,6 @@ fn_details_statusbottom } fn_details_terraria(){ -check_ip.sh -fn_parms -info_config.sh -info_distro.sh -fn_details_os -fn_details_performance -fn_details_disk -fn_details_gameserver -fn_details_backup -fn_details_commandlineparms echo -e "" echo -e "\e[92mPorts\e[0m" printf '%*s\n' "${COLUMNS:-$(tput cols)}" '' | tr ' ' = @@ -555,16 +453,6 @@ fn_details_statusbottom } fn_details_sdtd(){ -fn_check_ip.sh -fn_parms -info_config.sh -info_distro.sh -fn_details_os -fn_details_performance -fn_details_disk -fn_details_gameserver -fn_details_backup -fn_details_commandlineparms echo -e "" echo -e "\e[92mPorts\e[0m" printf '%*s\n' "${COLUMNS:-$(tput cols)}" '' | tr ' ' = @@ -602,16 +490,6 @@ fn_details_statusbottom } fn_details_hurtworld(){ -check_ip.sh -fn_parms -fn_details_config -fn_details_distro -fn_details_os -fn_details_performance -fn_details_disk -fn_details_gameserver -fn_details_backup -fn_details_commandlineparms echo -e "" echo -e "\e[92mPorts\e[0m" printf '%*s\n' "${COLUMNS:-$(tput cols)}" '' | tr ' ' = @@ -633,16 +511,6 @@ fn_details_statusbottom } fn_details_unreal(){ -check_ip.sh -fn_parms -info_config.sh -info_distro.sh -fn_details_os -fn_details_performance -fn_details_disk -fn_details_gameserver -fn_details_backup -fn_details_commandlineparms echo -e "" echo -e "\e[92mPorts\e[0m" printf '%*s\n' "${COLUMNS:-$(tput cols)}" '' | tr ' ' = @@ -690,16 +558,6 @@ fn_details_statusbottom } fn_details_ark(){ -check_ip.sh -fn_parms -info_config.sh -info_distro.sh -fn_details_os -fn_details_performance -fn_details_disk -fn_details_gameserver -fn_details_backup -fn_details_commandlineparms echo -e "" echo -e "\e[92mPorts\e[0m" printf '%*s\n' "${COLUMNS:-$(tput cols)}" '' | tr ' ' = @@ -718,6 +576,10 @@ echo -e "" fn_details_statusbottom } + +# Run checks and gathers details to display. +check.sh + if [ ! -e "${servercfgfullpath}" ]; then if [ "${gamename}" != "Hurtworld" ]; then echo "" @@ -734,8 +596,21 @@ if [ ! -e "${servercfgfullpath}" ]; then fi fi +info_config.sh +info_distro.sh info_glibc.sh +fn_details_os +fn_details_performance +fn_details_gameserver +fn_details_backup +# Some game servers do not have parms. +if [ "${gamename}" != "Teamspeak 3" ]||[ "${engine}" != "avalanche" ]||[ "${engine}" != "dontstarve" ]||[ "${engine}" == "projectzomboid" ]; then + fn_parms + fn_details_commandlineparms +fi + +# Display details depending on game or engine. if [ "${engine}" == "avalanche" ]; then fn_details_avalanche elif [ "${engine}" == "dontstarve" ]; then @@ -746,7 +621,7 @@ elif [ "${engine}" == "realvirtuality" ]; then fn_details_realvirtuality elif [ "${engine}" == "seriousengine35" ]; then fn_details_seriousengine35 -elif [ "${engine}" == "source" ] || [ "${engine}" == "goldsource" ]; then +elif [ "${engine}" == "source" ]||[ "${engine}" == "goldsource" ]; then fn_details_source elif [ "${engine}" == "spark" ]; then fn_details_spark @@ -756,7 +631,7 @@ elif [ "${engine}" == "teeworlds" ]; then fn_details_teeworlds elif [ "${engine}" == "terraria" ]; then fn_details_terraria -elif [ "${engine}" == "unreal" ] || [ "${engine}" == "unreal2" ]; then +elif [ "${engine}" == "unreal" ]||[ "${engine}" == "unreal2" ]; then fn_details_unreal elif [ "${gamename}" == "ARK: Survivial Evolved" ]; then fn_details_ark diff --git a/functions/dev_debug.sh b/functions/command_dev_debug.sh similarity index 100% rename from functions/dev_debug.sh rename to functions/command_dev_debug.sh diff --git a/functions/dev_detect_deps.sh b/functions/command_dev_detect_deps.sh similarity index 98% rename from functions/dev_detect_deps.sh rename to functions/command_dev_detect_deps.sh index 03069ea8e..28826a2bb 100644 --- a/functions/dev_detect_deps.sh +++ b/functions/command_dev_detect_deps.sh @@ -7,8 +7,7 @@ lgsm_version="271215" # Description: Detects dependencies the server binary requires. local modulename="Backup" -check_root.sh -check_systemdir.sh +check.sh cd "${executabledir}" if [ "${executable}" == "./hlds_run" ]; then executable=hlds_linux diff --git a/functions/command_install.sh b/functions/command_install.sh index 8f8d0a8ec..dc5b5bff9 100644 --- a/functions/command_install.sh +++ b/functions/command_install.sh @@ -4,7 +4,7 @@ # Website: http://gameservermanagers.com lgsm_version="271215" -check_root.sh +check.sh install_header.sh install_serverdir.sh diff --git a/functions/command_monitor.sh b/functions/command_monitor.sh index f99409f8d..728b59c49 100644 --- a/functions/command_monitor.sh +++ b/functions/command_monitor.sh @@ -10,8 +10,7 @@ lgsm_version="271215" local modulename="Monitor" fn_monitor_teamspeak3(){ -check_root.sh -check_systemdir.sh +check.sh logs.sh fn_printdots "${servername}" fn_scriptlog "${servername}" @@ -54,9 +53,7 @@ fn_restart } fn_monitor_tmux(){ -check_root.sh -check_systemdir.sh -check_ip.sh +check.sh info_config.sh fn_printdots "${servername}" fn_scriptlog "${servername}" diff --git a/functions/command_start.sh b/functions/command_start.sh index 424c69e4c..98212219e 100644 --- a/functions/command_start.sh +++ b/functions/command_start.sh @@ -9,9 +9,7 @@ lgsm_version="271215" local modulename="Starting" fn_start_teamspeak3(){ -check_root.sh -check_systemdir.sh -check_logs.sh +check.sh info_ts3status.sh if [ "${ts3status}" != "Server is running" ]; then diff --git a/functions/command_stop.sh b/functions/command_stop.sh index d567489e0..0b91ea69d 100644 --- a/functions/command_stop.sh +++ b/functions/command_stop.sh @@ -29,8 +29,7 @@ sdtd_telnet(){ } fn_stop_teamspeak3(){ -check_root.sh -check_systemdir.sh +check.sh fn_printdots "${servername}" fn_scriptlog "${servername}" sleep 1 @@ -50,13 +49,11 @@ echo -en "\n" } fn_stop_tmux(){ -check_root.sh -check_systemdir.sh +check.sh info_config.sh fn_printdots "${servername}" fn_scriptlog "${servername}" sleep 1 -check_tmux.sh if [ "${gamename}" == "7 Days To Die" ] ; then # if game is 7 Days To Die, we need special, graceful shutdown via telnet connection. @@ -70,7 +67,6 @@ if [ "${gamename}" == "7 Days To Die" ] ; then # If failed using localhost will use servers ip refused=$(echo -en "\n ${sdtdshutdown}"| grep "Timeout or EOF") if [ -n "${refused}" ]; then - check_ip.sh telnetip=${ip} fn_printwarn "Attempting graceful shutdown via telnet: localhost failed" fn_scriptlog "Warning! Attempting graceful shutdown failed using localhost" diff --git a/functions/command_validate.sh b/functions/command_validate.sh index 7d62f0dd5..369969f4d 100644 --- a/functions/command_validate.sh +++ b/functions/command_validate.sh @@ -9,8 +9,6 @@ lgsm_version="271215" local modulename="Validate" fn_validation(){ -check_steamcmd.sh -check_steamuser.sh fn_printwarn "Validating may overwrite some customised files." sleep 1 echo -en "\n" @@ -42,8 +40,7 @@ fi fn_scriptlog "Checking complete" } -check_root.sh -check_systemdir.sh +check.sh tmuxwc=$(tmux list-sessions 2>&1|awk '{print $1}'|grep -v failed|grep -Ec "^${servicename}:") if [ "${tmuxwc}" -eq 1 ]; then command_stop.sh diff --git a/functions/compress_unreal2_maps.sh b/functions/compress_unreal2_maps.sh index 5992cb8f6..2a0f88542 100644 --- a/functions/compress_unreal2_maps.sh +++ b/functions/compress_unreal2_maps.sh @@ -4,7 +4,7 @@ # Website: http://gameservermanagers.com lgsm_version="271215" -check_root.sh +check.sh clear echo "${gamename} Map Compressor" echo "============================" diff --git a/functions/compress_ut99_maps.sh b/functions/compress_ut99_maps.sh index ba14cb663..510a7b5a7 100644 --- a/functions/compress_ut99_maps.sh +++ b/functions/compress_ut99_maps.sh @@ -4,7 +4,7 @@ # Website: http://gameservermanagers.com lgsm_version="271215" -check_root.sh +check.sh clear echo "${gamename} Map Compressor" echo "============================" diff --git a/functions/install_serverfiles.sh b/functions/install_serverfiles.sh index e21ace3f7..24677da9c 100644 --- a/functions/install_serverfiles.sh +++ b/functions/install_serverfiles.sh @@ -5,7 +5,7 @@ lgsm_version="271215" fn_steaminstallcommand(){ -check_steamuser.sh +check.sh counter="0" while [ "${counter}" == "0" ]||[ "$(grep -wc 0x402 .finstall_serverfiles.sh.tmp)" -ge "1" ]||[ "$(grep -wc 0x406 .finstall_serverfiles.sh.tmp)" -ge "1" ]||[ "$(grep -wc 0x6 .finstall_serverfiles.sh.tmp)" -ge "1" ]||[ "$(grep -wc 0x106 .finstall_serverfiles.sh.tmp)" -ge "1" ]; do counter=$((counter+1)) diff --git a/functions/update_check.sh b/functions/update_check.sh index f1b9ae78a..b5f36f7b5 100644 --- a/functions/update_check.sh +++ b/functions/update_check.sh @@ -102,8 +102,7 @@ fi } fn_steamcmdcheck(){ -check_steamcmd.sh -check_steamuser.sh +check.sh fn_appmanifestcheck # Checks for server update from SteamCMD fn_printdots "Checking for update: SteamCMD" diff --git a/functions/update_dl.sh b/functions/update_dl.sh index aa9fc51b2..9c7106287 100644 --- a/functions/update_dl.sh +++ b/functions/update_dl.sh @@ -9,8 +9,7 @@ lgsm_version="271215" local modulename="Update" fn_steamcmd_dl(){ -check_root.sh -check_systemdir.sh +check.sh info_config.sh fn_printdots "Updating ${servername}" sleep 1 @@ -39,8 +38,7 @@ fi } fn_teamspeak3_dl(){ -check_root.sh -check_systemdir.sh +check.sh info_config.sh fn_printdots "Updating ${servername}" sleep 1 From 57cbdcee6002372c2045926c7b19a948eed2a475 Mon Sep 17 00:00:00 2001 From: Daniel Gibbs Date: Mon, 28 Dec 2015 16:41:23 +0000 Subject: [PATCH 03/25] else --- functions/check_ip.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/functions/check_ip.sh b/functions/check_ip.sh index 2d162fbb5..c8235b0c9 100644 --- a/functions/check_ip.sh +++ b/functions/check_ip.sh @@ -9,7 +9,7 @@ lgsm_version="271215" if [ "${gamename}" == "Teamspeak 3" ]; then : -elif +else if [ ! -f "/bin/ip" ]; then ipcommand="/sbin/ip" else From cd42c51d5c014cf276a196e353c07ef7c63c72a1 Mon Sep 17 00:00:00 2001 From: Daniel Gibbs Date: Mon, 28 Dec 2015 16:43:51 +0000 Subject: [PATCH 04/25] removed echo --- functions/check.sh | 1 - 1 file changed, 1 deletion(-) diff --git a/functions/check.sh b/functions/check.sh index d8924df0c..53ee4d617 100644 --- a/functions/check.sh +++ b/functions/check.sh @@ -30,7 +30,6 @@ local allowed_commands_array=( backup console debug details map-compressor monit for allowed_command in "${allowed_commands_array[@]}" do if [ "${allowed_command}" == "${getopt}" ]; then - echo "OK logs" check_logs.sh fi done From f7e25307e21bb90cd1a5cf333f345dfdf3125636 Mon Sep 17 00:00:00 2001 From: Daniel Gibbs Date: Mon, 28 Dec 2015 16:43:58 +0000 Subject: [PATCH 05/25] added newline --- functions/command_start.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/functions/command_start.sh b/functions/command_start.sh index 98212219e..0e549b535 100644 --- a/functions/command_start.sh +++ b/functions/command_start.sh @@ -143,11 +143,11 @@ sleep 1 tmuxwc=$(tmux list-sessions 2>&1|awk '{print $1}'|grep -Ec "^${servicename}:") # If the server fails to start if [ "${tmuxwc}" -eq 0 ]; then - fn_printfail "Unable to start ${servername}" + fn_printfailnl "Unable to start ${servername}" fn_scriptlog "Unable to start ${servername}" sleep 1 if [ -s "${scriptlogdir}/.${servicename}-tmux-error.tmp" ]; then - fn_printfail "Unable to start ${servername}: Tmux error:" + fn_printfailnl "Unable to start ${servername}: Tmux error:" fn_scriptlog "Tmux error" sleep 1 echo -en "\n" From 9e38714872713af043b6473d5daafee4144c88f1 Mon Sep 17 00:00:00 2001 From: Daniel Gibbs Date: Mon, 28 Dec 2015 16:46:04 +0000 Subject: [PATCH 06/25] start now only using check.sh --- functions/command_start.sh | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-) diff --git a/functions/command_start.sh b/functions/command_start.sh index 0e549b535..08bd013d7 100644 --- a/functions/command_start.sh +++ b/functions/command_start.sh @@ -71,10 +71,8 @@ echo -en "\n" } fn_start_tmux(){ -check_root.sh -check_systemdir.sh -check_ip.sh -check_logs.sh +check.sh + if [ "${gamename}" == "Counter Strike: Global Offensive" ]; then startfix=1 fix_csgo.sh @@ -99,11 +97,6 @@ fi fn_printdots "${servername}" fn_scriptlog "${servername}" sleep 1 -check_tmux.sh - -if [ "${gamename}" != "Mumble" ]; then - check_steamcmd.sh -fi if [ "${tmuxwc}" -eq 0 ]; then fn_scriptlog "Rotating log files" From 496463f45c278ffa2f2ad12b9d419ffbb849861d Mon Sep 17 00:00:00 2001 From: Daniel Gibbs Date: Mon, 28 Dec 2015 16:57:10 +0000 Subject: [PATCH 07/25] Added ability to be logged if available. --- functions/check_root.sh | 3 +++ functions/check_systemdir.sh | 3 +++ 2 files changed, 6 insertions(+) diff --git a/functions/check_root.sh b/functions/check_root.sh index 3f62a5d30..8f2e5ed54 100644 --- a/functions/check_root.sh +++ b/functions/check_root.sh @@ -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 diff --git a/functions/check_systemdir.sh b/functions/check_systemdir.sh index 30a192609..c1f65a0d7 100644 --- a/functions/check_systemdir.sh +++ b/functions/check_systemdir.sh @@ -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 From 3ca2d094a85f87a9a4aaf4de44c4f24fd53ae007 Mon Sep 17 00:00:00 2001 From: Daniel Gibbs Date: Mon, 28 Dec 2015 16:58:03 +0000 Subject: [PATCH 08/25] Merged check_steamuser.sh added mumble to ignore list --- functions/check.sh | 1 - functions/check_steamcmd.sh | 24 +++++++++++++++++++++--- 2 files changed, 21 insertions(+), 4 deletions(-) diff --git a/functions/check.sh b/functions/check.sh index 53ee4d617..4c0259053 100644 --- a/functions/check.sh +++ b/functions/check.sh @@ -46,7 +46,6 @@ local allowed_commands_array=( debug install start stop update validate ) for allowed_command in "${allowed_commands_array[@]}" do if [ "${allowed_command}" == "${getopt}" ]; then - check_steamuser.sh check_steamcmd.sh fi done diff --git a/functions/check_steamcmd.sh b/functions/check_steamcmd.sh index 049867eda..b2ba69727 100644 --- a/functions/check_steamcmd.sh +++ b/functions/check_steamcmd.sh @@ -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" ]; 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" From 6f7aca25b3ad80c2047ddc731c2f0d66835bccb3 Mon Sep 17 00:00:00 2001 From: Daniel Gibbs Date: Mon, 28 Dec 2015 21:31:53 +0000 Subject: [PATCH 09/25] changed to using function_selfname over getopt --- functions/check.sh | 19 +++++++++---------- functions/command_backup.sh | 2 ++ functions/command_console.sh | 2 ++ functions/command_debug.sh | 2 ++ functions/command_details.sh | 2 ++ functions/command_dev_debug.sh | 2 ++ functions/command_dev_detect_deps.sh | 2 ++ functions/command_install.sh | 2 ++ functions/command_monitor.sh | 1 + functions/command_start.sh | 1 + functions/command_stop.sh | 1 + functions/command_validate.sh | 1 + functions/compress_unreal2_maps.sh | 2 ++ functions/compress_ut99_maps.sh | 2 ++ functions/core_getopt.sh | 3 --- functions/update_check.sh | 3 ++- functions/update_dl.sh | 1 + 17 files changed, 34 insertions(+), 14 deletions(-) diff --git a/functions/check.sh b/functions/check.sh index 4c0259053..a7cd2ae32 100644 --- a/functions/check.sh +++ b/functions/check.sh @@ -19,41 +19,40 @@ array_contains () { return $in } - check_root.sh -if [ "${getopt}" != "install" ]||[ "${getopt}" != "auto-install" ]; then +if [ "${function_selfname}" != "install" ]||[ "${function_selfname}" != "auto-install" ]; then check_systemdir.sh fi -local allowed_commands_array=( backup console debug details map-compressor monitor start stop update validate ) +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 command_update.sh command_validate.sh ) for allowed_command in "${allowed_commands_array[@]}" do - if [ "${allowed_command}" == "${getopt}" ]; then + if [ "${allowed_command}" == "${function_selfname}" ]; then check_logs.sh fi done -local allowed_commands_array=( debug details monitor start stop ) +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}" == "${getopt}" ]; then + if [ "${allowed_command}" == "${function_selfname}" ]; then check_ip.sh fi done -local allowed_commands_array=( debug install start stop update validate ) +local allowed_commands_array=( command_debug.sh command_start.sh command_stop.sh command_update.sh command_validate.sh ) for allowed_command in "${allowed_commands_array[@]}" do - if [ "${allowed_command}" == "${getopt}" ]; then + if [ "${allowed_command}" == "${function_selfname}" ]; then check_steamcmd.sh fi done -local allowed_commands_array=( console start stop ) +local allowed_commands_array=( command_console.sh command_start.sh command_stop.sh ) for allowed_command in "${allowed_commands_array[@]}" do - if [ "${allowed_command}" == "${getopt}" ]; then + if [ "${allowed_command}" == "${function_selfname}" ]; then check_tmux.sh fi done \ No newline at end of file diff --git a/functions/command_backup.sh b/functions/command_backup.sh index 65a88508c..5f923ad07 100644 --- a/functions/command_backup.sh +++ b/functions/command_backup.sh @@ -7,6 +7,8 @@ lgsm_version="271215" # Description: Creates a .tar.gz file in the backup directory. local modulename="Backup" +function_selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))" + check.sh backupname="${servicename}-$(date '+%Y-%m-%d-%H%M%S')" echo "" diff --git a/functions/command_console.sh b/functions/command_console.sh index 4386cc770..4eab4d6eb 100644 --- a/functions/command_console.sh +++ b/functions/command_console.sh @@ -7,6 +7,8 @@ lgsm_version="271215" # Description: Gives access to the server tmux console. local modulename="Console" +function_selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))" + check.sh echo "" echo "${gamename} Console" diff --git a/functions/command_debug.sh b/functions/command_debug.sh index 5cf2f5138..bec1f7ade 100644 --- a/functions/command_debug.sh +++ b/functions/command_debug.sh @@ -7,6 +7,8 @@ lgsm_version="271215" # Description: Runs the server without tmux. Runs direct from the terminal. local modulename="Debug" +function_selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))" + check.sh info_distro.sh fn_parms diff --git a/functions/command_details.sh b/functions/command_details.sh index aca698dbc..30437b933 100644 --- a/functions/command_details.sh +++ b/functions/command_details.sh @@ -6,6 +6,8 @@ lgsm_version="271215" # Description: Displays server infomation. +function_selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))" + # Standard Details # This applies to all engines diff --git a/functions/command_dev_debug.sh b/functions/command_dev_debug.sh index ed92a90e3..87ba563a3 100644 --- a/functions/command_dev_debug.sh +++ b/functions/command_dev_debug.sh @@ -4,6 +4,8 @@ # Website: http://gameservermanagers.com lgsm_version="271215" +function_selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))" + if [ -f ".dev-debug" ]; then rm .dev-debug fn_printoknl "Disabled dev-debug" diff --git a/functions/command_dev_detect_deps.sh b/functions/command_dev_detect_deps.sh index 28826a2bb..30f89157d 100644 --- a/functions/command_dev_detect_deps.sh +++ b/functions/command_dev_detect_deps.sh @@ -7,6 +7,8 @@ lgsm_version="271215" # Description: Detects dependencies the server binary requires. local modulename="Backup" +function_selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))" + check.sh cd "${executabledir}" if [ "${executable}" == "./hlds_run" ]; then diff --git a/functions/command_install.sh b/functions/command_install.sh index dc5b5bff9..2ddb3a785 100644 --- a/functions/command_install.sh +++ b/functions/command_install.sh @@ -4,6 +4,8 @@ # Website: http://gameservermanagers.com lgsm_version="271215" +function_selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))" + check.sh install_header.sh install_serverdir.sh diff --git a/functions/command_monitor.sh b/functions/command_monitor.sh index 728b59c49..f253abc54 100644 --- a/functions/command_monitor.sh +++ b/functions/command_monitor.sh @@ -8,6 +8,7 @@ lgsm_version="271215" # then passes to monitor_gsquery.sh. local modulename="Monitor" +function_selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))" fn_monitor_teamspeak3(){ check.sh diff --git a/functions/command_start.sh b/functions/command_start.sh index 08bd013d7..2a4c9b74c 100644 --- a/functions/command_start.sh +++ b/functions/command_start.sh @@ -7,6 +7,7 @@ lgsm_version="271215" # Description: Starts the server. local modulename="Starting" +function_selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))" fn_start_teamspeak3(){ check.sh diff --git a/functions/command_stop.sh b/functions/command_stop.sh index 0b91ea69d..98d21c9a5 100644 --- a/functions/command_stop.sh +++ b/functions/command_stop.sh @@ -7,6 +7,7 @@ lgsm_version="271215" # Description: Stops the server. local modulename="Stopping" +function_selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))" sdtd_telnet(){ sdtdshutdown=$( expect -c ' diff --git a/functions/command_validate.sh b/functions/command_validate.sh index 369969f4d..1d3774276 100644 --- a/functions/command_validate.sh +++ b/functions/command_validate.sh @@ -7,6 +7,7 @@ lgsm_version="271215" # Description: Runs a server validation. local modulename="Validate" +function_selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))" fn_validation(){ fn_printwarn "Validating may overwrite some customised files." diff --git a/functions/compress_unreal2_maps.sh b/functions/compress_unreal2_maps.sh index 2a0f88542..627df96a0 100644 --- a/functions/compress_unreal2_maps.sh +++ b/functions/compress_unreal2_maps.sh @@ -4,6 +4,8 @@ # Website: http://gameservermanagers.com lgsm_version="271215" +function_selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))" + check.sh clear echo "${gamename} Map Compressor" diff --git a/functions/compress_ut99_maps.sh b/functions/compress_ut99_maps.sh index 510a7b5a7..cd3948edf 100644 --- a/functions/compress_ut99_maps.sh +++ b/functions/compress_ut99_maps.sh @@ -4,6 +4,8 @@ # Website: http://gameservermanagers.com lgsm_version="271215" +function_selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))" + check.sh clear echo "${gamename} Map Compressor" diff --git a/functions/core_getopt.sh b/functions/core_getopt.sh index 93b0a005c..563956310 100644 --- a/functions/core_getopt.sh +++ b/functions/core_getopt.sh @@ -203,8 +203,6 @@ case "$getopt" in fn_autoinstall;; dd|depsdetect) dev_detect_deps.sh;; - gc|gmod-content) - fn_content_gmod;; *) echo "Usage: $0 [option]" echo "${gamename} - Linux Game Server Manager - Version ${version}" @@ -227,7 +225,6 @@ 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[34mgmod-content\t\e[0mDownload gmod add-on content." } | column -s $'\t' -t esac exit diff --git a/functions/update_check.sh b/functions/update_check.sh index b5f36f7b5..18813cc4a 100644 --- a/functions/update_check.sh +++ b/functions/update_check.sh @@ -7,6 +7,7 @@ lgsm_version="271215" # Description: Checks if a server update is available. local modulename="Update" +function_selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))" ### SteamCMD Update Checker ### @@ -296,7 +297,7 @@ else fi } -check_logs.sh +check.sh fn_printdots "Checking for update" if [ "${gamename}" == "Teamspeak 3" ]; then fn_teamspeak3_check diff --git a/functions/update_dl.sh b/functions/update_dl.sh index 9c7106287..073760223 100644 --- a/functions/update_dl.sh +++ b/functions/update_dl.sh @@ -7,6 +7,7 @@ lgsm_version="271215" # Description: Runs a server update. local modulename="Update" +function_selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))" fn_steamcmd_dl(){ check.sh From 5db7d4e060e5d7090462f63cd237629e02205f49 Mon Sep 17 00:00:00 2001 From: Daniel Gibbs Date: Mon, 28 Dec 2015 22:23:13 +0000 Subject: [PATCH 10/25] removed checks where not required --- functions/update_check.sh | 2 -- 1 file changed, 2 deletions(-) diff --git a/functions/update_check.sh b/functions/update_check.sh index 18813cc4a..ad7b0dde5 100644 --- a/functions/update_check.sh +++ b/functions/update_check.sh @@ -103,7 +103,6 @@ fi } fn_steamcmdcheck(){ -check.sh fn_appmanifestcheck # Checks for server update from SteamCMD fn_printdots "Checking for update: SteamCMD" @@ -297,7 +296,6 @@ else fi } -check.sh fn_printdots "Checking for update" if [ "${gamename}" == "Teamspeak 3" ]; then fn_teamspeak3_check From 3b80940260c6ac28eaa809b65ae704b0ede6cdde Mon Sep 17 00:00:00 2001 From: Daniel Gibbs Date: Mon, 28 Dec 2015 23:19:52 +0000 Subject: [PATCH 11/25] added check.sh remove duplication of code --- functions/update_check.sh | 1 + functions/update_dl.sh | 22 +++++++--------------- 2 files changed, 8 insertions(+), 15 deletions(-) diff --git a/functions/update_check.sh b/functions/update_check.sh index ad7b0dde5..e0ba3ea96 100644 --- a/functions/update_check.sh +++ b/functions/update_check.sh @@ -296,6 +296,7 @@ else fi } +check.sh fn_printdots "Checking for update" if [ "${gamename}" == "Teamspeak 3" ]; then fn_teamspeak3_check diff --git a/functions/update_dl.sh b/functions/update_dl.sh index 073760223..21fa13154 100644 --- a/functions/update_dl.sh +++ b/functions/update_dl.sh @@ -10,13 +10,6 @@ local modulename="Update" function_selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))" fn_steamcmd_dl(){ -check.sh -info_config.sh -fn_printdots "Updating ${servername}" -sleep 1 -fn_printoknl "Updating ${servername}" -fn_scriptlog "Updating ${servername}" -sleep 1 cd "${rootdir}" cd "steamcmd" @@ -31,7 +24,6 @@ else ${unbuffer} ./steamcmd.sh +login "${steamuser}" "${steampass}" +force_install_dir "${filesdir}" +app_update "${appid}" +quit|tee -a "${scriptlog}" fi - if [ "${gamename}" == "Counter Strike: Global Offensive" ]; then echo -e '\n' fix_csgo.sh @@ -39,13 +31,6 @@ fi } fn_teamspeak3_dl(){ -check.sh -info_config.sh -fn_printdots "Updating ${servername}" -sleep 1 -fn_printoknl "Updating ${servername}" -fn_scriptlog "Updating ${servername}" -sleep 1 cd "${rootdir}" echo -e "downloading teamspeak3-server_linux-${ts3arch}-${availablebuild}.tar.gz...\c" fn_scriptlog "Downloading teamspeak3-server_linux-${ts3arch}-${availablebuild}.tar.gz" @@ -87,6 +72,13 @@ rm -f teamspeak3-server_linux-${ts3arch}-${availablebuild}.tar.gz rm -rf "${rootdir}/teamspeak3-server_linux-${ts3arch}" } +check.sh +info_config.sh +fn_printdots "Updating ${servername}" +sleep 1 +fn_printoknl "Updating ${servername}" +fn_scriptlog "Updating ${servername}" +sleep 1 if [ "${gamename}" == "Teamspeak 3" ]; then fn_teamspeak3_dl else From 55b2b83ed830e2c3cda9c8583f021b94c2473df9 Mon Sep 17 00:00:00 2001 From: Daniel Gibbs Date: Mon, 28 Dec 2015 23:21:39 +0000 Subject: [PATCH 12/25] named function correctly --- functions/check.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/functions/check.sh b/functions/check.sh index a7cd2ae32..6809a1695 100644 --- a/functions/check.sh +++ b/functions/check.sh @@ -25,7 +25,7 @@ if [ "${function_selfname}" != "install" ]||[ "${function_selfname}" != "auto-in check_systemdir.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 command_update.sh command_validate.sh ) +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 ) for allowed_command in "${allowed_commands_array[@]}" do if [ "${allowed_command}" == "${function_selfname}" ]; then @@ -41,7 +41,7 @@ do fi done -local allowed_commands_array=( command_debug.sh command_start.sh command_stop.sh command_update.sh command_validate.sh ) +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 From 2125090fe6a0e9aa9f3a1bfe306ce72c079cb705 Mon Sep 17 00:00:00 2001 From: Daniel Gibbs Date: Mon, 28 Dec 2015 23:29:05 +0000 Subject: [PATCH 13/25] code tidy --- functions/check.sh | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/functions/check.sh b/functions/check.sh index 6809a1695..1c7f78e6e 100644 --- a/functions/check.sh +++ b/functions/check.sh @@ -8,15 +8,15 @@ lgsm_version="271215" # Runs checks that will either halt on or fix an issue. array_contains () { - local seeking=$1; shift - local in=1 - for element; do - if [ ${element} == ${seeking} ]; then - in=0 - break - fi - done - return $in + local seeking=$1; shift + local in=1 + for element; do + if [ ${element} == ${seeking} ]; then + in=0 + break + fi + done + return $in } check_root.sh @@ -41,7 +41,7 @@ do fi done -local allowed_commands_array=( command_debug.sh command_start.sh command_stop.sh update_check.sh command_validate.sh ) +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 From 4aa2c3ad76c408cfa20199e86615178d6f97cabd Mon Sep 17 00:00:00 2001 From: Daniel Gibbs Date: Mon, 28 Dec 2015 23:32:25 +0000 Subject: [PATCH 14/25] renamed email_test --- functions/{email_test.sh => command_email_test.sh} | 6 +++--- functions/core_functions.sh | 2 +- functions/core_getopt.sh | 14 +++++++------- 3 files changed, 11 insertions(+), 11 deletions(-) rename functions/{email_test.sh => command_email_test.sh} (82%) diff --git a/functions/email_test.sh b/functions/command_email_test.sh similarity index 82% rename from functions/email_test.sh rename to functions/command_email_test.sh index 388c17bf9..b24ff3b01 100644 --- a/functions/email_test.sh +++ b/functions/command_email_test.sh @@ -1,5 +1,5 @@ #!/bin/bash -# LGSM email_test.sh function +# LGSM command_email_test.sh function # Author: Daniel Gibbs # Website: http://gameservermanagers.com lgsm_version="271215" @@ -7,8 +7,8 @@ lgsm_version="271215" # Description: Sends a test email notification. local modulename="Email" -check_root.sh -check_systemdir.sh +function_selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))" +check.sh info_config.sh if [ "${emailnotification}" = "on" ]; then fn_scriptlog "Sending test notification" diff --git a/functions/core_functions.sh b/functions/core_functions.sh index 868f65885..5d950ce56 100644 --- a/functions/core_functions.sh +++ b/functions/core_functions.sh @@ -206,7 +206,7 @@ functionfile="${FUNCNAME}" fn_runfunction } -email_test.sh(){ +command_email_test.sh(){ functionfile="${FUNCNAME}" fn_runfunction } diff --git a/functions/core_getopt.sh b/functions/core_getopt.sh index 563956310..73be96001 100644 --- a/functions/core_getopt.sh +++ b/functions/core_getopt.sh @@ -26,7 +26,7 @@ case "$getopt" in m|monitor) command_monitor.sh;; et|email-test) - email_test.sh;; + command_email_test.sh;; d|details) command_details.sh;; b|backup) @@ -85,7 +85,7 @@ case "$getopt" in m|monitor) command_monitor.sh;; et|email-test) - email_test.sh;; + command_email_test.sh;; d|details) command_details.sh;; b|backup) @@ -134,7 +134,7 @@ case "$getopt" in m|monitor) command_monitor.sh;; et|email-test) - email_test.sh;; + command_email_test.sh;; b|backup) command_backup.sh;; dev|dev-debug) @@ -186,7 +186,7 @@ case "$getopt" in m|monitor) command_monitor.sh;; et|email-test) - email_test.sh;; + command_email_test.sh;; d|details) command_details.sh;; b|backup) @@ -243,7 +243,7 @@ case "$getopt" in m|monitor) command_monitor.sh;; et|email-test) - email_test.sh;; + command_email_test.sh;; d|details) command_details.sh;; b|backup) @@ -305,7 +305,7 @@ case "$getopt" in m|monitor) command_monitor.sh;; et|email-test) - email_test.sh;; + command_email_test.sh;; d|details) command_details.sh;; b|backup) @@ -366,7 +366,7 @@ case "$getopt" in m|monitor) command_monitor.sh;; et|email-test) - email_test.sh;; + command_email_test.sh;; d|details) command_details.sh;; b|backup) From bd822058dd4f6d8a74eb218d60e0e90d06cd9e68 Mon Sep 17 00:00:00 2001 From: Daniel Gibbs Date: Mon, 28 Dec 2015 23:33:02 +0000 Subject: [PATCH 15/25] moved email_test --- functions/core_functions.sh | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/functions/core_functions.sh b/functions/core_functions.sh index 5d950ce56..28469a6cf 100644 --- a/functions/core_functions.sh +++ b/functions/core_functions.sh @@ -50,6 +50,11 @@ functionfile="${FUNCNAME}" fn_runfunction } +command_email_test.sh(){ +functionfile="${FUNCNAME}" +fn_runfunction +} + command_backup.sh(){ functionfile="${FUNCNAME}" fn_runfunction @@ -206,12 +211,6 @@ functionfile="${FUNCNAME}" fn_runfunction } -command_email_test.sh(){ -functionfile="${FUNCNAME}" -fn_runfunction -} - - # Logs logs.sh(){ From 93e6421e49a57eb84bb0fed6148dd7b7a8e0648b Mon Sep 17 00:00:00 2001 From: Daniel Gibbs Date: Mon, 28 Dec 2015 23:38:58 +0000 Subject: [PATCH 16/25] reversed check to deny --- functions/check.sh | 6 +++--- functions/update_functions.sh | 2 ++ 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/functions/check.sh b/functions/check.sh index 1c7f78e6e..030da8f30 100644 --- a/functions/check.sh +++ b/functions/check.sh @@ -25,10 +25,10 @@ if [ "${function_selfname}" != "install" ]||[ "${function_selfname}" != "auto-in check_systemdir.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 ) -for allowed_command in "${allowed_commands_array[@]}" +local denied_commands_array=( command_install.sh command_details.sh compress_unreal2_maps.sh compress_ut99_maps.sh ) +for denied_command in "${denied_commands_array[@]}" do - if [ "${allowed_command}" == "${function_selfname}" ]; then + if [ "${denied_command}" != "${function_selfname}" ]; then check_logs.sh fi done diff --git a/functions/update_functions.sh b/functions/update_functions.sh index 746db023a..350714ed0 100644 --- a/functions/update_functions.sh +++ b/functions/update_functions.sh @@ -6,6 +6,8 @@ lgsm_version="271215" # Description: Deletes the functions dir to allow re-downloading of functions from GitHub. +function_selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))" +check.sh fn_printdots "Updating functions" fn_scriptlog "Updating functions" sleep 1 From bccc635cc526fa64b032ba60742c6ec800776807 Mon Sep 17 00:00:00 2001 From: Daniel Gibbs Date: Mon, 28 Dec 2015 23:40:54 +0000 Subject: [PATCH 17/25] bug ut2k4 using wrong map-compressor --- functions/core_getopt.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/functions/core_getopt.sh b/functions/core_getopt.sh index 73be96001..ff6f870de 100644 --- a/functions/core_getopt.sh +++ b/functions/core_getopt.sh @@ -380,7 +380,7 @@ case "$getopt" in i|install) command_install.sh;; mc|map-compressor) - compress_ut99_maps.sh;; + compress_unreal2_maps.sh;; dd|depsdetect) dev_detect_deps.sh;; *) From a1be7a5012fe1e81284e53b228325c11a2a85c26 Mon Sep 17 00:00:00 2001 From: Daniel Gibbs Date: Mon, 28 Dec 2015 23:49:20 +0000 Subject: [PATCH 18/25] updated dev-debug name --- functions/core_getopt.sh | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/functions/core_getopt.sh b/functions/core_getopt.sh index ff6f870de..d6ff22779 100644 --- a/functions/core_getopt.sh +++ b/functions/core_getopt.sh @@ -36,7 +36,7 @@ case "$getopt" in d|debug) command_debug.sh;; dev|dev-debug) - dev_debug.sh;; + command_dev_debug.sh;; i|install) command_install.sh;; ai|auto-install) @@ -91,7 +91,7 @@ case "$getopt" in b|backup) command_backup.sh;; dev|dev-debug) - dev_debug.sh;; + command_dev_debug.sh;; i|install) command_install.sh;; ai|auto-install) @@ -138,7 +138,7 @@ case "$getopt" in b|backup) command_backup.sh;; dev|dev-debug) - dev_debug.sh;; + command_dev_debug.sh;; console) command_console.sh;; d|debug) @@ -196,7 +196,7 @@ case "$getopt" in d|debug) command_debug.sh;; dev|dev-debug) - dev_debug.sh;; + command_dev_debug.sh;; i|install) command_install.sh;; ai|auto-install) @@ -253,7 +253,7 @@ case "$getopt" in d|debug) command_debug.sh;; dev|dev-debug) - dev_debug.sh;; + command_dev_debug.sh;; i|install) command_install.sh;; mc|map-compressor) @@ -315,7 +315,7 @@ case "$getopt" in d|debug) command_debug.sh;; dev|dev-debug) - dev_debug.sh;; + command_dev_debug.sh;; i|install) command_install.sh;; ai|auto-install) @@ -376,7 +376,7 @@ case "$getopt" in d|debug) command_debug.sh;; dev|dev-debug) - dev_debug.sh;; + command_dev_debug.sh;; i|install) command_install.sh;; mc|map-compressor) From d7f5f9cc1cbd0dd1d4d557dda32e61af88ed30f5 Mon Sep 17 00:00:00 2001 From: Daniel Gibbs Date: Mon, 28 Dec 2015 23:50:19 +0000 Subject: [PATCH 19/25] date --- functions/command_dev_debug.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/functions/command_dev_debug.sh b/functions/command_dev_debug.sh index 87ba563a3..e2c9d9cc5 100644 --- a/functions/command_dev_debug.sh +++ b/functions/command_dev_debug.sh @@ -2,7 +2,7 @@ # LGSM dev_debug.sh function # Author: Daniel Gibbs # Website: http://gameservermanagers.com -lgsm_version="271215" +lgsm_version="281215" function_selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))" From dfc216a414ea6f9d71147770039c55c139eee780 Mon Sep 17 00:00:00 2001 From: Daniel Gibbs Date: Mon, 28 Dec 2015 23:51:28 +0000 Subject: [PATCH 20/25] updated names --- functions/core_functions.sh | 4 ++-- functions/core_getopt.sh | 14 +++++++------- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/functions/core_functions.sh b/functions/core_functions.sh index 28469a6cf..2aa1648c0 100644 --- a/functions/core_functions.sh +++ b/functions/core_functions.sh @@ -152,12 +152,12 @@ fn_runfunction # Dev -dev_debug.sh(){ +command_dev_debug.sh(){ functionfile="${FUNCNAME}" fn_runfunction } -dev_detect_deps.sh(){ +command_dev_detect_deps.sh(){ functionfile="${FUNCNAME}" fn_runfunction } diff --git a/functions/core_getopt.sh b/functions/core_getopt.sh index d6ff22779..6d1f1bfbc 100644 --- a/functions/core_getopt.sh +++ b/functions/core_getopt.sh @@ -42,7 +42,7 @@ case "$getopt" in ai|auto-install) fn_autoinstall;; dd|depsdetect) - dev_detect_deps.sh;; + command_dev_detect_deps.sh;; *) echo "Usage: $0 [option]" echo "${gamename} - Linux Game Server Manager - Version ${version}" @@ -97,7 +97,7 @@ case "$getopt" in ai|auto-install) fn_autoinstall;; dd|depsdetect) - dev_detect_deps.sh;; + command_dev_detect_deps.sh;; *) echo "Usage: $0 [option]" echo "${gamename} - Linux Game Server Manager - Version ${version}" @@ -144,7 +144,7 @@ case "$getopt" in d|debug) command_debug.sh;; dd|depsdetect) - dev_detect_deps.sh;; + command_dev_detect_deps.sh;; *) echo "Usage: $0 [option]" echo "${gamename} - Linux Game Server Manager - Version ${version}" @@ -202,7 +202,7 @@ case "$getopt" in ai|auto-install) fn_autoinstall;; dd|depsdetect) - dev_detect_deps.sh;; + command_dev_detect_deps.sh;; *) echo "Usage: $0 [option]" echo "${gamename} - Linux Game Server Manager - Version ${version}" @@ -259,7 +259,7 @@ case "$getopt" in mc|map-compressor) compress_ut99_maps.sh;; dd|depsdetect) - dev_detect_deps.sh;; + command_dev_detect_deps.sh;; *) echo "Usage: $0 [option]" echo "${gamename} - Linux Game Server Manager - Version ${version}" @@ -321,7 +321,7 @@ case "$getopt" in ai|auto-install) fn_autoinstall;; dd|depsdetect) - dev_detect_deps.sh;; + command_dev_detect_deps.sh;; mc|map-compressor) compress_unreal2_maps.sh;; *) @@ -382,7 +382,7 @@ case "$getopt" in mc|map-compressor) compress_unreal2_maps.sh;; dd|depsdetect) - dev_detect_deps.sh;; + command_dev_detect_deps.sh;; *) echo "Usage: $0 [option]" echo "${gamename} - Linux Game Server Manager - Version ${version}" From be2c79e028bc4919392f884b1a52a960523061a5 Mon Sep 17 00:00:00 2001 From: Daniel Gibbs Date: Mon, 28 Dec 2015 23:56:20 +0000 Subject: [PATCH 21/25] corrected systemdir checks --- functions/check.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/functions/check.sh b/functions/check.sh index 030da8f30..25716ded6 100644 --- a/functions/check.sh +++ b/functions/check.sh @@ -21,7 +21,7 @@ array_contains () { check_root.sh -if [ "${function_selfname}" != "install" ]||[ "${function_selfname}" != "auto-install" ]; then +if [ "${function_selfname}" != "command_install.sh" ]; then check_systemdir.sh fi From afbaddbf031d6351d87cc9683661c5edec099405 Mon Sep 17 00:00:00 2001 From: Daniel Gibbs Date: Tue, 29 Dec 2015 00:08:19 +0000 Subject: [PATCH 22/25] reverted to positive array Denied logic for array caused log check to run multiple times. --- functions/check.sh | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/functions/check.sh b/functions/check.sh index 25716ded6..577ca2780 100644 --- a/functions/check.sh +++ b/functions/check.sh @@ -25,10 +25,12 @@ if [ "${function_selfname}" != "command_install.sh" ]; then check_systemdir.sh fi -local denied_commands_array=( command_install.sh command_details.sh compress_unreal2_maps.sh compress_ut99_maps.sh ) -for denied_command in "${denied_commands_array[@]}" +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 [ "${denied_command}" != "${function_selfname}" ]; then + if [ "${allowed_command}" == "${function_selfname}" ]; then + : + else check_logs.sh fi done From 178bf946d8bf21c43c4d89fd3c3a37e35c1f4b34 Mon Sep 17 00:00:00 2001 From: Daniel Gibbs Date: Tue, 29 Dec 2015 00:08:49 +0000 Subject: [PATCH 23/25] logs fix --- functions/check.sh | 2 -- 1 file changed, 2 deletions(-) diff --git a/functions/check.sh b/functions/check.sh index 577ca2780..18586a3b3 100644 --- a/functions/check.sh +++ b/functions/check.sh @@ -29,8 +29,6 @@ local allowed_commands_array=( command_backup.sh command_console.sh command_debu for allowed_command in "${allowed_commands_array[@]}" do if [ "${allowed_command}" == "${function_selfname}" ]; then - : - else check_logs.sh fi done From f2d2467cbba4d66838e664362f1efb551160ffc9 Mon Sep 17 00:00:00 2001 From: Daniel Gibbs Date: Tue, 29 Dec 2015 00:13:28 +0000 Subject: [PATCH 24/25] Bypass steamcmd checks for non-steamcmd servers --- functions/check.sh | 6 +++++- functions/check_steamcmd.sh | 2 +- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/functions/check.sh b/functions/check.sh index 18586a3b3..909c04777 100644 --- a/functions/check.sh +++ b/functions/check.sh @@ -45,7 +45,11 @@ local allowed_commands_array=( command_debug.sh command_start.sh command_stop.sh for allowed_command in "${allowed_commands_array[@]}" do if [ "${allowed_command}" == "${function_selfname}" ]; then - check_steamcmd.sh + 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 diff --git a/functions/check_steamcmd.sh b/functions/check_steamcmd.sh index b2ba69727..530bd4b73 100644 --- a/functions/check_steamcmd.sh +++ b/functions/check_steamcmd.sh @@ -7,7 +7,7 @@ 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" ]||[ "${gamename}" == "Mumble" ]; 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 # Checks steamuser is setup. From 48281a3384fe043d66d00e93ea7a07426cff1b32 Mon Sep 17 00:00:00 2001 From: Daniel Gibbs Date: Tue, 29 Dec 2015 00:16:11 +0000 Subject: [PATCH 25/25] typo --- functions/core_getopt.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/functions/core_getopt.sh b/functions/core_getopt.sh index 6d1f1bfbc..2b90be321 100644 --- a/functions/core_getopt.sh +++ b/functions/core_getopt.sh @@ -408,7 +408,7 @@ exit } if [ "${gamename}" == "Mumble" ]; then - fn_getopt__mumble + fn_getopt_mumble elif [ "${gamename}" == "Teamspeak 3" ]; then fn_getopt_teamspeak3 elif [ "${engine}" == "unreal2" ]; then