From f01b5db0ab35d18e6211f8d4131af6764a12db85 Mon Sep 17 00:00:00 2001 From: Daniel Gibbs Date: Thu, 1 Sep 2016 22:47:27 +0100 Subject: [PATCH 1/7] #1027 and tmux improvements. --- lgsm/functions/check_deps.sh | 45 +++++++++++++++++++++++++----------- 1 file changed, 32 insertions(+), 13 deletions(-) diff --git a/lgsm/functions/check_deps.sh b/lgsm/functions/check_deps.sh index 51b9befbc..2944fca04 100644 --- a/lgsm/functions/check_deps.sh +++ b/lgsm/functions/check_deps.sh @@ -6,28 +6,37 @@ local commandname="CHECK" + + fn_deps_detector(){ # Checks if dependency is missing - if [ -n "$(command -v dpkg-query)" ]; then + if [ "${tmuxcheck}" == "1" ]; then + # Added for users compiling tmux from source to bypass check. + depstatus=0 + deptocheck="tmux" + unset tmuxcheck + elif [ "${javacheck}" == "1" ]; then + # Added for users using Oracle JRE to bypass check. + depstatus=0 + deptocheck="${javaversion}" + unset javacheck + elif [ -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} > /dev/null 2>&1 depstatus=$? fi + if [ "${depstatus}" == "0" ]; then + # if dependency is found missingdep=0 if [ "${function_selfname}" == "command_install.sh" ]; then - if [ "${tmuxcheck}" == "1" ]; then - # Added for users compiling tmux from source to bypass rpm check - echo -e "${green}tmux${default}" - unset tmuxcheck - fi echo -e "${green}${deptocheck}${default}" sleep 0.5 fi else - # if missing dependency is found + # if dependency is not found missingdep=1 if [ "${function_selfname}" == "command_install.sh" ]; then echo -e "${red}${deptocheck}${default}" @@ -141,9 +150,9 @@ if [ -n "$(command -v dpkg-query)" ]; then array_deps_required=( curl wget ca-certificates file bsdmainutils util-linux python bzip2 gzip ) # All servers except ts3 require tmux - if [ "${executable}" != "./ts3server_startscript.sh" ]; then + if [ "${gamename}" != "TeamSpeak 3" ]; then if [ "$(command -v tmux)" ]||[ "$(which tmux 2>/dev/null)" ]||[ -f "/usr/bin/tmux" ]||[ -f "/bin/tmux" ]; then - tmuxcheck=1 # Added for users compiling tmux from source to bypass rpm check + tmuxcheck=1 # Added for users compiling tmux from source to bypass check. else array_deps_required+=( tmux ) fi @@ -181,7 +190,12 @@ if [ -n "$(command -v dpkg-query)" ]; then array_deps_required+=( libncurses5:i386 ) # Project Zomboid and Minecraft elif [ "${engine}" == "projectzomboid" ]||[ "${engine}" == "lwjgl2" ]; then - array_deps_required+=( default-jdk ) + javaversion=$(java -version 2>&1 | grep "version") + if [ -n "${javaversion}" ]; then + javacheck=1 # Added for users using Oracle JRE to bypass the check. + else + array_deps_required+=( default-jre ) + fi # GoldenEye: Source elif [ "${gamename}" == "GoldenEye: Source" ]; then array_deps_required+=( zlib1g:i386 ) @@ -213,9 +227,9 @@ elif [ -n "$(command -v yum)" ]; then fi # All servers except ts3 require tmux - if [ "${executable}" != "./ts3server_startscript.sh" ]; then + if [ "${gamename}" != "TeamSpeak 3" ]; then if [ "$(command -v tmux)" ]||[ "$(which tmux 2>/dev/null)" ]||[ -f "/usr/bin/tmux" ]||[ -f "/bin/tmux" ]; then - tmuxcheck=1 # Added for users compiling tmux from source to bypass rpm check + tmuxcheck=1 # Added for users compiling tmux from source to bypass check. else array_deps_required+=( tmux ) fi @@ -242,7 +256,12 @@ elif [ -n "$(command -v yum)" ]; then array_deps_required+=( libcurl.i686 ) # Project Zomboid and Minecraft elif [ "${engine}" == "projectzomboid" ]||[ "${engine}" == "lwjgl2" ]; then - array_deps_required+=( java-1.8.0-openjdk ) + javaversion=$(java -version 2>&1 | grep "version") + if [ -n "${javaversion}" ]; then + javacheck=1 # Added for users using Oracle JRE to bypass the check. + else + array_deps_required+=( java-1.8.0-openjdk ) + fi # GoldenEye: Source elif [ "${gamename}" == "GoldenEye: Source" ]; then array_deps_required+=( zlib.i686 ) From 125887e78f64f62aad36c38f7ba8d6ad6ba22956 Mon Sep 17 00:00:00 2001 From: Daniel Gibbs Date: Thu, 1 Sep 2016 23:09:41 +0100 Subject: [PATCH 2/7] detect apt-get rather than dpkg-query #1004 --- lgsm/functions/check_deps.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lgsm/functions/check_deps.sh b/lgsm/functions/check_deps.sh index 2944fca04..eb9d21f03 100644 --- a/lgsm/functions/check_deps.sh +++ b/lgsm/functions/check_deps.sh @@ -20,7 +20,7 @@ fn_deps_detector(){ depstatus=0 deptocheck="${javaversion}" unset javacheck - elif [ -n "$(command -v dpkg-query)" ]; then + elif [ -n "$(command -v apt-get)" ]; then dpkg-query -W -f='${Status}' ${deptocheck} 2>/dev/null | grep -q -P '^install ok installed$' depstatus=$? elif [ -n "$(command -v yum)" ]; then From 0a6a5df900acee70548ea06925abf10e47df827c Mon Sep 17 00:00:00 2001 From: Daniel Gibbs Date: Fri, 2 Sep 2016 21:12:46 +0100 Subject: [PATCH 3/7] Updated md5sum --- lgsm/functions/command_dev_detect_ldd.sh | 31 ++++++++++++++++++++++++ lgsm/functions/install_server_files.sh | 2 +- 2 files changed, 32 insertions(+), 1 deletion(-) create mode 100644 lgsm/functions/command_dev_detect_ldd.sh diff --git a/lgsm/functions/command_dev_detect_ldd.sh b/lgsm/functions/command_dev_detect_ldd.sh new file mode 100644 index 000000000..80b1d460b --- /dev/null +++ b/lgsm/functions/command_dev_detect_ldd.sh @@ -0,0 +1,31 @@ +#!/bin/bash +# command_dev_detect_ldd.sh function +# Author: Daniel Gibbs +# Website: https://gameservermanagers.com +# Description: Automatically detects required deps using ldd. +# Can check a file or directory recursively. + +echo "=================================" +echo "LDD Requirements Checker" +echo "=================================" + +if [ -z "${filesdir}" ]; then + dir="$(dirname $(readlink -f "${BASH_SOURCE[0]}"))" +fi + +if [ -d "${filesdir}" ]; then + echo "Checking directory: " + echo "${filesdir}" +elif [ -f "${filesdir}" ]; then + echo "Checking file: " + echo "${filesdir}" +fi +echo "" + +find ${filesdir} -type f -print0 | +while IFS= read -r -d $'\0' line; do + ldd $line |grep "=>" >>"${lgsmdir}/tmp/detect_ldd.tmp" +done + +cat "${lgsmdir}/tmp/detect_ldd.tmp"|sort|uniq|sort -r --version-sort +rm "${lgsmdir}/tmp/detect_ldd.tmp" \ No newline at end of file diff --git a/lgsm/functions/install_server_files.sh b/lgsm/functions/install_server_files.sh index 78057b680..65f32c134 100644 --- a/lgsm/functions/install_server_files.sh +++ b/lgsm/functions/install_server_files.sh @@ -22,7 +22,7 @@ fn_install_server_files(){ elif [ "${gamename}" == "Unreal Tournament" ]; then fileurl="http://files.gameservermanagers.com/UnrealTournament/UnrealTournament-Server-XAN-3045522-Linux.zip"; filedir="${lgsmdir}/tmp"; filename="UnrealTournament-Server-XAN-3045522-Linux.zip"; executecmd="noexecute" run="norun"; force="noforce"; md5="553fed5645a9fc623e92563049bf79f6" elif [ "${gamename}" == "GoldenEye: Source" ]; then - fileurl="http://files.gameservermanagers.com/GoldenEyeSource/GoldenEye_Source_v5.0.1_full_server_linux.tar.bz2"; filedir="${lgsmdir}/tmp"; filename="GoldenEye_Source_v5.0.1_server_full_Linux.tar.bz2"; executecmd="noexecute" run="norun"; force="noforce"; md5="254533d4643ad2fe6f1f3ecc4f6b5e5f" + fileurl="http://files.gameservermanagers.com/GoldenEyeSource/GoldenEye_Source_v5.0.1_full_server_linux.tar.bz2"; filedir="${lgsmdir}/tmp"; filename="GoldenEye_Source_v5.0.1_server_full_Linux.tar.bz2"; executecmd="noexecute" run="norun"; force="noforce"; md5="ea227a150300abe346e757380325f84c" fi fn_fetch_file "${fileurl}" "${filedir}" "${filename}" "${executecmd}" "${run}" "${force}" "${md5}" fn_dl_extract "${filedir}" "${filename}" "${filesdir}" From 68b7a384d3211a5ff00ef1d42d8adcf2c9de9750 Mon Sep 17 00:00:00 2001 From: Daniel Gibbs Date: Fri, 2 Sep 2016 21:33:25 +0100 Subject: [PATCH 4/7] added detect ldd --- lgsm/functions/core_functions.sh | 5 +++++ lgsm/functions/core_getopt.sh | 16 ++++++++++++++++ 2 files changed, 21 insertions(+) diff --git a/lgsm/functions/core_functions.sh b/lgsm/functions/core_functions.sh index c02845054..de36e7a21 100644 --- a/lgsm/functions/core_functions.sh +++ b/lgsm/functions/core_functions.sh @@ -283,6 +283,11 @@ functionfile="${FUNCNAME}" fn_fetch_function } +command_dev_detect_ldd.sh(){ +functionfile="${FUNCNAME}" +fn_fetch_function +} + # Fix fix.sh(){ diff --git a/lgsm/functions/core_getopt.sh b/lgsm/functions/core_getopt.sh index 67f671209..faaedb9e0 100644 --- a/lgsm/functions/core_getopt.sh +++ b/lgsm/functions/core_getopt.sh @@ -45,6 +45,8 @@ case "${getopt}" in command_dev_detect_deps.sh;; dg|detect-glibc) command_dev_detect_glibc.sh;; + dg|detect-ldd) + command_dev_detect_ldd.sh;; *) if [ -n "${getopt}" ]; then echo -e "${red}Unknown command${default}: $0 ${getopt}" @@ -107,6 +109,8 @@ case "${getopt}" in command_dev_detect_deps.sh;; dg|detect-glibc) command_dev_detect_glibc.sh;; + dg|detect-ldd) + command_dev_detect_ldd.sh;; *) if [ -n "${getopt}" ]; then echo -e "${red}Unknown command${default}: $0 ${getopt}" @@ -168,6 +172,8 @@ case "${getopt}" in command_dev_detect_deps.sh;; dg|detect-glibc) command_dev_detect_glibc.sh;; + dg|detect-ldd) + command_dev_detect_ldd.sh;; *) if [ -n "${getopt}" ]; then echo -e "${red}Unknown command${default}: $0 ${getopt}" @@ -224,6 +230,8 @@ case "${getopt}" in command_dev_detect_deps.sh;; dg|detect-glibc) command_dev_detect_glibc.sh;; + dg|detect-ldd) + command_dev_detect_ldd.sh;; *) if [ -n "${getopt}" ]; then echo -e "${red}Unknown command${default}: $0 ${getopt}" @@ -288,6 +296,8 @@ case "${getopt}" in command_dev_detect_deps.sh;; dg|detect-glibc) command_dev_detect_glibc.sh;; + dg|detect-ldd) + command_dev_detect_ldd.sh;; fd|fastdl) command_fastdl.sh;; *) @@ -355,6 +365,8 @@ case "${getopt}" in command_dev_detect_deps.sh;; dg|detect-glibc) command_dev_detect_glibc.sh;; + dg|detect-ldd) + command_dev_detect_ldd.sh;; *) if [ -n "${getopt}" ]; then echo -e "${red}Unknown command${default}: $0 ${getopt}" @@ -423,6 +435,8 @@ case "${getopt}" in command_dev_detect_deps.sh;; dg|detect-glibc) command_dev_detect_glibc.sh;; + dg|detect-ldd) + command_dev_detect_ldd.sh;; mc|map-compressor) compress_unreal2_maps.sh;; *) @@ -493,6 +507,8 @@ case "${getopt}" in command_dev_detect_deps.sh;; dg|detect-glibc) command_dev_detect_glibc.sh;; + dg|detect-ldd) + command_dev_detect_ldd.sh;; *) if [ -n "${getopt}" ]; then echo -e "${red}Unknown command${default}: $0 ${getopt}" From 4630472d19fbf320296605b7a6a87085cb8b5acc Mon Sep 17 00:00:00 2001 From: Daniel Gibbs Date: Fri, 2 Sep 2016 21:36:17 +0100 Subject: [PATCH 5/7] changed dg to dl --- lgsm/functions/core_getopt.sh | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/lgsm/functions/core_getopt.sh b/lgsm/functions/core_getopt.sh index faaedb9e0..5b7042f8c 100644 --- a/lgsm/functions/core_getopt.sh +++ b/lgsm/functions/core_getopt.sh @@ -45,7 +45,7 @@ case "${getopt}" in command_dev_detect_deps.sh;; dg|detect-glibc) command_dev_detect_glibc.sh;; - dg|detect-ldd) + dl|detect-ldd) command_dev_detect_ldd.sh;; *) if [ -n "${getopt}" ]; then @@ -109,7 +109,7 @@ case "${getopt}" in command_dev_detect_deps.sh;; dg|detect-glibc) command_dev_detect_glibc.sh;; - dg|detect-ldd) + dl|detect-ldd) command_dev_detect_ldd.sh;; *) if [ -n "${getopt}" ]; then @@ -172,7 +172,7 @@ case "${getopt}" in command_dev_detect_deps.sh;; dg|detect-glibc) command_dev_detect_glibc.sh;; - dg|detect-ldd) + dl|detect-ldd) command_dev_detect_ldd.sh;; *) if [ -n "${getopt}" ]; then @@ -230,7 +230,7 @@ case "${getopt}" in command_dev_detect_deps.sh;; dg|detect-glibc) command_dev_detect_glibc.sh;; - dg|detect-ldd) + dl|detect-ldd) command_dev_detect_ldd.sh;; *) if [ -n "${getopt}" ]; then @@ -296,7 +296,7 @@ case "${getopt}" in command_dev_detect_deps.sh;; dg|detect-glibc) command_dev_detect_glibc.sh;; - dg|detect-ldd) + dl|detect-ldd) command_dev_detect_ldd.sh;; fd|fastdl) command_fastdl.sh;; @@ -365,7 +365,7 @@ case "${getopt}" in command_dev_detect_deps.sh;; dg|detect-glibc) command_dev_detect_glibc.sh;; - dg|detect-ldd) + dl|detect-ldd) command_dev_detect_ldd.sh;; *) if [ -n "${getopt}" ]; then @@ -435,7 +435,7 @@ case "${getopt}" in command_dev_detect_deps.sh;; dg|detect-glibc) command_dev_detect_glibc.sh;; - dg|detect-ldd) + dl|detect-ldd) command_dev_detect_ldd.sh;; mc|map-compressor) compress_unreal2_maps.sh;; @@ -507,7 +507,7 @@ case "${getopt}" in command_dev_detect_deps.sh;; dg|detect-glibc) command_dev_detect_glibc.sh;; - dg|detect-ldd) + dl|detect-ldd) command_dev_detect_ldd.sh;; *) if [ -n "${getopt}" ]; then From 14a066a076c9e14cba5c798589606871976d256e Mon Sep 17 00:00:00 2001 From: Daniel Gibbs Date: Sat, 3 Sep 2016 02:13:33 +0100 Subject: [PATCH 6/7] Added Shared Object dependencies Checker --- lgsm/functions/command_dev_detect_ldd.sh | 30 ++++++++++++++++++++---- 1 file changed, 26 insertions(+), 4 deletions(-) diff --git a/lgsm/functions/command_dev_detect_ldd.sh b/lgsm/functions/command_dev_detect_ldd.sh index 80b1d460b..b9be9386a 100644 --- a/lgsm/functions/command_dev_detect_ldd.sh +++ b/lgsm/functions/command_dev_detect_ldd.sh @@ -6,7 +6,7 @@ # Can check a file or directory recursively. echo "=================================" -echo "LDD Requirements Checker" +echo "Shared Object dependencies Checker" echo "=================================" if [ -z "${filesdir}" ]; then @@ -22,10 +22,32 @@ elif [ -f "${filesdir}" ]; then fi echo "" +files=$(find ${filesdir} | wc -l) find ${filesdir} -type f -print0 | while IFS= read -r -d $'\0' line; do - ldd $line |grep "=>" >>"${lgsmdir}/tmp/detect_ldd.tmp" + #ldd -v $line 2>/dev/null|grep "=>" >>"${lgsmdir}/tmp/detect_ldd.tmp" + if [ -n "$(ldd $line 2>/dev/null |grep -v "not a dynamic executable")" ]; then + echo "$line" >> "${lgsmdir}/tmp/detect_ldd.tmp" + ldd $line 2>/dev/null |grep -v "not a dynamic executable" >> "${lgsmdir}/tmp/detect_ldd.tmp" + + if [ -n "$(ldd $line 2>/dev/null |grep -v "not a dynamic executable"|grep "not found")" ]; then + echo "$line" >> "${lgsmdir}/tmp/detect_ldd_not_found.tmp" + ldd $line 2>/dev/null |grep -v "not a dynamic executable"|grep "not found" >> "${lgsmdir}/tmp/detect_ldd_not_found.tmp" + fi + fi + echo -n "$i / $files" $'\r' + ((i++)) done +echo "" +echo "" +echo "All" +echo "=================================" +cat "${lgsmdir}/tmp/detect_ldd.tmp" + +echo "" +echo "Not Found" +echo "=================================" +cat "${lgsmdir}/tmp/detect_ldd_not_found.tmp" -cat "${lgsmdir}/tmp/detect_ldd.tmp"|sort|uniq|sort -r --version-sort -rm "${lgsmdir}/tmp/detect_ldd.tmp" \ No newline at end of file +rm "${lgsmdir}/tmp/detect_ldd.tmp" +rm "${lgsmdir}/tmp/detect_ldd_not_found.tmp" \ No newline at end of file From 05f068d039c5a840f2e6ae05c3ae8831a4a24e67 Mon Sep 17 00:00:00 2001 From: Daniel Gibbs Date: Sat, 3 Sep 2016 02:13:49 +0100 Subject: [PATCH 7/7] added progress indicator --- lgsm/functions/command_dev_detect_glibc.sh | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/lgsm/functions/command_dev_detect_glibc.sh b/lgsm/functions/command_dev_detect_glibc.sh index 073da2cd7..c039e44cb 100644 --- a/lgsm/functions/command_dev_detect_glibc.sh +++ b/lgsm/functions/command_dev_detect_glibc.sh @@ -22,10 +22,13 @@ elif [ -f "${filesdir}" ]; then fi echo "" +files=$(find ${filesdir} | wc -l) find ${filesdir} -type f -print0 | while IFS= read -r -d $'\0' line; do objdump -T $line 2>/dev/null|grep -oP "GLIBC[^ ]+" >>"${lgsmdir}/tmp/detect_glibc.tmp" + echo -n "$i / $files" $'\r' + ((i++)) done - +echo "" cat "${lgsmdir}/tmp/detect_glibc.tmp"|sort|uniq|sort -r --version-sort rm "${lgsmdir}/tmp/detect_glibc.tmp" \ No newline at end of file