From 9198dc1ba4975551cb3e1b9601be2690106c51ac Mon Sep 17 00:00:00 2001 From: Daniel Gibbs Date: Sat, 16 Jan 2016 08:16:53 +0000 Subject: [PATCH 01/16] added error for readelf not existing --- functions/command_dev_detect_deps.sh | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/functions/command_dev_detect_deps.sh b/functions/command_dev_detect_deps.sh index 30f89157d..f6d1da766 100644 --- a/functions/command_dev_detect_deps.sh +++ b/functions/command_dev_detect_deps.sh @@ -35,10 +35,12 @@ elif [ "${executable}" == "./ts3server_startscript.sh" ]; then executable=ts3server_linux_amd64 fi -if [ -n "$(command -v eu-readelf)" ]; then +if [ "$(command -v eu-readelf)" ]; then readelf=eu-readelf -else +elif [ "$(command -v readelf)" ]; readelf=readelf +else + echo "readelf/eu-readelf not installed" fi ${readelf} -d ${executable} |grep NEEDED|awk '{ print $5 }'|sed 's/\[//g'|sed 's/\]//g' > "${rootdir}/.depdetect_readelf" From 10dbf68f17897b25d00846f796aee162c9d5bc70 Mon Sep 17 00:00:00 2001 From: Daniel Gibbs Date: Sun, 17 Jan 2016 21:03:37 +0000 Subject: [PATCH 02/16] 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 From 708448b02064bc2869978b94cb12b5ba4b365d73 Mon Sep 17 00:00:00 2001 From: Daniel Gibbs Date: Sat, 23 Jan 2016 07:51:57 +0000 Subject: [PATCH 03/16] added jc2server --- functions/check_deps.sh | 97 +++++++++++++++++++++++++---------------- 1 file changed, 60 insertions(+), 37 deletions(-) diff --git a/functions/check_deps.sh b/functions/check_deps.sh index f438f7240..a92f67bf4 100644 --- a/functions/check_deps.sh +++ b/functions/check_deps.sh @@ -2,54 +2,77 @@ # LGSM check_deps.sh function # Author: Daniel Gibbs # Website: http://gameservermanagers.com +lgsm_version="170116" # Description: Checks that the require dependencies are installed for LGSM fn_deps_detector(){ +# Checks is dependency is missing if [ -n "$(command -v dpkg-query)" ]; then - dpkg-query -W -f='${Status}' ${deptocheck} | grep -q -P '^install ok installed$'; + 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" + if [ "${depstatus}" == "0" ]; then + missingdep=0 + echo -en " \e[0;32m${deptocheck}\e[0m" + else + # if missing dependency is flagged + missingdep=1 + echo -en " \e[0;31m${deptocheck}\e[0m" + fi + sleep 0.5 +fi + +# Add missing dependencies are added to array_deps_missing array +if [ "${missingdep}" == "1" ]; then + array_deps_missing+=("${deptocheck}") fi +} +fn_deps_email(){ +# Adds postfix to required dependencies if email notification is enabled +if [ "${emailnotification}" == "on" ]; then + array_deps_required+=("mailutils postfix") +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 +# Generate array of missing deps +array_deps_missing=() +fn_printdots "Checking for missing dependencies:" +if [ "${executable}" == "./srcds_run" ]||[ "${executable}" == "./dabds.sh" ]||[ "${executable}" == "./srcds_run.sh" ]||[ "${executable}" == "./Jcmp-Server" ] ; then + local array_deps_required=( tmux curl lib32gcc1 libstdc++6:i386 ) + fn_deps_email +elif +else + fn_printfail "Unknown executable" + exit +fi -elif [ "${executable}" == "./ts3server_startscript.sh" ]; then - executable=ts3server_linux_amd64 +# Loop though required depenencies +for deptocheck in "${array_deps_required[@]}" +do + fn_deps_detector +done + +if [ "${#array_deps_missing[@]}" != "0" ]; then + fn_printwarnnl "Dependency Missing: \e[0;31m${array_deps_missing[@]}\e[0m" + sleep 2 + sudo -n true + if [ $? -eq 0 ]; then + fn_printinfonl "Attempting to install missing dependencies automatically" + echo -en ".\r" + sleep 1 + echo -en "..\r" + sleep 1 + echo -en "...\r" + sleep 1 + echo -en " \r" + sudo apt-get install ${array_deps_missing[@]} + else + echo "sudo apt-get install ${array_deps_missing[@]}" + fi +else + fn_printoknl "Checking for missing dependencies" fi \ No newline at end of file From 9da2c79acf852c21045b1d2371052ac83aa710d1 Mon Sep 17 00:00:00 2001 From: Daniel Gibbs Date: Sat, 23 Jan 2016 07:52:44 +0000 Subject: [PATCH 04/16] removed elif --- functions/check_deps.sh | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/functions/check_deps.sh b/functions/check_deps.sh index a92f67bf4..da297dc26 100644 --- a/functions/check_deps.sh +++ b/functions/check_deps.sh @@ -43,8 +43,7 @@ array_deps_missing=() fn_printdots "Checking for missing dependencies:" if [ "${executable}" == "./srcds_run" ]||[ "${executable}" == "./dabds.sh" ]||[ "${executable}" == "./srcds_run.sh" ]||[ "${executable}" == "./Jcmp-Server" ] ; then local array_deps_required=( tmux curl lib32gcc1 libstdc++6:i386 ) - fn_deps_email -elif + fn_deps_email else fn_printfail "Unknown executable" exit From bf3fda25b03c266488980a50b349403b139ab64b Mon Sep 17 00:00:00 2001 From: Daniel Gibbs Date: Sun, 31 Jan 2016 20:07:30 +0000 Subject: [PATCH 05/16] Altered script log messages slightly --- functions/check_deps.sh | 106 ++++++++++++++++++++++++---------- functions/fn_update_functions | 6 +- functions/update_check.sh | 1 - functions/update_functions.sh | 6 +- 4 files changed, 82 insertions(+), 37 deletions(-) diff --git a/functions/check_deps.sh b/functions/check_deps.sh index da297dc26..b279dc026 100644 --- a/functions/check_deps.sh +++ b/functions/check_deps.sh @@ -2,7 +2,7 @@ # LGSM check_deps.sh function # Author: Daniel Gibbs # Website: http://gameservermanagers.com -lgsm_version="170116" +lgsm_version="310116" # Description: Checks that the require dependencies are installed for LGSM @@ -10,17 +10,14 @@ lgsm_version="170116" fn_deps_detector(){ # Checks is dependency is missing if [ -n "$(command -v dpkg-query)" ]; then - dpkg-query -W -f='${Status}' ${deptocheck} | grep -q -P '^install ok installed$' + dpkg-query -W -f='${Status}' ${deptocheck} 2>/dev/null| grep -q -P '^install ok installed$' depstatus=$? if [ "${depstatus}" == "0" ]; then missingdep=0 - echo -en " \e[0;32m${deptocheck}\e[0m" else # if missing dependency is flagged missingdep=1 - echo -en " \e[0;31m${deptocheck}\e[0m" fi - sleep 0.5 fi # Add missing dependencies are added to array_deps_missing array @@ -32,33 +29,18 @@ fi fn_deps_email(){ # Adds postfix to required dependencies if email notification is enabled if [ "${emailnotification}" == "on" ]; then - array_deps_required+=("mailutils postfix") + array_deps_required+=( mailutils postfix ) fi } - -cd "${executabledir}" -# Generate array of missing deps -array_deps_missing=() -fn_printdots "Checking for missing dependencies:" -if [ "${executable}" == "./srcds_run" ]||[ "${executable}" == "./dabds.sh" ]||[ "${executable}" == "./srcds_run.sh" ]||[ "${executable}" == "./Jcmp-Server" ] ; then - local array_deps_required=( tmux curl lib32gcc1 libstdc++6:i386 ) - fn_deps_email -else - fn_printfail "Unknown executable" - exit -fi - -# Loop though required depenencies -for deptocheck in "${array_deps_required[@]}" -do - fn_deps_detector -done - +fn_found_missing_deps(){ if [ "${#array_deps_missing[@]}" != "0" ]; then - fn_printwarnnl "Dependency Missing: \e[0;31m${array_deps_missing[@]}\e[0m" + fn_printdots "Checking dependencies" sleep 2 - sudo -n true + fn_printwarn "Checking dependencies: Dependency missing: \e[0;31m${array_deps_missing[@]}\e[0m" + sleep 1 + echo -e "" + sudo -n true > /dev/null 2>&1 if [ $? -eq 0 ]; then fn_printinfonl "Attempting to install missing dependencies automatically" echo -en ".\r" @@ -69,9 +51,73 @@ if [ "${#array_deps_missing[@]}" != "0" ]; then sleep 1 echo -en " \r" sudo apt-get install ${array_deps_missing[@]} + exit 1 else + echo "" + fn_printinfomationnl "$(whoami) does not have sudo access. manually install dependencies" + echo "" echo "sudo apt-get install ${array_deps_missing[@]}" - fi -else - fn_printoknl "Checking for missing dependencies" + echo "" + exit 1 + fi +fi +} + + + +# Check will only run if using apt-get or yum +if [ -n "$(command -v dpkg-query)" ]; then + # Generate array of missing deps + array_deps_missing=() + fn_printdots "Checking dependencies" + + # LGSM requirement for curl + local array_deps_required=( curl ) + + # All servers except ts3 require tmux + if [ "${executable}" != "./ts3server_startscript.sh" ]; then + local array_deps_required+=( tmux ) + fi + + # All servers excelts ts3 & mumble require libstdc++6,lib32gcc1 + if [ "${executable}" != "./ts3server_startscript.sh" ]||[ "${executable}" != "./murmur.x86" ]; then + local array_deps_required+=( lib32gcc1 libstdc++6:i386 ) + fi + +# Game Specific requirements + + # Spark + if [ "${engine}" == "spark" ]; then + local array_deps_required+=( speex:i386 libtbb2 ) + # 7 Days to Die + elif [ "${executable}" == "./7DaysToDie.sh" ]; then + local array_deps_required+=( telnet expect ) + # Brainbread 2 and Don't Starve Together + elif [ "${gamename}" == "Brainbread 2" ]||[ "${gamename}" == "Don't Starve Together" ]; then + local array_deps_required+=( libcurl4-gnutls-dev:i386 ) + if [ "${engine}" == "projectzomboid" ]; then + local array_deps_required+=( openjdk-7-jre ) + # Unreal engine + elif [ "${executable}" == "./ucc-bin" ]; then + #UT2K4 + if [ -f "${executabledir}/ut2004-bin" ]; then + local array_deps_required+=( libsdl1.2debian libstdc++5:i386 bzip2 unzip ) + #UT99 + else + local array_deps_required+=( libsdl1.2debian bzip2 ) + fi + else + fn_printfail "Unknown executable" + exit + fi + fn_deps_email + + # Loop though required depenencies + for deptocheck in "${array_deps_required[@]}" + do + fn_deps_detector + done + + # user to be informaed of any missing dependecies + fn_found_missing_deps fi \ No newline at end of file diff --git a/functions/fn_update_functions b/functions/fn_update_functions index 185f44f5e..2de9afd6d 100644 --- a/functions/fn_update_functions +++ b/functions/fn_update_functions @@ -2,7 +2,7 @@ # LGSM update_functions.sh function # Author: Daniel Gibbs # Website: http://gameservermanagers.com -lgsm_version="271215" +lgsm_version="230116" # Description: LEGACY FUNCTION Deletes the functions dir to allow re-downloading of functions from GitHub. @@ -14,9 +14,9 @@ rm -rfv "${rootdir}/functions/"* exitcode=$? if [ "${exitcode}" == "0" ]; then fn_printok "Updating functions" - fn_scriptlog "Successfull! Updating functions" + fn_scriptlog "Success! Updating functions" else - fn_printokfail "Updating functions" + fn_printfail "Updating functions" fn_scriptlog "Failure! Updating functions" fi echo -ne "\n" \ No newline at end of file diff --git a/functions/update_check.sh b/functions/update_check.sh index e0ba3ea96..38e786544 100644 --- a/functions/update_check.sh +++ b/functions/update_check.sh @@ -188,7 +188,6 @@ sleep 1 # Checks currentbuild info is available, if fails a server restart will be forced to generate logs if [ -z "$(find ./* -name 'ts3server*_0.log')" ]; then fn_printfail "Checking for update: teamspeak.com" - fn_scriptlog "Checking for update: teamspeak.com" sleep 1 fn_printfailnl "Checking for update: teamspeak.com: No logs with server version found" fn_scriptlog "Failure! Checking for update: teamspeak.com: No logs with server version found" diff --git a/functions/update_functions.sh b/functions/update_functions.sh index 350714ed0..196b90f75 100644 --- a/functions/update_functions.sh +++ b/functions/update_functions.sh @@ -2,7 +2,7 @@ # LGSM update_functions.sh function # Author: Daniel Gibbs # Website: http://gameservermanagers.com -lgsm_version="271215" +lgsm_version="230116" # Description: Deletes the functions dir to allow re-downloading of functions from GitHub. @@ -16,9 +16,9 @@ rm -rfv "${rootdir}/functions/"* exitcode=$? if [ "${exitcode}" == "0" ]; then fn_printok "Updating functions" - fn_scriptlog "Successfull! Updating functions" + fn_scriptlog "Success! Updating functions" else - fn_printokfail "Updating functions" + fn_printfail "Updating functions" fn_scriptlog "Failure! Updating functions" fi echo -ne "\n" \ No newline at end of file From 70a5b460d8c3f69c517b348819f216a4fbb82588 Mon Sep 17 00:00:00 2001 From: Daniel Gibbs Date: Sun, 31 Jan 2016 20:14:23 +0000 Subject: [PATCH 06/16] removed local --- functions/check_deps.sh | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/functions/check_deps.sh b/functions/check_deps.sh index b279dc026..fabdf81b5 100644 --- a/functions/check_deps.sh +++ b/functions/check_deps.sh @@ -72,39 +72,39 @@ if [ -n "$(command -v dpkg-query)" ]; then fn_printdots "Checking dependencies" # LGSM requirement for curl - local array_deps_required=( curl ) + array_deps_required=( curl ) # All servers except ts3 require tmux if [ "${executable}" != "./ts3server_startscript.sh" ]; then - local array_deps_required+=( tmux ) + array_deps_required+=( tmux ) fi # All servers excelts ts3 & mumble require libstdc++6,lib32gcc1 if [ "${executable}" != "./ts3server_startscript.sh" ]||[ "${executable}" != "./murmur.x86" ]; then - local array_deps_required+=( lib32gcc1 libstdc++6:i386 ) + array_deps_required+=( lib32gcc1 libstdc++6:i386 ) fi # Game Specific requirements # Spark if [ "${engine}" == "spark" ]; then - local array_deps_required+=( speex:i386 libtbb2 ) + array_deps_required+=( speex:i386 libtbb2 ) # 7 Days to Die elif [ "${executable}" == "./7DaysToDie.sh" ]; then - local array_deps_required+=( telnet expect ) + array_deps_required+=( telnet expect ) # Brainbread 2 and Don't Starve Together elif [ "${gamename}" == "Brainbread 2" ]||[ "${gamename}" == "Don't Starve Together" ]; then - local array_deps_required+=( libcurl4-gnutls-dev:i386 ) - if [ "${engine}" == "projectzomboid" ]; then - local array_deps_required+=( openjdk-7-jre ) + array_deps_required+=( libcurl4-gnutls-dev:i386 ) + elif [ "${engine}" == "projectzomboid" ]; then + array_deps_required+=( openjdk-7-jre ) # Unreal engine elif [ "${executable}" == "./ucc-bin" ]; then #UT2K4 if [ -f "${executabledir}/ut2004-bin" ]; then - local array_deps_required+=( libsdl1.2debian libstdc++5:i386 bzip2 unzip ) + array_deps_required+=( libsdl1.2debian libstdc++5:i386 bzip2 unzip ) #UT99 else - local array_deps_required+=( libsdl1.2debian bzip2 ) + array_deps_required+=( libsdl1.2debian bzip2 ) fi else fn_printfail "Unknown executable" From 1e0c80fb1804f4997c789cbf3e286c02ff99ba6c Mon Sep 17 00:00:00 2001 From: Daniel Gibbs Date: Sun, 31 Jan 2016 20:20:03 +0000 Subject: [PATCH 07/16] Removed unknown exec if --- functions/check_deps.sh | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/functions/check_deps.sh b/functions/check_deps.sh index fabdf81b5..6a48f7214 100644 --- a/functions/check_deps.sh +++ b/functions/check_deps.sh @@ -105,10 +105,7 @@ if [ -n "$(command -v dpkg-query)" ]; then #UT99 else array_deps_required+=( libsdl1.2debian bzip2 ) - fi - else - fn_printfail "Unknown executable" - exit + fi fi fn_deps_email From fa5dfc64b310d2275c47a128ec659fd220ab6336 Mon Sep 17 00:00:00 2001 From: Daniel Gibbs Date: Sun, 31 Jan 2016 21:35:45 +0000 Subject: [PATCH 08/16] Added CentOS Support --- functions/check_deps.sh | 93 ++++++++++++++++++++++++++++++++++------- 1 file changed, 79 insertions(+), 14 deletions(-) diff --git a/functions/check_deps.sh b/functions/check_deps.sh index 6a48f7214..0e21baef8 100644 --- a/functions/check_deps.sh +++ b/functions/check_deps.sh @@ -12,6 +12,10 @@ fn_deps_detector(){ if [ -n "$(command -v dpkg-query)" ]; then dpkg-query -W -f='${Status}' ${deptocheck} 2>/dev/null| grep -q -P '^install ok installed$' depstatus=$? +elif [ -n "$(command -v yum)" ]; then + yum -q list installed ${deptocheck} 2>/dev/null + depstatus=$? +fi if [ "${depstatus}" == "0" ]; then missingdep=0 else @@ -29,7 +33,11 @@ fi fn_deps_email(){ # Adds postfix to required dependencies if email notification is enabled if [ "${emailnotification}" == "on" ]; then - array_deps_required+=( mailutils postfix ) + if [ -n "$(command -v dpkg-query)" ]; then + array_deps_required+=( mailutils postfix ) + elif [ -n "$(command -v yum)" ]; then + array_deps_required+=( mailx postfix ) + fi fi } @@ -50,20 +58,35 @@ if [ "${#array_deps_missing[@]}" != "0" ]; then echo -en "...\r" sleep 1 echo -en " \r" - sudo apt-get install ${array_deps_missing[@]} - exit 1 + if [ -n "$(command -v dpkg-query)" ]; then + echo "sudo apt-get install ${array_deps_missing[@]}" + elif [ -n "$(command -v yum)" ]; then + echo "yum install ${array_deps_missing[@]}" + fi else echo "" fn_printinfomationnl "$(whoami) does not have sudo access. manually install dependencies" echo "" - echo "sudo apt-get install ${array_deps_missing[@]}" + if [ -n "$(command -v dpkg-query)" ]; then + echo "sudo apt-get install ${array_deps_missing[@]}" + elif [ -n "$(command -v yum)" ]; then + echo "yum install ${array_deps_missing[@]}" + fi echo "" - exit 1 fi fi } +fn_check_loop(){ + # Loop though required depenencies + for deptocheck in "${array_deps_required[@]}" + do + fn_deps_detector + done + # user to be informaed of any missing dependecies + fn_found_missing_deps +} # Check will only run if using apt-get or yum if [ -n "$(command -v dpkg-query)" ]; then @@ -72,7 +95,7 @@ if [ -n "$(command -v dpkg-query)" ]; then fn_printdots "Checking dependencies" # LGSM requirement for curl - array_deps_required=( curl ) + array_deps_required=( curl ca-certificates ) # All servers except ts3 require tmux if [ "${executable}" != "./ts3server_startscript.sh" ]; then @@ -84,7 +107,7 @@ if [ -n "$(command -v dpkg-query)" ]; then array_deps_required+=( lib32gcc1 libstdc++6:i386 ) fi -# Game Specific requirements + # Game Specific requirements # Spark if [ "${engine}" == "spark" ]; then @@ -92,6 +115,9 @@ if [ -n "$(command -v dpkg-query)" ]; then # 7 Days to Die elif [ "${executable}" == "./7DaysToDie.sh" ]; then array_deps_required+=( telnet expect ) + # No More Room in Hell + elif [ "${gamename}" == "No More Room in Hell" ] + array_deps_required+=( lib32tinfo5 ) # Brainbread 2 and Don't Starve Together elif [ "${gamename}" == "Brainbread 2" ]||[ "${gamename}" == "Don't Starve Together" ]; then array_deps_required+=( libcurl4-gnutls-dev:i386 ) @@ -108,13 +134,52 @@ if [ -n "$(command -v dpkg-query)" ]; then fi fi fn_deps_email + fn_check_loop - # Loop though required depenencies - for deptocheck in "${array_deps_required[@]}" - do - fn_deps_detector - done +elif [ -n "$(command -v yum)" ]; then + # Generate array of missing deps + array_deps_missing=() + fn_printdots "Checking dependencies" - # user to be informaed of any missing dependecies - fn_found_missing_deps + # LGSM requirement for curl + array_deps_required=( curl ) + + # All servers except ts3 require tmux + if [ "${executable}" != "./ts3server_startscript.sh" ]; then + array_deps_required+=( tmux ) + fi + + # All servers excelts ts3 & mumble require libstdc++6,lib32gcc1 + if [ "${executable}" != "./ts3server_startscript.sh" ]||[ "${executable}" != "./murmur.x86" ]; then + array_deps_required+=( glibc.i686 libstdc++.i686 ) + fi + + # Game Specific requirements + + # Spark + if [ "${engine}" == "spark" ]; then + array_deps_required+=( speex.i686 tbb.i686 ) + # 7 Days to Die + elif [ "${executable}" == "./7DaysToDie.sh" ]; then + array_deps_required+=( telnet expect ) + # No More Room in Hell + elif [ "${gamename}" == "No More Room in Hell" ] + array_deps_required+=( ncurses-libs.i686 ) + # Brainbread 2 and Don't Starve Together + elif [ "${gamename}" == "Brainbread 2" ]||[ "${gamename}" == "Don't Starve Together" ]; then + array_deps_required+=( libcurl.i686 ) + elif [ "${engine}" == "projectzomboid" ]; then + array_deps_required+=( java-1.7.0-openjdk ) + # Unreal engine + elif [ "${executable}" == "./ucc-bin" ]; then + #UT2K4 + if [ -f "${executabledir}/ut2004-bin" ]; then + array_deps_required+=( compat-libstdc++-33.i686 SDL.i686 bzip2 unzip ) + #UT99 + else + array_deps_required+=( SDL.i686 bzip2 ) + fi + fi + fn_deps_email + fn_check_loop fi \ No newline at end of file From 94af491dfe43011136b8e5ef06feded04842f722 Mon Sep 17 00:00:00 2001 From: Daniel Gibbs Date: Sun, 31 Jan 2016 21:53:43 +0000 Subject: [PATCH 09/16] removed stray fi --- functions/check_deps.sh | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/functions/check_deps.sh b/functions/check_deps.sh index 0e21baef8..94899b20b 100644 --- a/functions/check_deps.sh +++ b/functions/check_deps.sh @@ -16,12 +16,11 @@ elif [ -n "$(command -v yum)" ]; then yum -q list installed ${deptocheck} 2>/dev/null depstatus=$? fi - if [ "${depstatus}" == "0" ]; then - missingdep=0 - else - # if missing dependency is flagged - missingdep=1 - fi +if [ "${depstatus}" == "0" ]; then + missingdep=0 +else + # if missing dependency is flagged + missingdep=1 fi # Add missing dependencies are added to array_deps_missing array From 288072bc866c6836e922158b07adda635d9612b8 Mon Sep 17 00:00:00 2001 From: Daniel Gibbs Date: Sun, 31 Jan 2016 22:04:51 +0000 Subject: [PATCH 10/16] added missing then --- functions/check_deps.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/functions/check_deps.sh b/functions/check_deps.sh index 94899b20b..07f67d719 100644 --- a/functions/check_deps.sh +++ b/functions/check_deps.sh @@ -115,7 +115,7 @@ if [ -n "$(command -v dpkg-query)" ]; then elif [ "${executable}" == "./7DaysToDie.sh" ]; then array_deps_required+=( telnet expect ) # No More Room in Hell - elif [ "${gamename}" == "No More Room in Hell" ] + elif [ "${gamename}" == "No More Room in Hell" ]; then array_deps_required+=( lib32tinfo5 ) # Brainbread 2 and Don't Starve Together elif [ "${gamename}" == "Brainbread 2" ]||[ "${gamename}" == "Don't Starve Together" ]; then @@ -162,7 +162,7 @@ elif [ -n "$(command -v yum)" ]; then elif [ "${executable}" == "./7DaysToDie.sh" ]; then array_deps_required+=( telnet expect ) # No More Room in Hell - elif [ "${gamename}" == "No More Room in Hell" ] + elif [ "${gamename}" == "No More Room in Hell" ]; then array_deps_required+=( ncurses-libs.i686 ) # Brainbread 2 and Don't Starve Together elif [ "${gamename}" == "Brainbread 2" ]||[ "${gamename}" == "Don't Starve Together" ]; then From f77bfa5b1b623f26eedf0d3cb1710fa0579bfb6d Mon Sep 17 00:00:00 2001 From: Daniel Gibbs Date: Sun, 31 Jan 2016 22:13:17 +0000 Subject: [PATCH 11/16] dev/null --- functions/check_deps.sh | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/functions/check_deps.sh b/functions/check_deps.sh index 07f67d719..14b1d71c3 100644 --- a/functions/check_deps.sh +++ b/functions/check_deps.sh @@ -13,7 +13,7 @@ if [ -n "$(command -v dpkg-query)" ]; then dpkg-query -W -f='${Status}' ${deptocheck} 2>/dev/null| grep -q -P '^install ok installed$' depstatus=$? elif [ -n "$(command -v yum)" ]; then - yum -q list installed ${deptocheck} 2>/dev/null + yum -q list installed ${deptocheck} > /dev/null 2>&1 depstatus=$? fi if [ "${depstatus}" == "0" ]; then @@ -91,7 +91,6 @@ fn_check_loop(){ if [ -n "$(command -v dpkg-query)" ]; then # Generate array of missing deps array_deps_missing=() - fn_printdots "Checking dependencies" # LGSM requirement for curl array_deps_required=( curl ca-certificates ) @@ -138,7 +137,6 @@ if [ -n "$(command -v dpkg-query)" ]; then elif [ -n "$(command -v yum)" ]; then # Generate array of missing deps array_deps_missing=() - fn_printdots "Checking dependencies" # LGSM requirement for curl array_deps_required=( curl ) From 6af31e04375bb93229f5ff61e6ba1d9aec1f3425 Mon Sep 17 00:00:00 2001 From: Daniel Gibbs Date: Sun, 31 Jan 2016 22:16:32 +0000 Subject: [PATCH 12/16] added add arch --- functions/check_deps.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/functions/check_deps.sh b/functions/check_deps.sh index 14b1d71c3..11a76d54b 100644 --- a/functions/check_deps.sh +++ b/functions/check_deps.sh @@ -58,7 +58,7 @@ if [ "${#array_deps_missing[@]}" != "0" ]; then sleep 1 echo -en " \r" if [ -n "$(command -v dpkg-query)" ]; then - echo "sudo apt-get install ${array_deps_missing[@]}" + echo "sudo dpkg --add-architecture i386; sudo apt-get install ${array_deps_missing[@]}" elif [ -n "$(command -v yum)" ]; then echo "yum install ${array_deps_missing[@]}" fi @@ -67,7 +67,7 @@ if [ "${#array_deps_missing[@]}" != "0" ]; then fn_printinfomationnl "$(whoami) does not have sudo access. manually install dependencies" echo "" if [ -n "$(command -v dpkg-query)" ]; then - echo "sudo apt-get install ${array_deps_missing[@]}" + echo "sudo dpkg --add-architecture i386; sudo apt-get install ${array_deps_missing[@]}" elif [ -n "$(command -v yum)" ]; then echo "yum install ${array_deps_missing[@]}" fi From e561a86acdce50ff1758feaf3cfdafe1800ca15a Mon Sep 17 00:00:00 2001 From: Daniel Gibbs Date: Sun, 31 Jan 2016 22:46:06 +0000 Subject: [PATCH 13/16] Added to installer --- functions/check_deps.sh | 14 ++++++++++---- functions/command_install.sh | 2 +- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/functions/check_deps.sh b/functions/check_deps.sh index 11a76d54b..d14d813bb 100644 --- a/functions/check_deps.sh +++ b/functions/check_deps.sh @@ -4,11 +4,11 @@ # Website: http://gameservermanagers.com lgsm_version="310116" -# Description: Checks that the require dependencies are installed for LGSM +# Description: Checks that the requires dependencies are installed for LGSM. fn_deps_detector(){ -# Checks is dependency is missing +# Checks if dependency is missing if [ -n "$(command -v dpkg-query)" ]; then dpkg-query -W -f='${Status}' ${deptocheck} 2>/dev/null| grep -q -P '^install ok installed$' depstatus=$? @@ -19,11 +19,11 @@ fi if [ "${depstatus}" == "0" ]; then missingdep=0 else - # if missing dependency is flagged + # if missing dependency is found missingdep=1 fi -# Add missing dependencies are added to array_deps_missing array +# Missing dependencies are added to array_deps_missing if [ "${missingdep}" == "1" ]; then array_deps_missing+=("${deptocheck}") fi @@ -87,6 +87,12 @@ fn_check_loop(){ fn_found_missing_deps } +if [ "${function_selfname}" == "command_install.sh" ]; then +echo "Server Directory" +echo "=================================" +fi + + # Check will only run if using apt-get or yum if [ -n "$(command -v dpkg-query)" ]; then # Generate array of missing deps diff --git a/functions/command_install.sh b/functions/command_install.sh index f2021f071..791cb160d 100644 --- a/functions/command_install.sh +++ b/functions/command_install.sh @@ -9,7 +9,7 @@ function_selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))" check.sh install_header.sh install_serverdir.sh - +check_deps.sh # Download and install if [ "${gamename}" == "Unreal Tournament 2004" ]; then install_dl_ut2k4.sh From 5906e07c01001e5674610d43d58f2f7edcf53150 Mon Sep 17 00:00:00 2001 From: Daniel Gibbs Date: Sun, 31 Jan 2016 22:47:35 +0000 Subject: [PATCH 14/16] Added installer mode --- functions/check_deps.sh | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/functions/check_deps.sh b/functions/check_deps.sh index d14d813bb..2224ea2f4 100644 --- a/functions/check_deps.sh +++ b/functions/check_deps.sh @@ -18,9 +18,13 @@ elif [ -n "$(command -v yum)" ]; then fi if [ "${depstatus}" == "0" ]; then missingdep=0 + echo -e "\e[0;32m${deptocheck}\e[0m" + sleep 0.5 else # if missing dependency is found missingdep=1 + echo -e "\e[0;31m${deptocheck}\e[0m" + sleep 0.5 fi # Missing dependencies are added to array_deps_missing @@ -88,8 +92,9 @@ fn_check_loop(){ } if [ "${function_selfname}" == "command_install.sh" ]; then -echo "Server Directory" -echo "=================================" + echo "" + echo "Checking Dependecies" + echo "=================================" fi From a3c917d3b77115a5f723c87856d4a67ec9e3c06a Mon Sep 17 00:00:00 2001 From: Daniel Gibbs Date: Sun, 31 Jan 2016 22:48:13 +0000 Subject: [PATCH 15/16] added if --- functions/check_deps.sh | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/functions/check_deps.sh b/functions/check_deps.sh index 2224ea2f4..cf685d3a1 100644 --- a/functions/check_deps.sh +++ b/functions/check_deps.sh @@ -18,13 +18,17 @@ elif [ -n "$(command -v yum)" ]; then fi if [ "${depstatus}" == "0" ]; then missingdep=0 - echo -e "\e[0;32m${deptocheck}\e[0m" - sleep 0.5 + if [ "${function_selfname}" == "command_install.sh" ]; then + echo -e "\e[0;32m${deptocheck}\e[0m" + sleep 0.5 + fi else # if missing dependency is found missingdep=1 - echo -e "\e[0;31m${deptocheck}\e[0m" - sleep 0.5 + if [ "${function_selfname}" == "command_install.sh" ]; then + echo -e "\e[0;31m${deptocheck}\e[0m" + sleep 0.5 + fi fi # Missing dependencies are added to array_deps_missing From 26ca719fa456779063dec194f56934364c0fc085 Mon Sep 17 00:00:00 2001 From: Daniel Gibbs Date: Mon, 1 Feb 2016 20:48:19 +0000 Subject: [PATCH 16/16] Add sleep for installer --- functions/check_deps.sh | 3 +++ 1 file changed, 3 insertions(+) diff --git a/functions/check_deps.sh b/functions/check_deps.sh index cf685d3a1..1e2e99fee 100644 --- a/functions/check_deps.sh +++ b/functions/check_deps.sh @@ -81,6 +81,9 @@ if [ "${#array_deps_missing[@]}" != "0" ]; then fi echo "" fi + if [ "${function_selfname}" == "command_install.sh" ]; then + sleep 5 + fi fi }