From 10dbf68f17897b25d00846f796aee162c9d5bc70 Mon Sep 17 00:00:00 2001 From: Daniel Gibbs Date: Sun, 17 Jan 2016 21:03:37 +0000 Subject: [PATCH] Initial code to detect missing deps This code is still broken --- functions/check.sh | 10 ++++++- functions/check_deps.sh | 55 +++++++++++++++++++++++++++++++++++++ functions/core_functions.sh | 7 ++++- 3 files changed, 70 insertions(+), 2 deletions(-) create mode 100644 functions/check_deps.sh diff --git a/functions/check.sh b/functions/check.sh index 150a8e138..ca50777cc 100644 --- a/functions/check.sh +++ b/functions/check.sh @@ -2,7 +2,7 @@ # LGSM fn_check function # Author: Daniel Gibbs # Website: http://gameservermanagers.com -lgsm_version="060116" +lgsm_version="170116" # Description: Overall function for managing checks. # Runs checks that will either halt on or fix an issue. @@ -33,6 +33,14 @@ do fi done +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_deps.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 diff --git a/functions/check_deps.sh b/functions/check_deps.sh new file mode 100644 index 000000000..f438f7240 --- /dev/null +++ b/functions/check_deps.sh @@ -0,0 +1,55 @@ +#!/bin/bash +# LGSM check_deps.sh function +# Author: Daniel Gibbs +# Website: http://gameservermanagers.com + +# Description: Checks that the require dependencies are installed for LGSM + + +fn_deps_detector(){ +if [ -n "$(command -v dpkg-query)" ]; then + dpkg-query -W -f='${Status}' ${deptocheck} | grep -q -P '^install ok installed$'; + depstatus=$? +elif [ -n "$(command -v rpm)" ]; then + rpm -qa ${deptocheck} |grep -q -P ${deptocheck} + depstatus=$? +else + echo "Unknown OS" +fi + +} + +cd "${executabledir}" +if [ "${executable}" == "./hlds_run" ]; then + local depslist=( lib32gcc1 libstdc++6 libstdc++6:i386 ) + for deptocheck in "${depstocheck[@]}" + do + fn_deps_detector + done + # gold source lib32gcc1 libstdc++6 libstdc++6:i386 +elif [ "${executable}" == "./srcds_run" ]||[ "${executable}" == "./dabds.sh" ]||[ "${executable}" == "./srcds_run.sh" ]; then + local depslist=( lib32gcc1 libstdc++6 libstdc++6:i386 ) + for deptocheck in "${depstocheck[@]}" + do + fn_deps_detector + done + # source lib32gcc1 libstdc++6 libstdc++6:i386 +elif [ "${executable}" == "./server_linux32" ]; then + # lib32gcc1 libstdc++6 libstdc++6:i386 speex:i386 libtbb2 +elif [ "${executable}" == "./runSam3_DedicatedServer.sh" ]; then + # spark lib32gcc1 libstdc++6 libstdc++6:i386 +elif [ "${executable}" == "./7DaysToDie.sh" ]; then + # lib32gcc1 libstdc++6 libstdc++6:i386 telnet expect +elif [ "${executable}" == "./ucc-bin" ]; then + + if [ -f "${executabledir}/ucc-bin-real" ]; then + executable=ucc-bin-real + elif [ -f "${executabledir}/ut2004-bin" ]; then + executable=ut2004-bin + else + executable=ut-bin + fi + +elif [ "${executable}" == "./ts3server_startscript.sh" ]; then + executable=ts3server_linux_amd64 +fi \ No newline at end of file diff --git a/functions/core_functions.sh b/functions/core_functions.sh index 560a2ee26..7b0f148cd 100644 --- a/functions/core_functions.sh +++ b/functions/core_functions.sh @@ -2,7 +2,7 @@ # LGSM core_functions.sh function # Author: Daniel Gibbs # Website: http://gameservermanagers.com -lgsm_version="060116" +lgsm_version="170116" # Description: Defines all functions to allow download and execution of functions using fn_runfunction. # This function is called first before any other function. Without this file other functions would not load. @@ -111,6 +111,11 @@ functionfile="${FUNCNAME}" fn_runfunction } +check_deps.sh(){ +functionfile="${FUNCNAME}" +fn_runfunction +} + check_ip.sh(){ functionfile="${FUNCNAME}" fn_runfunction