From 60a70250d61c4dcd431017995349d49d9698d552 Mon Sep 17 00:00:00 2001 From: Daniel Gibbs Date: Fri, 5 Feb 2016 10:52:23 +0000 Subject: [PATCH 001/117] New download manager core_dl will handle all downloads for LGSM allowing a consistent download experience --- functions/core_dl.sh | 29 +++++++++++++++++++++++++++++ functions/core_functions.sh | 8 ++++++++ 2 files changed, 37 insertions(+) create mode 100644 functions/core_dl.sh diff --git a/functions/core_dl.sh b/functions/core_dl.sh new file mode 100644 index 000000000..1ae0edfbf --- /dev/null +++ b/functions/core_dl.sh @@ -0,0 +1,29 @@ +#!/bin/bash +# LGSM core_dl.sh function +# Author: Daniel Gibbs +# Website: http://gameservermanagers.com +lgsm_version="050216" + +# Description: Deals with all downloads for LGSM. + +fn_curl_dl(){ +curl_filename=$1 +curl_filepath=$2 +curl_url=$3 +echo "curl_filename $curl_filename" +echo "curl_url ${curl_url}" +echo "curl_filepath ${curl_filepath}" + +echo -ne "Downloading ${mm_file_latest}...\c" + +curl_dl=$(curl --fail -o "${curl_filepath}" "${curl_url}" ) +exitcode=$? +if [ $? -ne 0 ]; then + fn_printfaileol + echo "${curl_dl}" + echo -e "${url}\n" + exit ${exitcode} +else + fn_printokeol +fi +} \ No newline at end of file diff --git a/functions/core_functions.sh b/functions/core_functions.sh index 7b0f148cd..f31e447a6 100644 --- a/functions/core_functions.sh +++ b/functions/core_functions.sh @@ -32,6 +32,11 @@ functionfile="${FUNCNAME}" fn_runfunction } +core_dl.sh(){ +functionfile="${FUNCNAME}" +fn_runfunction +} + # Command @@ -400,3 +405,6 @@ fn_runfunction # Calls on-screen messages core_messages.sh + +#Calls file downloader +core_dl.sh From 12e8dd1fc2747cef9255de6bfee4ab9a2a77caba Mon Sep 17 00:00:00 2001 From: Daniel Gibbs Date: Fri, 5 Feb 2016 10:54:08 +0000 Subject: [PATCH 002/117] date --- functions/core_functions.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/functions/core_functions.sh b/functions/core_functions.sh index f31e447a6..a975fd46e 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="170116" +lgsm_version="030216" # 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. From cecee81c3007934828f03476860ab523e95debbc Mon Sep 17 00:00:00 2001 From: Daniel Gibbs Date: Fri, 5 Feb 2016 11:34:27 +0000 Subject: [PATCH 003/117] added md5 checker --- functions/core_dl.sh | 83 +++++++++++++++++++++++++++++++++----------- 1 file changed, 63 insertions(+), 20 deletions(-) diff --git a/functions/core_dl.sh b/functions/core_dl.sh index 1ae0edfbf..88df26654 100644 --- a/functions/core_dl.sh +++ b/functions/core_dl.sh @@ -6,24 +6,67 @@ lgsm_version="050216" # Description: Deals with all downloads for LGSM. -fn_curl_dl(){ -curl_filename=$1 -curl_filepath=$2 -curl_url=$3 -echo "curl_filename $curl_filename" -echo "curl_url ${curl_url}" -echo "curl_filepath ${curl_filepath}" - -echo -ne "Downloading ${mm_file_latest}...\c" - -curl_dl=$(curl --fail -o "${curl_filepath}" "${curl_url}" ) -exitcode=$? -if [ $? -ne 0 ]; then - fn_printfaileol - echo "${curl_dl}" - echo -e "${url}\n" - exit ${exitcode} +# Downloads can be defined in code like so +# fn_dl "dl_filename" "dl_filepath" "dl_url" "dl_md5" +# fn_dl "file.tar.bz2" "/home/gameserver" "http://example.com/file.tar/bz2" "10cd7353aa9d758a075c600a6dd193fd" + +fn_dl_md5(){ +# Runs MD5 Check if available +if [ -n "${dl_md5}" ]; then + echo -ne "verifying ${dl_filename} with MD5...\c" + local md5check=$(md5sum "${dl_filepath}/${dl_filename}"|awk '{print $1;}') + if [ "${md5check}" != "${dl_md5}" ]; then + fn_printfaileol + echo "${dl_filename} MD5 checksum: ${md5check}" + echo -e "expected MD5 checksum: ${dl_md5}" + while true; do + read -e -i "y" -p "Retry download? [Y/n]" yn + case $yn in + [Yy]* ) retry_dl=1; fn_dl;; + [Nn]* ) echo Exiting; exit 1;; + * ) echo "Please answer yes or no.";; + esac + done + else + fn_printokeol + fi +fi +} + +fn_dl(){ +# defines variables from other script file +dl_filename=$1 +dl_filepath=$2 +dl_url=$3 +dl_md5=$4 + +if [ ! -f "${dl_filepath}/${dl_filename}" ]||[ -n "${retry_dl}" ]; then + echo -ne "downloading ${dl_filename}...\c" + + local dl=$(curl --fail -o "${dl_filepath}" "${dl_url}") + local exitcode=$? + if [ ${exitcode} -ne 0 ]; then + fn_printfaileol + echo "${curl_dl}" + echo -e "${url}\n" + exit ${exitcode} + else + fn_printokeol + fi +else + echo -ne "${dl_filename} already exists...\c" + fn_dl_md5 + while true; do + read -e -i "n" -p "Download again? [y/N]" yn + case $yn in + [Yy]* ) fn_dl; retry_dl=1;; + [Nn]* ) break;; + * ) echo "Please answer yes or no.";; + esac + done else - fn_printokeol -fi -} \ No newline at end of file + + +fn_dl_md5 +} + From 2162b357233bf51b1c00a03d57dc8e3ec93a084a Mon Sep 17 00:00:00 2001 From: Daniel Gibbs Date: Fri, 5 Feb 2016 11:34:37 +0000 Subject: [PATCH 004/117] using ut99 as test --- functions/install_dl_ut99.sh | 29 ++++++----------------------- 1 file changed, 6 insertions(+), 23 deletions(-) diff --git a/functions/install_dl_ut99.sh b/functions/install_dl_ut99.sh index c053ca18e..f2de71fea 100644 --- a/functions/install_dl_ut99.sh +++ b/functions/install_dl_ut99.sh @@ -2,34 +2,17 @@ # LGSM install_dl_ut99.sh function # Author: Daniel Gibbs # Website: http://gameservermanagers.com -lgsm_version="271215" +lgsm_version="050216" echo "" echo "Downloading Server Files" echo "=================================" sleep 1 -cd "${filesdir}" -if [ ! -f ut-server-436.tar.gz ]; then - wget http://gameservermanagers.com/files/ut99/ut-server-436.tar.gz -else - echo "ut-server-436.tar.gz already downloaded!" -fi -echo "Running MD5 checksum to verify the file" -sleep 1 -echo "MD5 checksum: 10cd7353aa9d758a075c600a6dd193fd" -md5check=$(md5sum ut-server-436.tar.gz|awk '{print $1;}') -echo "File returned: ${md5check}" -if [ "${md5check}" != "10cd7353aa9d758a075c600a6dd193fd" ]; then - echo "MD5 checksum: FAILED!" - read -p "Retry download? [y/N]" yn - case $yn in - [Yy]* ) rm -fv ut-server-436.tar.gz; fn_filesdl;; - [Nn]* ) echo Exiting; exit;; - * ) echo "Please answer yes or no.";; - esac -else - echo "MD5 checksum: PASSED" -fi +fn_dl "ut-server-436.tar.gz" "${filesdir}" "http://gameservermanagers.com/files/ut99/ut-server-436.tar.gz" "10cd7353aa9d758a075c600a6dd193fd" + + + + if [ ! -f UTPGPatch451.tar.bz2 ]; then wget http://gameservermanagers.com/files/ut99/UTPGPatch451.tar.bz2 else From efd17f045c7dc9629351265e95f6f6cbfe2bab33 Mon Sep 17 00:00:00 2001 From: Daniel Gibbs Date: Fri, 5 Feb 2016 11:36:30 +0000 Subject: [PATCH 005/117] else for fi --- functions/core_dl.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/functions/core_dl.sh b/functions/core_dl.sh index 88df26654..3192e45a0 100644 --- a/functions/core_dl.sh +++ b/functions/core_dl.sh @@ -63,8 +63,8 @@ else [Nn]* ) break;; * ) echo "Please answer yes or no.";; esac - done -else + done +fi fn_dl_md5 From 3b7afb9fea37fc2d719683af49945892f38fe83b Mon Sep 17 00:00:00 2001 From: Daniel Gibbs Date: Fri, 5 Feb 2016 11:44:58 +0000 Subject: [PATCH 006/117] Changed to and instead of or --- functions/check.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/functions/check.sh b/functions/check.sh index 0d919b8ab..101544b55 100644 --- a/functions/check.sh +++ b/functions/check.sh @@ -21,7 +21,7 @@ array_contains () { check_root.sh -if [ "${function_selfname}" != "command_install.sh" ]||[ "${function_selfname}" != "update_functions.sh" ]; then +if [ "${function_selfname}" != "command_install.sh" ] && [ "${function_selfname}" != "update_functions.sh" ]; then check_systemdir.sh fi From 63961792fcae6a76829f7b3c4832280e86f2c48a Mon Sep 17 00:00:00 2001 From: Daniel Gibbs Date: Fri, 5 Feb 2016 11:48:25 +0000 Subject: [PATCH 007/117] filename --- functions/core_dl.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/functions/core_dl.sh b/functions/core_dl.sh index 3192e45a0..d5029fdc9 100644 --- a/functions/core_dl.sh +++ b/functions/core_dl.sh @@ -43,7 +43,7 @@ dl_md5=$4 if [ ! -f "${dl_filepath}/${dl_filename}" ]||[ -n "${retry_dl}" ]; then echo -ne "downloading ${dl_filename}...\c" - local dl=$(curl --fail -o "${dl_filepath}" "${dl_url}") + local dl=$(curl --fail -o "${dl_filepath}/${dl_filename}" "${dl_url}") local exitcode=$? if [ ${exitcode} -ne 0 ]; then fn_printfaileol From 0d6dbbaccdf830f1efec39fa352e6a6f31608467 Mon Sep 17 00:00:00 2001 From: Daniel Gibbs Date: Fri, 5 Feb 2016 11:55:43 +0000 Subject: [PATCH 008/117] error is now displayed correctly --- functions/core_dl.sh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/functions/core_dl.sh b/functions/core_dl.sh index d5029fdc9..c6a05ecf1 100644 --- a/functions/core_dl.sh +++ b/functions/core_dl.sh @@ -43,11 +43,11 @@ dl_md5=$4 if [ ! -f "${dl_filepath}/${dl_filename}" ]||[ -n "${retry_dl}" ]; then echo -ne "downloading ${dl_filename}...\c" - local dl=$(curl --fail -o "${dl_filepath}/${dl_filename}" "${dl_url}") - local exitcode=$? + dl=$(curl --fail -o "${dl_filepath}/${dl_filename}" "${dl_url}" 2>&1) + exitcode=$? if [ ${exitcode} -ne 0 ]; then fn_printfaileol - echo "${curl_dl}" + echo "${dl}" echo -e "${url}\n" exit ${exitcode} else From be5cf54ab91980ac33a41f73f1f24258cf5feb62 Mon Sep 17 00:00:00 2001 From: Daniel Gibbs Date: Fri, 5 Feb 2016 12:11:59 +0000 Subject: [PATCH 009/117] echo commented old code --- functions/install_dl_ut99.sh | 48 +++++++++++++++++------------------- 1 file changed, 23 insertions(+), 25 deletions(-) diff --git a/functions/install_dl_ut99.sh b/functions/install_dl_ut99.sh index f2de71fea..820970d03 100644 --- a/functions/install_dl_ut99.sh +++ b/functions/install_dl_ut99.sh @@ -8,30 +8,28 @@ echo "" echo "Downloading Server Files" echo "=================================" sleep 1 +echo "" fn_dl "ut-server-436.tar.gz" "${filesdir}" "http://gameservermanagers.com/files/ut99/ut-server-436.tar.gz" "10cd7353aa9d758a075c600a6dd193fd" - - - -if [ ! -f UTPGPatch451.tar.bz2 ]; then - wget http://gameservermanagers.com/files/ut99/UTPGPatch451.tar.bz2 -else - echo "UTPGPatch451.tar.bz2 already downloaded!" -fi -echo "Running MD5 checksum to verify the file" -sleep 1 -echo "MD5 checksum: 77a735a78b1eb819042338859900b83b" -md5check=$(md5sum UTPGPatch451.tar.bz2|awk '{print $1;}') -echo "File returned: ${md5check}" -if [ "${md5check}" != "77a735a78b1eb819042338859900b83b" ]; then - echo "MD5 checksum: FAILED!" - read -p "Retry download? [y/N]" yn - case $yn in - [Yy]* ) rm -fv UTPGPatch451.tar.bz2; fn_filesdl;; - [Nn]* ) echo Exiting; exit;; - * ) echo "Please answer yes or no.";; - esac -else - echo "MD5 checksum: PASSED" -fi -echo "" \ No newline at end of file +#if [ ! -f UTPGPatch451.tar.bz2 ]; then +# wget http://gameservermanagers.com/files/ut99/UTPGPatch451.tar.bz2 +#else +# echo "UTPGPatch451.tar.bz2 already downloaded!" +#fi +#echo "Running MD5 checksum to verify the file" +#sleep 1 +#echo "MD5 checksum: 77a735a78b1eb819042338859900b83b" +#md5check=$(md5sum UTPGPatch451.tar.bz2|awk '{print $1;}') +#echo "File returned: ${md5check}" +#if [ "${md5check}" != "77a735a78b1eb819042338859900b83b" ]; then +# echo "MD5 checksum: FAILED!" +# read -p "Retry download? [y/N]" yn +# case $yn in +# [Yy]* ) rm -fv UTPGPatch451.tar.bz2; fn_filesdl;; +# [Nn]* ) echo Exiting; exit;; +# * ) echo "Please answer yes or no.";; +# esac +#else +# echo "MD5 checksum: PASSED" +#fi +#echo "" \ No newline at end of file From d5d4bee45ced0809330cd6217c455816d7ee1821 Mon Sep 17 00:00:00 2001 From: Daniel Gibbs Date: Fri, 5 Feb 2016 12:12:58 +0000 Subject: [PATCH 010/117] adjusting display --- functions/core_dl.sh | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/functions/core_dl.sh b/functions/core_dl.sh index c6a05ecf1..1d90acab7 100644 --- a/functions/core_dl.sh +++ b/functions/core_dl.sh @@ -41,14 +41,13 @@ dl_url=$3 dl_md5=$4 if [ ! -f "${dl_filepath}/${dl_filename}" ]||[ -n "${retry_dl}" ]; then - echo -ne "downloading ${dl_filename}...\c" - - dl=$(curl --fail -o "${dl_filepath}/${dl_filename}" "${dl_url}" 2>&1) + echo -e "downloading ${dl_filename}..." + dl=$(curl --progress-bar --fail -o "${dl_filepath}/${dl_filename}" "${dl_url}") exitcode=$? + echo -ne "downloading ${dl_filename}...\c" if [ ${exitcode} -ne 0 ]; then fn_printfaileol - echo "${dl}" - echo -e "${url}\n" + echo -e "${dl_url}\n" exit ${exitcode} else fn_printokeol From c846baa68e248c2ba9dbc28674740f51ab4e0b1a Mon Sep 17 00:00:00 2001 From: Daniel Gibbs Date: Sat, 6 Feb 2016 08:22:39 +0000 Subject: [PATCH 011/117] More changes --- functions/core_dl.sh | 4 ++-- functions/install_dl_ut99.sh | 26 +------------------------- 2 files changed, 3 insertions(+), 27 deletions(-) diff --git a/functions/core_dl.sh b/functions/core_dl.sh index 1d90acab7..b509d4f82 100644 --- a/functions/core_dl.sh +++ b/functions/core_dl.sh @@ -41,7 +41,7 @@ dl_url=$3 dl_md5=$4 if [ ! -f "${dl_filepath}/${dl_filename}" ]||[ -n "${retry_dl}" ]; then - echo -e "downloading ${dl_filename}..." + echo -ne "downloading ${dl_filename}..." dl=$(curl --progress-bar --fail -o "${dl_filepath}/${dl_filename}" "${dl_url}") exitcode=$? echo -ne "downloading ${dl_filename}...\c" @@ -53,7 +53,7 @@ if [ ! -f "${dl_filepath}/${dl_filename}" ]||[ -n "${retry_dl}" ]; then fn_printokeol fi else - echo -ne "${dl_filename} already exists...\c" + echo -e "${dl_filename} already exists...\c" fn_dl_md5 while true; do read -e -i "n" -p "Download again? [y/N]" yn diff --git a/functions/install_dl_ut99.sh b/functions/install_dl_ut99.sh index 820970d03..fa7d64d6d 100644 --- a/functions/install_dl_ut99.sh +++ b/functions/install_dl_ut99.sh @@ -8,28 +8,4 @@ echo "" echo "Downloading Server Files" echo "=================================" sleep 1 -echo "" -fn_dl "ut-server-436.tar.gz" "${filesdir}" "http://gameservermanagers.com/files/ut99/ut-server-436.tar.gz" "10cd7353aa9d758a075c600a6dd193fd" - -#if [ ! -f UTPGPatch451.tar.bz2 ]; then -# wget http://gameservermanagers.com/files/ut99/UTPGPatch451.tar.bz2 -#else -# echo "UTPGPatch451.tar.bz2 already downloaded!" -#fi -#echo "Running MD5 checksum to verify the file" -#sleep 1 -#echo "MD5 checksum: 77a735a78b1eb819042338859900b83b" -#md5check=$(md5sum UTPGPatch451.tar.bz2|awk '{print $1;}') -#echo "File returned: ${md5check}" -#if [ "${md5check}" != "77a735a78b1eb819042338859900b83b" ]; then -# echo "MD5 checksum: FAILED!" -# read -p "Retry download? [y/N]" yn -# case $yn in -# [Yy]* ) rm -fv UTPGPatch451.tar.bz2; fn_filesdl;; -# [Nn]* ) echo Exiting; exit;; -# * ) echo "Please answer yes or no.";; -# esac -#else -# echo "MD5 checksum: PASSED" -#fi -#echo "" \ No newline at end of file +fn_dl "ut-server-451-complete.tar.bz2" "${filesdir}" "http://gameservermanagers.com/files/ut99/ut-server-451-complete.tar.bz2" "42a8c9806e4fce10a56830caca83ce63" From 18df7ec459055e1f0de3976886efe719f628679e Mon Sep 17 00:00:00 2001 From: Daniel Gibbs Date: Tue, 16 Feb 2016 19:45:53 +0000 Subject: [PATCH 012/117] Upload to test --- JustCause2/jc2server | 75 ++++++++++++++------------- functions/core_dl.sh | 120 +++++++++++++++++++++++++++++++++++++------ 2 files changed, 144 insertions(+), 51 deletions(-) diff --git a/JustCause2/jc2server b/JustCause2/jc2server index 5435a3121..05034cfde 100644 --- a/JustCause2/jc2server +++ b/JustCause2/jc2server @@ -4,7 +4,7 @@ # Author: Daniel Gibbs # Website: http://gameservermanagers.com if [ -f ".dev-debug" ]; then - exec 5>dev-debug.log + run 5>dev-debug.log BASH_XTRACEFD="5" set -x fi @@ -36,7 +36,7 @@ parms="" # from a different repo and/or branch. githubuser="dgibbs64" githubrepo="linuxgsm" -githubbranch="master" +githubbranch="dlmanage" # Steam appid="261140" @@ -51,6 +51,8 @@ rootdir="$(dirname $(readlink -f "${BASH_SOURCE[0]}"))" selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))" lockselfname=".${servicename}.lock" filesdir="${rootdir}/serverfiles" +lgsmdir="${rootdir}/lgsm" +functionsdir="${lgsmdir}/functions" systemdir="${filesdir}" executabledir="${filesdir}" executable="./Jcmp-Server" @@ -76,55 +78,56 @@ consolelogdate="${consolelogdir}/${servicename}-console-$(date '+%d-%m-%Y-%H-%M- ##### Script ##### # Do not edit -fn_getgithubfile(){ -filename=$1 -exec=$2 -fileurl=${3:-$filename} -filepath="${rootdir}/${filename}" -filedir=$(dirname "${filepath}") -# If the function file is missing, then download -if [ ! -f "${filepath}" ]; then +# Fetches core_dl for file downloads +fn_fetch_core_dl(){ +github_file_url_dir="functions" +github_file_url_name="${functionfile}" +filedir="${functionsdir}" +filename="${github_file_url_name}" +githuburl="https://raw.githubusercontent.com/${githubuser}/${githubrepo}/${githubbranch}/${github_file_url_dir}/${github_file_url_name}" +# If the file is missing, then download +if [ ! -f "${filedir}/${filename}" ]; then if [ ! -d "${filedir}" ]; then - mkdir "${filedir}" + mkdir -p "${filedir}" fi - githuburl="https://raw.githubusercontent.com/${githubuser}/${githubrepo}/${githubbranch}/${fileurl}" echo -e " fetching ${filename}...\c" - if [ "$(command -v curl)" ]||[ "$(which curl >/dev/null 2>&1)" ]||[ -f "/usr/bin/curl" ]||[ -f "/bin/curl" ]; then - : - else + # Check curl exists and use available path + curlpaths="$(command -v curl 2>/dev/null) $(which curl >/dev/null 2>&1) /usr/bin/curl /bin/curl /usr/sbin/curl /sbin/curl $(echo $PATH | sed "s/\([:]\|\$\)/\/curl /g")" + for curlcmd in ${curlpaths} + do + if [ -x "${curlcmd}" ]; then + break + fi + done + # If curl exists download file + if [ "$(basename ${curlcmd})" == "curl" ]; then + curlfetch=$(${curlcmd} -s --fail -o "${filedir}/${filename}" "${githuburl}" 2>&1) + if [ $? -ne 0 ]; then + echo -e "\e[0;31mFAIL\e[0m\n" + echo "${curlfetch}" + echo -e "${githuburl}\n" + exit + else + echo -e "\e[0;32mOK\e[0m" + fi + else echo -e "\e[0;31mFAIL\e[0m\n" echo "Curl is not installed!" echo -e "" exit fi - curl=$(curl --fail -o "${filepath}" "${githuburl}" 2>&1) - if [ $? -ne 0 ]; then - echo -e "\e[0;31mFAIL\e[0m\n" - echo "${curl}" - echo -e "${githuburl}\n" - exit - else - echo -e "\e[0;32mOK\e[0m" - fi - if [ "${exec}" ]; then - chmod +x "${filepath}" - fi -fi -if [ "${exec}" ]; then - source "${filepath}" + chmod +x "${filedir}/${filename}" fi +source "${filedir}/${filename}" } -fn_runfunction(){ - fn_getgithubfile "functions/${functionfile}" 1 -} - -core_functions.sh(){ +core_dl.sh(){ # Functions are defined in core_functions.sh. functionfile="${FUNCNAME}" -fn_runfunction +fn_fetch_core_dl } +core_dl.sh core_functions.sh getopt=$1 diff --git a/functions/core_dl.sh b/functions/core_dl.sh index b509d4f82..4f786eea3 100644 --- a/functions/core_dl.sh +++ b/functions/core_dl.sh @@ -12,28 +12,28 @@ lgsm_version="050216" fn_dl_md5(){ # Runs MD5 Check if available -if [ -n "${dl_md5}" ]; then - echo -ne "verifying ${dl_filename} with MD5...\c" - local md5check=$(md5sum "${dl_filepath}/${dl_filename}"|awk '{print $1;}') +if [ -n "${md5}" ]; then + echo -ne "verifying ${filename} with MD5...\c" + local md5check=$(md5sum "${filedir}/${filename}"|awk '{print $1;}') if [ "${md5check}" != "${dl_md5}" ]; then fn_printfaileol - echo "${dl_filename} MD5 checksum: ${md5check}" - echo -e "expected MD5 checksum: ${dl_md5}" - while true; do - read -e -i "y" -p "Retry download? [Y/n]" yn - case $yn in - [Yy]* ) retry_dl=1; fn_dl;; - [Nn]* ) echo Exiting; exit 1;; - * ) echo "Please answer yes or no.";; - esac - done + echo "${filename} MD5 checksum: ${md5check}" + echo "expected MD5 checksum: ${dl_md5}" + fn_scriptlog "failed to verify ${filename} with MD5" + fn_scriptlog "${filename} MD5 checksum: ${md5check}" + fn_scriptlog "expected MD5 checksum: ${dl_md5}" + exit 1 else fn_printokeol + fn_scriptlog "verifyed ${filename} with MD5" + fn_scriptlog "${filename} MD5 checksum: ${md5check}" + fn_scriptlog "expected MD5 checksum: ${dl_md5}" fi fi } -fn_dl(){ + +fn_dl_file(){ # defines variables from other script file dl_filename=$1 dl_filepath=$2 @@ -65,7 +65,97 @@ else done fi - fn_dl_md5 } + + +# Downloads file using curl and run it if required +fn_dl_file(){ +fileurl="${1}" +filedir="${2}" +filename="${3}" +run=${4:-0} +force=${5:-0} +md5=${6} +# If the file is missing or forced, then download +if [ ! -f "${filedir}" ] || [ "${force}" == "1" ] || [ "${force}" == "yes" ]; then + if [ ! -d "${filedir}" ]; then + mkdir -p "${filedir}" + fi + + # Check curl exists and use available path + curlpaths="$(command -v curl 2>/dev/null) $(which curl >/dev/null 2>&1) /usr/bin/curl /bin/curl /usr/sbin/curl /sbin/curl $(echo $PATH | sed "s/\([:]\|\$\)/\/curl /g")" + for curlcmd in ${curlpaths} + do + if [ -x "${curlcmd}" ]; then + curlcmd=${curlcmd} + break + fi + done + # If curl exists download file + if [ "$(basename ${curlcmd})" == "curl" ]; then + # if larger file shows progress bar + if [ "${filename}" == *".tar"* ]; then + curlfetch=$(${curlcmd} --progress-bar -s --fail -o "${filedir}/${filename}" "${fileurl}" 2>&1) + else + curlfetch=$(${curlcmd} -s --fail -o "${filedir}/${filename}" "${fileurl}" 2>&1) + fi + if [ $? -ne 0 ]; then + fn_printfaileol + echo "${curlfetch}" + echo -e "${fileurl}\n" + fn_scriptlog "failed to download ${filedir}/${filename}" + fn_scriptlog "${curlfetch}" + fn_scriptlog -e "${fileurl}\n" + sleep 1 + echo "Removing failed ${filename}..." + rm -f "${filedir}/${filename}" + if [ $? -ne 0 ]; then + fn_printfaileol + else + fn_printokeol + fi + exit 1 + else + fn_printokeol + fn_scriptlog "downloaded ${filedir}/${filename}" + fi + else + echo -e "fn_printfaileol" + echo "Curl is not installed!" + echo -e "" + exit 1 + fi + fn_dl_md5 + + # make file executable if run is set + if [ "${run}" == "run" ]; then + chmod +x "${filedir}/${filename}" + fi +fi +# run file if run is set +if [ "${run}" == "run" ]; then + source "${filedir}/${filename}" +fi +} + + +# fn_fetch_file_github +# Parameters: +# github_file_url_dir: The directory the file is located in teh GitHub repo +# github_file_url_name: name of file +# filepath: location file to be saved +# run: Optional, set to 1 to make file executable +# force: force download of file even if exists +fn_fetch_file_github(){ +github_file_url_dir=${1} +github_file_url_name=${2} +filepath=${3} +filename="${github_file_url_name}" +run=${4:-0} +force=${5:-0} +githuburl="https://raw.githubusercontent.com/${githubuser}/${githubrepo}/${githubbranch}/${github_file_url_dir}/${github_file_url_name}" +echo -e " fetching ${filename}...\c" +fn_fetch_file "${githuburl}" "${filepath}" "${filename}" "${run}" "${force}" +} \ No newline at end of file From eee9851ded3228b7917d8de3d23d4d9e42e59aed Mon Sep 17 00:00:00 2001 From: Daniel Gibbs Date: Tue, 16 Feb 2016 20:41:37 +0000 Subject: [PATCH 013/117] Getting functions downloader working --- JustCause2/jc2server | 12 ++- functions/core_dl.sh | 43 ++++++----- functions/core_functions.sh | 149 +++++++++++++++++++----------------- 3 files changed, 108 insertions(+), 96 deletions(-) diff --git a/JustCause2/jc2server b/JustCause2/jc2server index 05034cfde..cedf158b8 100644 --- a/JustCause2/jc2server +++ b/JustCause2/jc2server @@ -9,7 +9,7 @@ if [ -f ".dev-debug" ]; then set -x fi -version="271215" +version="160316" #### Variables #### @@ -106,7 +106,7 @@ if [ ! -f "${filedir}/${filename}" ]; then echo -e "\e[0;31mFAIL\e[0m\n" echo "${curlfetch}" echo -e "${githuburl}\n" - exit + exit 1 else echo -e "\e[0;32mOK\e[0m" fi @@ -114,7 +114,7 @@ if [ ! -f "${filedir}/${filename}" ]; then echo -e "\e[0;31mFAIL\e[0m\n" echo "Curl is not installed!" echo -e "" - exit + exit 1 fi chmod +x "${filedir}/${filename}" fi @@ -127,6 +127,12 @@ functionfile="${FUNCNAME}" fn_fetch_core_dl } +core_functions.sh(){ +# Functions are defined in core_functions.sh. +functionfile="${FUNCNAME}" +fn_fetch_core_dl +} + core_dl.sh core_functions.sh diff --git a/functions/core_dl.sh b/functions/core_dl.sh index 4f786eea3..04c14cee3 100644 --- a/functions/core_dl.sh +++ b/functions/core_dl.sh @@ -71,25 +71,25 @@ fn_dl_md5 # Downloads file using curl and run it if required -fn_dl_file(){ -fileurl="${1}" -filedir="${2}" -filename="${3}" +# fn_fetch_file "fileurl" "filedir" "filename" "run" "force" "md5" +fn_fetch_file(){ +fileurl=${1} +filedir=${2} +filename=${3} run=${4:-0} force=${5:-0} md5=${6} -# If the file is missing or forced, then download -if [ ! -f "${filedir}" ] || [ "${force}" == "1" ] || [ "${force}" == "yes" ]; then +# If the file is missing, then download +if [ ! -f "${filedir}/${filename}" ]; then if [ ! -d "${filedir}" ]; then mkdir -p "${filedir}" fi - + echo -e " fetching ${filename}...\c" # Check curl exists and use available path curlpaths="$(command -v curl 2>/dev/null) $(which curl >/dev/null 2>&1) /usr/bin/curl /bin/curl /usr/sbin/curl /sbin/curl $(echo $PATH | sed "s/\([:]\|\$\)/\/curl /g")" for curlcmd in ${curlpaths} do if [ -x "${curlcmd}" ]; then - curlcmd=${curlcmd} break fi done @@ -105,24 +105,12 @@ if [ ! -f "${filedir}" ] || [ "${force}" == "1" ] || [ "${force}" == "yes" ]; th fn_printfaileol echo "${curlfetch}" echo -e "${fileurl}\n" - fn_scriptlog "failed to download ${filedir}/${filename}" - fn_scriptlog "${curlfetch}" - fn_scriptlog -e "${fileurl}\n" - sleep 1 - echo "Removing failed ${filename}..." - rm -f "${filedir}/${filename}" - if [ $? -ne 0 ]; then - fn_printfaileol - else - fn_printokeol - fi exit 1 else fn_printokeol - fn_scriptlog "downloaded ${filedir}/${filename}" fi else - echo -e "fn_printfaileol" + fn_printfaileol echo "Curl is not installed!" echo -e "" exit 1 @@ -158,4 +146,17 @@ force=${5:-0} githuburl="https://raw.githubusercontent.com/${githubuser}/${githubrepo}/${githubbranch}/${github_file_url_dir}/${github_file_url_name}" echo -e " fetching ${filename}...\c" fn_fetch_file "${githuburl}" "${filepath}" "${filename}" "${run}" "${force}" +} + + + +# Fetches functions +fn_fetch_function(){ +github_file_url_dir="functions" # github dir containing the file +github_file_url_name="${functionfile}" # name of the github file +githuburl="https://raw.githubusercontent.com/${githubuser}/${githubrepo}/${githubbranch}/${github_file_url_dir}/${github_file_url_name}" +filedir="${functionsdir}" # local dir that will contain the file +filename="${github_file_url_name}" # name of the local file +run="run" +fn_fetch_file "${githuburl}" "${filedir}" "${filename}" "${run}" } \ No newline at end of file diff --git a/functions/core_functions.sh b/functions/core_functions.sh index a975fd46e..c54dd3c19 100644 --- a/functions/core_functions.sh +++ b/functions/core_functions.sh @@ -2,97 +2,102 @@ # LGSM core_functions.sh function # Author: Daniel Gibbs # Website: http://gameservermanagers.com -lgsm_version="030216" +lgsm_version="160216" -# Description: Defines all functions to allow download and execution of functions using fn_runfunction. +# Description: Defines all functions to allow download and execution of functions using fn_fetch_function. # This function is called first before any other function. Without this file other functions would not load. #Legacy functions fn_functions(){ functionfile="${FUNCNAME}" -fn_runfunction +fn_fetch_function } fn_getopt(){ functionfile="${FUNCNAME}" -fn_runfunction +fn_fetch_function } # Core +core_dl.sh(){ +# Functions are defined in core_functions.sh. +functionfile="${FUNCNAME}" +fn_fetch_core_dl +} + core_getopt.sh(){ functionfile="${FUNCNAME}" -fn_runfunction +fn_fetch_core_dl } core_messages.sh(){ functionfile="${FUNCNAME}" -fn_runfunction +fn_fetch_core_dl } core_dl.sh(){ functionfile="${FUNCNAME}" -fn_runfunction +fn_fetch_core_dl } - # Command command_console.sh(){ functionfile="${FUNCNAME}" -fn_runfunction +fn_fetch_function } command_debug.sh(){ functionfile="${FUNCNAME}" -fn_runfunction +fn_fetch_function } command_details.sh(){ functionfile="${FUNCNAME}" -fn_runfunction +fn_fetch_function } command_email_test.sh(){ functionfile="${FUNCNAME}" -fn_runfunction +fn_fetch_function } command_backup.sh(){ functionfile="${FUNCNAME}" -fn_runfunction +fn_fetch_function } command_monitor.sh(){ functionfile="${FUNCNAME}" -fn_runfunction +fn_fetch_function } command_start.sh(){ functionfile="${FUNCNAME}" -fn_runfunction +fn_fetch_function } command_stop.sh(){ functionfile="${FUNCNAME}" -fn_runfunction +fn_fetch_function } command_validate.sh(){ functionfile="${FUNCNAME}" -fn_runfunction +fn_fetch_function } command_install.sh(){ functionfile="${FUNCNAME}" -fn_runfunction +fn_fetch_function } command_ts3_server_pass.sh(){ functionfile="${FUNCNAME}" -fn_runfunction +fn_fetch_function } fn_restart(){ @@ -108,52 +113,52 @@ command_start.sh check.sh(){ functionfile="${FUNCNAME}" -fn_runfunction +fn_fetch_function } check_config.sh(){ functionfile="${FUNCNAME}" -fn_runfunction +fn_fetch_function } check_deps.sh(){ functionfile="${FUNCNAME}" -fn_runfunction +fn_fetch_function } check_ip.sh(){ functionfile="${FUNCNAME}" -fn_runfunction +fn_fetch_function } check_logs.sh(){ functionfile="${FUNCNAME}" -fn_runfunction +fn_fetch_function } check_root.sh(){ functionfile="${FUNCNAME}" -fn_runfunction +fn_fetch_function } check_steamcmd.sh(){ functionfile="${FUNCNAME}" -fn_runfunction +fn_fetch_function } check_steamuser.sh(){ functionfile="${FUNCNAME}" -fn_runfunction +fn_fetch_function } check_systemdir.sh(){ functionfile="${FUNCNAME}" -fn_runfunction +fn_fetch_function } check_tmux.sh(){ functionfile="${FUNCNAME}" -fn_runfunction +fn_fetch_function } @@ -161,12 +166,12 @@ fn_runfunction compress_unreal2_maps.sh(){ functionfile="${FUNCNAME}" -fn_runfunction +fn_fetch_function } compress_ut99_maps.sh(){ functionfile="${FUNCNAME}" -fn_runfunction +fn_fetch_function } @@ -174,12 +179,12 @@ fn_runfunction command_dev_debug.sh(){ functionfile="${FUNCNAME}" -fn_runfunction +fn_fetch_function } command_dev_detect_deps.sh(){ functionfile="${FUNCNAME}" -fn_runfunction +fn_fetch_function } @@ -187,52 +192,52 @@ fn_runfunction fix.sh(){ functionfile="${FUNCNAME}" -fn_runfunction +fn_fetch_function } fix_arma3.sh(){ functionfile="${FUNCNAME}" -fn_runfunction +fn_fetch_function } fix_csgo.sh(){ functionfile="${FUNCNAME}" -fn_runfunction +fn_fetch_function } fix_dst.sh(){ functionfile="${FUNCNAME}" -fn_runfunction +fn_fetch_function } fix_ins.sh(){ functionfile="${FUNCNAME}" -fn_runfunction +fn_fetch_function } fix_steamcmd.sh(){ functionfile="${FUNCNAME}" -fn_runfunction +fn_fetch_function } fix_glibc.sh(){ functionfile="${FUNCNAME}" -fn_runfunction +fn_fetch_function } fix_ro.sh(){ functionfile="${FUNCNAME}" -fn_runfunction +fn_fetch_function } fix_kf.sh(){ functionfile="${FUNCNAME}" -fn_runfunction +fn_fetch_function } fix_ut2k4.sh(){ functionfile="${FUNCNAME}" -fn_runfunction +fn_fetch_function } @@ -240,22 +245,22 @@ fn_runfunction info_config.sh(){ functionfile="${FUNCNAME}" -fn_runfunction +fn_fetch_function } info_distro.sh(){ functionfile="${FUNCNAME}" -fn_runfunction +fn_fetch_function } info_glibc.sh(){ functionfile="${FUNCNAME}" -fn_runfunction +fn_fetch_function } info_ts3status.sh(){ functionfile="${FUNCNAME}" -fn_runfunction +fn_fetch_function } @@ -263,14 +268,14 @@ fn_runfunction email.sh(){ functionfile="${FUNCNAME}" -fn_runfunction +fn_fetch_function } # Logs logs.sh(){ functionfile="${FUNCNAME}" -fn_runfunction +fn_fetch_function } @@ -278,7 +283,7 @@ fn_runfunction monitor_gsquery.sh(){ functionfile="${FUNCNAME}" -fn_runfunction +fn_fetch_function } @@ -286,22 +291,22 @@ fn_runfunction update_check.sh(){ functionfile="${FUNCNAME}" -fn_runfunction +fn_fetch_function } update_functions.sh(){ functionfile="${FUNCNAME}" -fn_runfunction +fn_fetch_function } update_dl.sh(){ functionfile="${FUNCNAME}" -fn_runfunction +fn_fetch_function } update_functions.sh(){ functionfile="${FUNCNAME}" -fn_runfunction +fn_fetch_function } @@ -316,91 +321,91 @@ command_install.sh install_complete.sh(){ functionfile="${FUNCNAME}" -fn_runfunction +fn_fetch_function } install_config.sh(){ functionfile="${FUNCNAME}" -fn_runfunction +fn_fetch_function } install_gsquery.sh(){ functionfile="${FUNCNAME}" -fn_runfunction +fn_fetch_function } install_gslt.sh(){ functionfile="${FUNCNAME}" -fn_runfunction +fn_fetch_function } install_header.sh(){ functionfile="${FUNCNAME}" -fn_runfunction +fn_fetch_function } install_logs.sh(){ functionfile="${FUNCNAME}" -fn_runfunction +fn_fetch_function } install_retry.sh(){ functionfile="${FUNCNAME}" -fn_runfunction +fn_fetch_function } install_serverdir.sh(){ functionfile="${FUNCNAME}" -fn_runfunction +fn_fetch_function } install_serverfiles.sh(){ functionfile="${FUNCNAME}" -fn_runfunction +fn_fetch_function } install_steamcmd.sh(){ functionfile="${FUNCNAME}" -fn_runfunction +fn_fetch_function } install_ts3.sh(){ functionfile="${FUNCNAME}" -fn_runfunction +fn_fetch_function } install_ts3db.sh(){ functionfile="${FUNCNAME}" -fn_runfunction +fn_fetch_function } install_ut2k4.sh(){ functionfile="${FUNCNAME}" -fn_runfunction +fn_fetch_function } install_dl_ut2k4.sh(){ functionfile="${FUNCNAME}" -fn_runfunction +fn_fetch_function } install_ut2k4_key.sh(){ functionfile="${FUNCNAME}" -fn_runfunction +fn_fetch_function } install_ut99.sh(){ functionfile="${FUNCNAME}" -fn_runfunction +fn_fetch_function } install_dl_ut99.sh(){ functionfile="${FUNCNAME}" -fn_runfunction +fn_fetch_function } fix_ut99.sh(){ functionfile="${FUNCNAME}" -fn_runfunction +fn_fetch_function } # Calls on-screen messages From ea45e1adc0757211bd3f038974669f7f45905f6b Mon Sep 17 00:00:00 2001 From: Daniel Gibbs Date: Tue, 16 Feb 2016 22:24:49 +0000 Subject: [PATCH 014/117] turned in to functions --- functions/check_steamcmd.sh | 103 ++++++++++++++++++++---------------- 1 file changed, 56 insertions(+), 47 deletions(-) diff --git a/functions/check_steamcmd.sh b/functions/check_steamcmd.sh index a47081b8a..5c5c3db83 100644 --- a/functions/check_steamcmd.sh +++ b/functions/check_steamcmd.sh @@ -4,60 +4,69 @@ # Website: http://gameservermanagers.com lgsm_version="281215" -# Description: Downloads SteamCMD on install and checks if missing before running functions that require SteamCMD +# Description: Checks SteamCMD is installed and correct. -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. - if [ "${steamuser}" == "username" ]; then +fn_install_steamcmd(){ +echo "Installing steamCMD..." +if [ ! -d "${steamcmddir}" ]; then + mkdir -v "${steamcmddir}" +fi +fn_fetch_file "http://media.steampowered.com/client/steamcmd_linux.tar.gz" "${steamcmddir}" "steamcmd_linux.tar.gz" +tar --verbose -zxf "${steamcmddir}/steamcmd_linux.tar.gz" -C "${steamcmddir}" +rm -v "${steamcmddir}/steamcmd_linux.tar.gz" +chmod +x "${steamcmddir}/steamcmd.sh" +} + + +fn_check_steamcmd_user(){ +# 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 + if [ -d "${scriptlogdir}" ]; then fn_scriptlog "edit ${selfname}. change steamuser=\"username\" to a valid steam login." exit 1 fi +fi +# Anonymous user is set if steamuser is missing +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 - 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" - if [ ! -f "${steamcmddir}/steamcmd.sh" ]; then - fn_printwarnnl "SteamCMD is missing" - fn_scriptlog "SteamCMD is missing" - sleep 1 - if [ ! -d "${steamcmddir}" ]; then - mkdir -v "${steamcmddir}" - fi - curl=$(curl --fail -o "${steamcmddir}/steamcmd_linux.tar.gz" "http://media.steampowered.com/client/steamcmd_linux.tar.gz" 2>&1) - exitcode=$? - echo -e "downloading steamcmd_linux.tar.gz...\c" - if [ $exitcode -eq 0 ]; then - fn_printokeol - else - fn_printfaileol - echo "${curl}" - echo -e "${githuburl}\n" - exit $exitcode - fi - tar --verbose -zxf "${steamcmddir}/steamcmd_linux.tar.gz" -C "${steamcmddir}" - rm -v "${steamcmddir}/steamcmd_linux.tar.gz" - chmod +x "${steamcmddir}/steamcmd.sh" + steamuser="anonymous" + steampass="" + sleep 2 +fi +} + +fn_check_steamcmd_sh(){ +# Checks if SteamCMD exists when starting or updating a server. +# Re-installs if missing. +steamcmddir="${rootdir}/steamcmd" +if [ ! -f "${steamcmddir}/steamcmd.sh" ]; then + fn_printwarnnl "SteamCMD is missing" + fn_scriptlog "SteamCMD is missing" + sleep 1 + fn_install_steamcmd +fi +} + +fn_check_steamcmd_guard(){ +if [ "${function_selfname}" == "command_update.sh" ]||[ "${function_selfname}" == "command_validate.sh" ]; then + # Checks that steamcmd is working correctly and will prompt Steam Guard if required. + "${steamcmddir}"/steamcmd.sh +login "${steamuser}" "${steampass}" +quit + if [ $? -ne 0 ]; then + fn_printfailurenl "Error running SteamCMD" fi - if [ "${function_selfname}" == "command_update.sh" ]||[ "${function_selfname}" == "command_validate.sh" ]; then - # Checks that steamcmd is working correctly and will prompt Steam Guard if required. - "${steamcmddir}"/steamcmd.sh +login "${steamuser}" "${steampass}" +quit - if [ $? -ne 0 ]; then - fn_printfailurenl "Error running SteamCMD" - fi - fi +fi +} + +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 + fn_check_steamcmd_user + fn_check_steamcmd_sh + fn_check_steamcmd_guard fi From ec05d52a0f92dfe81225f22323f580b8df79e80d Mon Sep 17 00:00:00 2001 From: Daniel Gibbs Date: Tue, 16 Feb 2016 22:25:13 +0000 Subject: [PATCH 015/117] date --- functions/check_steamcmd.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/functions/check_steamcmd.sh b/functions/check_steamcmd.sh index 5c5c3db83..8e5f83544 100644 --- a/functions/check_steamcmd.sh +++ b/functions/check_steamcmd.sh @@ -2,7 +2,7 @@ # LGSM check_steamcmd.sh function # Author: Daniel Gibbs # Website: http://gameservermanagers.com -lgsm_version="281215" +lgsm_version="160316" # Description: Checks SteamCMD is installed and correct. From 3d7ac4ed4e9576cbd15ae4fa995c066f00351ab2 Mon Sep 17 00:00:00 2001 From: Daniel Gibbs Date: Wed, 17 Feb 2016 21:50:47 +0000 Subject: [PATCH 016/117] Added steamcmd check to start debug --- functions/check.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/functions/check.sh b/functions/check.sh index 101544b55..fa6b47306 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="050216" +lgsm_version="170216" # Description: Overall function for managing checks. # Runs checks that will either halt on or fix an issue. @@ -49,7 +49,7 @@ do fi done -local allowed_commands_array=( update_check.sh command_validate.sh ) +local allowed_commands_array=( update_check.sh command_debug.sh command_start.sh command_validate.sh ) for allowed_command in "${allowed_commands_array[@]}" do if [ "${allowed_command}" == "${function_selfname}" ]; then From 752365a1c62ba2316d47558d62edca47dcbcba90 Mon Sep 17 00:00:00 2001 From: Daniel Gibbs Date: Wed, 17 Feb 2016 23:02:28 +0000 Subject: [PATCH 017/117] added a trap plus more fine tuning --- functions/core_dl.sh | 61 ++++++++++++++++---------------------------- 1 file changed, 22 insertions(+), 39 deletions(-) diff --git a/functions/core_dl.sh b/functions/core_dl.sh index 04c14cee3..d2a0c2372 100644 --- a/functions/core_dl.sh +++ b/functions/core_dl.sh @@ -10,6 +10,7 @@ lgsm_version="050216" # fn_dl "dl_filename" "dl_filepath" "dl_url" "dl_md5" # fn_dl "file.tar.bz2" "/home/gameserver" "http://example.com/file.tar/bz2" "10cd7353aa9d758a075c600a6dd193fd" + fn_dl_md5(){ # Runs MD5 Check if available if [ -n "${md5}" ]; then @@ -32,43 +33,19 @@ if [ -n "${md5}" ]; then fi } - -fn_dl_file(){ -# defines variables from other script file -dl_filename=$1 -dl_filepath=$2 -dl_url=$3 -dl_md5=$4 - -if [ ! -f "${dl_filepath}/${dl_filename}" ]||[ -n "${retry_dl}" ]; then - echo -ne "downloading ${dl_filename}..." - dl=$(curl --progress-bar --fail -o "${dl_filepath}/${dl_filename}" "${dl_url}") - exitcode=$? - echo -ne "downloading ${dl_filename}...\c" - if [ ${exitcode} -ne 0 ]; then - fn_printfaileol - echo -e "${dl_url}\n" - exit ${exitcode} - else - fn_printokeol - fi -else - echo -e "${dl_filename} already exists...\c" - fn_dl_md5 - while true; do - read -e -i "n" -p "Download again? [y/N]" yn - case $yn in - [Yy]* ) fn_dl; retry_dl=1;; - [Nn]* ) break;; - * ) echo "Please answer yes or no.";; - esac - done -fi - -fn_dl_md5 +fn_dl_extract(){ +# extracts archives +: } - +# trap to remove file download if canceled before completed +fn_fetch_trap() { + echo "" + fn_printinfomationnl "Cancelling download" + sleep 1 + fn_printinfomation "Removing ${filename}" + rm -f "${filedir}/${filename}" +} # Downloads file using curl and run it if required # fn_fetch_file "fileurl" "filedir" "filename" "run" "force" "md5" @@ -79,12 +56,13 @@ filename=${3} run=${4:-0} force=${5:-0} md5=${6} + # If the file is missing, then download if [ ! -f "${filedir}/${filename}" ]; then if [ ! -d "${filedir}" ]; then mkdir -p "${filedir}" fi - echo -e " fetching ${filename}...\c" + echo -ne " fetching ${filename}...\c" # Check curl exists and use available path curlpaths="$(command -v curl 2>/dev/null) $(which curl >/dev/null 2>&1) /usr/bin/curl /bin/curl /usr/sbin/curl /sbin/curl $(echo $PATH | sed "s/\([:]\|\$\)/\/curl /g")" for curlcmd in ${curlpaths} @@ -95,9 +73,12 @@ if [ ! -f "${filedir}/${filename}" ]; then done # If curl exists download file if [ "$(basename ${curlcmd})" == "curl" ]; then + # trap to remove part downloaded files + trap fn_fetch_trap EXIT + # if larger file shows progress bar - if [ "${filename}" == *".tar"* ]; then - curlfetch=$(${curlcmd} --progress-bar -s --fail -o "${filedir}/${filename}" "${fileurl}" 2>&1) + if [[ $filename == *"tar"* ]]; then + curlfetch=$(${curlcmd} --progress-bar --fail -o "${filedir}/${filename}" "${fileurl}") else curlfetch=$(${curlcmd} -s --fail -o "${filedir}/${filename}" "${fileurl}" 2>&1) fi @@ -108,7 +89,9 @@ if [ ! -f "${filedir}/${filename}" ]; then exit 1 else fn_printokeol - fi + fi + # remove trap + trap - SIGINT SIGQUIT SIGTSTP else fn_printfaileol echo "Curl is not installed!" From 79b0389642a2164876b372a35965a0db10cf4ab8 Mon Sep 17 00:00:00 2001 From: Daniel Gibbs Date: Wed, 17 Feb 2016 23:02:54 +0000 Subject: [PATCH 018/117] looks better during install --- functions/check_steamcmd.sh | 22 +++++++++++++++------- 1 file changed, 15 insertions(+), 7 deletions(-) diff --git a/functions/check_steamcmd.sh b/functions/check_steamcmd.sh index 8e5f83544..4c65ec557 100644 --- a/functions/check_steamcmd.sh +++ b/functions/check_steamcmd.sh @@ -8,14 +8,15 @@ lgsm_version="160316" fn_install_steamcmd(){ -echo "Installing steamCMD..." +echo "Installing steamCMD" if [ ! -d "${steamcmddir}" ]; then mkdir -v "${steamcmddir}" fi fn_fetch_file "http://media.steampowered.com/client/steamcmd_linux.tar.gz" "${steamcmddir}" "steamcmd_linux.tar.gz" tar --verbose -zxf "${steamcmddir}/steamcmd_linux.tar.gz" -C "${steamcmddir}" rm -v "${steamcmddir}/steamcmd_linux.tar.gz" -chmod +x "${steamcmddir}/steamcmd.sh" +chmod +x "${steamcmddir}/steamcmd.sh" +echo "" } @@ -43,13 +44,20 @@ fi fn_check_steamcmd_sh(){ # Checks if SteamCMD exists when starting or updating a server. -# Re-installs if missing. +# Installs if missing. steamcmddir="${rootdir}/steamcmd" if [ ! -f "${steamcmddir}/steamcmd.sh" ]; then - fn_printwarnnl "SteamCMD is missing" - fn_scriptlog "SteamCMD is missing" - sleep 1 - fn_install_steamcmd + if [ "${function_selfname}" == "command_install.sh" ]; then + fn_install_steamcmd + else + fn_printwarnnl "SteamCMD is missing" + fn_scriptlog "SteamCMD is missing" + sleep 1 + fn_install_steamcmd + fi +elif [ "${function_selfname}" == "command_install.sh" ]; then + fn_printinfomation "SteamCMD is already installed..." + fn_printokeol fi } From a9e3345fe74eb7c1bfc208a84e226704793f962c Mon Sep 17 00:00:00 2001 From: Daniel Gibbs Date: Fri, 19 Feb 2016 23:19:29 +0000 Subject: [PATCH 019/117] Fixed trap --- functions/core_dl.sh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/functions/core_dl.sh b/functions/core_dl.sh index d2a0c2372..1a54b8714 100644 --- a/functions/core_dl.sh +++ b/functions/core_dl.sh @@ -38,7 +38,7 @@ fn_dl_extract(){ : } -# trap to remove file download if canceled before completed +# Trap to remove file download if canceled before completed fn_fetch_trap() { echo "" fn_printinfomationnl "Cancelling download" @@ -74,7 +74,7 @@ if [ ! -f "${filedir}/${filename}" ]; then # If curl exists download file if [ "$(basename ${curlcmd})" == "curl" ]; then # trap to remove part downloaded files - trap fn_fetch_trap EXIT + trap fn_fetch_trap INT # if larger file shows progress bar if [[ $filename == *"tar"* ]]; then @@ -91,7 +91,7 @@ if [ ! -f "${filedir}/${filename}" ]; then fn_printokeol fi # remove trap - trap - SIGINT SIGQUIT SIGTSTP + trap - INT else fn_printfaileol echo "Curl is not installed!" From 72bbe93ecfd07427906255ab7646cfa11a825b68 Mon Sep 17 00:00:00 2001 From: Daniel Gibbs Date: Fri, 19 Feb 2016 23:25:45 +0000 Subject: [PATCH 020/117] Moved logs creation to allow logging on install --- functions/command_install.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/functions/command_install.sh b/functions/command_install.sh index 791cb160d..7f5753e3b 100644 --- a/functions/command_install.sh +++ b/functions/command_install.sh @@ -9,6 +9,7 @@ function_selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))" check.sh install_header.sh install_serverdir.sh +install_logs.sh check_deps.sh # Download and install if [ "${gamename}" == "Unreal Tournament 2004" ]; then @@ -27,7 +28,6 @@ fi # Configuration fix.sh -install_logs.sh install_gsquery.sh install_config.sh if [ "${gamename}" == "Counter Strike: Global Offensive" ]||[ "${gamename}" == "Team Fortress 2" ]||[ "${gamename}" == "BrainBread 2" ]; then From 988b52dbe8d44a2b04afe3d9f137d591a9b7ff0a Mon Sep 17 00:00:00 2001 From: Daniel Gibbs Date: Sat, 20 Feb 2016 00:46:51 +0000 Subject: [PATCH 021/117] Removed redundant function --- functions/check_steamuser.sh | 23 ----------------------- functions/core_functions.sh | 5 ----- 2 files changed, 28 deletions(-) delete mode 100644 functions/check_steamuser.sh diff --git a/functions/check_steamuser.sh b/functions/check_steamuser.sh deleted file mode 100644 index a807dc70e..000000000 --- a/functions/check_steamuser.sh +++ /dev/null @@ -1,23 +0,0 @@ -#!/bin/bash -# LGSM check_steamuser.sh function -# Author: Daniel Gibbs -# Website: http://gameservermanagers.com -lgsm_version="271215" - -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 diff --git a/functions/core_functions.sh b/functions/core_functions.sh index c54dd3c19..551e543db 100644 --- a/functions/core_functions.sh +++ b/functions/core_functions.sh @@ -146,11 +146,6 @@ functionfile="${FUNCNAME}" fn_fetch_function } -check_steamuser.sh(){ -functionfile="${FUNCNAME}" -fn_fetch_function -} - check_systemdir.sh(){ functionfile="${FUNCNAME}" fn_fetch_function From 7cf9f88210e5aa063a9472d8365e8c74a0e31efd Mon Sep 17 00:00:00 2001 From: Daniel Gibbs Date: Sat, 20 Feb 2016 00:49:20 +0000 Subject: [PATCH 022/117] adding extraction feature --- functions/check_steamcmd.sh | 6 ++---- functions/core_dl.sh | 40 ++++++++++++++++++++++++++++--------- 2 files changed, 33 insertions(+), 13 deletions(-) diff --git a/functions/check_steamcmd.sh b/functions/check_steamcmd.sh index 4c65ec557..d62d5e249 100644 --- a/functions/check_steamcmd.sh +++ b/functions/check_steamcmd.sh @@ -12,11 +12,9 @@ echo "Installing steamCMD" if [ ! -d "${steamcmddir}" ]; then mkdir -v "${steamcmddir}" fi -fn_fetch_file "http://media.steampowered.com/client/steamcmd_linux.tar.gz" "${steamcmddir}" "steamcmd_linux.tar.gz" -tar --verbose -zxf "${steamcmddir}/steamcmd_linux.tar.gz" -C "${steamcmddir}" -rm -v "${steamcmddir}/steamcmd_linux.tar.gz" +fn_fetch_file "http://media.steampowered.com/client/steamcmd_linux.tar.gz" "${lgsmdir}/tmp" "steamcmd_linux.tar.gz" +fn_dl_extract "${lgsmdir}/tmp" "steamcmd_linux.tar.gz" "${steamcmddir}" chmod +x "${steamcmddir}/steamcmd.sh" -echo "" } diff --git a/functions/core_dl.sh b/functions/core_dl.sh index 1a54b8714..e2b1c61b6 100644 --- a/functions/core_dl.sh +++ b/functions/core_dl.sh @@ -34,8 +34,26 @@ fi } fn_dl_extract(){ +filedir=${1} +filename=${2} +extractdir=${3} # extracts archives -: +echo -ne "extracting ${filename}..." +mime=$(file -b --mime-type "${filedir}/${filename}") + +if [ "${mime}" == "application/gzip" ]; then + tarcmd=$(tar -zxf "${filedir}/${filename}" -C "${extractdir}") +elif [ "${mime}" == "application/x-bzip2" ]; then + tarcmd=$(tar -jxf "${filedir}/${filename}" -C "${extractdir}") +fi +local exitcode=$? +if [ ${exitcode} -ne 0 ]; then + fn_printfaileol + echo "${tarcmd}" + exit ${exitcode} +else + fn_printokeol +fi } # Trap to remove file download if canceled before completed @@ -62,7 +80,7 @@ if [ ! -f "${filedir}/${filename}" ]; then if [ ! -d "${filedir}" ]; then mkdir -p "${filedir}" fi - echo -ne " fetching ${filename}...\c" + # Check curl exists and use available path curlpaths="$(command -v curl 2>/dev/null) $(which curl >/dev/null 2>&1) /usr/bin/curl /bin/curl /usr/sbin/curl /sbin/curl $(echo $PATH | sed "s/\([:]\|\$\)/\/curl /g")" for curlcmd in ${curlpaths} @@ -78,15 +96,20 @@ if [ ! -f "${filedir}/${filename}" ]; then # if larger file shows progress bar if [[ $filename == *"tar"* ]]; then - curlfetch=$(${curlcmd} --progress-bar --fail -o "${filedir}/${filename}" "${fileurl}") - else - curlfetch=$(${curlcmd} -s --fail -o "${filedir}/${filename}" "${fileurl}" 2>&1) + echo -ne "downloading ${filename}..." + sleep 1 + curlcmd=$(${curlcmd} --progress-bar --fail -o "${filedir}/${filename}" "${fileurl}") + echo -ne "downloading ${filename}..." + else + echo -ne " fetching ${filename}...\c" + curlcmd=$(${curlcmd} -s --fail -o "${filedir}/${filename}" "${fileurl}" 2>&1) fi - if [ $? -ne 0 ]; then + local exitcode=$? + if [ ${exitcode} -ne 0 ]; then fn_printfaileol - echo "${curlfetch}" + echo "${curlcmd}" echo -e "${fileurl}\n" - exit 1 + exit ${exitcode} else fn_printokeol fi @@ -99,7 +122,6 @@ if [ ! -f "${filedir}/${filename}" ]; then exit 1 fi fn_dl_md5 - # make file executable if run is set if [ "${run}" == "run" ]; then chmod +x "${filedir}/${filename}" From 55fff7a689988ebfde137f569397a9cffaf7670c Mon Sep 17 00:00:00 2001 From: Daniel Gibbs Date: Sat, 20 Feb 2016 00:53:30 +0000 Subject: [PATCH 023/117] removed echo --- functions/check_steamcmd.sh | 1 - 1 file changed, 1 deletion(-) diff --git a/functions/check_steamcmd.sh b/functions/check_steamcmd.sh index d62d5e249..ff713b85f 100644 --- a/functions/check_steamcmd.sh +++ b/functions/check_steamcmd.sh @@ -8,7 +8,6 @@ lgsm_version="160316" fn_install_steamcmd(){ -echo "Installing steamCMD" if [ ! -d "${steamcmddir}" ]; then mkdir -v "${steamcmddir}" fi From 6afee9f422f229e5cc5436dd403db48dfe12e0cf Mon Sep 17 00:00:00 2001 From: Daniel Gibbs Date: Sat, 20 Feb 2016 16:43:49 +0000 Subject: [PATCH 024/117] Moving install ut99 to new system --- functions/install_dl_ut99.sh | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/functions/install_dl_ut99.sh b/functions/install_dl_ut99.sh index fa7d64d6d..8a9157c55 100644 --- a/functions/install_dl_ut99.sh +++ b/functions/install_dl_ut99.sh @@ -8,4 +8,5 @@ echo "" echo "Downloading Server Files" echo "=================================" sleep 1 -fn_dl "ut-server-451-complete.tar.bz2" "${filesdir}" "http://gameservermanagers.com/files/ut99/ut-server-451-complete.tar.bz2" "42a8c9806e4fce10a56830caca83ce63" +fn_fetch_file "http://gameservermanagers.com/files/ut-server-451-complete.tar.bz2" "${lgsmdir}/tmp" "ut-server-451-complete.tar.bz2" "norun" "noforce" "42a8c9806e4fce10a56830caca83ce63" +fn_dl_extract "${lgsmdir}/tmp" "ut-server-451-complete.tar.bz2" "${filesdir}" \ No newline at end of file From 05dce64eb7bc166ee8f7395de05da8a47759d46b Mon Sep 17 00:00:00 2001 From: Daniel Gibbs Date: Sat, 20 Feb 2016 17:55:31 +0000 Subject: [PATCH 025/117] Update MD5 Check --- functions/core_dl.sh | 19 ++++++++++--------- functions/install_dl_ut99.sh | 2 +- 2 files changed, 11 insertions(+), 10 deletions(-) diff --git a/functions/core_dl.sh b/functions/core_dl.sh index e2b1c61b6..f1a416638 100644 --- a/functions/core_dl.sh +++ b/functions/core_dl.sh @@ -14,21 +14,22 @@ lgsm_version="050216" fn_dl_md5(){ # Runs MD5 Check if available if [ -n "${md5}" ]; then - echo -ne "verifying ${filename} with MD5...\c" - local md5check=$(md5sum "${filedir}/${filename}"|awk '{print $1;}') - if [ "${md5check}" != "${dl_md5}" ]; then + echo -ne "verifying ${filename} with MD5..." + sleep 1 + local md5sumcmd=$(md5sum "${filedir}/${filename}"|awk '{print $1;}') + if [ "${md5sumcmd}" != "${md5}" ]; then fn_printfaileol - echo "${filename} MD5 checksum: ${md5check}" - echo "expected MD5 checksum: ${dl_md5}" + echo "${filename} returned MD5 checksum: ${md5sumcmd}" + echo "expected MD5 checksum: ${md5}" fn_scriptlog "failed to verify ${filename} with MD5" - fn_scriptlog "${filename} MD5 checksum: ${md5check}" - fn_scriptlog "expected MD5 checksum: ${dl_md5}" + fn_scriptlog "${filename} returned MD5 checksum: ${md5sumcmd}" + fn_scriptlog "expected MD5 checksum: ${md5}" exit 1 else fn_printokeol fn_scriptlog "verifyed ${filename} with MD5" - fn_scriptlog "${filename} MD5 checksum: ${md5check}" - fn_scriptlog "expected MD5 checksum: ${dl_md5}" + fn_scriptlog "${filename} returned MD5 checksum: ${md5sumcmd}" + fn_scriptlog "expected MD5 checksum: ${md5}" fi fi } diff --git a/functions/install_dl_ut99.sh b/functions/install_dl_ut99.sh index 8a9157c55..7d8b2fd23 100644 --- a/functions/install_dl_ut99.sh +++ b/functions/install_dl_ut99.sh @@ -8,5 +8,5 @@ echo "" echo "Downloading Server Files" echo "=================================" sleep 1 -fn_fetch_file "http://gameservermanagers.com/files/ut-server-451-complete.tar.bz2" "${lgsmdir}/tmp" "ut-server-451-complete.tar.bz2" "norun" "noforce" "42a8c9806e4fce10a56830caca83ce63" +fn_fetch_file "http://gameservermanagers.com/files/ut-server-451-complete.tar.bz2" "${lgsmdir}/tmp" "ut-server-451-complete.tar.bz2" "norun" "noforce" "e623fdff5ed600a9bfccab852e18d34d" fn_dl_extract "${lgsmdir}/tmp" "ut-server-451-complete.tar.bz2" "${filesdir}" \ No newline at end of file From f732744910401a035a1e7d047a824c45f50f04ed Mon Sep 17 00:00:00 2001 From: Daniel Gibbs Date: Sat, 20 Feb 2016 17:56:16 +0000 Subject: [PATCH 026/117] Altered how source is run --- functions/core_dl.sh | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/functions/core_dl.sh b/functions/core_dl.sh index f1a416638..91c9d02c4 100644 --- a/functions/core_dl.sh +++ b/functions/core_dl.sh @@ -122,16 +122,19 @@ if [ ! -f "${filedir}/${filename}" ]; then echo -e "" exit 1 fi - fn_dl_md5 # make file executable if run is set if [ "${run}" == "run" ]; then chmod +x "${filedir}/${filename}" - fi -fi -# run file if run is set -if [ "${run}" == "run" ]; then - source "${filedir}/${filename}" + fi fi + +if [ -f "${filedir}/${filename}" ]; then + fn_dl_md5 + # run file if run is set + if [ "${run}" == "run" ]; then + source "${filedir}/${filename}" + fi +fi } From bc254d39a8c2adb14801c789af9aa543eb908a70 Mon Sep 17 00:00:00 2001 From: Daniel Gibbs Date: Sat, 20 Feb 2016 18:01:23 +0000 Subject: [PATCH 027/117] Updated ut99 to use new download system --- UnrealTournament99/ut99server | 91 +++++++++++++++++++---------------- 1 file changed, 50 insertions(+), 41 deletions(-) diff --git a/UnrealTournament99/ut99server b/UnrealTournament99/ut99server index a1dd53887..8fe315593 100644 --- a/UnrealTournament99/ut99server +++ b/UnrealTournament99/ut99server @@ -9,7 +9,7 @@ if [ -f ".dev-debug" ]; then set -x fi -version="121215" +version="200216" #### Variables #### @@ -28,6 +28,13 @@ parms="server ${defaultmap}.unr ini=${servercfgfullpath}" #### Advanced Variables #### +# Github Branch Select +# Allows for the use of different function files +# from a different repo and/or branch. +githubuser="dgibbs64" +githubrepo="linuxgsm" +githubbranch="master" + # Server Details servicename="ut99-server" gamename="Unreal Tournament 99" @@ -38,6 +45,8 @@ rootdir="$(dirname $(readlink -f "${BASH_SOURCE[0]}"))" selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))" lockselfname=".${servicename}.lock" filesdir="${rootdir}/serverfiles" +lgsmdir="${rootdir}/lgsm" +functionsdir="${lgsmdir}/functions" systemdir="${filesdir}/System" executabledir="${systemdir}" executable="./ucc-bin" @@ -60,66 +69,66 @@ emaillog="${scriptlogdir}/${servicename}-email.log" scriptlogdate="${scriptlogdir}/${servicename}-script-$(date '+%d-%m-%Y-%H-%M-%S').log" consolelogdate="${consolelogdir}/${servicename}-console-$(date '+%d-%m-%Y-%H-%M-%S').log" -# Github Branch Select -# Allows for the use of different function files -# from a different repo and/or branch. -githubuser="dgibbs64" -githubrepo="linuxgsm" -githubbranch="master" - ##### Script ##### # Do not edit -fn_getgithubfile(){ -filename=$1 -exec=$2 -fileurl=${3:-$filename} -filepath="${rootdir}/${filename}" -filedir=$(dirname "${filepath}") -# If the function file is missing, then download -if [ ! -f "${filepath}" ]; then +# Fetches core_dl for file downloads +fn_fetch_core_dl(){ +github_file_url_dir="functions" +github_file_url_name="${functionfile}" +filedir="${functionsdir}" +filename="${github_file_url_name}" +githuburl="https://raw.githubusercontent.com/${githubuser}/${githubrepo}/${githubbranch}/${github_file_url_dir}/${github_file_url_name}" +# If the file is missing, then download +if [ ! -f "${filedir}/${filename}" ]; then if [ ! -d "${filedir}" ]; then - mkdir "${filedir}" + mkdir -p "${filedir}" fi - githuburl="https://raw.githubusercontent.com/${githubuser}/${githubrepo}/${githubbranch}/${fileurl}" echo -e " fetching ${filename}...\c" - if [ "$(command -v curl)" ]||[ "$(which curl >/dev/null 2>&1)" ]||[ -f "/usr/bin/curl" ]||[ -f "/bin/curl" ]; then - : - else + # Check curl exists and use available path + curlpaths="$(command -v curl 2>/dev/null) $(which curl >/dev/null 2>&1) /usr/bin/curl /bin/curl /usr/sbin/curl /sbin/curl $(echo $PATH | sed "s/\([:]\|\$\)/\/curl /g")" + for curlcmd in ${curlpaths} + do + if [ -x "${curlcmd}" ]; then + break + fi + done + # If curl exists download file + if [ "$(basename ${curlcmd})" == "curl" ]; then + curlfetch=$(${curlcmd} -s --fail -o "${filedir}/${filename}" "${githuburl}" 2>&1) + if [ $? -ne 0 ]; then + echo -e "\e[0;31mFAIL\e[0m\n" + echo "${curlfetch}" + echo -e "${githuburl}\n" + exit 1 + else + echo -e "\e[0;32mOK\e[0m" + fi + else echo -e "\e[0;31mFAIL\e[0m\n" echo "Curl is not installed!" echo -e "" - exit - fi - curl=$(curl --fail -o "${filepath}" "${githuburl}" 2>&1) - if [ $? -ne 0 ]; then - echo -e "\e[0;31mFAIL\e[0m\n" - echo "${curl}" - echo -e "${githuburl}\n" - exit - else - echo -e "\e[0;32mOK\e[0m" - fi - if [ "${exec}" ]; then - chmod +x "${filepath}" + exit 1 fi + chmod +x "${filedir}/${filename}" fi -if [ "${exec}" ]; then - source "${filepath}" -fi +source "${filedir}/${filename}" } -fn_runfunction(){ - fn_getgithubfile "functions/${functionfile}" 1 +core_dl.sh(){ +# Functions are defined in core_functions.sh. +functionfile="${FUNCNAME}" +fn_fetch_core_dl } core_functions.sh(){ # Functions are defined in core_functions.sh. functionfile="${FUNCNAME}" -fn_runfunction +fn_fetch_core_dl } +core_dl.sh core_functions.sh getopt=$1 -core_getopt.sh +core_getopt.sh \ No newline at end of file From 15f99b7076708c92ad21dc80dcc3aa9dcc173991 Mon Sep 17 00:00:00 2001 From: Daniel Gibbs Date: Sat, 20 Feb 2016 18:21:15 +0000 Subject: [PATCH 028/117] Merging ut99server files in to install_server_files --- functions/command_install.sh | 5 +- functions/install_dl_ut99.sh | 12 ---- functions/install_server_files.sh | 109 ++++++++++++++++++++++++++++++ 3 files changed, 111 insertions(+), 15 deletions(-) delete mode 100644 functions/install_dl_ut99.sh create mode 100644 functions/install_server_files.sh diff --git a/functions/command_install.sh b/functions/command_install.sh index 7f5753e3b..a68a5cc62 100644 --- a/functions/command_install.sh +++ b/functions/command_install.sh @@ -2,7 +2,7 @@ # LGSM fn_install function # Author: Daniel Gibbs # Website: http://gameservermanagers.com -lgsm_version="271215" +lgsm_version="200216" function_selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))" @@ -17,8 +17,7 @@ if [ "${gamename}" == "Unreal Tournament 2004" ]; then install_ut2k4.sh install_ut2k4_key.sh elif [ "${gamename}" == "Unreal Tournament 99" ]; then - install_dl_ut99.sh - install_ut99.sh + install_server_files.sh elif [ "${gamename}" == "Teamspeak 3" ]; then install_ts3.sh elif [ ! -z "${appid}" ]; then diff --git a/functions/install_dl_ut99.sh b/functions/install_dl_ut99.sh deleted file mode 100644 index 7d8b2fd23..000000000 --- a/functions/install_dl_ut99.sh +++ /dev/null @@ -1,12 +0,0 @@ -#!/bin/bash -# LGSM install_dl_ut99.sh function -# Author: Daniel Gibbs -# Website: http://gameservermanagers.com -lgsm_version="050216" - -echo "" -echo "Downloading Server Files" -echo "=================================" -sleep 1 -fn_fetch_file "http://gameservermanagers.com/files/ut-server-451-complete.tar.bz2" "${lgsmdir}/tmp" "ut-server-451-complete.tar.bz2" "norun" "noforce" "e623fdff5ed600a9bfccab852e18d34d" -fn_dl_extract "${lgsmdir}/tmp" "ut-server-451-complete.tar.bz2" "${filesdir}" \ No newline at end of file diff --git a/functions/install_server_files.sh b/functions/install_server_files.sh new file mode 100644 index 000000000..d0af67112 --- /dev/null +++ b/functions/install_server_files.sh @@ -0,0 +1,109 @@ +#!/bin/bash +# LGSM install_server_files.sh function +# Author: Daniel Gibbs +# Website: http://gameservermanagers.com +lgsm_version="050216" + + +fn_install_server_files(){ +if [ "${gamename}" == "Unreal Tournament 99" ]; then + fileurl="http://gameservermanagers.com/files/ut-server-451-complete.tar.bz2"; filedir="${lgsmdir}/tmp"; filename="ut-server-451-complete.tar.bz2"; run="norun"; force="noforce"; md5="e623fdff5ed600a9bfccab852e18d34d" +fi +fn_fetch_file "${fileurl}" "${filedir}" "${filename}" "${run}" "${force}" "${md5}" +fn_dl_extract "${filedir}" "${filename}" "${filesdir}" +} + +#!/bin/bash +# LGSM install_serverfiles.sh function +# Author: Daniel Gibbs +# Website: http://gameservermanagers.com +lgsm_version="271215" + +fn_install_server_files_steamcmd(){ +check.sh +mkdir -pv "${filesdir}" +counter="0" +while [ "${counter}" == "0" ]||[ "$(grep -wc 0x402 .install_serverfiles.sh.tmp)" -ge "1" ]||[ "$(grep -wc 0x406 .install_serverfiles.sh.tmp)" -ge "1" ]||[ "$(grep -wc 0x6 .install_serverfiles.sh.tmp)" -ge "1" ]||[ "$(grep -wc 0x106 .install_serverfiles.sh.tmp)" -ge "1" ]; do + counter=$((counter+1)) + cd "${rootdir}/steamcmd" + if [ "${counter}" -le "10" ]; then + # Attempt 1-4: Standard attempt + # Attempt 5-6: Validate attempt + # Attempt 7-8: Validate, delete long name dir + # Attempt 9-10: Validate, delete long name dir, re-download SteamCMD + # Attempt 11: Failure + + if [ "${counter}" -ge "2" ]; then + fn_printwarningnl "SteamCMD did not complete the download, retrying: Attempt ${counter}:" + fi + + if [ "${counter}" -ge "7" ]; then + echo "Removing $(find ${filesdir} -type d -print0 | grep -Ez '[^/]{30}$')" + find ${filesdir} -type d -print0 | grep -Ez '[^/]{30}$' | xargs -0 rm -rf + fi + if [ "${counter}" -ge "9" ]; then + rm -rf "${rootdir}/steamcmd" + check_steamcmd.sh + fi + + # Detects if unbuffer command is available. + if [ $(command -v unbuffer) ]; then + unbuffer=unbuffer + fi + + if [ "${counter}" -le "4" ]; then + if [ "${engine}" == "goldsource" ]; then + ${unbuffer} ./steamcmd.sh +login "${steamuser}" "${steampass}" +force_install_dir "${filesdir}" +app_set_config 90 mod ${appidmod} +app_update "${appid}" +quit |tee .install_serverfiles.sh.tmp + else + ${unbuffer} ./steamcmd.sh +login "${steamuser}" "${steampass}" +force_install_dir "${filesdir}" +app_update "${appid}" +quit |tee .install_serverfiles.sh.tmp + fi + elif [ "${counter}" -ge "5" ]; then + if [ "${engine}" == "goldsource" ]; then + ${unbuffer} ./steamcmd.sh +login "${steamuser}" "${steampass}" +force_install_dir "${filesdir}" +app_set_config 90 mod ${appidmod} +app_update "${appid}" -validate +quit |tee .install_serverfiles.sh.tmp + else + ${unbuffer} ./steamcmd.sh +login "${steamuser}" "${steampass}" +force_install_dir "${filesdir}" +app_update "${appid}" -validate +quit |tee .install_serverfiles.sh.tmp + fi + fi + elif [ "${counter}" -ge "11" ]; then + fn_printfailurenl "SteamCMD did not complete the download, too many retrys" + break + fi + +done + +# Goldsource servers commonly fail to download all the server files required. +# Validating a few of times may reduce the chance of this issue. +if [ "${engine}" == "goldsource" ]; then + counter="0" + while [ "${counter}" -le "4" ]; do + counter=$((counter+1)) + ${unbuffer} ./steamcmd.sh +login "${steamuser}" "${steampass}" +force_install_dir "${filesdir}" +app_set_config 90 mod ${appidmod} +app_update "${appid}" -validate +quit |tee .install_serverfiles.sh.tmp + done +fi +rm -f .install_serverfiles.sh.tmp +} + +echo "" +echo "Installing ${gamename} Server" +echo "=================================" +sleep 1 +if [ -z "${appid}" ]; then + fn_install_server_files_steamcmd +fi + +if [ ! -z "${appid}" ]||[ "${gamename}" == "GoldenEye: Source" ]; then + fn_install_server_files +fi + +if [ -z "${autoinstall}" ]; then + echo "" + echo "=================================" + while true; do + read -e -i "y" -p "Was the install successful? [Y/n]" yn + case $yn in + [Yy]* ) break;; + [Nn]* ) install_retry.sh;; + * ) echo "Please answer yes or no.";; + esac + done +fi \ No newline at end of file From 61258600c1fdc296315ade01cce003f9aa393777 Mon Sep 17 00:00:00 2001 From: Daniel Gibbs Date: Sat, 20 Feb 2016 18:24:12 +0000 Subject: [PATCH 029/117] renamed serverfiles to server_files --- functions/core_functions.sh | 12 +----------- 1 file changed, 1 insertion(+), 11 deletions(-) diff --git a/functions/core_functions.sh b/functions/core_functions.sh index 551e543db..4fbbd25e7 100644 --- a/functions/core_functions.sh +++ b/functions/core_functions.sh @@ -353,7 +353,7 @@ install_serverdir.sh(){ functionfile="${FUNCNAME}" fn_fetch_function } -install_serverfiles.sh(){ +install_server_files.sh(){ functionfile="${FUNCNAME}" fn_fetch_function } @@ -388,16 +388,6 @@ functionfile="${FUNCNAME}" fn_fetch_function } -install_ut99.sh(){ -functionfile="${FUNCNAME}" -fn_fetch_function -} - -install_dl_ut99.sh(){ -functionfile="${FUNCNAME}" -fn_fetch_function -} - fix_ut99.sh(){ functionfile="${FUNCNAME}" fn_fetch_function From a422f3c08208594fc2216dedba97c0e9f6545ab1 Mon Sep 17 00:00:00 2001 From: Daniel Gibbs Date: Sat, 20 Feb 2016 18:29:03 +0000 Subject: [PATCH 030/117] corrected if --- functions/install_server_files.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/functions/install_server_files.sh b/functions/install_server_files.sh index d0af67112..be0576e3f 100644 --- a/functions/install_server_files.sh +++ b/functions/install_server_files.sh @@ -87,11 +87,11 @@ echo "" echo "Installing ${gamename} Server" echo "=================================" sleep 1 -if [ -z "${appid}" ]; then +if [ -n "${appid}" ]; then fn_install_server_files_steamcmd fi -if [ ! -z "${appid}" ]||[ "${gamename}" == "GoldenEye: Source" ]; then +if [ -z "${appid}" ]||[ "${gamename}" == "GoldenEye: Source" ]; then fn_install_server_files fi From ff5be5c68f6016a9ba9442b21f3c4deeaddfd722 Mon Sep 17 00:00:00 2001 From: Daniel Gibbs Date: Fri, 26 Feb 2016 10:20:46 +0000 Subject: [PATCH 031/117] Added auto install to unreal games --- functions/core_getopt.sh | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/functions/core_getopt.sh b/functions/core_getopt.sh index 95196d0ef..92c8897ab 100644 --- a/functions/core_getopt.sh +++ b/functions/core_getopt.sh @@ -259,6 +259,8 @@ case "$getopt" in command_dev_debug.sh;; i|install) command_install.sh;; + ai|auto-install) + fn_autoinstall;; mc|map-compressor) compress_ut99_maps.sh;; dd|depsdetect) @@ -382,6 +384,8 @@ case "$getopt" in command_dev_debug.sh;; i|install) command_install.sh;; + ai|auto-install) + fn_autoinstall;; mc|map-compressor) compress_unreal2_maps.sh;; dd|depsdetect) From a3a0d78b44d953f2c81af6325ea93ef2ccce49b4 Mon Sep 17 00:00:00 2001 From: Daniel Gibbs Date: Fri, 26 Feb 2016 10:21:40 +0000 Subject: [PATCH 032/117] Auto install descriptions --- functions/core_getopt.sh | 2 ++ 1 file changed, 2 insertions(+) diff --git a/functions/core_getopt.sh b/functions/core_getopt.sh index 92c8897ab..ed3bd1369 100644 --- a/functions/core_getopt.sh +++ b/functions/core_getopt.sh @@ -283,6 +283,7 @@ case "$getopt" in echo -e "\e[34mconsole\t\e[0mConsole allows you to access the live view of a server." 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[34mmap-compressor\t\e[0mCompresses all ${gamename} server maps." } | column -s $'\t' -t esac @@ -408,6 +409,7 @@ case "$getopt" in echo -e "\e[34mconsole\t\e[0mConsole allows you to access the live view of a server." 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[34mmap-compressor\t\e[0mCompresses all ${gamename} server maps." } | column -s $'\t' -t esac From b21c1eeac0fadb4620f3e33c84e2d87873d487cd Mon Sep 17 00:00:00 2001 From: Daniel Gibbs Date: Fri, 26 Feb 2016 10:29:13 +0000 Subject: [PATCH 033/117] Moved gsquery to functions --- {GameServerQuery => functions}/gsquery.py | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename {GameServerQuery => functions}/gsquery.py (100%) diff --git a/GameServerQuery/gsquery.py b/functions/gsquery.py similarity index 100% rename from GameServerQuery/gsquery.py rename to functions/gsquery.py From 85e93ad0736e99d7e0d21885253d9bd611b4cb40 Mon Sep 17 00:00:00 2001 From: Daniel Gibbs Date: Fri, 26 Feb 2016 10:56:52 +0000 Subject: [PATCH 034/117] Added gsquery.py to functions --- functions/core_functions.sh | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/functions/core_functions.sh b/functions/core_functions.sh index 4fbbd25e7..fdc5f9565 100644 --- a/functions/core_functions.sh +++ b/functions/core_functions.sh @@ -281,6 +281,11 @@ functionfile="${FUNCNAME}" fn_fetch_function } +gsquery.py(){ +functionfile="${FUNCNAME}" +fn_fetch_function +} + # Update From 33ed3562ab0d74ae8ae6d0c06dbbeb0f1b5e4650 Mon Sep 17 00:00:00 2001 From: Daniel Gibbs Date: Fri, 26 Feb 2016 11:37:10 +0000 Subject: [PATCH 035/117] Code tidy --- functions/info_config.sh | 46 ++++++++++++++++++++-------------------- 1 file changed, 23 insertions(+), 23 deletions(-) diff --git a/functions/info_config.sh b/functions/info_config.sh index 60d2d77e0..6e9f1412b 100644 --- a/functions/info_config.sh +++ b/functions/info_config.sh @@ -197,29 +197,29 @@ elif [ "${engine}" == "realvirtuality" ]; then slots="\e[0;31mUNAVAILABLE\e[0m" fi - # port - if [ "${port}" != "" ]; then - port=${port} - fi - if [ ! -n "${port}" ]; then - port="0" - fi - - # query port - if [ "${port}" != "" ]; then - queryport=$((port+1)) - fi - if [ ! -n "${queryport}" ]; then - queryport="0" - fi - - # master port - if [ "${port}" != "" ]; then - masterport=$((port+2)) - fi - if [ ! -n "${masterport}" ]; then - masterport="0" - fi + # port + if [ "${port}" != "" ]; then + port=${port} + fi + if [ ! -n "${port}" ]; then + port="0" + fi + + # query port + if [ "${port}" != "" ]; then + queryport=$((port+1)) + fi + if [ ! -n "${queryport}" ]; then + queryport="0" + fi + + # master port + if [ "${port}" != "" ]; then + masterport=$((port+2)) + fi + if [ ! -n "${masterport}" ]; then + masterport="0" + fi # Serious Sam elif [ "${engine}" == "seriousengine35" ]; then From 911d649f43efab38be1d627664f38d7dc0fbd803 Mon Sep 17 00:00:00 2001 From: Daniel Gibbs Date: Fri, 26 Feb 2016 13:13:00 +0000 Subject: [PATCH 036/117] Added excecutecmd to allow cmds to not execute --- functions/core_dl.sh | 27 +++++++++++++++------------ functions/core_functions.sh | 6 ------ 2 files changed, 15 insertions(+), 18 deletions(-) diff --git a/functions/core_dl.sh b/functions/core_dl.sh index 91c9d02c4..2ad1f3b67 100644 --- a/functions/core_dl.sh +++ b/functions/core_dl.sh @@ -67,14 +67,15 @@ fn_fetch_trap() { } # Downloads file using curl and run it if required -# fn_fetch_file "fileurl" "filedir" "filename" "run" "force" "md5" +# fn_fetch_file "fileurl" "filedir" "filename" "executecmd" "run" "force" "md5" fn_fetch_file(){ fileurl=${1} filedir=${2} filename=${3} -run=${4:-0} -force=${5:-0} -md5=${6} +executecmd=${4:-0} +run=${5:-0} +force=${6:-0} +md5=${7} # If the file is missing, then download if [ ! -f "${filedir}/${filename}" ]; then @@ -122,8 +123,8 @@ if [ ! -f "${filedir}/${filename}" ]; then echo -e "" exit 1 fi - # make file executable if run is set - if [ "${run}" == "run" ]; then + # make file executecmd if executecmd is set + if [ "${executecmd}" == "executecmd" ]; then chmod +x "${filedir}/${filename}" fi fi @@ -143,18 +144,19 @@ fi # github_file_url_dir: The directory the file is located in teh GitHub repo # github_file_url_name: name of file # filepath: location file to be saved -# run: Optional, set to 1 to make file executable +# executecmd: set to "executecmd" to make file executecmd +# run: Optional, set to run to execute the file # force: force download of file even if exists fn_fetch_file_github(){ github_file_url_dir=${1} github_file_url_name=${2} filepath=${3} filename="${github_file_url_name}" -run=${4:-0} -force=${5:-0} +executecmd=${4:-0} +run=${5:-0} +force=${6:-0} githuburl="https://raw.githubusercontent.com/${githubuser}/${githubrepo}/${githubbranch}/${github_file_url_dir}/${github_file_url_name}" -echo -e " fetching ${filename}...\c" -fn_fetch_file "${githuburl}" "${filepath}" "${filename}" "${run}" "${force}" +fn_fetch_file "${githuburl}" "${filepath}" "${filename}" "${executecmd}" "${run}" "${force}" } @@ -166,6 +168,7 @@ github_file_url_name="${functionfile}" # name of the github file githuburl="https://raw.githubusercontent.com/${githubuser}/${githubrepo}/${githubbranch}/${github_file_url_dir}/${github_file_url_name}" filedir="${functionsdir}" # local dir that will contain the file filename="${github_file_url_name}" # name of the local file +executecmd="executecmd" run="run" -fn_fetch_file "${githuburl}" "${filedir}" "${filename}" "${run}" +fn_fetch_file "${githuburl}" "${filedir}" "${filename}" "${executecmd}" "${run}" } \ No newline at end of file diff --git a/functions/core_functions.sh b/functions/core_functions.sh index fdc5f9565..0ef2cc095 100644 --- a/functions/core_functions.sh +++ b/functions/core_functions.sh @@ -281,12 +281,6 @@ functionfile="${FUNCNAME}" fn_fetch_function } -gsquery.py(){ -functionfile="${FUNCNAME}" -fn_fetch_function -} - - # Update update_check.sh(){ From 1e2ec54367a5f3fa368ad281e5bf128bc0e7b2e0 Mon Sep 17 00:00:00 2001 From: Daniel Gibbs Date: Fri, 26 Feb 2016 18:49:49 +0000 Subject: [PATCH 037/117] Added fn_printokeolnl and fn_printfaileolnl --- functions/core_messages.sh | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/functions/core_messages.sh b/functions/core_messages.sh index 939e73889..c8b3fb7f0 100644 --- a/functions/core_messages.sh +++ b/functions/core_messages.sh @@ -2,7 +2,7 @@ # LGSM fn_messages function # Author: Daniel Gibbs # Website: http://gameservermanagers.com -lgsm_version="271215" +lgsm_version="380216" # Description: Defines on-screen messages such as [ OK ] and how script logs look. @@ -139,10 +139,18 @@ fn_printinfomationnl(){ # FAIL for end of line fn_printokeol(){ + echo -en "\e[0;32mOK\e[0m" +} + +fn_printokeolnl(){ echo -e "\e[0;32mOK\e[0m" } # FAIL for end of line fn_printfaileol(){ + echo -en "\e[0;31mFAIL\e[0m\n" +} + +fn_printfaileolnl(){ echo -e "\e[0;31mFAIL\e[0m\n" } \ No newline at end of file From 5d687b023dde4653b1f4f564635edef5fff8edfe Mon Sep 17 00:00:00 2001 From: Daniel Gibbs Date: Fri, 26 Feb 2016 19:00:47 +0000 Subject: [PATCH 038/117] Major update to monitor_gsquery.sh * Now loops for 60 seconds checking 4 times for if fails * gsquery .py moved to functions dir * uses new core_dl feature so gsquery is auto installed * removed old code * added colors --- functions/monitor_gsquery.sh | 157 +++++++++++++++++------------------ 1 file changed, 77 insertions(+), 80 deletions(-) diff --git a/functions/monitor_gsquery.sh b/functions/monitor_gsquery.sh index 55e2e9fc2..c714d64ee 100644 --- a/functions/monitor_gsquery.sh +++ b/functions/monitor_gsquery.sh @@ -4,94 +4,91 @@ # Website: http://gameservermanagers.com lgsm_version="271215" -# Description: uses gsquery.py to directly query the server. -# Detects if the server has frozen. +# Description: uses gsquery.py to query the server port. +# Detects if the server has frozen with the proccess still running. local modulename="Monitor" -if [ -f "${rootdir}/gsquery.py" ]; then - if [ "${engine}" == "unreal" ]||[ "${engine}" == "unreal2" ]; then - gameport=$(grep Port= "${servercfgfullpath}"|grep -v Master|grep -v LAN|grep -v Proxy|grep -v Listen|tr -d '\r'|tr -cd '[:digit:]') - port=$((${gameport} + 1)) - elif [ "${engine}" == "spark" ]; then - port=$((${port} + 1)) - elif [ "${engine}" == "realvirtuality" ]; then - queryport=$(grep -s steamqueryport= "${servercfgfullpath}"|grep -v //|tr -d '\r'|tr -cd '[:digit:]') - port=${queryport} - elif [ "${gamename}" == "7 Days To Die" ]; then - gameport=$(grep ServerPort "${servercfgfullpath}"|tr -cd '[:digit:]') - port=$((${gameport} + 1)) - elif [ "${gamename}" == "Hurtworld" ]; then - gameport="${port}" - port="${queryport}" - fi - fn_printinfo "Detected gsquery.py" - fn_scriptlog "Detected gsquery.py" - sleep 1 - fn_printdots "Querying port: ${ip}:${port} : QUERYING" - fn_scriptlog "Querying port: ${ip}:${port} : QUERYING" - sleep 1 - serverquery=$("${rootdir}/gsquery.py" -a ${ip} -p ${port} -e ${engine} 2>&1) + +# Downloads gsquery.py if missing +if [ ! -f "${functionsdir}/gsquery.py" ]; then + fn_fetch_file_github "functions" "gsquery.py" "${functionsdir}" "executecmd" "norun" "noforce" +fi + +info_config.sh + +if [ "${engine}" == "unreal" ]||[ "${engine}" == "unreal2" ]; then + port=$((${port} + 1)) +elif [ "${engine}" == "spark" ]; then + port=$((${port} + 1)) +fi + +if [ -z "${queryport}" ]; then + port="${queryport}" +fi + + +fn_printinfo "Querying port: gsquery.py enabled" +fn_scriptlog "gsquery.py enabled" +sleep 1 +fn_printdots "Querying port: ${ip}:${port}: 0/1 : " +fn_printqueryingeol +fn_scriptlog "Querying port: ${ip}:${port}: 1 : QUERYING" +sleep 1 + + +# Will query up to 4 times every 15 seconds. +# Servers changing map can return a failure. +# Will Wait up to 60 seconds to confirm server is down giving server time to change map. +queryattempt=0 +totalseconds=0 +for i in {1..4}; do + gsquerycmd=$("${functionsdir}"/gsquery.py -a ${ip} -p 1 -e ${engine} 2>&1) exitcode=$? - if [ "${exitcode}" == "1" ]||[ "${exitcode}" == "2" ]||[ "${exitcode}" == "3" ]||[ "${exitcode}" == "4" ]; then - fn_printfail "Querying port: ${ip}:${port} : ${serverquery}" - fn_scriptlog "Querying port: ${ip}:${port} : ${serverquery}" + + if [ "${exitcode}" == "0" ]; then + # Server OK + fn_printok "Querying port: ${ip}:${port}: " + fn_printokeol + fn_scriptlog "Querying port: ${ip}:${port}: OK" sleep 1 - echo -en "\n" - if [ -z "${secondquery}" ]; then - if [ "${engine}" == "unreal2" ]; then - # unreal 2: Map change can take around 60 seconds - fn_printinfo "Waiting 60 seconds to re-query" - fn_scriptlog "Waiting 60 seconds to re-query" - sleep 60 - else - fn_printinfo "Waiting 30 seconds to re-query" - fn_scriptlog "Waiting 30 seconds to re-query" - sleep 30 - fi - secondquery=1 - monitor_gsquery.sh - fi + exit + else + # Server failed query + queryattempt=$((queryattempt + 1)) + fn_scriptlog "Querying port: ${ip}:${port}: ${totalseconds}/${queryattempt} : ${gsquerycmd}" + seconds=0 + # Seconds counter + while [ true ]; do + fn_printfail "Querying port: ${ip}:${port}: ${totalseconds}/${queryattempt} : \e[0;31m${gsquerycmd}\e[0m" + seconds=$((seconds + 1)) + totalseconds=$((totalseconds + 1)) + sleep 1 + if [ "${seconds}" == "15" ]; then + fn_printdots "Querying port: ${ip}:${port}: ${totalseconds}/${queryattempt} : " + fn_printqueryingeol + fn_scriptlog "Querying port: ${ip}:${port}: ${queryattempt} : QUERYING" + sleep 1 + break + fi + done + fi + + if [ "${queryattempt}" == "4" ]; then + # Server failed query 4 times confirmed failure + fn_printfail "Querying port: ${ip}:${port}: " + fn_printfaileol + fn_scriptlog "Querying port: ${ip}:${port}: ${gsquerycmd}" + fn_scriptlog "Querying port: ${ip}:${port}: FAIL" + sleep 1 + + # Send email notification if enabled if [ "${emailnotification}" = "on" ]; then info_config.sh subject="${servicename} Monitor - Starting ${servername}" - failurereason="Failed to query ${servicename}: ${serverquery}" + failurereason="Failed to query ${servicename}: ${gsquerycmd}" actiontaken="restarted ${servicename}" email.sh fi fn_restart - exit 1 - elif [ "${exitcode}" == "0" ]; then - fn_printok "Querying port: ${ip}:${port} : OK" - fn_scriptlog "Querying port: ${ip}:${port} : OK" - sleep 1 - echo -en "\n" - exit - elif [ "${exitcode}" == "126" ]; then - fn_printfail "Querying port: ${ip}:${port} : ERROR: ${rootdir}/gsquery.py: Permission denied" - fn_scriptlog "Querying port: ${ip}:${port} : ERROR: ${rootdir}/gsquery.py: Permission denied" - sleep 1 - echo -en "\n" - echo "Attempting to resolve automatically" - chmod +x -v "${rootdir}/gsquery.py" - if [ $? -eq 0 ]; then - monitor_gsquery.sh - else - fn_printfailure "Unable to resolve automatically. Please manually fix permissions.\n" - owner=$(ls -al ${rootdir}/gsquery.py|awk '{ print $3 }') - echo "As user ${owner} or root run the following command." - whoami=$(whoami) - echo -en "\nchown ${whoami}:${whoami} ${rootdir}/gsquery.py\n\n" - exit 1 - fi - else - fn_printfail "Querying port: ${ip}:${port} : UNKNOWN ERROR" - fn_scriptlog "Querying port: ${ip}:${port} : UNKNOWN ERROR" - sleep 1 - echo -en "\n" - ${rootdir}/gsquery.py -a ${ip} -p ${port} -e ${engine} - exit 1 - fi -else - fn_printfailnl "Could not find ${rootdir}/gsquery.py" - fn_scriptlog "Could not find ${rootdir}/gsquery.py" -fi + fi +done \ No newline at end of file From d1491d598489736b2cdf4d33536d8891ea5ceae3 Mon Sep 17 00:00:00 2001 From: Daniel Gibbs Date: Fri, 26 Feb 2016 19:00:58 +0000 Subject: [PATCH 039/117] Added fn_printqueryingeol --- functions/core_messages.sh | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/functions/core_messages.sh b/functions/core_messages.sh index c8b3fb7f0..88a0a8127 100644 --- a/functions/core_messages.sh +++ b/functions/core_messages.sh @@ -153,4 +153,13 @@ fn_printfaileol(){ fn_printfaileolnl(){ echo -e "\e[0;31mFAIL\e[0m\n" +} + +# QUERYING for end of line +fn_printqueryingeol(){ + echo -en "\e[0;31mQUERYING\e[0m\n" +} + +fn_printqueryingeolnl(){ + echo -e "\e[0;31mQUERYING\e[0m\n" } \ No newline at end of file From 20fd5936fb36f9ca2a5c3d5b0fb091a4a21031a9 Mon Sep 17 00:00:00 2001 From: Daniel Gibbs Date: Fri, 26 Feb 2016 19:01:37 +0000 Subject: [PATCH 040/117] Minor tidy --- functions/info_config.sh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/functions/info_config.sh b/functions/info_config.sh index 6e9f1412b..3fe13fc0e 100644 --- a/functions/info_config.sh +++ b/functions/info_config.sh @@ -207,7 +207,7 @@ elif [ "${engine}" == "realvirtuality" ]; then # query port if [ "${port}" != "" ]; then - queryport=$((port+1)) + queryport=$((port + 1)) fi if [ ! -n "${queryport}" ]; then queryport="0" @@ -215,7 +215,7 @@ elif [ "${engine}" == "realvirtuality" ]; then # master port if [ "${port}" != "" ]; then - masterport=$((port+2)) + masterport=$((port + 2)) fi if [ ! -n "${masterport}" ]; then masterport="0" @@ -274,7 +274,7 @@ elif [ "${engine}" == "seriousengine35" ]; then # query port if [ -f "${servercfgfullpath}" ]; then - queryport=$((${port} + 1)) + queryport=$((port + 1)) fi if [ ! -n "${queryport}" ]; then queryport="0" From 7a13b5f669dad176877ec3aea20824aa766fc8ad Mon Sep 17 00:00:00 2001 From: Daniel Gibbs Date: Fri, 26 Feb 2016 19:02:52 +0000 Subject: [PATCH 041/117] Removed gsquery installed --- functions/command_install.sh | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/functions/command_install.sh b/functions/command_install.sh index a68a5cc62..bd61e4930 100644 --- a/functions/command_install.sh +++ b/functions/command_install.sh @@ -2,7 +2,7 @@ # LGSM fn_install function # Author: Daniel Gibbs # Website: http://gameservermanagers.com -lgsm_version="200216" +lgsm_version="260216" function_selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))" @@ -27,7 +27,6 @@ fi # Configuration fix.sh -install_gsquery.sh install_config.sh if [ "${gamename}" == "Counter Strike: Global Offensive" ]||[ "${gamename}" == "Team Fortress 2" ]||[ "${gamename}" == "BrainBread 2" ]; then install_gslt.sh From cec75582c30c5d10d3a86e1189d49bb86331c784 Mon Sep 17 00:00:00 2001 From: Daniel Gibbs Date: Fri, 26 Feb 2016 19:06:29 +0000 Subject: [PATCH 042/117] Updated fn_printokeol to fn_printokeolnl --- functions/check_steamcmd.sh | 2 +- functions/core_dl.sh | 14 +++++++------- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/functions/check_steamcmd.sh b/functions/check_steamcmd.sh index ff713b85f..760b0b835 100644 --- a/functions/check_steamcmd.sh +++ b/functions/check_steamcmd.sh @@ -54,7 +54,7 @@ if [ ! -f "${steamcmddir}/steamcmd.sh" ]; then fi elif [ "${function_selfname}" == "command_install.sh" ]; then fn_printinfomation "SteamCMD is already installed..." - fn_printokeol + fn_printokeolnl fi } diff --git a/functions/core_dl.sh b/functions/core_dl.sh index 2ad1f3b67..9d2b95fff 100644 --- a/functions/core_dl.sh +++ b/functions/core_dl.sh @@ -18,7 +18,7 @@ if [ -n "${md5}" ]; then sleep 1 local md5sumcmd=$(md5sum "${filedir}/${filename}"|awk '{print $1;}') if [ "${md5sumcmd}" != "${md5}" ]; then - fn_printfaileol + fn_printfaileolnl echo "${filename} returned MD5 checksum: ${md5sumcmd}" echo "expected MD5 checksum: ${md5}" fn_scriptlog "failed to verify ${filename} with MD5" @@ -26,7 +26,7 @@ if [ -n "${md5}" ]; then fn_scriptlog "expected MD5 checksum: ${md5}" exit 1 else - fn_printokeol + fn_printokeolnl fn_scriptlog "verifyed ${filename} with MD5" fn_scriptlog "${filename} returned MD5 checksum: ${md5sumcmd}" fn_scriptlog "expected MD5 checksum: ${md5}" @@ -49,11 +49,11 @@ elif [ "${mime}" == "application/x-bzip2" ]; then fi local exitcode=$? if [ ${exitcode} -ne 0 ]; then - fn_printfaileol + fn_printfaileolnl echo "${tarcmd}" exit ${exitcode} else - fn_printokeol + fn_printokeolnl fi } @@ -108,17 +108,17 @@ if [ ! -f "${filedir}/${filename}" ]; then fi local exitcode=$? if [ ${exitcode} -ne 0 ]; then - fn_printfaileol + fn_printfaileolnl echo "${curlcmd}" echo -e "${fileurl}\n" exit ${exitcode} else - fn_printokeol + fn_printokeolnl fi # remove trap trap - INT else - fn_printfaileol + fn_printfaileolnl echo "Curl is not installed!" echo -e "" exit 1 From 5de4021e75acdb9c36befdf21ef826ba07f290e8 Mon Sep 17 00:00:00 2001 From: Daniel Gibbs Date: Fri, 26 Feb 2016 19:06:44 +0000 Subject: [PATCH 043/117] Removed install_gsquery.sh --- functions/install_gsquery.sh | 30 ------------------------------ 1 file changed, 30 deletions(-) delete mode 100644 functions/install_gsquery.sh diff --git a/functions/install_gsquery.sh b/functions/install_gsquery.sh deleted file mode 100644 index a113ea829..000000000 --- a/functions/install_gsquery.sh +++ /dev/null @@ -1,30 +0,0 @@ -#!/bin/bash -# LGSM install_gsquery.sh function -# Author: Daniel Gibbs -# Website: http://gameservermanagers.com -lgsm_version="271215" - -fn_dlgsquery(){ -cd "${rootdir}" -echo -e "downloading gsquery.py...\c" -wget -N /dev/null "http://gameservermanagers.com/dl/gsquery.py" 2>&1 | grep -F "HTTP" | grep -v "Moved Permanently" | cut -c45- | uniq -chmod +x gsquery.py -} - -if [ "${engine}" == "avalanche" ]||[ "${engine}" == "goldsource" ]||[ "${engine}" == "realvirtuality" ]||[ "${engine}" == "source" ]||[ "${engine}" == "spark" ]||[ "${engine}" == "unity3d" ]||[ "${gamename}" == "Hurtworld" ]||[ "${engine}" == "unreal" ]||[ "${engine}" == "unreal2" ]; then - echo "" - echo "GameServerQuery" - echo "============================" - if [ -z ${autoinstall} ]; then - while true; do - read -e -i "y" -p "Do you want to install GameServerQuery? [Y/n]" yn - case $yn in - [Yy]* ) fn_dlgsquery;break;; - [Nn]* ) echo ""; echo "Not installing GameServerQuery.";break;; - * ) echo "Please answer yes or no.";; - esac - done - else - fn_dlgsquery - fi -fi From 59a40f71d16c84edec366e7815920a5aa76ccad3 Mon Sep 17 00:00:00 2001 From: Daniel Gibbs Date: Fri, 26 Feb 2016 20:27:09 +0000 Subject: [PATCH 044/117] Corrected variable --- functions/install_config.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/functions/install_config.sh b/functions/install_config.sh index 913bf26f0..257e29fd7 100644 --- a/functions/install_config.sh +++ b/functions/install_config.sh @@ -103,7 +103,7 @@ echo "" } fn_ut99config(){ -echo "${defaultcfg} > ${servercfgfullpath}" +echo "${servercfgdefault} > ${servercfgfullpath}" tr -d '\r' < "${servercfgdefault}" > "${servercfgfullpath}" sleep 1 echo "" From 457bc70edb7121f1b562f6ff0691c09801771f40 Mon Sep 17 00:00:00 2001 From: Daniel Gibbs Date: Fri, 26 Feb 2016 20:27:58 +0000 Subject: [PATCH 045/117] Added gamelogdir --- UnrealTournament99/ut99server | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/UnrealTournament99/ut99server b/UnrealTournament99/ut99server index 8fe315593..36d31750a 100644 --- a/UnrealTournament99/ut99server +++ b/UnrealTournament99/ut99server @@ -9,7 +9,7 @@ if [ -f ".dev-debug" ]; then set -x fi -version="200216" +version="260216" #### Variables #### @@ -59,6 +59,7 @@ backupdir="${rootdir}/backups" # Logging logdays="7" +gamelogdir="${systemdir}/Logs/" scriptlogdir="${rootdir}/log/script" consolelogdir="${rootdir}/log/console" From 5b4e0d77116fb28b256b04e875adeebfc2feb8f7 Mon Sep 17 00:00:00 2001 From: Daniel Gibbs Date: Fri, 26 Feb 2016 22:38:16 +0000 Subject: [PATCH 046/117] Updated glibc requirements --- functions/fix_glibc.sh | 2 +- functions/info_glibc.sh | 10 ++++++++-- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/functions/fix_glibc.sh b/functions/fix_glibc.sh index 0270788ab..83422f12b 100644 --- a/functions/fix_glibc.sh +++ b/functions/fix_glibc.sh @@ -93,7 +93,7 @@ elif [ "$(ldd --version | sed -n '1 p' | tr -cd '[:digit:]' | tail -c 3)" -lt 21 wget -nv -N https://github.com/dgibbs64/linuxgsm/raw/master/Insurgency/dependencies/librt.so.1 wget -nv -N https://github.com/dgibbs64/linuxgsm/raw/master/Insurgency/dependencies/libpthread.so.0 elif [ "${gamename}" == "Left 4 Dead" ]; then - glibcversion="2.07" + glibcversion="2.3.6" fn_glibcfixmsg cp -v "${rootdir}/steamcmd/linux32/libstdc++.so.6" "${filesdir}/bin/libstdc++.so.6" # Natural Selection 2 diff --git a/functions/info_glibc.sh b/functions/info_glibc.sh index 4181d011d..c1442593e 100644 --- a/functions/info_glibc.sh +++ b/functions/info_glibc.sh @@ -2,7 +2,7 @@ # LGSM info_glibc.sh function # Author: Daniel Gibbs # Website: http://gameservermanagers.com -lgsm_version="100116" +lgsm_version="260216" # Description: stores details on servers Glibc requirements. @@ -43,7 +43,7 @@ elif [ "${engine}" == "seriousengine35" ]; then glibcrequired="2.13" glibcfix="yes" elif [ "${engine}" == "source" ]||[ "${engine}" == "goldsource" ]; then - glibcrequired="2.07" + glibcrequired="2.3.6" glibcfix="no" elif [ "${engine}" == "spark" ]; then glibcrequired="2.15" @@ -51,6 +51,12 @@ elif [ "${engine}" == "spark" ]; then elif [ "${engine}" == "starbound" ]; then glibcrequired="2.12" glibcfix="no" +elif [ "${engine}" == "unreal" ]; then + glibcrequired="2.1" + glibcfix="no" +elif [ "${engine}" == "unreal2" ]; then + glibcrequired="2.4" + glibcfix="no" elif [ "${engine}" == "unreal4" ]; then glibcrequired="2.14" glibcfix="no" From 020d8ee689fd3a72b7bd0912e6b286e5e593f7b4 Mon Sep 17 00:00:00 2001 From: Daniel Gibbs Date: Fri, 26 Feb 2016 22:42:23 +0000 Subject: [PATCH 047/117] moved lgsmdir --- JustCause2/jc2server | 2 +- UnrealTournament99/ut99server | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/JustCause2/jc2server b/JustCause2/jc2server index cedf158b8..2d4010e71 100644 --- a/JustCause2/jc2server +++ b/JustCause2/jc2server @@ -50,9 +50,9 @@ engine="avalanche" rootdir="$(dirname $(readlink -f "${BASH_SOURCE[0]}"))" selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))" lockselfname=".${servicename}.lock" -filesdir="${rootdir}/serverfiles" lgsmdir="${rootdir}/lgsm" functionsdir="${lgsmdir}/functions" +filesdir="${rootdir}/serverfiles" systemdir="${filesdir}" executabledir="${filesdir}" executable="./Jcmp-Server" diff --git a/UnrealTournament99/ut99server b/UnrealTournament99/ut99server index 36d31750a..36704e0b2 100644 --- a/UnrealTournament99/ut99server +++ b/UnrealTournament99/ut99server @@ -44,9 +44,9 @@ engine="unreal" rootdir="$(dirname $(readlink -f "${BASH_SOURCE[0]}"))" selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))" lockselfname=".${servicename}.lock" -filesdir="${rootdir}/serverfiles" lgsmdir="${rootdir}/lgsm" functionsdir="${lgsmdir}/functions" +filesdir="${rootdir}/serverfiles" systemdir="${filesdir}/System" executabledir="${systemdir}" executable="./ucc-bin" From de4b2914005e27a03d33f03e81ca619186750e01 Mon Sep 17 00:00:00 2001 From: Daniel Gibbs Date: Fri, 26 Feb 2016 22:42:37 +0000 Subject: [PATCH 048/117] updated for core_dl --- UnrealTournament2004/ut2k4server | 75 ++++++++++++++++++-------------- 1 file changed, 42 insertions(+), 33 deletions(-) diff --git a/UnrealTournament2004/ut2k4server b/UnrealTournament2004/ut2k4server index d74310b30..444e16871 100644 --- a/UnrealTournament2004/ut2k4server +++ b/UnrealTournament2004/ut2k4server @@ -35,6 +35,8 @@ engine="unreal2" rootdir="$(dirname $(readlink -f "${BASH_SOURCE[0]}"))" selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))" lockselfname=".${servicename}.lock" +lgsmdir="${rootdir}/lgsm" +functionsdir="${lgsmdir}/functions" filesdir="${rootdir}/serverfiles" systemdir="${filesdir}/System" executabledir="${systemdir}" @@ -71,56 +73,63 @@ githubbranch="master" ##### Script ##### # Do not edit -fn_getgithubfile(){ -filename=$1 -exec=$2 -fileurl=${3:-$filename} -filepath="${rootdir}/${filename}" -filedir=$(dirname "${filepath}") -# If the function file is missing, then download -if [ ! -f "${filepath}" ]; then +# Fetches core_dl for file downloads +fn_fetch_core_dl(){ +github_file_url_dir="functions" +github_file_url_name="${functionfile}" +filedir="${functionsdir}" +filename="${github_file_url_name}" +githuburl="https://raw.githubusercontent.com/${githubuser}/${githubrepo}/${githubbranch}/${github_file_url_dir}/${github_file_url_name}" +# If the file is missing, then download +if [ ! -f "${filedir}/${filename}" ]; then if [ ! -d "${filedir}" ]; then - mkdir "${filedir}" + mkdir -p "${filedir}" fi - githuburl="https://raw.githubusercontent.com/${githubuser}/${githubrepo}/${githubbranch}/${fileurl}" echo -e " fetching ${filename}...\c" - if [ "$(command -v curl)" ]||[ "$(which curl >/dev/null 2>&1)" ]||[ -f "/usr/bin/curl" ]||[ -f "/bin/curl" ]; then - : - else + # Check curl exists and use available path + curlpaths="$(command -v curl 2>/dev/null) $(which curl >/dev/null 2>&1) /usr/bin/curl /bin/curl /usr/sbin/curl /sbin/curl $(echo $PATH | sed "s/\([:]\|\$\)/\/curl /g")" + for curlcmd in ${curlpaths} + do + if [ -x "${curlcmd}" ]; then + break + fi + done + # If curl exists download file + if [ "$(basename ${curlcmd})" == "curl" ]; then + curlfetch=$(${curlcmd} -s --fail -o "${filedir}/${filename}" "${githuburl}" 2>&1) + if [ $? -ne 0 ]; then + echo -e "\e[0;31mFAIL\e[0m\n" + echo "${curlfetch}" + echo -e "${githuburl}\n" + exit 1 + else + echo -e "\e[0;32mOK\e[0m" + fi + else echo -e "\e[0;31mFAIL\e[0m\n" echo "Curl is not installed!" echo -e "" - exit - fi - curl=$(curl --fail -o "${filepath}" "${githuburl}" 2>&1) - if [ $? -ne 0 ]; then - echo -e "\e[0;31mFAIL\e[0m\n" - echo "${curl}" - echo -e "${githuburl}\n" - exit - else - echo -e "\e[0;32mOK\e[0m" - fi - if [ "${exec}" ]; then - chmod +x "${filepath}" + exit 1 fi + chmod +x "${filedir}/${filename}" fi -if [ "${exec}" ]; then - source "${filepath}" -fi +source "${filedir}/${filename}" } -fn_runfunction(){ - fn_getgithubfile "functions/${functionfile}" 1 +core_dl.sh(){ +# Functions are defined in core_functions.sh. +functionfile="${FUNCNAME}" +fn_fetch_core_dl } core_functions.sh(){ # Functions are defined in core_functions.sh. functionfile="${FUNCNAME}" -fn_runfunction +fn_fetch_core_dl } +core_dl.sh core_functions.sh getopt=$1 -core_getopt.sh +core_getopt.sh \ No newline at end of file From 7809ae0320c8c9244f1409170cc351aae5db0924 Mon Sep 17 00:00:00 2001 From: Daniel Gibbs Date: Sat, 27 Feb 2016 10:53:55 +0000 Subject: [PATCH 049/117] Updated urls --- functions/install_server_files.sh | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/functions/install_server_files.sh b/functions/install_server_files.sh index be0576e3f..32d6dff7a 100644 --- a/functions/install_server_files.sh +++ b/functions/install_server_files.sh @@ -2,23 +2,20 @@ # LGSM install_server_files.sh function # Author: Daniel Gibbs # Website: http://gameservermanagers.com -lgsm_version="050216" +lgsm_version="270216" fn_install_server_files(){ if [ "${gamename}" == "Unreal Tournament 99" ]; then - fileurl="http://gameservermanagers.com/files/ut-server-451-complete.tar.bz2"; filedir="${lgsmdir}/tmp"; filename="ut-server-451-complete.tar.bz2"; run="norun"; force="noforce"; md5="e623fdff5ed600a9bfccab852e18d34d" + fileurl="http://gameservermanagers.com/files/UnrealTournament99/ut99-server-451-ultimate-linux.tar.bz2"; filedir="${lgsmdir}/tmp"; filename="ut99-server-451-ultimate-linux.tar.bz2"; run="norun"; force="noforce"; md5="e623fdff5ed600a9bfccab852e18d34d" +elif [ "${gamename}" == "Unreal Tournament 2004" ]; then + fileurl="http://gameservermanagers.com/files/UnrealTournament2004/ut2004-server-3339-ultimate-linux.tar.bz2"; filedir="${lgsmdir}/tmp"; filename="ut2004-server-3339-ultimate-linux.tar.bz2"; run="norun"; force="noforce"; md5="e623fdff5ed600a9bfccab852e18d34d" fi + fn_fetch_file "${fileurl}" "${filedir}" "${filename}" "${run}" "${force}" "${md5}" fn_dl_extract "${filedir}" "${filename}" "${filesdir}" } -#!/bin/bash -# LGSM install_serverfiles.sh function -# Author: Daniel Gibbs -# Website: http://gameservermanagers.com -lgsm_version="271215" - fn_install_server_files_steamcmd(){ check.sh mkdir -pv "${filesdir}" From d3f7be4919e76e761bf5e72d8e4d5056f0949ed0 Mon Sep 17 00:00:00 2001 From: Daniel Gibbs Date: Sat, 27 Feb 2016 11:05:33 +0000 Subject: [PATCH 050/117] fixed progress bar showing for some .sh files --- functions/core_dl.sh | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/functions/core_dl.sh b/functions/core_dl.sh index 9d2b95fff..d6fc8cd04 100644 --- a/functions/core_dl.sh +++ b/functions/core_dl.sh @@ -95,9 +95,8 @@ if [ ! -f "${filedir}/${filename}" ]; then if [ "$(basename ${curlcmd})" == "curl" ]; then # trap to remove part downloaded files trap fn_fetch_trap INT - # if larger file shows progress bar - if [[ $filename == *"tar"* ]]; then + if [ ${filename##*.} == "bz2" ]; then echo -ne "downloading ${filename}..." sleep 1 curlcmd=$(${curlcmd} --progress-bar --fail -o "${filedir}/${filename}" "${fileurl}") From 3c09d25d031afb675833908c235fd7bc71c478ed Mon Sep 17 00:00:00 2001 From: Daniel Gibbs Date: Sat, 27 Feb 2016 11:11:56 +0000 Subject: [PATCH 051/117] Renamed files --- functions/command_install.sh | 4 ++-- functions/{install_serverdir.sh => install_server_dir.sh} | 0 2 files changed, 2 insertions(+), 2 deletions(-) rename functions/{install_serverdir.sh => install_server_dir.sh} (100%) diff --git a/functions/command_install.sh b/functions/command_install.sh index bd61e4930..7dd44ffa0 100644 --- a/functions/command_install.sh +++ b/functions/command_install.sh @@ -8,7 +8,7 @@ function_selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))" check.sh install_header.sh -install_serverdir.sh +install_server_dir.sh install_logs.sh check_deps.sh # Download and install @@ -22,7 +22,7 @@ elif [ "${gamename}" == "Teamspeak 3" ]; then install_ts3.sh elif [ ! -z "${appid}" ]; then install_steamcmd.sh - install_serverfiles.sh + install_server_files.sh fi # Configuration diff --git a/functions/install_serverdir.sh b/functions/install_server_dir.sh similarity index 100% rename from functions/install_serverdir.sh rename to functions/install_server_dir.sh From e90e6bf9d2ad51d64544a20c25ad1adb64bddc27 Mon Sep 17 00:00:00 2001 From: Daniel Gibbs Date: Sat, 27 Feb 2016 11:12:52 +0000 Subject: [PATCH 052/117] Updated functions function --- functions/update_functions.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/functions/update_functions.sh b/functions/update_functions.sh index 196b90f75..e205dd901 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="230116" +lgsm_version="270216" # Description: Deletes the functions dir to allow re-downloading of functions from GitHub. @@ -12,7 +12,7 @@ fn_printdots "Updating functions" fn_scriptlog "Updating functions" sleep 1 echo -ne "\n" -rm -rfv "${rootdir}/functions/"* +rm -rfv "${functionsdir}/"* exitcode=$? if [ "${exitcode}" == "0" ]; then fn_printok "Updating functions" From 3b6431ab6e37a3d898000311a96e24e25795ef38 Mon Sep 17 00:00:00 2001 From: Daniel Gibbs Date: Sat, 27 Feb 2016 11:14:01 +0000 Subject: [PATCH 053/117] renamed function --- functions/core_functions.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/functions/core_functions.sh b/functions/core_functions.sh index 0ef2cc095..5d6464444 100644 --- a/functions/core_functions.sh +++ b/functions/core_functions.sh @@ -348,7 +348,7 @@ functionfile="${FUNCNAME}" fn_fetch_function } -install_serverdir.sh(){ +install_server_dir.sh(){ functionfile="${FUNCNAME}" fn_fetch_function } From de924018bcbda2f61e8eab053c8a17f7941c52aa Mon Sep 17 00:00:00 2001 From: Daniel Gibbs Date: Sat, 27 Feb 2016 11:36:25 +0000 Subject: [PATCH 054/117] Converted to using exit codes for steamcmd errors --- functions/install_server_files.sh | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/functions/install_server_files.sh b/functions/install_server_files.sh index 32d6dff7a..103fecf3a 100644 --- a/functions/install_server_files.sh +++ b/functions/install_server_files.sh @@ -17,10 +17,8 @@ fn_dl_extract "${filedir}" "${filename}" "${filesdir}" } fn_install_server_files_steamcmd(){ -check.sh -mkdir -pv "${filesdir}" counter="0" -while [ "${counter}" == "0" ]||[ "$(grep -wc 0x402 .install_serverfiles.sh.tmp)" -ge "1" ]||[ "$(grep -wc 0x406 .install_serverfiles.sh.tmp)" -ge "1" ]||[ "$(grep -wc 0x6 .install_serverfiles.sh.tmp)" -ge "1" ]||[ "$(grep -wc 0x106 .install_serverfiles.sh.tmp)" -ge "1" ]; do +while [ "${counter}" == "0" ]||[ "${exitcode}" != "0" ]; do counter=$((counter+1)) cd "${rootdir}/steamcmd" if [ "${counter}" -le "10" ]; then @@ -50,15 +48,19 @@ while [ "${counter}" == "0" ]||[ "$(grep -wc 0x402 .install_serverfiles.sh.tmp)" if [ "${counter}" -le "4" ]; then if [ "${engine}" == "goldsource" ]; then - ${unbuffer} ./steamcmd.sh +login "${steamuser}" "${steampass}" +force_install_dir "${filesdir}" +app_set_config 90 mod ${appidmod} +app_update "${appid}" +quit |tee .install_serverfiles.sh.tmp + ${unbuffer} ./steamcmd.sh +login "${steamuser}" "${steampass}" +force_install_dir "${filesdir}" +app_set_config 90 mod "${appidmod}" +app_update "${appid}" +quit + local exitcode=$? else - ${unbuffer} ./steamcmd.sh +login "${steamuser}" "${steampass}" +force_install_dir "${filesdir}" +app_update "${appid}" +quit |tee .install_serverfiles.sh.tmp + ${unbuffer} ./steamcmd.sh +login "${steamuser}" "${steampass}" +force_install_dir "${filesdir}" +app_update "${appid}" +quit + local exitcode=$? fi elif [ "${counter}" -ge "5" ]; then if [ "${engine}" == "goldsource" ]; then - ${unbuffer} ./steamcmd.sh +login "${steamuser}" "${steampass}" +force_install_dir "${filesdir}" +app_set_config 90 mod ${appidmod} +app_update "${appid}" -validate +quit |tee .install_serverfiles.sh.tmp + ${unbuffer} ./steamcmd.sh +login "${steamuser}" "${steampass}" +force_install_dir "${filesdir}" +app_set_config 90 mod "${appidmod}" +app_update "${appid}" -validate +quit + local exitcode=$? else - ${unbuffer} ./steamcmd.sh +login "${steamuser}" "${steampass}" +force_install_dir "${filesdir}" +app_update "${appid}" -validate +quit |tee .install_serverfiles.sh.tmp + ${unbuffer} ./steamcmd.sh +login "${steamuser}" "${steampass}" +force_install_dir "${filesdir}" +app_update "${appid}" -validate +quit + local exitcode=$? fi fi elif [ "${counter}" -ge "11" ]; then @@ -74,10 +76,10 @@ if [ "${engine}" == "goldsource" ]; then counter="0" while [ "${counter}" -le "4" ]; do counter=$((counter+1)) - ${unbuffer} ./steamcmd.sh +login "${steamuser}" "${steampass}" +force_install_dir "${filesdir}" +app_set_config 90 mod ${appidmod} +app_update "${appid}" -validate +quit |tee .install_serverfiles.sh.tmp + ${unbuffer} ./steamcmd.sh +login "${steamuser}" "${steampass}" +force_install_dir "${filesdir}" +app_set_config 90 mod ${appidmod} +app_update "${appid}" -validate +quit + local exitcode=$? done fi -rm -f .install_serverfiles.sh.tmp } echo "" From 20ea49c65f6554ba12398c6363b8f37126db9cea Mon Sep 17 00:00:00 2001 From: Daniel Gibbs Date: Sat, 27 Feb 2016 11:38:08 +0000 Subject: [PATCH 055/117] tidy --- functions/install_server_files.sh | 2 -- 1 file changed, 2 deletions(-) diff --git a/functions/install_server_files.sh b/functions/install_server_files.sh index 103fecf3a..112a7fe4b 100644 --- a/functions/install_server_files.sh +++ b/functions/install_server_files.sh @@ -4,7 +4,6 @@ # Website: http://gameservermanagers.com lgsm_version="270216" - fn_install_server_files(){ if [ "${gamename}" == "Unreal Tournament 99" ]; then fileurl="http://gameservermanagers.com/files/UnrealTournament99/ut99-server-451-ultimate-linux.tar.bz2"; filedir="${lgsmdir}/tmp"; filename="ut99-server-451-ultimate-linux.tar.bz2"; run="norun"; force="noforce"; md5="e623fdff5ed600a9bfccab852e18d34d" @@ -67,7 +66,6 @@ while [ "${counter}" == "0" ]||[ "${exitcode}" != "0" ]; do fn_printfailurenl "SteamCMD did not complete the download, too many retrys" break fi - done # Goldsource servers commonly fail to download all the server files required. From 2e70c72476ce4af4601890940986213ce84c5c47 Mon Sep 17 00:00:00 2001 From: Daniel Gibbs Date: Sat, 27 Feb 2016 11:56:25 +0000 Subject: [PATCH 056/117] Renamed function --- functions/{check_systemdir.sh => check_system_dir.sh} | 2 +- functions/core_functions.sh | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) rename functions/{check_systemdir.sh => check_system_dir.sh} (89%) diff --git a/functions/check_systemdir.sh b/functions/check_system_dir.sh similarity index 89% rename from functions/check_systemdir.sh rename to functions/check_system_dir.sh index c1f65a0d7..ecada4e09 100644 --- a/functions/check_systemdir.sh +++ b/functions/check_system_dir.sh @@ -1,5 +1,5 @@ #!/bin/bash -# LGSM check_systemdir.sh function +# LGSM check_system_dir.sh function # Author: Daniel Gibbs # Website: http://gameservermanagers.com lgsm_version="271215" diff --git a/functions/core_functions.sh b/functions/core_functions.sh index 5d6464444..eb1096828 100644 --- a/functions/core_functions.sh +++ b/functions/core_functions.sh @@ -146,7 +146,7 @@ functionfile="${FUNCNAME}" fn_fetch_function } -check_systemdir.sh(){ +check_system_dir.sh(){ functionfile="${FUNCNAME}" fn_fetch_function } From 2ed6a60db2bd61acdb28e0851e90052d11e11c11 Mon Sep 17 00:00:00 2001 From: Daniel Gibbs Date: Sat, 27 Feb 2016 11:56:36 +0000 Subject: [PATCH 057/117] renamed function --- functions/check.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/functions/check.sh b/functions/check.sh index fa6b47306..dd64d9ef1 100644 --- a/functions/check.sh +++ b/functions/check.sh @@ -22,7 +22,7 @@ array_contains () { check_root.sh if [ "${function_selfname}" != "command_install.sh" ] && [ "${function_selfname}" != "update_functions.sh" ]; then - check_systemdir.sh + check_system_dir.sh fi local allowed_commands_array=( command_backup.sh command_console.sh command_debug.sh command_details.sh command_unreal2_maps.sh command_ut99_maps.sh command_monitor.sh command_start.sh command_stop.sh update_check.sh command_validate.sh update_functions.sh command_email_test.sh ) From 8160e36804700f83f0eca4b7ca6ed60d53433d80 Mon Sep 17 00:00:00 2001 From: Daniel Gibbs Date: Sat, 27 Feb 2016 11:57:21 +0000 Subject: [PATCH 058/117] prevent from deleting everything if no var --- functions/update_functions.sh | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/functions/update_functions.sh b/functions/update_functions.sh index e205dd901..970dc9773 100644 --- a/functions/update_functions.sh +++ b/functions/update_functions.sh @@ -12,8 +12,17 @@ fn_printdots "Updating functions" fn_scriptlog "Updating functions" sleep 1 echo -ne "\n" -rm -rfv "${functionsdir}/"* -exitcode=$? +if [ -d "${rootdir}/functions/" ]; then + rm -rfv "${rootdir}/functions/" + exitcode=$? +elif [ -z "${functionsdir}" ]; then + rm -rfv "${functionsdir}/"* + exitcode=$? +else + fn_printfail "Updating functions" + fn_scriptlog "Failure! Updating functions" +fi + if [ "${exitcode}" == "0" ]; then fn_printok "Updating functions" fn_scriptlog "Success! Updating functions" From 017360f18355e746c8ab82a4d8ea23ce4af4c09c Mon Sep 17 00:00:00 2001 From: Daniel Gibbs Date: Sat, 27 Feb 2016 15:12:27 +0000 Subject: [PATCH 059/117] No longer required --- functions/install_serverfiles.sh | 87 -------------------------------- 1 file changed, 87 deletions(-) delete mode 100644 functions/install_serverfiles.sh diff --git a/functions/install_serverfiles.sh b/functions/install_serverfiles.sh deleted file mode 100644 index 24677da9c..000000000 --- a/functions/install_serverfiles.sh +++ /dev/null @@ -1,87 +0,0 @@ -#!/bin/bash -# LGSM finstall_serverfiles.sh function -# Author: Daniel Gibbs -# Website: http://gameservermanagers.com -lgsm_version="271215" - -fn_steaminstallcommand(){ -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)) - cd "${rootdir}/steamcmd" - if [ "${counter}" -le "10" ]; then - # Attempt 1-4: Standard attempt - # Attempt 5-6: Validate attempt - # Attempt 7-8: Validate, delete long name dir - # Attempt 9-10: Validate, delete long name dir, re-download SteamCMD - # Attempt 11: Failure - - if [ "${counter}" -ge "2" ]; then - fn_printwarningnl "SteamCMD did not complete the download, retrying: Attempt ${counter}:" - fi - - if [ "${counter}" -ge "7" ]; then - echo "Removing $(find ${filesdir} -type d -print0 | grep -Ez '[^/]{30}$')" - find ${filesdir} -type d -print0 | grep -Ez '[^/]{30}$' | xargs -0 rm -rf - fi - if [ "${counter}" -ge "9" ]; then - rm -rf "${rootdir}/steamcmd" - check_steamcmd.sh - fi - - # Detects if unbuffer command is available. - if [ $(command -v unbuffer) ]; then - unbuffer=unbuffer - fi - - if [ "${counter}" -le "4" ]; then - if [ "${engine}" == "goldsource" ]; then - ${unbuffer} ./steamcmd.sh +login "${steamuser}" "${steampass}" +force_install_dir "${filesdir}" +app_set_config 90 mod ${appidmod} +app_update "${appid}" +quit |tee .finstall_serverfiles.sh.tmp - else - ${unbuffer} ./steamcmd.sh +login "${steamuser}" "${steampass}" +force_install_dir "${filesdir}" +app_update "${appid}" +quit |tee .finstall_serverfiles.sh.tmp - fi - elif [ "${counter}" -ge "5" ]; then - if [ "${engine}" == "goldsource" ]; then - ${unbuffer} ./steamcmd.sh +login "${steamuser}" "${steampass}" +force_install_dir "${filesdir}" +app_set_config 90 mod ${appidmod} +app_update "${appid}" -validate +quit |tee .finstall_serverfiles.sh.tmp - else - ${unbuffer} ./steamcmd.sh +login "${steamuser}" "${steampass}" +force_install_dir "${filesdir}" +app_update "${appid}" -validate +quit |tee .finstall_serverfiles.sh.tmp - fi - fi - elif [ "${counter}" -ge "11" ]; then - fn_printfailurenl "SteamCMD did not complete the download, too many retrys" - break - fi - -done - -# Goldsource servers commonly fail to download all the server files required. -# Validating a few of times may reduce the chance of this issue. -if [ "${engine}" == "goldsource" ]; then - counter="0" - while [ "${counter}" -le "4" ]; do - counter=$((counter+1)) - ${unbuffer} ./steamcmd.sh +login "${steamuser}" "${steampass}" +force_install_dir "${filesdir}" +app_set_config 90 mod ${appidmod} +app_update "${appid}" -validate +quit |tee .finstall_serverfiles.sh.tmp - done -fi -rm -f .finstall_serverfiles.sh.tmp -} - -echo "" -echo "Installing ${gamename} Server" -echo "=================================" -sleep 1 -mkdir -pv "${filesdir}" -fn_steaminstallcommand -if [ -z "${autoinstall}" ]; then - echo "" - echo "=================================" - while true; do - read -e -i "y" -p "Was the install successful? [Y/n]" yn - case $yn in - [Yy]* ) break;; - [Nn]* ) install_retry.sh;; - * ) echo "Please answer yes or no.";; - esac - done -fi From 1502542fc89bab20bd76a40680a94965ab9026ff Mon Sep 17 00:00:00 2001 From: Daniel Gibbs Date: Sat, 27 Feb 2016 15:15:10 +0000 Subject: [PATCH 060/117] Changed ut2004 to new system --- functions/command_install.sh | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/functions/command_install.sh b/functions/command_install.sh index 7dd44ffa0..e933b2598 100644 --- a/functions/command_install.sh +++ b/functions/command_install.sh @@ -13,8 +13,7 @@ install_logs.sh check_deps.sh # Download and install if [ "${gamename}" == "Unreal Tournament 2004" ]; then - install_dl_ut2k4.sh - install_ut2k4.sh + install_server_files.sh install_ut2k4_key.sh elif [ "${gamename}" == "Unreal Tournament 99" ]; then install_server_files.sh From 867fb3b911c01fc30c0c9abfd01fc2ba441871ac Mon Sep 17 00:00:00 2001 From: Daniel Gibbs Date: Sat, 27 Feb 2016 15:45:59 +0000 Subject: [PATCH 061/117] Altered header to link to github contrib page --- functions/install_header.sh | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/functions/install_header.sh b/functions/install_header.sh index 1ee637c77..ae8ab9240 100644 --- a/functions/install_header.sh +++ b/functions/install_header.sh @@ -9,12 +9,6 @@ echo "=================================" echo "${gamename}" echo "Linux Game Server Manager" echo "by Daniel Gibbs" -if [ "${gamename}" == "ARMA 3" ]; then - echo "contributions by Scarsz" -elif [ "${gamename}" == "Left 4 Dead" ]; then - echo "contributions by Summit Singh Thakur" -elif [ "${gamename}" == "Teeworlds" ]; then - echo "contributions by Bryce Van Dyk (SingingTree)" -fi +echo "Contributors: http://goo.gl/qLmitD" echo "http://gameservermanagers.com" echo "=================================" \ No newline at end of file From 15413e23669bd6abb058d8242e721b747d7e4452 Mon Sep 17 00:00:00 2001 From: Daniel Gibbs Date: Sat, 27 Feb 2016 15:46:15 +0000 Subject: [PATCH 062/117] added ut2l4 server cd-key option --- functions/core_getopt.sh | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/functions/core_getopt.sh b/functions/core_getopt.sh index ed3bd1369..47cd5f748 100644 --- a/functions/core_getopt.sh +++ b/functions/core_getopt.sh @@ -386,7 +386,9 @@ case "$getopt" in i|install) command_install.sh;; ai|auto-install) - fn_autoinstall;; + fn_autoinstall;; + sck|server-cd-key) + install_ut2k4_key.sh;; mc|map-compressor) compress_unreal2_maps.sh;; dd|depsdetect) @@ -410,6 +412,7 @@ 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[34mserver-cd-key\t\e[0mAdd your server cd key" echo -e "\e[34mmap-compressor\t\e[0mCompresses all ${gamename} server maps." } | column -s $'\t' -t esac From ddb475fa2e75ebe4c1c61094e5066ecbebdbf417 Mon Sep 17 00:00:00 2001 From: Daniel Gibbs Date: Sat, 27 Feb 2016 15:49:15 +0000 Subject: [PATCH 063/117] Added auto-install mode --- functions/install_ut2k4_key.sh | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/functions/install_ut2k4_key.sh b/functions/install_ut2k4_key.sh index 35a9599f6..34dcab124 100644 --- a/functions/install_ut2k4_key.sh +++ b/functions/install_ut2k4_key.sh @@ -4,6 +4,7 @@ # Website: http://gameservermanagers.com lgsm_version="271215" + echo "" echo "Enter ${gamename} CD Key" echo "=================================" @@ -12,8 +13,14 @@ echo "To get your server listed on the Master Server list" echo "you must get a free CD key. Get a key here:" echo "http://www.unrealtournament.com/ut2004server/cdkey.php" echo "" -echo "Once you have the key enter it below" -echo -n "KEY: " -read CODE -echo ""\""CDKey"\""="\""${CODE}"\""" > "${systemdir}/cdkey" +if [ -z "${autoinstall}" ]; then + echo "Once you have the key enter it below" + echo -n "KEY: " + read CODE + echo ""\""CDKey"\""="\""${CODE}"\""" > "${systemdir}/cdkey" + +else + echo "You can add your key using the following command" + echo "./${selfname} server-cd-key" +fi echo "" \ No newline at end of file From bceae77c2483b0cf5cc81d8d5182044c381939c1 Mon Sep 17 00:00:00 2001 From: Daniel Gibbs Date: Sat, 27 Feb 2016 15:51:38 +0000 Subject: [PATCH 064/117] corrected if and renamed function --- ...te_functions.sh => command_update_functions.sh} | 2 +- functions/core_getopt.sh | 14 +++++++------- 2 files changed, 8 insertions(+), 8 deletions(-) rename functions/{update_functions.sh => command_update_functions.sh} (94%) diff --git a/functions/update_functions.sh b/functions/command_update_functions.sh similarity index 94% rename from functions/update_functions.sh rename to functions/command_update_functions.sh index 970dc9773..7cc1c4cb2 100644 --- a/functions/update_functions.sh +++ b/functions/command_update_functions.sh @@ -15,7 +15,7 @@ echo -ne "\n" if [ -d "${rootdir}/functions/" ]; then rm -rfv "${rootdir}/functions/" exitcode=$? -elif [ -z "${functionsdir}" ]; then +elif [ -n "${functionsdir}" ]; then rm -rfv "${functionsdir}/"* exitcode=$? else diff --git a/functions/core_getopt.sh b/functions/core_getopt.sh index 47cd5f748..899b6257a 100644 --- a/functions/core_getopt.sh +++ b/functions/core_getopt.sh @@ -20,7 +20,7 @@ case "$getopt" in forceupdate=1; update_check.sh;; uf|update-functions) - update_functions.sh;; + command_update_functions.sh;; v|validate) command_validate.sh;; m|monitor) @@ -81,7 +81,7 @@ case "$getopt" in u|update) update_check.sh;; uf|update-functions) - update_functions.sh;; + command_update_functions.sh;; m|monitor) command_monitor.sh;; et|email-test) @@ -133,7 +133,7 @@ case "$getopt" in r|restart) fn_restart;; uf|update-functions) - update_functions.sh;; + command_update_functions.sh;; m|monitor) command_monitor.sh;; et|email-test) @@ -183,7 +183,7 @@ case "$getopt" in forceupdate=1; update_check.sh;; uf|update-functions) - update_functions.sh;; + command_update_functions.sh;; v|validate) command_validate.sh;; m|monitor) @@ -242,7 +242,7 @@ case "$getopt" in r|restart) fn_restart;; uf|update-functions) - update_functions.sh;; + command_update_functions.sh;; m|monitor) command_monitor.sh;; et|email-test) @@ -305,7 +305,7 @@ case "$getopt" in forceupdate=1; update_check.sh;; uf|update-functions) - update_functions.sh;; + command_update_functions.sh;; v|validate) command_validate.sh;; m|monitor) @@ -368,7 +368,7 @@ case "$getopt" in r|restart) fn_restart;; uf|update-functions) - update_functions.sh;; + command_update_functions.sh;; m|monitor) command_monitor.sh;; et|email-test) From 2037faa487aa6951d710c777758dec49699e8f9b Mon Sep 17 00:00:00 2001 From: Daniel Gibbs Date: Sat, 27 Feb 2016 19:36:23 +0000 Subject: [PATCH 065/117] tee tidy --- functions/command_validate.sh | 4 ++-- functions/fix_ut99.sh | 2 +- functions/logs.sh | 14 +++++++------- functions/update_dl.sh | 4 ++-- 4 files changed, 12 insertions(+), 12 deletions(-) diff --git a/functions/command_validate.sh b/functions/command_validate.sh index b6dc36819..40e23c01e 100644 --- a/functions/command_validate.sh +++ b/functions/command_validate.sh @@ -29,9 +29,9 @@ if [ $(command -v unbuffer) ]; then fi if [ "${engine}" == "goldsource" ]; then - ${unbuffer} ./steamcmd.sh +login "${steamuser}" "${steampass}" +force_install_dir "${filesdir}" +app_set_config 90 mod ${appidmod} +app_update "${appid}" +app_update "${appid}" validate +quit|tee -a "${scriptlog}" + ${unbuffer} ./steamcmd.sh +login "${steamuser}" "${steampass}" +force_install_dir "${filesdir}" +app_set_config 90 mod ${appidmod} +app_update "${appid}" +app_update "${appid}" validate +quit| tee -a "${scriptlog}" else - ${unbuffer} ./steamcmd.sh +login "${steamuser}" "${steampass}" +force_install_dir "${filesdir}" +app_update "${appid}" validate +quit|tee -a "${scriptlog}" + ${unbuffer} ./steamcmd.sh +login "${steamuser}" "${steampass}" +force_install_dir "${filesdir}" +app_update "${appid}" validate +quit| tee -a "${scriptlog}" fi fix.sh diff --git a/functions/fix_ut99.sh b/functions/fix_ut99.sh index d4ceca37f..aceb37128 100644 --- a/functions/fix_ut99.sh +++ b/functions/fix_ut99.sh @@ -12,7 +12,7 @@ echo "UpdateMinutes=1" echo "MasterServerAddress=unreal.epicgames.com" echo "MasterServerPort=27900" echo "Region=0" -}|tee -a "${servercfgfullpath}" > /dev/null 2>&1 +}| tee -a "${servercfgfullpath}" > /dev/null 2>&1 sleep 1 echo "removing dead gamespy.com master server." sed -i '/master0.gamespy.com/d' "${servercfgfullpath}" diff --git a/functions/logs.sh b/functions/logs.sh index a294c4d35..54c9a9836 100644 --- a/functions/logs.sh +++ b/functions/logs.sh @@ -37,18 +37,18 @@ if [ $(find "${scriptlogdir}"/ -type f -mtime +"${logdays}"|wc -l) -ne "0" ]; th echo -en "\n" # Logging logfiles to be removed according to "${logdays}", counting and removing them # Script logfiles - find "${scriptlogdir}"/ -type f -mtime +"${logdays}"|tee >> "${scriptlog}" + find "${scriptlogdir}"/ -type f -mtime +"${logdays}"| tee >> "${scriptlog}" scriptcount=$(find "${scriptlogdir}"/ -type f -mtime +"${logdays}"|wc -l) find "${scriptlogdir}"/ -mtime +"${logdays}" -type f -exec rm -f {} \; # SRCDS and unreal logfiles if [ "${engine}" == "unreal2" ]||[ "${engine}" == "source" ]; then - find "${gamelogdir}"/ -type f -mtime +"${logdays}"|tee >> "${scriptlog}" + find "${gamelogdir}"/ -type f -mtime +"${logdays}"| tee >> "${scriptlog}" gamecount=$(find "${gamelogdir}"/ -type f -mtime +"${logdays}"|wc -l) find "${gamelogdir}"/ -mtime +"${logdays}" -type f -exec rm -f {} \; fi # Console logfiles if [ -n "${consolelog}" ]; then - find "${consolelogdir}"/ -type f -mtime +"${logdays}"|tee >> "${scriptlog}" + find "${consolelogdir}"/ -type f -mtime +"${logdays}"| tee >> "${scriptlog}" consolecount=$(find "${consolelogdir}"/ -type f -mtime +"${logdays}"|wc -l) find "${consolelogdir}"/ -mtime +"${logdays}" -type f -exec rm -f {} \; fi @@ -56,7 +56,7 @@ if [ $(find "${scriptlogdir}"/ -type f -mtime +"${logdays}"|wc -l) -ne "0" ]; th if [ "${engine}" == "source" ]; then # SourceMod logfiles if [ -d "${sourcemodlogdir}" ]; then - find "${sourcemodlogdir}"/ -type f -mtime +"${logdays}"|tee >> "${scriptlog}" + find "${sourcemodlogdir}"/ -type f -mtime +"${logdays}"| tee >> "${scriptlog}" smcount=$(find "${sourcemodlogdir}"/ -type f -mtime +"${logdays}"|wc -l) find "${sourcemodlogdir}"/ -mtime +"${logdays}" -type f -exec rm -f {} \; fi @@ -64,13 +64,13 @@ if [ $(find "${scriptlogdir}"/ -type f -mtime +"${logdays}"|wc -l) -ne "0" ]; th if [ "${gamename}" == "Garry's Mod" ]; then # ULX logfiles if [ -d "${ulxlogdir}" ]; then - find "${ulxlogdir}"/ -type f -mtime +"${logdays}"|tee >> "${scriptlog}" + find "${ulxlogdir}"/ -type f -mtime +"${logdays}"| tee >> "${scriptlog}" ulxcount=$(find "${ulxlogdir}"/ -type f -mtime +"${logdays}"|wc -l) find "${ulxlogdir}"/ -mtime +"${logdays}" -type f -exec rm -f {} \; fi # DarkRP logfiles if [ -d "${darkrplogdir}" ]; then - find "${darkrplogdir}"/ -type f -mtime +"${logdays}"|tee >> "${scriptlog}" + find "${darkrplogdir}"/ -type f -mtime +"${logdays}"| tee >> "${scriptlog}" darkrpcount=$(find "${darkrplogdir}"/ -type f -mtime +"${logdays}"|wc -l) find "${darkrplogdir}"/ -mtime +"${logdays}" -type f -exec rm -f {} \; fi @@ -78,7 +78,7 @@ if [ $(find "${scriptlogdir}"/ -type f -mtime +"${logdays}"|wc -l) -ne "0" ]; th fi # Legacy support if [ -d "${legacyserverlogdir}" ]; then - find "${legacyserverlogdir}"/ -type f -mtime +"${logdays}"|tee >> "${scriptlog}" + find "${legacyserverlogdir}"/ -type f -mtime +"${logdays}"| tee >> "${scriptlog}" legacycount=$(find "${legacyserverlogdir}"/ -type f -mtime +"${logdays}"|wc -l) find "${legacyserverlogdir}"/ -mtime +"${logdays}" -type f -exec rm -f {} \; # Remove folder if empty diff --git a/functions/update_dl.sh b/functions/update_dl.sh index a80caa6d8..0c07fc31a 100644 --- a/functions/update_dl.sh +++ b/functions/update_dl.sh @@ -19,9 +19,9 @@ if [ $(command -v unbuffer) ]; then fi if [ "${engine}" == "goldsource" ]; then - ${unbuffer} ./steamcmd.sh +login "${steamuser}" "${steampass}" +force_install_dir "${filesdir}" +app_set_config 90 mod ${appidmod} +app_update "${appid}" +quit|tee -a "${scriptlog}" + ${unbuffer} ./steamcmd.sh +login "${steamuser}" "${steampass}" +force_install_dir "${filesdir}" +app_set_config 90 mod ${appidmod} +app_update "${appid}" +quit| tee -a "${scriptlog}" else - ${unbuffer} ./steamcmd.sh +login "${steamuser}" "${steampass}" +force_install_dir "${filesdir}" +app_update "${appid}" +quit|tee -a "${scriptlog}" + ${unbuffer} ./steamcmd.sh +login "${steamuser}" "${steampass}" +force_install_dir "${filesdir}" +app_update "${appid}" +quit| tee -a "${scriptlog}" fi fix.sh From 0dbeb0789cdac77f1d685630f66b0bc609ee3d0e Mon Sep 17 00:00:00 2001 From: Daniel Gibbs Date: Sat, 27 Feb 2016 19:36:49 +0000 Subject: [PATCH 066/117] Added script logging and removed unzip dep --- functions/check_deps.sh | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/functions/check_deps.sh b/functions/check_deps.sh index 3f9312024..d562369a8 100644 --- a/functions/check_deps.sh +++ b/functions/check_deps.sh @@ -53,6 +53,7 @@ if [ "${#array_deps_missing[@]}" != "0" ]; then fn_printdots "Checking dependencies" sleep 2 fn_printwarn "Checking dependencies: Dependency missing: \e[0;31m${array_deps_missing[@]}\e[0m" + fn_scriptlog "Checking dependencies: Dependency missing: \e[0;31m${array_deps_missing[@]}\e[0m" sleep 1 echo -e "" sudo -n true > /dev/null 2>&1 @@ -73,6 +74,7 @@ if [ "${#array_deps_missing[@]}" != "0" ]; then else echo "" fn_printinfomationnl "$(whoami) does not have sudo access. manually install dependencies" + fn_scriptlog "$(whoami) does not have sudo access. manually install dependencies" echo "" if [ -n "$(command -v dpkg-query)" ]; then echo "sudo dpkg --add-architecture i386; sudo apt-get install ${array_deps_missing[@]}" @@ -147,7 +149,7 @@ if [ -n "$(command -v dpkg-query)" ]; then elif [ "${executable}" == "./ucc-bin" ]; then #UT2K4 if [ -f "${executabledir}/ut2004-bin" ]; then - array_deps_required+=( libsdl1.2debian libstdc++5:i386 bzip2 unzip ) + array_deps_required+=( libsdl1.2debian libstdc++5:i386 bzip2 ) #UT99 else array_deps_required+=( libsdl1.2debian bzip2 ) @@ -193,7 +195,7 @@ elif [ -n "$(command -v yum)" ]; then elif [ "${executable}" == "./ucc-bin" ]; then #UT2K4 if [ -f "${executabledir}/ut2004-bin" ]; then - array_deps_required+=( compat-libstdc++-33.i686 SDL.i686 bzip2 unzip ) + array_deps_required+=( compat-libstdc++-33.i686 SDL.i686 bzip2 ) #UT99 else array_deps_required+=( SDL.i686 bzip2 ) From 4c0eaa3144e0e37504d644b040250e4c6be67b10 Mon Sep 17 00:00:00 2001 From: Daniel Gibbs Date: Sat, 27 Feb 2016 19:49:10 +0000 Subject: [PATCH 067/117] No longer required --- functions/install_dl_ut2k4.sh | 54 ----------------------------------- functions/install_ut2k4.sh | 42 --------------------------- functions/install_ut99.sh | 42 --------------------------- 3 files changed, 138 deletions(-) delete mode 100644 functions/install_dl_ut2k4.sh delete mode 100644 functions/install_ut2k4.sh delete mode 100644 functions/install_ut99.sh diff --git a/functions/install_dl_ut2k4.sh b/functions/install_dl_ut2k4.sh deleted file mode 100644 index 687867e74..000000000 --- a/functions/install_dl_ut2k4.sh +++ /dev/null @@ -1,54 +0,0 @@ -#!/bin/bash -# LGSM install_dl_ut2k4.sh function -# Author: Daniel Gibbs -# Website: http://gameservermanagers.com -lgsm_version="271215" - -echo "" -echo "Downloading Server Files" -echo "=================================" -sleep 1 -cd "${filesdir}" -if [ ! -f dedicatedserver3339-bonuspack.zip ]; then - wget http://gameservermanagers.com/files/ut2004/dedicatedserver3339-bonuspack.zip -else - echo "dedicatedserver3339-bonuspack.zip already downloaded!" -fi -echo "Running MD5 checksum to verify the file" -sleep 1 -echo "MD5 checksum: d3f28c5245c4c02802d48e4f0ffd3e34" -md5check=$(md5sum dedicatedserver3339-bonuspack.zip|awk '{print $1;}') -echo "File returned: ${md5check}" -if [ "${md5check}" != "d3f28c5245c4c02802d48e4f0ffd3e34" ]; then - echo "MD5 checksum: FAILED!" - read -p "Retry download? [y/N]" yn - case $yn in - [Yy]* ) rm -fv dedicatedserver3339-bonuspack.zip; install_dl_ut2k4.sh;; - [Nn]* ) echo Exiting; exit;; - * ) echo "Please answer yes or no.";; - esac -else - echo "MD5 checksum: PASSED" -fi -if [ ! -f ut2004-lnxpatch3369-2.tar.bz2 ]; then - wget http://gameservermanagers.com/files/ut2004/ut2004-lnxpatch3369-2.tar.bz2 -else - echo "ut2004-lnxpatch3369-2.tar.bz2 already downloaded!" -fi -echo "Running MD5 checksum to verify the file" -sleep 1 -echo "MD5 checksum: 0fa447e05fe5a38e0e32adf171be405e" -md5check=$(md5sum ut2004-lnxpatch3369-2.tar.bz2|awk '{print $1;}') -echo "File returned: ${md5check}" -if [ "${md5check}" != "0fa447e05fe5a38e0e32adf171be405e" ]; then - echo "MD5 checksum: FAILED!" - read -p "Retry download? [y/N]" yn - case $yn in - [Yy]* ) rm -fv ut2004-lnxpatch3369-2.tar.bz2; install_dl_ut2k4.sh;; - [Nn]* ) echo Exiting; exit;; - * ) echo "Please answer yes or no.";; - esac -else - echo "MD5 checksum: PASSED" -fi -echo "" \ No newline at end of file diff --git a/functions/install_ut2k4.sh b/functions/install_ut2k4.sh deleted file mode 100644 index 44d78b885..000000000 --- a/functions/install_ut2k4.sh +++ /dev/null @@ -1,42 +0,0 @@ -#!/bin/bash -# LGSM install_ut2k4.sh function -# Author: Daniel Gibbs -# Website: http://gameservermanagers.com -lgsm_version="271215" - -echo "" -echo "Installing ${gamename} Server" -echo "=================================" -sleep 1 -cd "${filesdir}" -echo "Extracting dedicatedserver3339-bonuspack.zip" -sleep 1 -unzip dedicatedserver3339-bonuspack.zip -echo "Extracting ut2004-lnxpatch3369-2.tar.bz2" -sleep 1 -tar -xvjf ut2004-lnxpatch3369-2.tar.bz2 UT2004-Patch/ --strip-components=1 -while true; do - read -p "Was the install successful? [y/N]" yn - case $yn in - [Yy]* ) break;; - [Nn]* ) install_retry.sh;; - * ) echo "Please answer yes or no.";; -esac -done -while true; do - read -p "Remove ut2004-lnxpatch3369-2.tar.bz2? [y/N]" yn - case $yn in - [Yy]* ) rm -fv ut2004-lnxpatch3369-2.tar.bz2; break;; - [Nn]* ) break;; - * ) echo "Please answer yes or no.";; - esac -done -while true; do - read -p "Remove dedicatedserver3339-bonuspack.zip? [y/N]" yn - case $yn in - [Yy]* ) rm -fv dedicatedserver3339-bonuspack.zip; break;; - [Nn]* ) break;; - * ) echo "Please answer yes or no.";; - esac -done -echo "" \ No newline at end of file diff --git a/functions/install_ut99.sh b/functions/install_ut99.sh deleted file mode 100644 index 32b49f7a1..000000000 --- a/functions/install_ut99.sh +++ /dev/null @@ -1,42 +0,0 @@ -#!/bin/bash -# LGSM install_ut99.sh function -# Author: Daniel Gibbs -# Website: http://gameservermanagers.com -lgsm_version="271215" - -echo "" -echo "Installing ${gamename} Server" -echo "=================================" -sleep 1 -cd "${filesdir}" -echo "Extracting ut-server-436.tar.gz" -sleep 1 -tar -zxvf ut-server-436.tar.gz ut-server/ --strip-components=1 -echo "Extracting UTPGPatch451.tar.bz2" -sleep 1 -tar -jxvf UTPGPatch451.tar.bz2 -while true; do - read -p "Was the install successful? [y/N]" yn - case $yn in - [Yy]* ) break;; - [Nn]* ) install_retry.sh;; - * ) echo "Please answer yes or no.";; -esac -done -while true; do - read -p "Remove ut-server-436.tar.gz? [y/N]" yn - case $yn in - [Yy]* ) rm -fv ut-server-436.tar.gz; break;; - [Nn]* ) break;; - * ) echo "Please answer yes or no.";; - esac -done -while true; do - read -p "Remove UTPGPatch451.tar.bz2? [y/N]" yn - case $yn in - [Yy]* ) rm -fv UTPGPatch451.tar.bz2; break;; - [Nn]* ) break;; - * ) echo "Please answer yes or no.";; - esac -done -echo "" \ No newline at end of file From 19b9e779d9e9a22736d556723f1e2b7eece098bd Mon Sep 17 00:00:00 2001 From: Daniel Gibbs Date: Sat, 27 Feb 2016 19:49:47 +0000 Subject: [PATCH 068/117] Added logging --- functions/install_complete.sh | 1 + functions/install_logs.sh | 5 +++-- functions/install_server_files.sh | 2 ++ functions/install_ut2k4_key.sh | 3 ++- 4 files changed, 8 insertions(+), 3 deletions(-) diff --git a/functions/install_complete.sh b/functions/install_complete.sh index a782b4f7a..b6fab789d 100644 --- a/functions/install_complete.sh +++ b/functions/install_complete.sh @@ -12,6 +12,7 @@ if [ "${gamename}" == "Don't Starve Together" ]; then fi echo "=================================" echo "Install Complete!" +fn_scriptlog "Install Complete!" echo "" echo "To start server type:" echo "./${selfname} start" diff --git a/functions/install_logs.sh b/functions/install_logs.sh index 6496ad647..c90aadb36 100644 --- a/functions/install_logs.sh +++ b/functions/install_logs.sh @@ -2,7 +2,7 @@ # LGSM install_logs.sh function # Author: Daniel Gibbs # Website: http://gameservermanagers.com -lgsm_version="271215" +lgsm_version="270216" if [ "${checklogs}" != "1" ]; then echo "" @@ -44,4 +44,5 @@ if [ -d "${rootdir}/Steam/logs" ]; then ln -nfsv "${rootdir}/Steam/logs" "${rootdir}/log/steamcmd" fi fi -sleep 1 \ No newline at end of file +sleep 1 +fn_scriptlog "Logs installed" \ No newline at end of file diff --git a/functions/install_server_files.sh b/functions/install_server_files.sh index 112a7fe4b..8f152db84 100644 --- a/functions/install_server_files.sh +++ b/functions/install_server_files.sh @@ -29,6 +29,7 @@ while [ "${counter}" == "0" ]||[ "${exitcode}" != "0" ]; do if [ "${counter}" -ge "2" ]; then fn_printwarningnl "SteamCMD did not complete the download, retrying: Attempt ${counter}:" + fn_scriptlog "SteamCMD did not complete the download, retrying: Attempt ${counter}:" fi if [ "${counter}" -ge "7" ]; then @@ -64,6 +65,7 @@ while [ "${counter}" == "0" ]||[ "${exitcode}" != "0" ]; do fi elif [ "${counter}" -ge "11" ]; then fn_printfailurenl "SteamCMD did not complete the download, too many retrys" + fn_scriptlog "SteamCMD did not complete the download, too many retrys" break fi done diff --git a/functions/install_ut2k4_key.sh b/functions/install_ut2k4_key.sh index 34dcab124..f582f4c16 100644 --- a/functions/install_ut2k4_key.sh +++ b/functions/install_ut2k4_key.sh @@ -18,7 +18,8 @@ if [ -z "${autoinstall}" ]; then echo -n "KEY: " read CODE echo ""\""CDKey"\""="\""${CODE}"\""" > "${systemdir}/cdkey" - + if [ -f "${systemdir}/cdkey" ]; then + fn_scriptlog "UT2K4 Server CD Key created" else echo "You can add your key using the following command" echo "./${selfname} server-cd-key" From 364856e81916f711b79170a177161de78d1340d0 Mon Sep 17 00:00:00 2001 From: Daniel Gibbs Date: Sat, 27 Feb 2016 19:50:03 +0000 Subject: [PATCH 069/117] Optimised function --- functions/install_gslt.sh | 53 +++++++++++++++++---------------------- 1 file changed, 23 insertions(+), 30 deletions(-) diff --git a/functions/install_gslt.sh b/functions/install_gslt.sh index 5919fac33..b7649eade 100644 --- a/functions/install_gslt.sh +++ b/functions/install_gslt.sh @@ -2,41 +2,34 @@ # LGSM install_gslt.sh function # Author: Daniel Gibbs # Website: http://gameservermanagers.com -lgsm_version="271215" +lgsm_version="270216" # Description: Configures GSLT. -if [ -z "${autoinstall}" ]; then - echo "" - echo "Game Server Login Token" - echo "============================" - sleep 1 - if [ "${gamename}" == "Counter Strike: Global Offensive" ]; then - echo "GSLT is required to run a public ${gamename} server" - else - echo "GSLT is an optional feature for ${gamename} server" - fi +echo "" +echo "Game Server Login Token" +echo "============================" +sleep 1 +if [ "${gamename}" == "Counter Strike: Global Offensive" ]; then + echo "GSLT is required to run a public ${gamename} server" + fn_scriptlog "GSLT is required to run a public ${gamename} server" +else + echo "GSLT is an optional feature for ${gamename} server" + fn_scriptlog "GSLT is an optional feature for ${gamename} server" +fi - echo "Get more info and a token here:" - echo "http://gameservermanagers.com/gslt" - echo "" +echo "Get more info and a token here:" +echo "http://gameservermanagers.com/gslt" +fn_scriptlog "Get more info and a token here:" +fn_scriptlog "http://gameservermanagers.com/gslt" +echo "" +if [ -z "${autoinstall}" ]; then echo "Enter token below (Can be blank)." echo -n "GSLT TOKEN: " read token sed -i -e "s/gslt=\"\"/gslt=\"${token}\"/g" "${rootdir}/${selfname}" - sleep 1 - echo "The GSLT can be changed by editing ${selfname}." - echo "" -else - if [ "${gamename}" == "Counter Strike: Global Offensive" ]; then - fn_printinfomationnl "GSLT is required to run a public ${gamename} server" - else - fn_printinfomationnl "GSLT is an optional feature for ${gamename} server" - fi - echo "Get more info and a token here:" - echo "http://gameservermanagers.com/gslt" - echo "" - sleep 1 - echo "The GSLT can be changed by editing ${selfname}." - sleep 1 -fi \ No newline at end of file +fi +sleep 1 +echo "The GSLT can be changed by editing ${selfname}." +fn_scriptlog "The GSLT can be changed by editing ${selfname}." +echo "" \ No newline at end of file From f924b10dc3059d5aa0da5aa288f73d03dc7ac420 Mon Sep 17 00:00:00 2001 From: Daniel Gibbs Date: Sat, 27 Feb 2016 19:51:50 +0000 Subject: [PATCH 070/117] removed legacy functions dir --- functions/command_update_functions.sh | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/functions/command_update_functions.sh b/functions/command_update_functions.sh index 7cc1c4cb2..3c530e4a0 100644 --- a/functions/command_update_functions.sh +++ b/functions/command_update_functions.sh @@ -12,10 +12,14 @@ fn_printdots "Updating functions" fn_scriptlog "Updating functions" sleep 1 echo -ne "\n" + +# Removed legecy functions dir if [ -d "${rootdir}/functions/" ]; then rm -rfv "${rootdir}/functions/" exitcode=$? -elif [ -n "${functionsdir}" ]; then +fi + +if [ -n "${functionsdir}" ]; then rm -rfv "${functionsdir}/"* exitcode=$? else From bc0fc9d1ccdc63cfac00627616dc73f16469d5fb Mon Sep 17 00:00:00 2001 From: Daniel Gibbs Date: Sat, 27 Feb 2016 19:55:32 +0000 Subject: [PATCH 071/117] Corrected update_functions name --- functions/check.sh | 4 ++-- functions/core_functions.sh | 4 ++-- functions/fn_update_functions | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/functions/check.sh b/functions/check.sh index dd64d9ef1..0c2fbe7bf 100644 --- a/functions/check.sh +++ b/functions/check.sh @@ -21,11 +21,11 @@ array_contains () { check_root.sh -if [ "${function_selfname}" != "command_install.sh" ] && [ "${function_selfname}" != "update_functions.sh" ]; then +if [ "${function_selfname}" != "command_install.sh" ] && [ "${function_selfname}" != "command_update_functions.sh" ]; then check_system_dir.sh fi -local allowed_commands_array=( command_backup.sh command_console.sh command_debug.sh command_details.sh command_unreal2_maps.sh command_ut99_maps.sh command_monitor.sh command_start.sh command_stop.sh update_check.sh command_validate.sh update_functions.sh command_email_test.sh ) +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 command_update_functions.sh command_email_test.sh ) for allowed_command in "${allowed_commands_array[@]}" do if [ "${allowed_command}" == "${function_selfname}" ]; then diff --git a/functions/core_functions.sh b/functions/core_functions.sh index eb1096828..5fbcc44d6 100644 --- a/functions/core_functions.sh +++ b/functions/core_functions.sh @@ -288,7 +288,7 @@ functionfile="${FUNCNAME}" fn_fetch_function } -update_functions.sh(){ +command_update_functions.sh(){ functionfile="${FUNCNAME}" fn_fetch_function } @@ -298,7 +298,7 @@ functionfile="${FUNCNAME}" fn_fetch_function } -update_functions.sh(){ +fn_update_functions.sh(){ functionfile="${FUNCNAME}" fn_fetch_function } diff --git a/functions/fn_update_functions b/functions/fn_update_functions index 2de9afd6d..bf4e5446d 100644 --- a/functions/fn_update_functions +++ b/functions/fn_update_functions @@ -1,5 +1,5 @@ #!/bin/bash -# LGSM update_functions.sh function +# LGSM command_update_functions.sh function # Author: Daniel Gibbs # Website: http://gameservermanagers.com lgsm_version="230116" From 91c88c0632bbc95c48e2527d754b2771382591cf Mon Sep 17 00:00:00 2001 From: Daniel Gibbs Date: Sat, 27 Feb 2016 21:57:53 +0000 Subject: [PATCH 072/117] tidy --- functions/fn_update_functions | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/functions/fn_update_functions b/functions/fn_update_functions index bf4e5446d..414649f6a 100644 --- a/functions/fn_update_functions +++ b/functions/fn_update_functions @@ -1,5 +1,5 @@ #!/bin/bash -# LGSM command_update_functions.sh function +# LGSM fn_update_functions.sh function # Author: Daniel Gibbs # Website: http://gameservermanagers.com lgsm_version="230116" From 78be6b86913c380f6b243ceb8edbc7ef3a2a2650 Mon Sep 17 00:00:00 2001 From: Daniel Gibbs Date: Sat, 27 Feb 2016 21:58:58 +0000 Subject: [PATCH 073/117] Added code for legacy servers to allow them to work --- functions/core_functions.sh | 52 +++++++++++++++++++++++++++++++++++-- 1 file changed, 50 insertions(+), 2 deletions(-) diff --git a/functions/core_functions.sh b/functions/core_functions.sh index 5fbcc44d6..b0813243d 100644 --- a/functions/core_functions.sh +++ b/functions/core_functions.sh @@ -2,12 +2,12 @@ # LGSM core_functions.sh function # Author: Daniel Gibbs # Website: http://gameservermanagers.com -lgsm_version="160216" +lgsm_version="270216" # Description: Defines all functions to allow download and execution of functions using fn_fetch_function. # This function is called first before any other function. Without this file other functions would not load. -#Legacy functions +# Code/functions for legacy lgsm scripts fn_functions(){ functionfile="${FUNCNAME}" @@ -19,6 +19,54 @@ functionfile="${FUNCNAME}" fn_fetch_function } +# fn_fetch_core_dl also placed here to allow legecy scripts to still download core functions +if [ -n "${lgsmdir}" ]; then + lgsmdir="${rootdir}/lgsm" + functionsdir="${lgsmdir}/functions" +fi + +fn_fetch_core_dl(){ +github_file_url_dir="functions" +github_file_url_name="${functionfile}" +filedir="${functionsdir}" +filename="${github_file_url_name}" +githuburl="https://raw.githubusercontent.com/${githubuser}/${githubrepo}/${githubbranch}/${github_file_url_dir}/${github_file_url_name}" +# If the file is missing, then download +if [ ! -f "${filedir}/${filename}" ]; then + if [ ! -d "${filedir}" ]; then + mkdir -p "${filedir}" + fi + echo -e " fetching ${filename}...\c" + # Check curl exists and use available path + curlpaths="$(command -v curl 2>/dev/null) $(which curl >/dev/null 2>&1) /usr/bin/curl /bin/curl /usr/sbin/curl /sbin/curl $(echo $PATH | sed "s/\([:]\|\$\)/\/curl /g")" + for curlcmd in ${curlpaths} + do + if [ -x "${curlcmd}" ]; then + break + fi + done + # If curl exists download file + if [ "$(basename ${curlcmd})" == "curl" ]; then + curlfetch=$(${curlcmd} -s --fail -o "${filedir}/${filename}" "${githuburl}" 2>&1) + if [ $? -ne 0 ]; then + echo -e "\e[0;31mFAIL\e[0m\n" + echo "${curlfetch}" + echo -e "${githuburl}\n" + exit 1 + else + echo -e "\e[0;32mOK\e[0m" + fi + else + echo -e "\e[0;31mFAIL\e[0m\n" + echo "Curl is not installed!" + echo -e "" + exit 1 + fi + chmod +x "${filedir}/${filename}" +fi +source "${filedir}/${filename}" +} + # Core From ee76be76cf89891e8506780845c727284714cb88 Mon Sep 17 00:00:00 2001 From: Daniel Gibbs Date: Sat, 27 Feb 2016 21:59:26 +0000 Subject: [PATCH 074/117] Added message explaining multiple dl attempts --- functions/install_server_files.sh | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/functions/install_server_files.sh b/functions/install_server_files.sh index 8f152db84..b09cc0ba2 100644 --- a/functions/install_server_files.sh +++ b/functions/install_server_files.sh @@ -28,8 +28,8 @@ while [ "${counter}" == "0" ]||[ "${exitcode}" != "0" ]; do # Attempt 11: Failure if [ "${counter}" -ge "2" ]; then - fn_printwarningnl "SteamCMD did not complete the download, retrying: Attempt ${counter}:" - fn_scriptlog "SteamCMD did not complete the download, retrying: Attempt ${counter}:" + fn_printwarningnl "SteamCMD did not complete the download, retrying: Attempt ${counter}" + fn_scriptlog "SteamCMD did not complete the download, retrying: Attempt ${counter}" fi if [ "${counter}" -ge "7" ]; then @@ -73,6 +73,7 @@ done # Goldsource servers commonly fail to download all the server files required. # Validating a few of times may reduce the chance of this issue. if [ "${engine}" == "goldsource" ]; then + fn_printinfomationnl "Goldsource servers commonly fail to download all the server files required. Validating a few of times may reduce the chance of this issue." counter="0" while [ "${counter}" -le "4" ]; do counter=$((counter+1)) From 3a5086c82146974fe8e6fb9339b7d40a40de490b Mon Sep 17 00:00:00 2001 From: Daniel Gibbs Date: Sat, 27 Feb 2016 22:03:21 +0000 Subject: [PATCH 075/117] corrected if --- functions/core_functions.sh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/functions/core_functions.sh b/functions/core_functions.sh index b0813243d..c0490ffcb 100644 --- a/functions/core_functions.sh +++ b/functions/core_functions.sh @@ -7,7 +7,7 @@ lgsm_version="270216" # Description: Defines all functions to allow download and execution of functions using fn_fetch_function. # This function is called first before any other function. Without this file other functions would not load. -# Code/functions for legacy lgsm scripts +# Code/functions for legacy servers fn_functions(){ functionfile="${FUNCNAME}" @@ -19,8 +19,8 @@ functionfile="${FUNCNAME}" fn_fetch_function } -# fn_fetch_core_dl also placed here to allow legecy scripts to still download core functions -if [ -n "${lgsmdir}" ]; then +# fn_fetch_core_dl also placed here to allow legecy servers to still download core functions +if [ -z "${lgsmdir}" ]; then lgsmdir="${rootdir}/lgsm" functionsdir="${lgsmdir}/functions" fi From 190fa025323849cab7f7823f5208f7fc0037c285 Mon Sep 17 00:00:00 2001 From: Daniel Gibbs Date: Sun, 28 Feb 2016 13:10:33 +0000 Subject: [PATCH 076/117] code tidy --- functions/core_dl.sh | 83 ++++++++++++++++++++++++++++---------------- 1 file changed, 54 insertions(+), 29 deletions(-) diff --git a/functions/core_dl.sh b/functions/core_dl.sh index d6fc8cd04..31143eb34 100644 --- a/functions/core_dl.sh +++ b/functions/core_dl.sh @@ -6,10 +6,17 @@ lgsm_version="050216" # Description: Deals with all downloads for LGSM. -# Downloads can be defined in code like so -# fn_dl "dl_filename" "dl_filepath" "dl_url" "dl_md5" -# fn_dl "file.tar.bz2" "/home/gameserver" "http://example.com/file.tar/bz2" "10cd7353aa9d758a075c600a6dd193fd" - +# fileurl: The URL of the file: http://example.com/dl/File.tar.bz2 +# filedir: location the file is to be saved: /home/server/lgsm/tmp +# filename: name of file (this can be different from the url name): file.tar.bz2 +# executecmd: Optional, set to "executecmd" to make file executable using chmod +x +# run: Optional, set to run to execute the file +# force: Optional, force re-download of file even if exists +# md5: Optional, Checks file against an md5 sum +# +# Downloads can be defined in code like so: +# fn_fetch_file "${fileurl}" "${filedir}" "${filename}" "${executecmd}" "${run}" "${force}" "${md5}" +# fn_fetch_file "http://example.com/file.tar.bz2" "/some/dir" "file.tar.bz2" "executecmd" "run" "force" "10cd7353aa9d758a075c600a6dd193fd" fn_dl_md5(){ # Runs MD5 Check if available @@ -34,12 +41,17 @@ if [ -n "${md5}" ]; then fi } +# Extracts bzip2 or gzip files +# Extracts can be defined in code like so: +# fn_dl_extract "${filedir}" "${filename}" "${extractdir}" +# fn_dl_extract "/home/gameserver/lgsm/tmp" "file.tar.bz2" "/home/gamserver/serverfiles" fn_dl_extract(){ filedir=${1} filename=${2} extractdir=${3} # extracts archives echo -ne "extracting ${filename}..." +fn_scriptlog "extracting download" mime=$(file -b --mime-type "${filedir}/${filename}") if [ "${mime}" == "application/gzip" ]; then @@ -50,7 +62,8 @@ fi local exitcode=$? if [ ${exitcode} -ne 0 ]; then fn_printfaileolnl - echo "${tarcmd}" + fn_scriptlog "extracting download: FAIL" + echo "${tarcmd}" | tee -a "${scriptlog}" exit ${exitcode} else fn_printokeolnl @@ -60,14 +73,14 @@ fi # Trap to remove file download if canceled before completed fn_fetch_trap() { echo "" - fn_printinfomationnl "Cancelling download" + fn_printinfomationnl "cancelling download" + fn_scriptlog "canceling download" sleep 1 - fn_printinfomation "Removing ${filename}" - rm -f "${filedir}/${filename}" + fn_printinfomation "removing ${filename}" + fn_scriptlog "removing ${filename}" + rm -f "${filedir}/${filename}" | tee -a "${scriptlog}" } -# Downloads file using curl and run it if required -# fn_fetch_file "fileurl" "filedir" "filename" "executecmd" "run" "force" "md5" fn_fetch_file(){ fileurl=${1} filedir=${2} @@ -98,27 +111,32 @@ if [ ! -f "${filedir}/${filename}" ]; then # if larger file shows progress bar if [ ${filename##*.} == "bz2" ]; then echo -ne "downloading ${filename}..." + fn_scriptlog "downloading ${filename}" sleep 1 curlcmd=$(${curlcmd} --progress-bar --fail -o "${filedir}/${filename}" "${fileurl}") echo -ne "downloading ${filename}..." else echo -ne " fetching ${filename}...\c" + fn_scriptlog "fetching ${filename}" curlcmd=$(${curlcmd} -s --fail -o "${filedir}/${filename}" "${fileurl}" 2>&1) fi local exitcode=$? if [ ${exitcode} -ne 0 ]; then fn_printfaileolnl - echo "${curlcmd}" - echo -e "${fileurl}\n" + fn_scriptlog "downloading ${filename}: FAIL" + echo "${curlcmd}" | tee -a "${scriptlog}" + echo -e "${fileurl}\n" | tee -a "${scriptlog}" exit ${exitcode} else fn_printokeolnl + fn_scriptlog "downloading ${filename}: OK" fi # remove trap trap - INT else fn_printfaileolnl echo "Curl is not installed!" + fn_scriptlog "Curl is not installed!" echo -e "" exit 1 fi @@ -138,36 +156,43 @@ fi } -# fn_fetch_file_github -# Parameters: -# github_file_url_dir: The directory the file is located in teh GitHub repo -# github_file_url_name: name of file -# filepath: location file to be saved + +# fileurl: The directory the file is located in teh GitHub repo +# filedir: name of file +# filename: location file to be saved # executecmd: set to "executecmd" to make file executecmd # run: Optional, set to run to execute the file # force: force download of file even if exists +# md5: Checks fail against an md5 sum + + +# Fetches files from the github repo fn_fetch_file_github(){ -github_file_url_dir=${1} -github_file_url_name=${2} -filepath=${3} -filename="${github_file_url_name}" -executecmd=${4:-0} -run=${5:-0} -force=${6:-0} +github_file_url_dir="${1}" +github_file_url_name="${2}" githuburl="https://raw.githubusercontent.com/${githubuser}/${githubrepo}/${githubbranch}/${github_file_url_dir}/${github_file_url_name}" -fn_fetch_file "${githuburl}" "${filepath}" "${filename}" "${executecmd}" "${run}" "${force}" +fileurl="${githuburl}" +filedir="${3}" +filename="${github_file_url_name}" +executecmd="${4:-0}" +run="${5:-0}" +force="${6:-0}" +md5="${7:-0}" +fn_fetch_file "${fileurl}" "${filedir}" "${filename}" "${executecmd}" "${run}" "${force}" "${md5}" } - # Fetches functions fn_fetch_function(){ github_file_url_dir="functions" # github dir containing the file github_file_url_name="${functionfile}" # name of the github file githuburl="https://raw.githubusercontent.com/${githubuser}/${githubrepo}/${githubbranch}/${github_file_url_dir}/${github_file_url_name}" -filedir="${functionsdir}" # local dir that will contain the file -filename="${github_file_url_name}" # name of the local file +fileurl="${githuburl}" +filedir="${functionsdir}" +filename="${github_file_url_name}" executecmd="executecmd" run="run" -fn_fetch_file "${githuburl}" "${filedir}" "${filename}" "${executecmd}" "${run}" +force="noforce" +md5="" +fn_fetch_file "${fileurl}" "${filedir}" "${filename}" "${executecmd}" "${run}" "${force}" "${md5}" } \ No newline at end of file From 0a5c682d717c8708c79ca6baaf54e3a7e745e760 Mon Sep 17 00:00:00 2001 From: Daniel Gibbs Date: Sun, 28 Feb 2016 13:10:47 +0000 Subject: [PATCH 077/117] corrected if best practice --- functions/command_install.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/functions/command_install.sh b/functions/command_install.sh index e933b2598..fb4682d53 100644 --- a/functions/command_install.sh +++ b/functions/command_install.sh @@ -19,7 +19,7 @@ elif [ "${gamename}" == "Unreal Tournament 99" ]; then install_server_files.sh elif [ "${gamename}" == "Teamspeak 3" ]; then install_ts3.sh -elif [ ! -z "${appid}" ]; then +elif [ -n "${appid}" ]; then install_steamcmd.sh install_server_files.sh fi From 2d31f4795c34d208a83b302cca2c40f1e23a508e Mon Sep 17 00:00:00 2001 From: Daniel Gibbs Date: Sun, 28 Feb 2016 13:15:22 +0000 Subject: [PATCH 078/117] scriptlog will no longer be used if not installed --- functions/core_dl.sh | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/functions/core_dl.sh b/functions/core_dl.sh index 31143eb34..5ba80c58e 100644 --- a/functions/core_dl.sh +++ b/functions/core_dl.sh @@ -111,32 +111,39 @@ if [ ! -f "${filedir}/${filename}" ]; then # if larger file shows progress bar if [ ${filename##*.} == "bz2" ]; then echo -ne "downloading ${filename}..." - fn_scriptlog "downloading ${filename}" + if [ -z "${scriptlog}" ]; then + fn_scriptlog "downloading ${filename}" + fi sleep 1 curlcmd=$(${curlcmd} --progress-bar --fail -o "${filedir}/${filename}" "${fileurl}") echo -ne "downloading ${filename}..." else echo -ne " fetching ${filename}...\c" - fn_scriptlog "fetching ${filename}" + if [ -z "${scriptlog}" ]; then + fn_scriptlog "fetching ${filename}" + fi curlcmd=$(${curlcmd} -s --fail -o "${filedir}/${filename}" "${fileurl}" 2>&1) fi local exitcode=$? if [ ${exitcode} -ne 0 ]; then fn_printfaileolnl - fn_scriptlog "downloading ${filename}: FAIL" + if [ -z "${scriptlog}" ]; then + fn_scriptlog "downloading ${filename}: FAIL" + fi echo "${curlcmd}" | tee -a "${scriptlog}" echo -e "${fileurl}\n" | tee -a "${scriptlog}" exit ${exitcode} else fn_printokeolnl - fn_scriptlog "downloading ${filename}: OK" + if [ -z "${scriptlog}" ]; then + fn_scriptlog "downloading ${filename}: OK" + fi fi # remove trap trap - INT else fn_printfaileolnl echo "Curl is not installed!" - fn_scriptlog "Curl is not installed!" echo -e "" exit 1 fi From b038d38589cfdb8f2c2da23bf8b59a56152a50fb Mon Sep 17 00:00:00 2001 From: Daniel Gibbs Date: Sun, 28 Feb 2016 13:16:50 +0000 Subject: [PATCH 079/117] alterred to use -f --- functions/core_dl.sh | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/functions/core_dl.sh b/functions/core_dl.sh index 5ba80c58e..7b2860f7e 100644 --- a/functions/core_dl.sh +++ b/functions/core_dl.sh @@ -111,7 +111,7 @@ if [ ! -f "${filedir}/${filename}" ]; then # if larger file shows progress bar if [ ${filename##*.} == "bz2" ]; then echo -ne "downloading ${filename}..." - if [ -z "${scriptlog}" ]; then + if [ -f "${scriptlog}" ]; then fn_scriptlog "downloading ${filename}" fi sleep 1 @@ -119,7 +119,7 @@ if [ ! -f "${filedir}/${filename}" ]; then echo -ne "downloading ${filename}..." else echo -ne " fetching ${filename}...\c" - if [ -z "${scriptlog}" ]; then + if [ -f "${scriptlog}" ]; then fn_scriptlog "fetching ${filename}" fi curlcmd=$(${curlcmd} -s --fail -o "${filedir}/${filename}" "${fileurl}" 2>&1) @@ -127,7 +127,7 @@ if [ ! -f "${filedir}/${filename}" ]; then local exitcode=$? if [ ${exitcode} -ne 0 ]; then fn_printfaileolnl - if [ -z "${scriptlog}" ]; then + if [ -f "${scriptlog}" ]; then fn_scriptlog "downloading ${filename}: FAIL" fi echo "${curlcmd}" | tee -a "${scriptlog}" @@ -135,7 +135,7 @@ if [ ! -f "${filedir}/${filename}" ]; then exit ${exitcode} else fn_printokeolnl - if [ -z "${scriptlog}" ]; then + if [ -f "${scriptlog}" ]; then fn_scriptlog "downloading ${filename}: OK" fi fi From 013332bfb1f1cae229218f32d975686efef9516a Mon Sep 17 00:00:00 2001 From: Daniel Gibbs Date: Sun, 28 Feb 2016 13:26:10 +0000 Subject: [PATCH 080/117] Update trap messages --- functions/core_dl.sh | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) diff --git a/functions/core_dl.sh b/functions/core_dl.sh index 7b2860f7e..856253592 100644 --- a/functions/core_dl.sh +++ b/functions/core_dl.sh @@ -73,12 +73,12 @@ fi # Trap to remove file download if canceled before completed fn_fetch_trap() { echo "" - fn_printinfomationnl "cancelling download" - fn_scriptlog "canceling download" + fn_printinfomationnl "downloading ${filename}: CANCELED" + fn_scriptlog "downloading ${filename}: CANCELED" sleep 1 - fn_printinfomation "removing ${filename}" - fn_scriptlog "removing ${filename}" + fn_printinfomation "downloading ${filename}: REMOVED" rm -f "${filedir}/${filename}" | tee -a "${scriptlog}" + fn_scriptlog "downloading ${filename}: REMOVED" } fn_fetch_file(){ @@ -111,17 +111,11 @@ if [ ! -f "${filedir}/${filename}" ]; then # if larger file shows progress bar if [ ${filename##*.} == "bz2" ]; then echo -ne "downloading ${filename}..." - if [ -f "${scriptlog}" ]; then - fn_scriptlog "downloading ${filename}" - fi sleep 1 curlcmd=$(${curlcmd} --progress-bar --fail -o "${filedir}/${filename}" "${fileurl}") echo -ne "downloading ${filename}..." else echo -ne " fetching ${filename}...\c" - if [ -f "${scriptlog}" ]; then - fn_scriptlog "fetching ${filename}" - fi curlcmd=$(${curlcmd} -s --fail -o "${filedir}/${filename}" "${fileurl}" 2>&1) fi local exitcode=$? From 9ea653ac84ad9c0191da2e773a9340e131de0d1b Mon Sep 17 00:00:00 2001 From: Daniel Gibbs Date: Sun, 28 Feb 2016 13:36:01 +0000 Subject: [PATCH 081/117] added exit to trap --- functions/core_dl.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/functions/core_dl.sh b/functions/core_dl.sh index 856253592..9d2a52233 100644 --- a/functions/core_dl.sh +++ b/functions/core_dl.sh @@ -79,6 +79,7 @@ fn_fetch_trap() { fn_printinfomation "downloading ${filename}: REMOVED" rm -f "${filedir}/${filename}" | tee -a "${scriptlog}" fn_scriptlog "downloading ${filename}: REMOVED" + exit } fn_fetch_file(){ From 6d1819e05fd0950511a57cb2b7eca990e419bb85 Mon Sep 17 00:00:00 2001 From: Daniel Gibbs Date: Sun, 28 Feb 2016 13:41:38 +0000 Subject: [PATCH 082/117] Added CANCELED and REMOVED eol --- functions/core_messages.sh | 18 ++++++++++++++++++ functions/install_logs.sh | 2 +- 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/functions/core_messages.sh b/functions/core_messages.sh index 88a0a8127..8d4f87ebe 100644 --- a/functions/core_messages.sh +++ b/functions/core_messages.sh @@ -162,4 +162,22 @@ fn_printqueryingeol(){ fn_printqueryingeolnl(){ echo -e "\e[0;31mQUERYING\e[0m\n" +} + +# CANCELED for end of line +fn_printcanceledeol(){ + echo -en "\e[0;31mQUERYING\e[0m\n" +} + +fn_printcanceledeolnl(){ + echo -e "\e[0;31mQUERYING\e[0m\n" +} + +# REMOVED for end of line +fn_printremovedeol(){ + echo -en "\e[0;31mQUERYING\e[0m\n" +} + +fn_printremovedeolnl(){ + echo -e "\e[0;31mQUERYING\e[0m\n" } \ No newline at end of file diff --git a/functions/install_logs.sh b/functions/install_logs.sh index c90aadb36..2722ef19b 100644 --- a/functions/install_logs.sh +++ b/functions/install_logs.sh @@ -45,4 +45,4 @@ if [ -d "${rootdir}/Steam/logs" ]; then fi fi sleep 1 -fn_scriptlog "Logs installed" \ No newline at end of file +fn_scriptlog "logs installed" \ No newline at end of file From 83a5a22a6e8dc41cd7e1972d3df45544fa318a55 Mon Sep 17 00:00:00 2001 From: Daniel Gibbs Date: Sun, 28 Feb 2016 13:42:18 +0000 Subject: [PATCH 083/117] added canceled and removed --- functions/core_messages.sh | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/functions/core_messages.sh b/functions/core_messages.sh index 8d4f87ebe..56251e6db 100644 --- a/functions/core_messages.sh +++ b/functions/core_messages.sh @@ -166,18 +166,18 @@ fn_printqueryingeolnl(){ # CANCELED for end of line fn_printcanceledeol(){ - echo -en "\e[0;31mQUERYING\e[0m\n" + echo -en "\e[0;31mCANCELED\e[0m\n" } fn_printcanceledeolnl(){ - echo -e "\e[0;31mQUERYING\e[0m\n" + echo -e "\e[0;31mCANCELED\e[0m\n" } # REMOVED for end of line fn_printremovedeol(){ - echo -en "\e[0;31mQUERYING\e[0m\n" + echo -en "\e[0;31mREMOVED\e[0m\n" } fn_printremovedeolnl(){ - echo -e "\e[0;31mQUERYING\e[0m\n" + echo -e "\e[0;31mREMOVED\e[0m\n" } \ No newline at end of file From fedd6394e60d3d92211ab7d4b336aaf31163ef89 Mon Sep 17 00:00:00 2001 From: Daniel Gibbs Date: Sun, 28 Feb 2016 13:44:47 +0000 Subject: [PATCH 084/117] Updated trap messages --- functions/core_dl.sh | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/functions/core_dl.sh b/functions/core_dl.sh index 9d2a52233..fae71b735 100644 --- a/functions/core_dl.sh +++ b/functions/core_dl.sh @@ -73,11 +73,13 @@ fi # Trap to remove file download if canceled before completed fn_fetch_trap() { echo "" - fn_printinfomationnl "downloading ${filename}: CANCELED" + echo -ne "downloading ${filename}: " + fn_printcanceledeol fn_scriptlog "downloading ${filename}: CANCELED" sleep 1 - fn_printinfomation "downloading ${filename}: REMOVED" rm -f "${filedir}/${filename}" | tee -a "${scriptlog}" + echo -ne "downloading ${filename}: " + fn_printremovedeol fn_scriptlog "downloading ${filename}: REMOVED" exit } From 931cf2855f94783dd30232a6810f662057ae3e89 Mon Sep 17 00:00:00 2001 From: Daniel Gibbs Date: Sun, 28 Feb 2016 13:51:01 +0000 Subject: [PATCH 085/117] updated md5sums --- functions/install_server_files.sh | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/functions/install_server_files.sh b/functions/install_server_files.sh index b09cc0ba2..b99bb9692 100644 --- a/functions/install_server_files.sh +++ b/functions/install_server_files.sh @@ -6,12 +6,11 @@ lgsm_version="270216" fn_install_server_files(){ if [ "${gamename}" == "Unreal Tournament 99" ]; then - fileurl="http://gameservermanagers.com/files/UnrealTournament99/ut99-server-451-ultimate-linux.tar.bz2"; filedir="${lgsmdir}/tmp"; filename="ut99-server-451-ultimate-linux.tar.bz2"; run="norun"; force="noforce"; md5="e623fdff5ed600a9bfccab852e18d34d" + fileurl="http://gameservermanagers.com/files/UnrealTournament99/ut99-server-451-ultimate-linux.tar.bz2"; filedir="${lgsmdir}/tmp"; filename="ut99-server-451-ultimate-linux.tar.bz2"; executecmd="noexecute" run="norun"; force="noforce"; md5="49cb24d0550ff6ddeaba6007045c6edd" elif [ "${gamename}" == "Unreal Tournament 2004" ]; then - fileurl="http://gameservermanagers.com/files/UnrealTournament2004/ut2004-server-3339-ultimate-linux.tar.bz2"; filedir="${lgsmdir}/tmp"; filename="ut2004-server-3339-ultimate-linux.tar.bz2"; run="norun"; force="noforce"; md5="e623fdff5ed600a9bfccab852e18d34d" + fileurl="http://gameservermanagers.com/files/UnrealTournament2004/ut2004-server-3339-ultimate-linux.tar.bz2"; filedir="${lgsmdir}/tmp"; filename="ut2004-server-3339-ultimate-linux.tar.bz2"; executecmd="noexecute" run="norun"; force="noforce"; md5="67c5e2cd9c2a4b04f163962ee41eff54" fi - -fn_fetch_file "${fileurl}" "${filedir}" "${filename}" "${run}" "${force}" "${md5}" +fn_fetch_file "${fileurl}" "${filedir}" "${filename}" "${executecmd}" "${run}" "${force}" "${md5}" fn_dl_extract "${filedir}" "${filename}" "${filesdir}" } From d9f9e76ad974b07b30ac5a57467e1c6c08a38075 Mon Sep 17 00:00:00 2001 From: Daniel Gibbs Date: Sun, 28 Feb 2016 14:47:40 +0000 Subject: [PATCH 086/117] Added module name to all install functions --- functions/command_install.sh | 1 + functions/core_dl.sh | 4 ++-- functions/install_complete.sh | 2 ++ functions/install_config.sh | 2 ++ functions/install_gslt.sh | 2 ++ functions/install_header.sh | 2 ++ functions/install_logs.sh | 2 ++ functions/install_retry.sh | 2 ++ functions/install_server_dir.sh | 2 ++ functions/install_server_files.sh | 2 ++ functions/install_steamcmd.sh | 2 ++ functions/install_ts3.sh | 2 ++ functions/install_ts3db.sh | 2 ++ functions/install_ut2k4_key.sh | 1 + 14 files changed, 26 insertions(+), 2 deletions(-) diff --git a/functions/command_install.sh b/functions/command_install.sh index fb4682d53..9c7eb7180 100644 --- a/functions/command_install.sh +++ b/functions/command_install.sh @@ -4,6 +4,7 @@ # Website: http://gameservermanagers.com lgsm_version="260216" +local modulename="Install" function_selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))" check.sh diff --git a/functions/core_dl.sh b/functions/core_dl.sh index fae71b735..597a97150 100644 --- a/functions/core_dl.sh +++ b/functions/core_dl.sh @@ -28,13 +28,13 @@ if [ -n "${md5}" ]; then fn_printfaileolnl echo "${filename} returned MD5 checksum: ${md5sumcmd}" echo "expected MD5 checksum: ${md5}" - fn_scriptlog "failed to verify ${filename} with MD5" + fn_scriptlog "verifying ${filename} with MD5: FAIL" fn_scriptlog "${filename} returned MD5 checksum: ${md5sumcmd}" fn_scriptlog "expected MD5 checksum: ${md5}" exit 1 else fn_printokeolnl - fn_scriptlog "verifyed ${filename} with MD5" + fn_scriptlog "verifying ${filename} with MD5: OK" fn_scriptlog "${filename} returned MD5 checksum: ${md5sumcmd}" fn_scriptlog "expected MD5 checksum: ${md5}" fi diff --git a/functions/install_complete.sh b/functions/install_complete.sh index b6fab789d..5ea9a127b 100644 --- a/functions/install_complete.sh +++ b/functions/install_complete.sh @@ -4,6 +4,8 @@ # Website: http://gameservermanagers.com lgsm_version="271215" +local modulename="Install" + if [ "${gamename}" == "Don't Starve Together" ]; then echo "" echo "An Authentication Token is required to run this server!" diff --git a/functions/install_config.sh b/functions/install_config.sh index 257e29fd7..a47be1157 100644 --- a/functions/install_config.sh +++ b/functions/install_config.sh @@ -4,6 +4,8 @@ # Website: http://gameservermanagers.com lgsm_version="100116" +local modulename="Install" + fn_defaultconfig(){ echo "creating ${servercfg} config file." cp -v "${servercfgdefault}" "${servercfgfullpath}" diff --git a/functions/install_gslt.sh b/functions/install_gslt.sh index b7649eade..5bd309f28 100644 --- a/functions/install_gslt.sh +++ b/functions/install_gslt.sh @@ -6,6 +6,8 @@ lgsm_version="270216" # Description: Configures GSLT. +local modulename="Install" + echo "" echo "Game Server Login Token" echo "============================" diff --git a/functions/install_header.sh b/functions/install_header.sh index ae8ab9240..2f48fdc9c 100644 --- a/functions/install_header.sh +++ b/functions/install_header.sh @@ -4,6 +4,8 @@ # Website: http://gameservermanagers.com lgsm_version="271215" +local modulename="Install" + clear echo "=================================" echo "${gamename}" diff --git a/functions/install_logs.sh b/functions/install_logs.sh index 2722ef19b..a1687d962 100644 --- a/functions/install_logs.sh +++ b/functions/install_logs.sh @@ -4,6 +4,8 @@ # Website: http://gameservermanagers.com lgsm_version="270216" +local modulename="Install" + if [ "${checklogs}" != "1" ]; then echo "" echo "Creating log directorys" diff --git a/functions/install_retry.sh b/functions/install_retry.sh index 2e7697af5..7f04ac9ed 100644 --- a/functions/install_retry.sh +++ b/functions/install_retry.sh @@ -4,6 +4,8 @@ # Website: http://gameservermanagers.com lgsm_version="271215" +local modulename="Install" + while true; do read -e -i "y" -p "Retry install? [Y/n]" yn case $yn in diff --git a/functions/install_server_dir.sh b/functions/install_server_dir.sh index 2c664e8e3..1a4f54b77 100644 --- a/functions/install_server_dir.sh +++ b/functions/install_server_dir.sh @@ -4,6 +4,8 @@ # Website: http://gameservermanagers.com lgsm_version="271215" +local modulename="Install" + echo "" echo "Server Directory" echo "=================================" diff --git a/functions/install_server_files.sh b/functions/install_server_files.sh index b99bb9692..f345c09f1 100644 --- a/functions/install_server_files.sh +++ b/functions/install_server_files.sh @@ -4,6 +4,8 @@ # Website: http://gameservermanagers.com lgsm_version="270216" +local modulename="Install" + fn_install_server_files(){ if [ "${gamename}" == "Unreal Tournament 99" ]; then fileurl="http://gameservermanagers.com/files/UnrealTournament99/ut99-server-451-ultimate-linux.tar.bz2"; filedir="${lgsmdir}/tmp"; filename="ut99-server-451-ultimate-linux.tar.bz2"; executecmd="noexecute" run="norun"; force="noforce"; md5="49cb24d0550ff6ddeaba6007045c6edd" diff --git a/functions/install_steamcmd.sh b/functions/install_steamcmd.sh index 1f744e7f6..de371bbd8 100644 --- a/functions/install_steamcmd.sh +++ b/functions/install_steamcmd.sh @@ -6,6 +6,8 @@ lgsm_version="271215" # Description: Downloads SteamCMD on install. +local modulename="Install" + echo "" echo "Installing SteamCMD" echo "=================================" diff --git a/functions/install_ts3.sh b/functions/install_ts3.sh index 27598ac56..3a2acc224 100644 --- a/functions/install_ts3.sh +++ b/functions/install_ts3.sh @@ -4,6 +4,8 @@ # Website: http://gameservermanagers.com lgsm_version="271215" +local modulename="Install" + info_distro.sh # Gets the teamspeak server architecture if [ "${arch}" == "x86_64" ]; then diff --git a/functions/install_ts3db.sh b/functions/install_ts3db.sh index 57c87b97d..90f5b0329 100644 --- a/functions/install_ts3db.sh +++ b/functions/install_ts3db.sh @@ -5,6 +5,8 @@ # Website: http://gameservermanagers.com lgsm_version="271215" +local modulename="Install" + fn_install_ts3db_mariadb(){ echo "" echo "checking if libmariadb2 is installed" diff --git a/functions/install_ut2k4_key.sh b/functions/install_ut2k4_key.sh index f582f4c16..53b603de1 100644 --- a/functions/install_ut2k4_key.sh +++ b/functions/install_ut2k4_key.sh @@ -4,6 +4,7 @@ # Website: http://gameservermanagers.com lgsm_version="271215" +local modulename="Install" echo "" echo "Enter ${gamename} CD Key" From 664c35413cd1d346a2fe55c6a22d797b02b62133 Mon Sep 17 00:00:00 2001 From: Daniel Gibbs Date: Sun, 28 Feb 2016 14:55:53 +0000 Subject: [PATCH 087/117] Fixed gsquery.py download --- functions/core_dl.sh | 4 ++-- functions/monitor_gsquery.sh | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/functions/core_dl.sh b/functions/core_dl.sh index 597a97150..8275d5770 100644 --- a/functions/core_dl.sh +++ b/functions/core_dl.sh @@ -20,7 +20,7 @@ lgsm_version="050216" fn_dl_md5(){ # Runs MD5 Check if available -if [ -n "${md5}" ]; then +if [ -n "${md5}" ]||[ "${md5}" == "nomd5" ]; then echo -ne "verifying ${filename} with MD5..." sleep 1 local md5sumcmd=$(md5sum "${filedir}/${filename}"|awk '{print $1;}') @@ -181,7 +181,7 @@ filename="${github_file_url_name}" executecmd="${4:-0}" run="${5:-0}" force="${6:-0}" -md5="${7:-0}" +md5="${7}" fn_fetch_file "${fileurl}" "${filedir}" "${filename}" "${executecmd}" "${run}" "${force}" "${md5}" } diff --git a/functions/monitor_gsquery.sh b/functions/monitor_gsquery.sh index c714d64ee..5fa63b32e 100644 --- a/functions/monitor_gsquery.sh +++ b/functions/monitor_gsquery.sh @@ -11,7 +11,7 @@ local modulename="Monitor" # Downloads gsquery.py if missing if [ ! -f "${functionsdir}/gsquery.py" ]; then - fn_fetch_file_github "functions" "gsquery.py" "${functionsdir}" "executecmd" "norun" "noforce" + fn_fetch_file_github "functions" "gsquery.py" "${functionsdir}" "executecmd" "norun" "noforce" "nomd5" fi info_config.sh From ece19b33550a2632b43e3a9aee1ed0a3a98eebd4 Mon Sep 17 00:00:00 2001 From: Daniel Gibbs Date: Sun, 28 Feb 2016 16:01:33 +0000 Subject: [PATCH 088/117] Updated messages func names Update al messages function names to make is easier to read --- functions/check_config.sh | 2 +- functions/check_deps.sh | 8 +-- functions/check_ip.sh | 2 +- functions/check_logs.sh | 4 +- functions/check_root.sh | 2 +- functions/check_steamcmd.sh | 12 ++--- functions/check_system_dir.sh | 2 +- functions/check_tmux.sh | 2 +- functions/command_backup.sh | 4 +- functions/command_console.sh | 8 +-- functions/command_debug.sh | 8 +-- functions/command_details.sh | 2 +- functions/command_dev_debug.sh | 4 +- functions/command_email_test.sh | 2 +- functions/command_monitor.sh | 26 +++++----- functions/command_start.sh | 20 ++++---- functions/command_stop.sh | 38 +++++++------- functions/command_ts3_server_pass.sh | 10 ++-- functions/command_update_functions.sh | 8 +-- functions/command_validate.sh | 6 +-- functions/core_dl.sh | 18 +++---- functions/core_messages.sh | 73 ++++++++++++++------------- functions/email.sh | 4 +- functions/fix_arma3.sh | 8 +-- functions/fix_csgo.sh | 8 +-- functions/fix_dst.sh | 8 +-- functions/fix_glibc.sh | 4 +- functions/fix_steamcmd.sh | 8 +-- functions/fn_update_functions | 6 +-- functions/install_server_dir.sh | 2 +- functions/install_server_files.sh | 6 +-- functions/install_ts3.sh | 6 +-- functions/install_ts3db.sh | 2 +- functions/logs.sh | 8 +-- functions/monitor_gsquery.sh | 20 ++++---- functions/update_check.sh | 54 ++++++++++---------- functions/update_dl.sh | 4 +- tests/tests_jc2server.sh | 12 ++--- tests/tests_ts3server.sh | 6 +-- 39 files changed, 215 insertions(+), 212 deletions(-) diff --git a/functions/check_config.sh b/functions/check_config.sh index 24d32318f..c329cca95 100644 --- a/functions/check_config.sh +++ b/functions/check_config.sh @@ -8,7 +8,7 @@ lgsm_version="060116" if [ ! -e "${servercfgfullpath}" ]; then if [ "${gamename}" != "Hurtworld" ]; then - fn_printwarnnl "Config file missing!" + fn_print_warn_nl "Config file missing!" echo "${servercfgfullpath}" fn_scriptlog "Configuration file missing!" fn_scriptlog "${servercfgfullpath}" diff --git a/functions/check_deps.sh b/functions/check_deps.sh index d562369a8..3cd5d32ce 100644 --- a/functions/check_deps.sh +++ b/functions/check_deps.sh @@ -50,15 +50,15 @@ fi fn_found_missing_deps(){ if [ "${#array_deps_missing[@]}" != "0" ]; then - fn_printdots "Checking dependencies" + fn_print_dots "Checking dependencies" sleep 2 - fn_printwarn "Checking dependencies: Dependency missing: \e[0;31m${array_deps_missing[@]}\e[0m" + fn_print_warn "Checking dependencies: Dependency missing: \e[0;31m${array_deps_missing[@]}\e[0m" fn_scriptlog "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" + fn_print_info_nl "Attempting to install missing dependencies automatically" echo -en ".\r" sleep 1 echo -en "..\r" @@ -73,7 +73,7 @@ if [ "${#array_deps_missing[@]}" != "0" ]; then fi else echo "" - fn_printinfomationnl "$(whoami) does not have sudo access. manually install dependencies" + fn_print_infomation_nl "$(whoami) does not have sudo access. manually install dependencies" fn_scriptlog "$(whoami) does not have sudo access. manually install dependencies" echo "" if [ -n "$(command -v dpkg-query)" ]; then diff --git a/functions/check_ip.sh b/functions/check_ip.sh index 3e7e86cd3..c4b5be149 100644 --- a/functions/check_ip.sh +++ b/functions/check_ip.sh @@ -20,7 +20,7 @@ else if [ "${ip}" == "0.0.0.0" ]||[ "${ip}" == "" ]; then if [ "${getipwc}" -ge "2" ]; then - fn_printwarn "Multiple active network interfaces found.\n\n" + fn_print_warn "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" diff --git a/functions/check_logs.sh b/functions/check_logs.sh index 92ed2cad1..f390eeab4 100644 --- a/functions/check_logs.sh +++ b/functions/check_logs.sh @@ -8,9 +8,9 @@ lgsm_version="271215" # Create dir's for the script and console logs if [ ! -d "${scriptlogdir}" ]; then - fn_printdots "Checking for log files" + fn_print_dots "Checking for log files" sleep 1 - fn_printinfo "Checking for log files: Creating log files" + fn_print_info "Checking for log files: Creating log files" echo -en "\n" checklogs=1 install_logs.sh diff --git a/functions/check_root.sh b/functions/check_root.sh index 8f2e5ed54..1a37cef57 100644 --- a/functions/check_root.sh +++ b/functions/check_root.sh @@ -5,7 +5,7 @@ lgsm_version="271215" if [ $(whoami) = "root" ]; then - fn_printfailnl "Do NOT run this script as root!" + fn_print_fail_nl "Do NOT run this script as root!" if [ -d "${scriptlogdir}" ]; then fn_scriptlog "${selfname} attempted to run as root." fi diff --git a/functions/check_steamcmd.sh b/functions/check_steamcmd.sh index 760b0b835..4039c4ef8 100644 --- a/functions/check_steamcmd.sh +++ b/functions/check_steamcmd.sh @@ -20,7 +20,7 @@ chmod +x "${steamcmddir}/steamcmd.sh" fn_check_steamcmd_user(){ # Checks steamuser is setup. if [ "${steamuser}" == "username" ]; then - fn_printfailnl "Steam login not set. Update steamuser." + fn_print_fail_nl "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." @@ -29,7 +29,7 @@ if [ "${steamuser}" == "username" ]; then fi # Anonymous user is set if steamuser is missing if [ -z "${steamuser}" ]; then - fn_printwarnnl "Steam login not set. Using anonymous login." + fn_print_warn_nl "Steam login not set. Using anonymous login." if [ -d "${scriptlogdir}" ]; then fn_scriptlog "Steam login not set. Using anonymous login." fi @@ -47,14 +47,14 @@ if [ ! -f "${steamcmddir}/steamcmd.sh" ]; then if [ "${function_selfname}" == "command_install.sh" ]; then fn_install_steamcmd else - fn_printwarnnl "SteamCMD is missing" + fn_print_warn_nl "SteamCMD is missing" fn_scriptlog "SteamCMD is missing" sleep 1 fn_install_steamcmd fi elif [ "${function_selfname}" == "command_install.sh" ]; then - fn_printinfomation "SteamCMD is already installed..." - fn_printokeolnl + fn_print_infomation "SteamCMD is already installed..." + fn_print_ok_eol_nl fi } @@ -63,7 +63,7 @@ if [ "${function_selfname}" == "command_update.sh" ]||[ "${function_selfname}" = # Checks that steamcmd is working correctly and will prompt Steam Guard if required. "${steamcmddir}"/steamcmd.sh +login "${steamuser}" "${steampass}" +quit if [ $? -ne 0 ]; then - fn_printfailurenl "Error running SteamCMD" + fn_print_failure_nl "Error running SteamCMD" fi fi } diff --git a/functions/check_system_dir.sh b/functions/check_system_dir.sh index ecada4e09..d5d57e75b 100644 --- a/functions/check_system_dir.sh +++ b/functions/check_system_dir.sh @@ -5,7 +5,7 @@ lgsm_version="271215" if [ ! -d "${systemdir}" ]; then - fn_printfailnl "Cannot access ${systemdir}: No such directory" + fn_print_fail_nl "Cannot access ${systemdir}: No such directory" if [ -d "${scriptlogdir}" ]; then fn_scriptlog "Cannot access ${systemdir}: No such directory." fi diff --git a/functions/check_tmux.sh b/functions/check_tmux.sh index ac142ebe4..49f43dd21 100644 --- a/functions/check_tmux.sh +++ b/functions/check_tmux.sh @@ -9,7 +9,7 @@ lgsm_version="271215" if [ "$(command -v tmux)" ]||[ "$(which tmux >/dev/null 2>&1)" ]||[ -f "/usr/bin/tmux" ]||[ -f "/bin/tmux" ]; then : else - fn_printfailnl "Tmux not installed" + fn_print_fail_nl "Tmux not installed" sleep 1 fn_scriptlog "Tmux is not installed" echo " * Tmux is required to run this server." diff --git a/functions/command_backup.sh b/functions/command_backup.sh index 5f923ad07..d8d52f4bc 100644 --- a/functions/command_backup.sh +++ b/functions/command_backup.sh @@ -30,7 +30,7 @@ done tmuxwc=$(tmux list-sessions 2>&1|awk '{print $1}'|grep -v failed|grep -Ec "^${servicename}:") if [ "${tmuxwc}" -eq 1 ]; then echo "" - fn_printwarningnl "${servicename} is currently running." + fn_print_warning_nl "${servicename} is currently running." sleep 1 while true; do read -p "Stop ${servicename} while running the backup? [y/N]" yn @@ -59,6 +59,6 @@ echo "Backup created: ${backupdir}/${backupname}.tar.gz" fn_scriptlog "Created: ${backupdir}/${backupname}.tar.gz" sleep 1 echo "" -fn_printcompletenl "Complete." +fn_print_complete_nl "Complete." fn_scriptlog "Complete" echo "" diff --git a/functions/command_console.sh b/functions/command_console.sh index 4eab4d6eb..f7f2c1323 100644 --- a/functions/command_console.sh +++ b/functions/command_console.sh @@ -15,7 +15,7 @@ echo "${gamename} Console" echo "============================" echo "" echo "Press \"CTRL+b d\" to exit console." -fn_printwarningnl "Do NOT press CTRL+c to exit." +fn_print_warning_nl "Do NOT press CTRL+c to exit." echo "" while true; do read -e -i "y" -p "Continue? [y/N]" yn @@ -25,16 +25,16 @@ while true; do * ) echo "Please answer yes or no.";; esac done -fn_printdots "Starting" +fn_print_dots "Starting" sleep 1 tmuxwc=$(tmux list-sessions 2>&1|awk '{print $1}'|grep -v failed|grep -Ec "^${servicename}:") if [ "${tmuxwc}" -eq 1 ]; then - fn_printoknl "Starting" + fn_print_ok_nl "Starting" fn_scriptlog "accessed" sleep 1 tmux attach-session -t ${servicename} else - fn_printfailnl "Server not running" + fn_print_fail_nl "Server not running" fn_scriptlog "Failed to access: Server not running" sleep 1 while true; do diff --git a/functions/command_debug.sh b/functions/command_debug.sh index 097ddf289..7c9aca38b 100644 --- a/functions/command_debug.sh +++ b/functions/command_debug.sh @@ -31,7 +31,7 @@ fi echo "" echo -e "Use for identifying server issues only!" echo -e "Press CTRL+c to drop out of debug mode." -fn_printwarningnl "If ${servicename} is already running it will be stopped." +fn_print_warning_nl "If ${servicename} is already running it will be stopped." echo "" while true; do read -e -i "y" -p "Continue? [Y/n]" yn @@ -42,13 +42,13 @@ while true; do esac done fn_scriptlog "Starting debug" -fn_printinfonl "Stopping any running servers" +fn_print_info_nl "Stopping any running servers" fn_scriptlog "Stopping any running servers" sleep 1 command_stop.sh -fn_printdots "Starting debug" +fn_print_dots "Starting debug" sleep 1 -fn_printok "Starting debug" +fn_print_ok "Starting debug" fn_scriptlog "Started debug" sleep 1 echo -en "\n" diff --git a/functions/command_details.sh b/functions/command_details.sh index 0084f20e5..177575fe8 100644 --- a/functions/command_details.sh +++ b/functions/command_details.sh @@ -628,5 +628,5 @@ elif [ "${gamename}" == "7 Days To Die" ]; then elif [ "${gamename}" == "Teamspeak 3" ]; then fn_details_teamspeak3 else - fn_printerrornl "Unable to detect server engine." + fn_print_error_nl "Unable to detect server engine." fi diff --git a/functions/command_dev_debug.sh b/functions/command_dev_debug.sh index e2c9d9cc5..1855f5919 100644 --- a/functions/command_dev_debug.sh +++ b/functions/command_dev_debug.sh @@ -8,8 +8,8 @@ function_selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))" if [ -f ".dev-debug" ]; then rm .dev-debug - fn_printoknl "Disabled dev-debug" + fn_print_ok_nl "Disabled dev-debug" else date > .dev-debug - fn_printoknl "Enabled dev-debug" + fn_print_ok_nl "Enabled dev-debug" fi \ No newline at end of file diff --git a/functions/command_email_test.sh b/functions/command_email_test.sh index b24ff3b01..26a0b6a42 100644 --- a/functions/command_email_test.sh +++ b/functions/command_email_test.sh @@ -17,6 +17,6 @@ if [ "${emailnotification}" = "on" ]; then actiontaken="Sent test email...hello is this thing on?" email.sh else - fn_printfailnl "Notifications not enabled" + fn_print_fail_nl "Notifications not enabled" fn_scriptlog "Notifications not enabled" fi \ No newline at end of file diff --git a/functions/command_monitor.sh b/functions/command_monitor.sh index f253abc54..e09b6236c 100644 --- a/functions/command_monitor.sh +++ b/functions/command_monitor.sh @@ -13,33 +13,33 @@ function_selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))" fn_monitor_teamspeak3(){ check.sh logs.sh -fn_printdots "${servername}" +fn_print_dots "${servername}" fn_scriptlog "${servername}" sleep 1 if [ ! -f "${rootdir}/${lockselfname}" ]; then - fn_printinfo "Disabled: No lock file found" + fn_print_info "Disabled: No lock file found" fn_scriptlog "Disabled: No lock file found" sleep 1 echo -en "\n" echo "To enable monitor run ./${selfname} start" exit 1 fi -fn_printdots "Checking session: CHECKING" +fn_print_dots "Checking session: CHECKING" fn_scriptlog "Checking session: CHECKING" sleep 1 info_ts3status.sh if [ "${ts3status}" = "Server is running" ]; then - fn_printok "Checking session: OK" + fn_print_ok "Checking session: OK" fn_scriptlog "Checking session: OK" sleep 1 sleep 0.5 echo -en "\n" exit else - fn_printfail "Checking session: FAIL" + fn_print_fail "Checking session: FAIL" fn_scriptlog "Checking session: FAIL" sleep 1 - fn_printfail "Checking session: FAIL: ${ts3status}" + fn_print_fail "Checking session: FAIL: ${ts3status}" fn_scriptlog "Checking session: FAIL: ${ts3status}" failurereason="${ts3status}" if [ "${emailnotification}" = "on" ]; then @@ -56,11 +56,11 @@ fn_restart fn_monitor_tmux(){ check.sh info_config.sh -fn_printdots "${servername}" +fn_print_dots "${servername}" fn_scriptlog "${servername}" sleep 1 if [ ! -f "${rootdir}/${lockselfname}" ]; then - fn_printinfo "Disabled: No lock file found" + fn_print_info "Disabled: No lock file found" fn_scriptlog "Disabled: No lock file found" sleep 1 echo -en "\n" @@ -70,12 +70,12 @@ fi updatecheck=$(ps -ef|grep "${selfname} update"|grep -v grep|wc -l) if [ "${updatecheck}" = "0" ]||[ "${gamename}" == "Unreal Tournament 99" ]||[ "${gamename}" == "Unreal Tournament 2004" ]; then - fn_printdots "Checking session: CHECKING" + fn_print_dots "Checking session: CHECKING" fn_scriptlog "Checking session: CHECKING" sleep 1 tmuxwc=$(tmux list-sessions 2>&1|awk '{print $1}'|grep -v failed|grep -Ec "^${servicename}:") if [ "${tmuxwc}" -eq 1 ]; then - fn_printok "Checking session: OK" + fn_print_ok "Checking session: OK" fn_scriptlog "Checking session: OK" sleep 1 echo -en "\n" @@ -85,7 +85,7 @@ if [ "${updatecheck}" = "0" ]||[ "${gamename}" == "Unreal Tournament 99" ]||[ "$ fi exit $? else - fn_printfail "Checking session: FAIL" + fn_print_fail "Checking session: FAIL" fn_scriptlog "Checking session: FAIL" sleep 1 echo -en "\n" @@ -99,10 +99,10 @@ if [ "${updatecheck}" = "0" ]||[ "${gamename}" == "Unreal Tournament 99" ]||[ "$ command_start.sh fi else - fn_printinfonl "SteamCMD is currently checking for updates" + fn_print_info_nl "SteamCMD is currently checking for updates" fn_scriptlog "SteamCMD is currently checking for updates" sleep 1 - fn_printinfonl "When update is complete ${servicename} will start" + fn_print_info_nl "When update is complete ${servicename} will start" fn_scriptlog "When update is complete ${servicename} will start" sleep 1 fi diff --git a/functions/command_start.sh b/functions/command_start.sh index 309a8078f..fd30a17bb 100644 --- a/functions/command_start.sh +++ b/functions/command_start.sh @@ -21,7 +21,7 @@ if [ "${ts3status}" != "Server is running" ]; then fi if [ ! -e "${servercfgfullpath}" ]; then - fn_printwarn "${servercfgfullpath} is missing" + fn_print_warn "${servercfgfullpath} is missing" fn_scriptlog "${servercfgfullpath} is missing" sleep 2 echo -en "\n" @@ -39,12 +39,12 @@ fi logs.sh -fn_printdots "${servername}" +fn_print_dots "${servername}" fn_scriptlog "${servername}" sleep 1 if [ "${ts3status}" == "Server is running" ]; then - fn_printinfo "${servername} is already running" + fn_print_info "${servername} is already running" fn_scriptlog "${servername} is already running" sleep 1 echo -en "\n" @@ -63,12 +63,12 @@ fi sleep 1 info_ts3status.sh if [ "${ts3status}" = "Server seems to have died" ]||[ "${ts3status}" = "No server running (ts3server.pid is missing)" ]; then - fn_printfailnl "Unable to start ${servername}" + fn_print_fail_nl "Unable to start ${servername}" fn_scriptlog "Unable to start ${servername}" echo -e " Check log files: ${rootdir}/log" exit 1 else - fn_printok "${servername}" + fn_print_ok "${servername}" fn_scriptlog "Started ${servername}" fi sleep 0.5 @@ -90,7 +90,7 @@ if [ "${tmuxwc}" -eq 0 ]; then fi fi -fn_printdots "${servername}" +fn_print_dots "${servername}" fn_scriptlog "${servername}" sleep 1 @@ -104,7 +104,7 @@ if [ "${tmuxwc}" -eq 0 ]; then fi if [ "${tmuxwc}" -eq 1 ]; then - fn_printinfo "${servername} is already running" + fn_print_info "${servername} is already running" fn_scriptlog "${servername} is already running" sleep 1 echo -en "\n" @@ -132,11 +132,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_printfailnl "Unable to start ${servername}" + fn_print_fail_nl "Unable to start ${servername}" fn_scriptlog "Unable to start ${servername}" sleep 1 if [ -s "${scriptlogdir}/.${servicename}-tmux-error.tmp" ]; then - fn_printfailnl "Unable to start ${servername}: Tmux error:" + fn_print_fail_nl "Unable to start ${servername}: Tmux error:" fn_scriptlog "Tmux error" sleep 1 echo -en "\n" @@ -180,7 +180,7 @@ if [ "${tmuxwc}" -eq 0 ]; then fi exit 1 else - fn_printok "${servername}" + fn_print_ok "${servername}" fn_scriptlog "Started ${servername}" fi rm "${scriptlogdir}/.${servicename}-tmux-error.tmp" diff --git a/functions/command_stop.sh b/functions/command_stop.sh index 98d21c9a5..d5d589beb 100644 --- a/functions/command_stop.sh +++ b/functions/command_stop.sh @@ -31,16 +31,16 @@ sdtd_telnet(){ fn_stop_teamspeak3(){ check.sh -fn_printdots "${servername}" +fn_print_dots "${servername}" fn_scriptlog "${servername}" sleep 1 info_ts3status.sh if [ "${ts3status}" = "No server running (ts3server.pid is missing)" ]; then - fn_printfail "${servername} is already stopped" + fn_print_fail "${servername} is already stopped" fn_scriptlog "${servername} is already stopped" else ${filesdir}/ts3server_startscript.sh stop > /dev/null 2>&1 - fn_printok "${servername}" + fn_print_ok "${servername}" fn_scriptlog "Stopped ${servername}" fi # Remove lock file @@ -52,14 +52,14 @@ echo -en "\n" fn_stop_tmux(){ check.sh info_config.sh -fn_printdots "${servername}" +fn_print_dots "${servername}" fn_scriptlog "${servername}" sleep 1 if [ "${gamename}" == "7 Days To Die" ] ; then # if game is 7 Days To Die, we need special, graceful shutdown via telnet connection. # Set below variable to be called for expect to operate correctly.. - fn_printdots "Attempting graceful shutdown via telnet" + fn_print_dots "Attempting graceful shutdown via telnet" fn_scriptlog "Attempting graceful shutdown via telnet" sleep 1 telnetip=127.0.0.1 @@ -69,11 +69,11 @@ if [ "${gamename}" == "7 Days To Die" ] ; then refused=$(echo -en "\n ${sdtdshutdown}"| grep "Timeout or EOF") if [ -n "${refused}" ]; then telnetip=${ip} - fn_printwarn "Attempting graceful shutdown via telnet: localhost failed" + fn_print_warn "Attempting graceful shutdown via telnet: localhost failed" fn_scriptlog "Warning! Attempting graceful shutdown failed using localhost" sleep 5 echo -en "\n" - fn_printdots "Attempting graceful shutdown via telnet: using ${telnetip}" + fn_print_dots "Attempting graceful shutdown via telnet: using ${telnetip}" fn_scriptlog "Attempting graceful shutdown via telnet using ${telnetip}" sdtd_telnet sleep 1 @@ -82,14 +82,14 @@ if [ "${gamename}" == "7 Days To Die" ] ; then refused=$(echo -en "\n ${sdtdshutdown}"| grep "Timeout or EOF") completed=$(echo -en "\n ${sdtdshutdown}"| grep "Completed.") if [ -n "${refused}" ]; then - fn_printfail "Attempting graceful shutdown via telnet" + fn_print_fail "Attempting graceful shutdown via telnet" fn_scriptlog "Attempting graceful shutdown failed" fn_scriptlog "${refused}" elif [ -n "${completed}" ]; then - fn_printok "Attempting graceful shutdown via telnet" + fn_print_ok "Attempting graceful shutdown via telnet" fn_scriptlog "Attempting graceful shutdown succeeded" else - fn_printfail "Attempting graceful shutdown via telnet: Unknown error" + fn_print_fail "Attempting graceful shutdown via telnet: Unknown error" fn_scriptlog "Attempting graceful shutdown failed" fn_scriptlog "Unknown error" fi @@ -99,29 +99,29 @@ if [ "${gamename}" == "7 Days To Die" ] ; then echo -en "\n ${sdtdshutdown}" echo -en "\n\n" sleep 1 - fn_printdots "${servername}" + fn_print_dots "${servername}" fn_scriptlog "${servername}" sleep 5 pid=$(tmux list-sessions 2>&1|awk '{print $1}'|grep -Ec "^${servicename}:") if [ "${pid}" == "0" ]; then - fn_printok "${servername} is already stopped using graceful shutdown" + fn_print_ok "${servername} is already stopped using graceful shutdown" fn_scriptlog "${servername} is already stopped using graceful shutdown" else tmux kill-session -t "${servicename}" - fn_printok "${servername}" + fn_print_ok "${servername}" fn_scriptlog "Stopped ${servername}" fi else pid=$(tmux list-sessions 2>&1|awk '{print $1}'|grep -Ec "^${servicename}:") if [ "${pid}" == "0" ]; then - fn_printfail "${servername} is already stopped" + fn_print_fail "${servername} is already stopped" fn_scriptlog "${servername} is already stopped" else if [ "${engine}" == "source" ]||[ "${engine}" == "goldsource" ]; then sleep 1 - fn_printdots "Attempting graceful shutdown" + fn_print_dots "Attempting graceful shutdown" fn_scriptlog "Attempting graceful shutdown" tmux send -t "${servicename}" quit ENTER > /dev/null 2>&1 counter=0 @@ -130,19 +130,19 @@ else sleep 1 let counter=counter+1 if [ "${counter}" -gt "1" ]; then - fn_printdots "Attempting graceful shutdown: ${counter}" + fn_print_dots "Attempting graceful shutdown: ${counter}" fi done pid=$(tmux list-sessions 2>&1|awk '{print $1}'|grep -Ec "^${servicename}:") if [ "${pid}" == "0" ]; then - fn_printok "Attempting graceful shutdown" + fn_print_ok "Attempting graceful shutdown" else - fn_printfail "Attempting graceful shutdown" + fn_print_fail "Attempting graceful shutdown" fi fi tmux kill-session -t "${servicename}" > /dev/null 2>&1 - fn_printok "${servername}" + fn_print_ok "${servername}" fn_scriptlog "Stopped ${servername}" fi fi diff --git a/functions/command_ts3_server_pass.sh b/functions/command_ts3_server_pass.sh index 3cd0f0b1f..eba76523a 100644 --- a/functions/command_ts3_server_pass.sh +++ b/functions/command_ts3_server_pass.sh @@ -17,8 +17,8 @@ echo "${gamename} ServerAdmin Password Change" echo "============================" echo "" echo "Press \"CTRL+b d\" to exit console." -fn_printinfomationnl "You are about to change the ${gamename} ServerAdmin password." -fn_printwarningnl "${gamename} will restart during this process." +fn_print_infomation_nl "You are about to change the ${gamename} ServerAdmin password." +fn_print_warning_nl "${gamename} will restart during this process." echo "" while true; do read -e -i "y" -p "Continue? [y/N]" yn @@ -34,18 +34,18 @@ read -p "Enter new password : " newpassword fn_serveradmin_password_set(){ -fn_printinfonl "Applying new password" +fn_print_info_nl "Applying new password" fn_scriptlog "Applying new password" sleep 1 # Stop any running server command_stop.sh # Start server in "new password mode" ts3serverpass="1" -fn_printinfonl "Starting server with new password" +fn_print_info_nl "Starting server with new password" command_start.sh # Stop server in "new password mode" command_stop.sh -fn_printoknl "Password applied" +fn_print_ok_nl "Password applied" fn_scriptlog "New ServerAdmin password applied" sleep 1 } diff --git a/functions/command_update_functions.sh b/functions/command_update_functions.sh index 3c530e4a0..9c0ac4b90 100644 --- a/functions/command_update_functions.sh +++ b/functions/command_update_functions.sh @@ -8,7 +8,7 @@ lgsm_version="270216" function_selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))" check.sh -fn_printdots "Updating functions" +fn_print_dots "Updating functions" fn_scriptlog "Updating functions" sleep 1 echo -ne "\n" @@ -23,15 +23,15 @@ if [ -n "${functionsdir}" ]; then rm -rfv "${functionsdir}/"* exitcode=$? else - fn_printfail "Updating functions" + fn_print_fail "Updating functions" fn_scriptlog "Failure! Updating functions" fi if [ "${exitcode}" == "0" ]; then - fn_printok "Updating functions" + fn_print_ok "Updating functions" fn_scriptlog "Success! Updating functions" else - fn_printfail "Updating functions" + fn_print_fail "Updating functions" fn_scriptlog "Failure! Updating functions" fi echo -ne "\n" \ No newline at end of file diff --git a/functions/command_validate.sh b/functions/command_validate.sh index 40e23c01e..59c03b6ff 100644 --- a/functions/command_validate.sh +++ b/functions/command_validate.sh @@ -10,15 +10,15 @@ local modulename="Validate" function_selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))" fn_validation(){ -fn_printwarn "Validating may overwrite some customised files." +fn_print_warn "Validating may overwrite some customised files." sleep 1 echo -en "\n" echo -en "https://developer.valvesoftware.com/wiki/SteamCMD#Validate" sleep 5 echo -en "\n" -fn_printdots "Checking server files" +fn_print_dots "Checking server files" sleep 1 -fn_printok "Checking server files" +fn_print_ok "Checking server files" fn_scriptlog "Checking server files" sleep 1 diff --git a/functions/core_dl.sh b/functions/core_dl.sh index 8275d5770..cf3a2d777 100644 --- a/functions/core_dl.sh +++ b/functions/core_dl.sh @@ -25,7 +25,7 @@ if [ -n "${md5}" ]||[ "${md5}" == "nomd5" ]; then sleep 1 local md5sumcmd=$(md5sum "${filedir}/${filename}"|awk '{print $1;}') if [ "${md5sumcmd}" != "${md5}" ]; then - fn_printfaileolnl + fn_print_fail_eol_nl echo "${filename} returned MD5 checksum: ${md5sumcmd}" echo "expected MD5 checksum: ${md5}" fn_scriptlog "verifying ${filename} with MD5: FAIL" @@ -33,7 +33,7 @@ if [ -n "${md5}" ]||[ "${md5}" == "nomd5" ]; then fn_scriptlog "expected MD5 checksum: ${md5}" exit 1 else - fn_printokeolnl + fn_print_ok_eol_nl fn_scriptlog "verifying ${filename} with MD5: OK" fn_scriptlog "${filename} returned MD5 checksum: ${md5sumcmd}" fn_scriptlog "expected MD5 checksum: ${md5}" @@ -61,12 +61,12 @@ elif [ "${mime}" == "application/x-bzip2" ]; then fi local exitcode=$? if [ ${exitcode} -ne 0 ]; then - fn_printfaileolnl + fn_print_fail_eol_nl fn_scriptlog "extracting download: FAIL" echo "${tarcmd}" | tee -a "${scriptlog}" exit ${exitcode} else - fn_printokeolnl + fn_print_ok_eol_nl fi } @@ -74,12 +74,12 @@ fi fn_fetch_trap() { echo "" echo -ne "downloading ${filename}: " - fn_printcanceledeol + fn_print_canceled_eol fn_scriptlog "downloading ${filename}: CANCELED" sleep 1 rm -f "${filedir}/${filename}" | tee -a "${scriptlog}" echo -ne "downloading ${filename}: " - fn_printremovedeol + fn_print_removed_eol fn_scriptlog "downloading ${filename}: REMOVED" exit } @@ -123,7 +123,7 @@ if [ ! -f "${filedir}/${filename}" ]; then fi local exitcode=$? if [ ${exitcode} -ne 0 ]; then - fn_printfaileolnl + fn_print_fail_eol_nl if [ -f "${scriptlog}" ]; then fn_scriptlog "downloading ${filename}: FAIL" fi @@ -131,7 +131,7 @@ if [ ! -f "${filedir}/${filename}" ]; then echo -e "${fileurl}\n" | tee -a "${scriptlog}" exit ${exitcode} else - fn_printokeolnl + fn_print_ok_eol_nl if [ -f "${scriptlog}" ]; then fn_scriptlog "downloading ${filename}: OK" fi @@ -139,7 +139,7 @@ if [ ! -f "${filedir}/${filename}" ]; then # remove trap trap - INT else - fn_printfaileolnl + fn_print_fail_eol_nl echo "Curl is not installed!" echo -e "" exit 1 diff --git a/functions/core_messages.sh b/functions/core_messages.sh index 56251e6db..6581d2f17 100644 --- a/functions/core_messages.sh +++ b/functions/core_messages.sh @@ -6,6 +6,9 @@ lgsm_version="380216" # Description: Defines on-screen messages such as [ OK ] and how script logs look. +# nl: new line: message is following by a new line +# eol: end of line: message is placed at the end of the current line + # Date and servicename for log files. fn_scriptlog(){ if [ -n "${modulename}" ]; then @@ -16,7 +19,7 @@ fn_scriptlog(){ } # [ FAIL ] -fn_printfail(){ +fn_print_fail(){ if [ -n "${modulename}" ]; then echo -en "\r\033[K[\e[0;31m FAIL \e[0m] ${modulename} ${servicename}: $@" else @@ -24,7 +27,7 @@ fn_printfail(){ fi } -fn_printfailnl(){ +fn_print_fail_nl(){ if [ -n "${modulename}" ]; then echo -e "\r\033[K[\e[0;31m FAIL \e[0m] ${modulename} ${servicename}: $@" else @@ -33,7 +36,7 @@ fn_printfailnl(){ } # [ OK ] -fn_printok(){ +fn_print_ok(){ if [ -n "${modulename}" ]; then echo -en "\r\033[K[\e[0;32m OK \e[0m] ${modulename} ${servicename}: $@" else @@ -41,7 +44,7 @@ fn_printok(){ fi } -fn_printoknl(){ +fn_print_ok_nl(){ if [ -n "${modulename}" ]; then echo -e "\r\033[K[\e[0;32m OK \e[0m] ${modulename} ${servicename}: $@" else @@ -50,7 +53,7 @@ fn_printoknl(){ } # [ INFO ] -fn_printinfo(){ +fn_print_info(){ if [ -n "${modulename}" ]; then echo -en "\r\033[K[\e[0;36m INFO \e[0m] ${modulename} ${servicename}: $@" else @@ -58,7 +61,7 @@ fn_printinfo(){ fi } -fn_printinfonl(){ +fn_print_info_nl(){ if [ -n "${modulename}" ]; then echo -e "\r\033[K[\e[0;36m INFO \e[0m] ${modulename} ${servicename}: $@" else @@ -67,7 +70,7 @@ fn_printinfonl(){ } # [ WARN ] -fn_printwarn(){ +fn_print_warn(){ if [ -n "${modulename}" ]; then echo -en "\r\033[K[\e[1;33m WARN \e[0m] ${modulename} ${servicename}: $@" else @@ -75,7 +78,7 @@ fn_printwarn(){ fi } -fn_printwarnnl(){ +fn_print_warn_nl(){ if [ -n "${modulename}" ]; then echo -e "\r\033[K[\e[1;33m WARN \e[0m] ${modulename} ${servicename}: $@" else @@ -84,7 +87,7 @@ fn_printwarnnl(){ } # [ .... ] -fn_printdots(){ +fn_print_dots(){ if [ -n "${modulename}" ]; then echo -en "\r\033[K[ .... ] ${modulename} ${servicename}: $@" else @@ -93,91 +96,91 @@ fn_printdots(){ } # Complete! -fn_printcomplete(){ +fn_print_complete(){ echo -en "\e[0;32mComplete!\e[0m $@" } -fn_printcompletenl(){ +fn_print_complete_nl(){ echo -e "\e[0;32mComplete!\e[0m $@" } # Warning! -fn_printwarning(){ +fn_print_warning(){ echo -en "\e[0;33mWarning!\e[0m $@" } -fn_printwarningnl(){ +fn_print_warning_nl(){ echo -e "\e[0;33mWarning!\e[0m $@" } # Failure! -fn_printfailure(){ +fn_print_failure(){ echo -en "\e[0;31mFailure!\e[0m $@" } -fn_printfailurenl(){ +fn_print_failure_nl(){ echo -e "\e[0;31mFailure!\e[0m $@" } # Error! -fn_printerror(){ +fn_print_error(){ echo -en "\e[0;31mError!\e[0m $@" } -fn_printerrornl(){ +fn_print_error_nl(){ echo -e "\e[0;31mError!\e[0m $@" } # Info! -fn_printinfomation(){ - echo -en "\e[0;36mInfo!\e[0m $@" +fn_print_infomation(){ + echo -en "\e[0;36mInfomation!\e[0m $@" } -fn_printinfomationnl(){ - echo -e "\e[0;36mInfo!\e[0m $@" +fn_print_infomation_nl(){ + echo -e "\e[0;36mInfomation!\e[0m $@" } # FAIL for end of line -fn_printokeol(){ +fn_print_ok_eol(){ echo -en "\e[0;32mOK\e[0m" } -fn_printokeolnl(){ +fn_print_ok_eol_nl(){ echo -e "\e[0;32mOK\e[0m" } # FAIL for end of line -fn_printfaileol(){ +fn_print_fail_eol(){ echo -en "\e[0;31mFAIL\e[0m\n" } -fn_printfaileolnl(){ +fn_print_fail_eol_nl(){ echo -e "\e[0;31mFAIL\e[0m\n" } # QUERYING for end of line -fn_printqueryingeol(){ - echo -en "\e[0;31mQUERYING\e[0m\n" +fn_print_querying_eol(){ + echo -en "\e[0;36mQUERYING\e[0m\n" } -fn_printqueryingeolnl(){ - echo -e "\e[0;31mQUERYING\e[0m\n" +fn_print_querying_eol_nl(){ + echo -e "\e[0;36mQUERYING\e[0m\n" } # CANCELED for end of line -fn_printcanceledeol(){ - echo -en "\e[0;31mCANCELED\e[0m\n" +fn_print_canceled_eol(){ + echo -en "\e[0;33mCANCELED\e[0m\n" } -fn_printcanceledeolnl(){ - echo -e "\e[0;31mCANCELED\e[0m\n" +fn_print_canceled_eol_nl(){ + echo -e "\e[0;33mCANCELED\e[0m\n" } # REMOVED for end of line -fn_printremovedeol(){ +fn_print_removed_eol(){ echo -en "\e[0;31mREMOVED\e[0m\n" } -fn_printremovedeolnl(){ +fn_print_removed_eol_nl(){ echo -e "\e[0;31mREMOVED\e[0m\n" } \ No newline at end of file diff --git a/functions/email.sh b/functions/email.sh index 93d259d80..66d5acba7 100644 --- a/functions/email.sh +++ b/functions/email.sh @@ -7,7 +7,7 @@ lgsm_version="020216" # Description: Sends email notification if monitor picks up a failure. local modulename="Email" -fn_printdots "Sending notification to ${email}" +fn_print_dots "Sending notification to ${email}" info_distro.sh info_config.sh check_ip.sh @@ -64,7 +64,7 @@ if [ ! -z "${gamelogdir}" ]; then tail "${gamelogdir}"/* | grep -v "==>" | sed '/^$/d' | tail -25 >> "${emaillog}" fi mail -s "${subject}" ${email} < "${emaillog}" -fn_printok "Sending notification to ${email}" +fn_print_ok "Sending notification to ${email}" fn_scriptlog "Sent notification to ${email}" sleep 1 echo -en "\n" diff --git a/functions/fix_arma3.sh b/functions/fix_arma3.sh index b0a1317de..b076fe065 100644 --- a/functions/fix_arma3.sh +++ b/functions/fix_arma3.sh @@ -7,19 +7,19 @@ lgsm_version="301215" # Fixes line 63: 20150 Segmentation fault (core dumped) #488 fn_msg_start(){ - fn_printdots "Applying ${fixname} fix: ${gamename}" + fn_print_dots "Applying ${fixname} fix: ${gamename}" sleep 1 - fn_printinfo "Applying ${fixname} fix: ${gamename}" + fn_print_info "Applying ${fixname} fix: ${gamename}" fn_scriptlog "Applying ${fixname} fix: ${gamename}" sleep 1 } fn_msg_end(){ if [ $? -ne 0 ]; then - fn_printfailnl "Applying ${fixname} fix: ${gamename}" + fn_print_fail_nl "Applying ${fixname} fix: ${gamename}" fn_scriptlog "Failure! Applying ${fixname} fix: ${gamename}" else - fn_printoknl "Applying ${fixname} fix: ${gamename}" + fn_print_ok_nl "Applying ${fixname} fix: ${gamename}" fn_scriptlog "Complete! Applying ${fixname} fix: ${gamename}" fi } diff --git a/functions/fix_csgo.sh b/functions/fix_csgo.sh index 4227d36eb..33fd7c169 100644 --- a/functions/fix_csgo.sh +++ b/functions/fix_csgo.sh @@ -7,19 +7,19 @@ lgsm_version="301215" # Description: Resolves various issues with csgo. fn_msg_start(){ - fn_printdots "Applying ${fixname} fix: ${gamename}" + fn_print_dots "Applying ${fixname} fix: ${gamename}" sleep 1 - fn_printinfo "Applying ${fixname} fix: ${gamename}" + fn_print_info "Applying ${fixname} fix: ${gamename}" fn_scriptlog "Applying ${fixname} fix: ${gamename}" sleep 1 } fn_msg_end(){ if [ $? -ne 0 ]; then - fn_printfailnl "Applying ${fixname} fix: ${gamename}" + fn_print_fail_nl "Applying ${fixname} fix: ${gamename}" fn_scriptlog "Failure! Applying ${fixname} fix: ${gamename}" else - fn_printoknl "Applying ${fixname} fix: ${gamename}" + fn_print_ok_nl "Applying ${fixname} fix: ${gamename}" fn_scriptlog "Complete! Applying ${fixname} fix: ${gamename}" fi } diff --git a/functions/fix_dst.sh b/functions/fix_dst.sh index 7a0028504..b860f6d09 100644 --- a/functions/fix_dst.sh +++ b/functions/fix_dst.sh @@ -7,19 +7,19 @@ lgsm_version="020116" # Fixes line 63: 20150 Segmentation fault (core dumped) #488 fn_msg_start(){ - fn_printdots "Applying ${fixname} fix: ${gamename}" + fn_print_dots "Applying ${fixname} fix: ${gamename}" sleep 1 - fn_printinfo "Applying ${fixname} fix: ${gamename}" + fn_print_info "Applying ${fixname} fix: ${gamename}" fn_scriptlog "Applying ${fixname} fix: ${gamename}" sleep 1 } fn_msg_end(){ if [ $? -ne 0 ]; then - fn_printfailnl "Applying ${fixname} fix: ${gamename}" + fn_print_fail_nl "Applying ${fixname} fix: ${gamename}" fn_scriptlog "Failure! Applying ${fixname} fix: ${gamename}" else - fn_printoknl "Applying ${fixname} fix: ${gamename}" + fn_print_ok_nl "Applying ${fixname} fix: ${gamename}" fn_scriptlog "Complete! Applying ${fixname} fix: ${gamename}" fi } diff --git a/functions/fix_glibc.sh b/functions/fix_glibc.sh index 83422f12b..c46a1b5a0 100644 --- a/functions/fix_glibc.sh +++ b/functions/fix_glibc.sh @@ -9,7 +9,7 @@ echo "" echo "GLIBC Fix required" echo "============================" sleep 1 -fn_printwarningnl "${gamename} requires GLIBC_${glibcversion} or above" +fn_print_warning_nl "${gamename} requires GLIBC_${glibcversion} or above" sleep 1 echo "" echo -e "Currently installed:\e[0;31m GLIBC_$(ldd --version |grep ldd|awk '{print $NF}')\e[0;39m" @@ -34,7 +34,7 @@ echo -en "\n" # if ldd command not detected if [ -z $(command -v ldd) ]; then echo "" - fn_printfailurenl "GLIBC is not detected" + fn_print_failure_nl "GLIBC is not detected" sleep 1 echo "Install GLIBC and retry installation." sleep 1 diff --git a/functions/fix_steamcmd.sh b/functions/fix_steamcmd.sh index 862b4736f..a05f783c4 100644 --- a/functions/fix_steamcmd.sh +++ b/functions/fix_steamcmd.sh @@ -7,19 +7,19 @@ lgsm_version="010116" # Description: fixes various issues related to steamCMD. fn_msg_start(){ - fn_printdots "Applying ${fixname} fix: ${gamename}" + fn_print_dots "Applying ${fixname} fix: ${gamename}" sleep 1 - fn_printinfo "Applying ${fixname} fix: ${gamename}" + fn_print_info "Applying ${fixname} fix: ${gamename}" fn_scriptlog "Applying ${fixname} fix: ${gamename}" sleep 1 } fn_msg_end(){ if [ $? -ne 0 ]; then - fn_printfailnl "Applying ${fixname} fix: ${gamename}" + fn_print_fail_nl "Applying ${fixname} fix: ${gamename}" fn_scriptlog "Failure! Applying ${fixname} fix: ${gamename}" else - fn_printoknl "Applying ${fixname} fix: ${gamename}" + fn_print_ok_nl "Applying ${fixname} fix: ${gamename}" fn_scriptlog "Complete! Applying ${fixname} fix: ${gamename}" fi } diff --git a/functions/fn_update_functions b/functions/fn_update_functions index 414649f6a..5fbb28975 100644 --- a/functions/fn_update_functions +++ b/functions/fn_update_functions @@ -6,17 +6,17 @@ lgsm_version="230116" # Description: LEGACY FUNCTION Deletes the functions dir to allow re-downloading of functions from GitHub. -fn_printdots "Updating functions" +fn_print_dots "Updating functions" fn_scriptlog "Updating functions" sleep 1 echo -ne "\n" rm -rfv "${rootdir}/functions/"* exitcode=$? if [ "${exitcode}" == "0" ]; then - fn_printok "Updating functions" + fn_print_ok "Updating functions" fn_scriptlog "Success! Updating functions" else - fn_printfail "Updating functions" + fn_print_fail "Updating functions" fn_scriptlog "Failure! Updating functions" fi echo -ne "\n" \ No newline at end of file diff --git a/functions/install_server_dir.sh b/functions/install_server_dir.sh index 1a4f54b77..ab73ecfd2 100644 --- a/functions/install_server_dir.sh +++ b/functions/install_server_dir.sh @@ -14,7 +14,7 @@ echo "" pwd echo "" if [ -d "${filesdir}" ]; then - fn_printwarningnl "A server is already installed here." + fn_print_warning_nl "A server is already installed here." fi if [ -z "${autoinstall}" ]; then while true; do diff --git a/functions/install_server_files.sh b/functions/install_server_files.sh index f345c09f1..d6655689b 100644 --- a/functions/install_server_files.sh +++ b/functions/install_server_files.sh @@ -29,7 +29,7 @@ while [ "${counter}" == "0" ]||[ "${exitcode}" != "0" ]; do # Attempt 11: Failure if [ "${counter}" -ge "2" ]; then - fn_printwarningnl "SteamCMD did not complete the download, retrying: Attempt ${counter}" + fn_print_warning_nl "SteamCMD did not complete the download, retrying: Attempt ${counter}" fn_scriptlog "SteamCMD did not complete the download, retrying: Attempt ${counter}" fi @@ -65,7 +65,7 @@ while [ "${counter}" == "0" ]||[ "${exitcode}" != "0" ]; do fi fi elif [ "${counter}" -ge "11" ]; then - fn_printfailurenl "SteamCMD did not complete the download, too many retrys" + fn_print_failure_nl "SteamCMD did not complete the download, too many retrys" fn_scriptlog "SteamCMD did not complete the download, too many retrys" break fi @@ -74,7 +74,7 @@ done # Goldsource servers commonly fail to download all the server files required. # Validating a few of times may reduce the chance of this issue. if [ "${engine}" == "goldsource" ]; then - fn_printinfomationnl "Goldsource servers commonly fail to download all the server files required. Validating a few of times may reduce the chance of this issue." + fn_print_infomation_nl "Goldsource servers commonly fail to download all the server files required. Validating a few of times may reduce the chance of this issue." counter="0" while [ "${counter}" -le "4" ]; do counter=$((counter+1)) diff --git a/functions/install_ts3.sh b/functions/install_ts3.sh index 3a2acc224..5cf2f0f85 100644 --- a/functions/install_ts3.sh +++ b/functions/install_ts3.sh @@ -13,7 +13,7 @@ if [ "${arch}" == "x86_64" ]; then elif [ "${arch}" == "i386" ]||[ "${arch}" == "i686" ]; then ts3arch="x86" else - fn_printfailure "${arch} is an unsupported architecture" + fn_print_failure "${arch} is an unsupported architecture" exit 1 fi @@ -43,9 +43,9 @@ rm -f ".ts3_version_numbers.tmp" # Checks availablebuild info is available if [ -z "${availablebuild}" ]; then - fn_printfail "Checking for update: teamspeak.com" + fn_print_fail "Checking for update: teamspeak.com" sleep 1 - fn_printfail "Checking for update: teamspeak.com: Not returning version info" + fn_print_fail "Checking for update: teamspeak.com: Not returning version info" sleep 2 exit 1 fi diff --git a/functions/install_ts3db.sh b/functions/install_ts3db.sh index 90f5b0329..61e2db7d4 100644 --- a/functions/install_ts3db.sh +++ b/functions/install_ts3db.sh @@ -55,7 +55,7 @@ if [ -z "${autoinstall}" ]; then esac done else -fn_printwarningnl "./${selfname} auto-install is uses sqlite. For MariaDB/MySQL use ./${selfname} install" +fn_print_warning_nl "./${selfname} auto-install is uses sqlite. For MariaDB/MySQL use ./${selfname} install" fi ## Get privilege key diff --git a/functions/logs.sh b/functions/logs.sh index 54c9a9836..79d4de462 100644 --- a/functions/logs.sh +++ b/functions/logs.sh @@ -18,7 +18,7 @@ fi # Log manager will start the cleanup if it finds logs older than "${logdays}" if [ $(find "${scriptlogdir}"/ -type f -mtime +"${logdays}"|wc -l) -ne "0" ]; then - fn_printdots "Starting" + fn_print_dots "Starting" # Set addon logs directories sourcemodlogdir="${systemdir}/addons/sourcemod/logs" ulxlogdir="${systemdir}/data/ulx_logs" @@ -27,11 +27,11 @@ if [ $(find "${scriptlogdir}"/ -type f -mtime +"${logdays}"|wc -l) -ne "0" ]; th # Setting up counting variables scriptcount="0" ; consolecount="0" ; gamecount="0" ; srcdscount="0" ; smcount="0" ; ulxcount="0" ; darkrpcount="0" ; legacycount="0" sleep 1 - fn_printok "Starting" + fn_print_ok "Starting" fn_scriptlog "Starting" sleep 1 echo -en "\n" - fn_printinfo "Removing logs older than "${logdays}" days" + fn_print_info "Removing logs older than "${logdays}" days" fn_scriptlog "Removing logs older than "${logdays}" days" sleep 1 echo -en "\n" @@ -90,7 +90,7 @@ if [ $(find "${scriptlogdir}"/ -type f -mtime +"${logdays}"|wc -l) -ne "0" ]; th # Count total amount of files removed count=$((${scriptcount} + ${consolecount} + ${gamecount} + ${srcdscount} + ${smcount} + ${ulxcount} + ${darkrpcount} + ${legacycount})) # Job done - fn_printok "Removed ${count} log files" + fn_print_ok "Removed ${count} log files" fn_scriptlog "Removed ${count} log files" sleep 1 echo -en "\n" diff --git a/functions/monitor_gsquery.sh b/functions/monitor_gsquery.sh index 5fa63b32e..7a57aa694 100644 --- a/functions/monitor_gsquery.sh +++ b/functions/monitor_gsquery.sh @@ -27,11 +27,11 @@ if [ -z "${queryport}" ]; then fi -fn_printinfo "Querying port: gsquery.py enabled" +fn_print_info "Querying port: gsquery.py enabled" fn_scriptlog "gsquery.py enabled" sleep 1 -fn_printdots "Querying port: ${ip}:${port}: 0/1 : " -fn_printqueryingeol +fn_print_dots "Querying port: ${ip}:${port}: 0/1 : " +fn_print_querying_eol fn_scriptlog "Querying port: ${ip}:${port}: 1 : QUERYING" sleep 1 @@ -47,8 +47,8 @@ for i in {1..4}; do if [ "${exitcode}" == "0" ]; then # Server OK - fn_printok "Querying port: ${ip}:${port}: " - fn_printokeol + fn_print_ok "Querying port: ${ip}:${port}: " + fn_print_ok_eol fn_scriptlog "Querying port: ${ip}:${port}: OK" sleep 1 exit @@ -59,13 +59,13 @@ for i in {1..4}; do seconds=0 # Seconds counter while [ true ]; do - fn_printfail "Querying port: ${ip}:${port}: ${totalseconds}/${queryattempt} : \e[0;31m${gsquerycmd}\e[0m" + fn_print_fail "Querying port: ${ip}:${port}: ${totalseconds}/${queryattempt} : \e[0;31m${gsquerycmd}\e[0m" seconds=$((seconds + 1)) totalseconds=$((totalseconds + 1)) sleep 1 if [ "${seconds}" == "15" ]; then - fn_printdots "Querying port: ${ip}:${port}: ${totalseconds}/${queryattempt} : " - fn_printqueryingeol + fn_print_dots "Querying port: ${ip}:${port}: ${totalseconds}/${queryattempt} : " + fn_print_querying_eol fn_scriptlog "Querying port: ${ip}:${port}: ${queryattempt} : QUERYING" sleep 1 break @@ -75,8 +75,8 @@ for i in {1..4}; do if [ "${queryattempt}" == "4" ]; then # Server failed query 4 times confirmed failure - fn_printfail "Querying port: ${ip}:${port}: " - fn_printfaileol + fn_print_fail "Querying port: ${ip}:${port}: " + fn_print_fail_eol fn_scriptlog "Querying port: ${ip}:${port}: ${gsquerycmd}" fn_scriptlog "Querying port: ${ip}:${port}: FAIL" sleep 1 diff --git a/functions/update_check.sh b/functions/update_check.sh index 773c88b25..4342e7237 100644 --- a/functions/update_check.sh +++ b/functions/update_check.sh @@ -22,10 +22,10 @@ fn_appmanifestinfo # This is an error is corrected below if required. if [ "${appmanifestfilewc}" -ge "2" ]; then sleep 1 - fn_printwarn "Multiple appmanifest_${appid}.acf files found" + fn_print_warn "Multiple appmanifest_${appid}.acf files found" fn_scriptlog "Warning! Multiple appmanifest_${appid}.acf files found" sleep 2 - fn_printdots "Removing x${appmanifestfilewc} appmanifest_${appid}.acf files" + fn_print_dots "Removing x${appmanifestfilewc} appmanifest_${appid}.acf files" sleep 1 for appfile in ${appmanifestfile}; do rm "${appfile}" @@ -33,7 +33,7 @@ if [ "${appmanifestfilewc}" -ge "2" ]; then appmanifestfilewc1="${appmanifestfilewc}" fn_appmanifestinfo if [ "${appmanifestfilewc}" -ge "2" ]; then - fn_printfail "Unable to remove x${appmanifestfilewc} appmanifest_${appid}.acf files" + fn_print_fail "Unable to remove x${appmanifestfilewc} appmanifest_${appid}.acf files" fn_scriptlog "Failure! Unable to remove x${appmanifestfilewc} appmanifest_${appid}.acf files" sleep 1 echo "" @@ -44,10 +44,10 @@ if [ "${appmanifestfilewc}" -ge "2" ]; then exit 1 else sleep 1 - fn_printok "Removed x${appmanifestfilewc1} appmanifest_${appid}.acf files" + fn_print_ok "Removed x${appmanifestfilewc1} appmanifest_${appid}.acf files" fn_scriptlog "Success! Removed x${appmanifestfilewc1} appmanifest_${appid}.acf files" sleep 1 - fn_printinfonl "Forcing update to correct issue" + fn_print_info_nl "Forcing update to correct issue" fn_scriptlog "Forcing update to correct issue" sleep 1 update_dl.sh @@ -55,15 +55,15 @@ if [ "${appmanifestfilewc}" -ge "2" ]; then fi elif [ "${appmanifestfilewc}" -eq "0" ]; then if [ "${forceupdate}" == "1" ]; then - fn_printfail "Still no appmanifest_${appid}.acf found: Unable to update" + fn_print_fail "Still no appmanifest_${appid}.acf found: Unable to update" fn_scriptlog "Warning! Still no appmanifest_${appid}.acf found: Unable to update" exit 1 fi forceupdate=1 - fn_printwarn "No appmanifest_${appid}.acf found" + fn_print_warn "No appmanifest_${appid}.acf found" fn_scriptlog "Warning! No appmanifest_${appid}.acf found" sleep 2 - fn_printinfonl "Forcing update to correct issue" + fn_print_info_nl "Forcing update to correct issue" fn_scriptlog "Forcing update to correct issue" sleep 1 update_dl.sh @@ -73,12 +73,12 @@ fi fn_logupdaterequest(){ # Checks for server update requests from server logs. -fn_printdots "Checking for update: Server logs" +fn_print_dots "Checking for update: Server logs" fn_scriptlog "Checking for update: Server logs" sleep 1 requestrestart=$(grep -Ec "MasterRequestRestart" "${consolelog}") if [ "${requestrestart}" -ge "1" ]; then - fn_printoknl "Checking for update: Server logs: Update requested" + fn_print_ok_nl "Checking for update: Server logs: Update requested" sleep 1 echo "" echo -ne "Applying update.\r" @@ -98,7 +98,7 @@ if [ "${requestrestart}" -ge "1" ]; then update_dl.sh fi else - fn_printok "Checking for update: Server logs: No update requested" + fn_print_ok "Checking for update: Server logs: No update requested" sleep 1 fi } @@ -106,7 +106,7 @@ fi fn_steamcmdcheck(){ fn_appmanifestcheck # Checks for server update from SteamCMD -fn_printdots "Checking for update: SteamCMD" +fn_print_dots "Checking for update: SteamCMD" fn_scriptlog "Checking for update: SteamCMD" sleep 1 @@ -122,14 +122,14 @@ if [ -f "${HOME}/Steam/appcache/appinfo.vdf" ]; then fi availablebuild=$(./steamcmd.sh +login "${steamuser}" "${steampass}" +app_info_update 1 +app_info_print "${appid}" +app_info_print "${appid}" +quit | grep -EA 1000 "^\s+\"branches\"$" | grep -EA 5 "^\s+\"public\"$" | grep -m 1 -EB 10 "^\s+}$" | grep -E "^\s+\"buildid\"\s+" | tr '[:blank:]"' ' ' | tr -s ' ' | cut -d\ -f3) if [ -z "${availablebuild}" ]; then - fn_printfail "Checking for update: SteamCMD" + fn_print_fail "Checking for update: SteamCMD" fn_scriptlog "Failure! Checking for update: SteamCMD" sleep 1 - fn_printfailnl "Checking for update: SteamCMD: Not returning version info" + fn_print_fail_nl "Checking for update: SteamCMD: Not returning version info" fn_scriptlog "Failure! Checking for update: SteamCMD: Not returning version info" exit 1 else - fn_printok "Checking for update: SteamCMD" + fn_print_ok "Checking for update: SteamCMD" fn_scriptlog "Success! Checking for update: SteamCMD" sleep 1 fi @@ -172,7 +172,7 @@ else echo -e " Available version: \e[0;32m${availablebuild}\e[0;39m" echo -e " https://steamdb.info/app/${appid}/" echo -e "" - fn_printoknl "No update available" + fn_print_ok_nl "No update available" fn_scriptlog "Current build: ${currentbuild}" fn_scriptlog "Available build: ${availablebuild}" fi @@ -182,19 +182,19 @@ fi fn_teamspeak3_check(){ # Checks for server update from teamspeak.com using a mirror dl.4players.de -fn_printdots "Checking for update: teamspeak.com" +fn_print_dots "Checking for update: teamspeak.com" fn_scriptlog "Checking for update: teamspeak.com" sleep 1 # Gets currentbuild info # 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_print_fail "Checking for update: teamspeak.com" sleep 1 - fn_printfailnl "Checking for update: teamspeak.com: No logs with server version found" + fn_print_fail_nl "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" sleep 2 - fn_printinfonl "Checking for update: teamspeak.com: Forcing server restart" + fn_print_info_nl "Checking for update: teamspeak.com: Forcing server restart" fn_scriptlog "Checking for update: teamspeak.com: Forcing server restart" sleep 2 command_stop.sh @@ -202,7 +202,7 @@ if [ -z "$(find ./* -name 'ts3server*_0.log')" ]; then sleep 2 # If still failing will exit if [ -z "$(find ./* -name 'ts3server*_0.log')" ]; then - fn_printfailnl "Checking for update: teamspeak.com: Still No logs with server version found" + fn_print_fail_nl "Checking for update: teamspeak.com: Still No logs with server version found" fn_scriptlog "Failure! Checking for update: teamspeak.com: Still No logs with server version found" exit 1 fi @@ -217,7 +217,7 @@ elif [ "${arch}" == "i386" ]||[ "${arch}" == "i686" ]; then ts3arch="x86" else echo "" - fn_printfailure "${arch} is an unsupported architecture" + fn_print_failure "${arch} is an unsupported architecture" exit 1 fi @@ -249,15 +249,15 @@ rm -f ".ts3_version_numbers.tmp" # Checks availablebuild info is available if [ -z "${availablebuild}" ]; then - fn_printfail "Checking for update: teamspeak.com" + fn_print_fail "Checking for update: teamspeak.com" fn_scriptlog "Checking for update: teamspeak.com" sleep 1 - fn_printfail "Checking for update: teamspeak.com: Not returning version info" + fn_print_fail "Checking for update: teamspeak.com: Not returning version info" fn_scriptlog "Failure! Checking for update: teamspeak.com: Not returning version info" sleep 2 exit 1 else - fn_printok "Checking for update: teamspeak.com" + fn_print_ok "Checking for update: teamspeak.com" fn_scriptlog "Success! Checking for update: teamspeak.com" sleep 1 fi @@ -303,14 +303,14 @@ else echo -e " Current version: \e[0;32m${currentbuild}\e[0;39m" echo -e " Available version: \e[0;32m${availablebuild}\e[0;39m" echo -e "" - fn_printoknl "No update available" + fn_print_ok_nl "No update available" fn_scriptlog "Current build: ${currentbuild}" fn_scriptlog "Available build: ${availablebuild}" fi } check.sh -fn_printdots "Checking for update" +fn_print_dots "Checking for update" if [ "${gamename}" == "Teamspeak 3" ]; then fn_teamspeak3_check elif [ "${engine}" == "goldsource" ]||[ "${forceupdate}" == "1" ]; then diff --git a/functions/update_dl.sh b/functions/update_dl.sh index 0c07fc31a..f23bd2c64 100644 --- a/functions/update_dl.sh +++ b/functions/update_dl.sh @@ -71,9 +71,9 @@ rm -rf "${rootdir}/teamspeak3-server_linux_${ts3arch}" check.sh info_config.sh -fn_printdots "Updating ${servername}" +fn_print_dots "Updating ${servername}" sleep 1 -fn_printoknl "Updating ${servername}" +fn_print_ok_nl "Updating ${servername}" fn_scriptlog "Updating ${servername}" sleep 1 if [ "${gamename}" == "Teamspeak 3" ]; then diff --git a/tests/tests_jc2server.sh b/tests/tests_jc2server.sh index 61b326506..0fce4904c 100644 --- a/tests/tests_jc2server.sh +++ b/tests/tests_jc2server.sh @@ -325,7 +325,7 @@ echo "Description:" echo "change the buildid tricking SteamCMD to update." requiredstatus="OFFLINE" fn_setstatus -fn_printinfonl "changed buildid to 0." +fn_print_info_nl "changed buildid to 0." sed -i 's/[0-9]\+/0/' ${filesdir}/steamapps/appmanifest_${appid}.acf update_check.sh echo "" @@ -338,7 +338,7 @@ echo "Description:" echo "change the buildid tricking SteamCMD to update server while already running." requiredstatus="ONLINE" fn_setstatus -fn_printinfonl "changed buildid to 0." +fn_print_info_nl "changed buildid to 0." sed -i 's/[0-9]\+/0/' ${filesdir}/steamapps/appmanifest_${appid}.acf update_check.sh echo "" @@ -351,7 +351,7 @@ echo "Description:" echo "removing appmanifest file will cause script to repair." requiredstatus="OFFLINE" fn_setstatus -fn_printinfonl "removed appmanifest_${appid}.acf." +fn_print_info_nl "removed appmanifest_${appid}.acf." rm --verbose "${filesdir}/steamapps/appmanifest_${appid}.acf" update_check.sh echo "" @@ -433,7 +433,7 @@ echo "Description:" echo "run monitor while server is offline with no lockfile." requiredstatus="OFFLINE" fn_setstatus -fn_printinfonl "creating lockfile." +fn_print_info_nl "creating lockfile." date > "${rootdir}/${lockselfname}" (command_monitor.sh) echo "" @@ -449,7 +449,7 @@ fn_setstatus sed -i 's/[0-9]\+/0/' "${servercfgfullpath}" (command_monitor.sh) echo "" -fn_printinfonl "Reseting ${servercfg}." +fn_print_info_nl "Reseting ${servercfg}." install_config.sh echo "" echo "Test complete!" @@ -478,7 +478,7 @@ echo "" requiredstatus="OFFLINE" fn_setstatus sleep 1 -fn_printinfo "Tidying up directories." +fn_print_info "Tidying up directories." sleep 1 rm -rfv ${serverfiles} echo "END" diff --git a/tests/tests_ts3server.sh b/tests/tests_ts3server.sh index b3207c368..cd7c94f23 100644 --- a/tests/tests_ts3server.sh +++ b/tests/tests_ts3server.sh @@ -345,7 +345,7 @@ echo "Description:" echo "run monitor while server is offline with no lockfile." requiredstatus="OFFLINE" fn_setstatus -fn_printinfonl "creating lockfile." +fn_print_info_nl "creating lockfile." date > "${rootdir}/${lockselfname}" (command_monitor.sh) echo "" @@ -361,7 +361,7 @@ fn_setstatus sed -i 's/[0-9]\+/0/' "${servercfgfullpath}" (command_monitor.sh) echo "" -fn_printinfonl "Reseting ${servercfg}." +fn_print_info_nl "Reseting ${servercfg}." install_config.sh echo "" echo "Test complete!" @@ -390,7 +390,7 @@ echo "" requiredstatus="OFFLINE" fn_setstatus sleep 1 -fn_printinfo "Tidying up directories." +fn_print_info "Tidying up directories." sleep 1 rm -rfv ${serverfiles} echo "END" \ No newline at end of file From 661e579dbe2894ce8be8878ee70537274c4ad9a4 Mon Sep 17 00:00:00 2001 From: Daniel Gibbs Date: Sun, 28 Feb 2016 16:05:19 +0000 Subject: [PATCH 089/117] Corrected if --- functions/core_dl.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/functions/core_dl.sh b/functions/core_dl.sh index cf3a2d777..959161a27 100644 --- a/functions/core_dl.sh +++ b/functions/core_dl.sh @@ -20,7 +20,7 @@ lgsm_version="050216" fn_dl_md5(){ # Runs MD5 Check if available -if [ -n "${md5}" ]||[ "${md5}" == "nomd5" ]; then +if [ -n "${md5}" ]||[ "${md5}" != "nomd5" ]; then echo -ne "verifying ${filename} with MD5..." sleep 1 local md5sumcmd=$(md5sum "${filedir}/${filename}"|awk '{print $1;}') From 66f72ebad5348ca9450ef43d4c57baf7ec63ca29 Mon Sep 17 00:00:00 2001 From: Daniel Gibbs Date: Sun, 28 Feb 2016 16:05:26 +0000 Subject: [PATCH 090/117] Updated notes --- functions/core_messages.sh | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/functions/core_messages.sh b/functions/core_messages.sh index 6581d2f17..acc7ffa5f 100644 --- a/functions/core_messages.sh +++ b/functions/core_messages.sh @@ -9,7 +9,8 @@ lgsm_version="380216" # nl: new line: message is following by a new line # eol: end of line: message is placed at the end of the current line -# Date and servicename for log files. +# Date, servicename & module details displayed in log files. +# e.g Feb 28 14:56:58 ut99-server: Monitor: fn_scriptlog(){ if [ -n "${modulename}" ]; then echo -e "$(date '+%b %d %H:%M:%S') ${servicename}: ${modulename}: ${1}" >> "${scriptlog}" From a7f6289efa263e9ae013c71630394efc1135abc9 Mon Sep 17 00:00:00 2001 From: Daniel Gibbs Date: Sun, 28 Feb 2016 16:18:05 +0000 Subject: [PATCH 091/117] Fixed md5 checker --- functions/core_dl.sh | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/functions/core_dl.sh b/functions/core_dl.sh index 959161a27..45f46e1c6 100644 --- a/functions/core_dl.sh +++ b/functions/core_dl.sh @@ -20,7 +20,7 @@ lgsm_version="050216" fn_dl_md5(){ # Runs MD5 Check if available -if [ -n "${md5}" ]||[ "${md5}" != "nomd5" ]; then +if [ "${md5}" != "0" ]&&[ "${md5}" != "nomd5" ]; then echo -ne "verifying ${filename} with MD5..." sleep 1 local md5sumcmd=$(md5sum "${filedir}/${filename}"|awk '{print $1;}') @@ -46,9 +46,9 @@ fi # fn_dl_extract "${filedir}" "${filename}" "${extractdir}" # fn_dl_extract "/home/gameserver/lgsm/tmp" "file.tar.bz2" "/home/gamserver/serverfiles" fn_dl_extract(){ -filedir=${1} -filename=${2} -extractdir=${3} +filedir="${1}" +filename="${2}" +extractdir="${3}" # extracts archives echo -ne "extracting ${filename}..." fn_scriptlog "extracting download" @@ -85,13 +85,13 @@ fn_fetch_trap() { } fn_fetch_file(){ -fileurl=${1} -filedir=${2} -filename=${3} -executecmd=${4:-0} -run=${5:-0} -force=${6:-0} -md5=${7} +fileurl="${1}" +filedir="${2}" +filename="${3}" +executecmd="${4:-0}" +run="${5:-0}" +force="${6:-0}" +md5="${7:-0}" # If the file is missing, then download if [ ! -f "${filedir}/${filename}" ]; then @@ -181,7 +181,7 @@ filename="${github_file_url_name}" executecmd="${4:-0}" run="${5:-0}" force="${6:-0}" -md5="${7}" +md5="${7:-0}" fn_fetch_file "${fileurl}" "${filedir}" "${filename}" "${executecmd}" "${run}" "${force}" "${md5}" } @@ -197,6 +197,6 @@ filename="${github_file_url_name}" executecmd="executecmd" run="run" force="noforce" -md5="" +md5="nomd5" fn_fetch_file "${fileurl}" "${filedir}" "${filename}" "${executecmd}" "${run}" "${force}" "${md5}" } \ No newline at end of file From 2c1627b6cdfd732f65aa9822c596d8fd5a9a1488 Mon Sep 17 00:00:00 2001 From: Daniel Gibbs Date: Sun, 28 Feb 2016 16:18:14 +0000 Subject: [PATCH 092/117] minor edit --- functions/monitor_gsquery.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/functions/monitor_gsquery.sh b/functions/monitor_gsquery.sh index 7a57aa694..b82496601 100644 --- a/functions/monitor_gsquery.sh +++ b/functions/monitor_gsquery.sh @@ -55,7 +55,7 @@ for i in {1..4}; do else # Server failed query queryattempt=$((queryattempt + 1)) - fn_scriptlog "Querying port: ${ip}:${port}: ${totalseconds}/${queryattempt} : ${gsquerycmd}" + fn_scriptlog "Querying port: ${ip}:${port}: ${queryattempt} : ${gsquerycmd}" seconds=0 # Seconds counter while [ true ]; do From c2382c73a09985d3b2f59beceebec799b33a44d7 Mon Sep 17 00:00:00 2001 From: Daniel Gibbs Date: Sun, 28 Feb 2016 16:40:27 +0000 Subject: [PATCH 093/117] Correcting more messages --- functions/core_messages.sh | 16 ++++++------- functions/monitor_gsquery.sh | 46 ++++++++++++++++++------------------ 2 files changed, 31 insertions(+), 31 deletions(-) diff --git a/functions/core_messages.sh b/functions/core_messages.sh index acc7ffa5f..eeaac4170 100644 --- a/functions/core_messages.sh +++ b/functions/core_messages.sh @@ -152,36 +152,36 @@ fn_print_ok_eol_nl(){ # FAIL for end of line fn_print_fail_eol(){ - echo -en "\e[0;31mFAIL\e[0m\n" + echo -en "\e[0;31mFAIL\e[0m" } fn_print_fail_eol_nl(){ - echo -e "\e[0;31mFAIL\e[0m\n" + echo -e "\e[0;31mFAIL\e[0m" } # QUERYING for end of line fn_print_querying_eol(){ - echo -en "\e[0;36mQUERYING\e[0m\n" + echo -en "\e[0;36mQUERYING\e[0m" } fn_print_querying_eol_nl(){ - echo -e "\e[0;36mQUERYING\e[0m\n" + echo -e "\e[0;36mQUERYING\e[0m" } # CANCELED for end of line fn_print_canceled_eol(){ - echo -en "\e[0;33mCANCELED\e[0m\n" + echo -en "\e[0;33mCANCELED\e[0m" } fn_print_canceled_eol_nl(){ - echo -e "\e[0;33mCANCELED\e[0m\n" + echo -e "\e[0;33mCANCELED\e[0m" } # REMOVED for end of line fn_print_removed_eol(){ - echo -en "\e[0;31mREMOVED\e[0m\n" + echo -en "\e[0;31mREMOVED\e[0m" } fn_print_removed_eol_nl(){ - echo -e "\e[0;31mREMOVED\e[0m\n" + echo -e "\e[0;31mREMOVED\e[0m" } \ No newline at end of file diff --git a/functions/monitor_gsquery.sh b/functions/monitor_gsquery.sh index b82496601..95e72a670 100644 --- a/functions/monitor_gsquery.sh +++ b/functions/monitor_gsquery.sh @@ -26,59 +26,59 @@ if [ -z "${queryport}" ]; then port="${queryport}" fi - +queryattempt=1 +totalseconds=0 fn_print_info "Querying port: gsquery.py enabled" fn_scriptlog "gsquery.py enabled" sleep 1 -fn_print_dots "Querying port: ${ip}:${port}: 0/1 : " +fn_print_dots "Querying port: ${ip}:${port} :${totalseconds}/${queryattempt} : " fn_print_querying_eol -fn_scriptlog "Querying port: ${ip}:${port}: 1 : QUERYING" +fn_scriptlog "Querying port: ${ip}:${port} : ${queryattempt} : QUERYING" sleep 1 # Will query up to 4 times every 15 seconds. # Servers changing map can return a failure. # Will Wait up to 60 seconds to confirm server is down giving server time to change map. -queryattempt=0 -totalseconds=0 + for i in {1..4}; do gsquerycmd=$("${functionsdir}"/gsquery.py -a ${ip} -p 1 -e ${engine} 2>&1) exitcode=$? if [ "${exitcode}" == "0" ]; then # Server OK - fn_print_ok "Querying port: ${ip}:${port}: " + fn_print_ok "Querying port: ${ip}:${port} : " fn_print_ok_eol - fn_scriptlog "Querying port: ${ip}:${port}: OK" + fn_scriptlog "Querying port: ${ip}:${port} : OK" sleep 1 exit else # Server failed query - queryattempt=$((queryattempt + 1)) - fn_scriptlog "Querying port: ${ip}:${port}: ${queryattempt} : ${gsquerycmd}" + fn_scriptlog "Querying port: ${ip}:${port} : ${queryattempt} : ${gsquerycmd}" seconds=0 # Seconds counter while [ true ]; do - fn_print_fail "Querying port: ${ip}:${port}: ${totalseconds}/${queryattempt} : \e[0;31m${gsquerycmd}\e[0m" - seconds=$((seconds + 1)) - totalseconds=$((totalseconds + 1)) - sleep 1 - if [ "${seconds}" == "15" ]; then - fn_print_dots "Querying port: ${ip}:${port}: ${totalseconds}/${queryattempt} : " - fn_print_querying_eol - fn_scriptlog "Querying port: ${ip}:${port}: ${queryattempt} : QUERYING" + fn_print_fail "Querying port: ${ip}:${port} : ${totalseconds}/${queryattempt} : \e[0;31m${gsquerycmd}\e[0m" + seconds=$((seconds + 1)) + totalseconds=$((totalseconds + 1)) + sleep 1 + if [ "${seconds}" == "15" ]; then + queryattempt=$((queryattempt + 1)) + fn_print_dots "Querying port: ${ip}:${port} : ${totalseconds}/${queryattempt} : " + fn_print_querying_eol + fn_scriptlog "Querying port: ${ip}:${port} : ${queryattempt} : QUERYING" sleep 1 - break - fi + break + fi done fi if [ "${queryattempt}" == "4" ]; then # Server failed query 4 times confirmed failure - fn_print_fail "Querying port: ${ip}:${port}: " + fn_print_fail "Querying port: ${ip}:${port} : " fn_print_fail_eol - fn_scriptlog "Querying port: ${ip}:${port}: ${gsquerycmd}" - fn_scriptlog "Querying port: ${ip}:${port}: FAIL" + fn_scriptlog "Querying port: ${ip}:${port} : ${gsquerycmd}" + fn_scriptlog "Querying port: ${ip}:${port} : FAIL" sleep 1 # Send email notification if enabled @@ -90,5 +90,5 @@ for i in {1..4}; do email.sh fi fn_restart - fi + fi done \ No newline at end of file From 9f5425bda724e16a7688822c2f7780cb7ff6f15e Mon Sep 17 00:00:00 2001 From: Daniel Gibbs Date: Sun, 28 Feb 2016 21:51:36 +0000 Subject: [PATCH 094/117] Fixed looping issues --- functions/monitor_gsquery.sh | 137 +++++++++++++++++------------------ 1 file changed, 68 insertions(+), 69 deletions(-) diff --git a/functions/monitor_gsquery.sh b/functions/monitor_gsquery.sh index 95e72a670..058351770 100644 --- a/functions/monitor_gsquery.sh +++ b/functions/monitor_gsquery.sh @@ -2,93 +2,92 @@ # LGSM monitor_gsquery.sh function # Author: Daniel Gibbs # Website: http://gameservermanagers.com -lgsm_version="271215" +lgsm_version="270216" # Description: uses gsquery.py to query the server port. # Detects if the server has frozen with the proccess still running. local modulename="Monitor" -# Downloads gsquery.py if missing -if [ ! -f "${functionsdir}/gsquery.py" ]; then - fn_fetch_file_github "functions" "gsquery.py" "${functionsdir}" "executecmd" "norun" "noforce" "nomd5" -fi +# Forces legecy servers to use gsquery as vat gsquery is not present in legecy +if [ -z "${gsquery}" ]; then + gsquery="yes" +fi -info_config.sh +if [ "${gsquery}" == "yes" ]; then -if [ "${engine}" == "unreal" ]||[ "${engine}" == "unreal2" ]; then - port=$((${port} + 1)) -elif [ "${engine}" == "spark" ]; then - port=$((${port} + 1)) -fi + # Downloads gsquery.py if missing + if [ ! -f "${functionsdir}/gsquery.py" ]; then + fn_fetch_file_github "functions" "gsquery.py" "${functionsdir}" "executecmd" "norun" "noforce" "nomd5" + fi -if [ -z "${queryport}" ]; then - port="${queryport}" -fi + info_config.sh -queryattempt=1 -totalseconds=0 -fn_print_info "Querying port: gsquery.py enabled" -fn_scriptlog "gsquery.py enabled" -sleep 1 -fn_print_dots "Querying port: ${ip}:${port} :${totalseconds}/${queryattempt} : " -fn_print_querying_eol -fn_scriptlog "Querying port: ${ip}:${port} : ${queryattempt} : QUERYING" -sleep 1 + if [ "${engine}" == "unreal" ]||[ "${engine}" == "unreal2" ]; then + port=$((port + 1)) + elif [ "${engine}" == "spark" ]; then + port=$((port + 1)) + fi + if [ -z "${queryport}" ]; then + port="${queryport}" + fi -# Will query up to 4 times every 15 seconds. -# Servers changing map can return a failure. -# Will Wait up to 60 seconds to confirm server is down giving server time to change map. + fn_print_info "Querying port: gsquery.py enabled" + fn_scriptlog "Querying port: gsquery.py enabled" + sleep 1 -for i in {1..4}; do - gsquerycmd=$("${functionsdir}"/gsquery.py -a ${ip} -p 1 -e ${engine} 2>&1) - exitcode=$? + # Will query up to 4 times every 15 seconds. + # Servers changing map can return a failure. + # Will Wait up to 60 seconds to confirm server is down giving server time to change map. + totalseconds=0 + for queryattempt in {1..5}; do + fn_print_dots "Querying port: ${ip}:${port} : ${totalseconds}/${queryattempt} : " + fn_print_querying_eol + fn_scriptlog "Querying port: ${ip}:${port} : ${queryattempt} : QUERYING" + + gsquerycmd=$("${functionsdir}"/gsquery.py -a "${ip}" -p 1 -e "${engine}" 2>&1) + exitcode=$? - if [ "${exitcode}" == "0" ]; then - # Server OK - fn_print_ok "Querying port: ${ip}:${port} : " - fn_print_ok_eol - fn_scriptlog "Querying port: ${ip}:${port} : OK" sleep 1 - exit - else - # Server failed query - fn_scriptlog "Querying port: ${ip}:${port} : ${queryattempt} : ${gsquerycmd}" - seconds=0 - # Seconds counter - while [ true ]; do - fn_print_fail "Querying port: ${ip}:${port} : ${totalseconds}/${queryattempt} : \e[0;31m${gsquerycmd}\e[0m" - seconds=$((seconds + 1)) - totalseconds=$((totalseconds + 1)) + if [ "${exitcode}" == "0" ]; then + # Server OK + fn_print_ok "Querying port: ${ip}:${port} : ${queryattempt} : " + fn_print_ok_eol + fn_scriptlog "Querying port: ${ip}:${port} : ${queryattempt} : OK" sleep 1 - if [ "${seconds}" == "15" ]; then - queryattempt=$((queryattempt + 1)) - fn_print_dots "Querying port: ${ip}:${port} : ${totalseconds}/${queryattempt} : " - fn_print_querying_eol - fn_scriptlog "Querying port: ${ip}:${port} : ${queryattempt} : QUERYING" + exit + else + # Server failed query + fn_scriptlog "Querying port: ${ip}:${port} : ${queryattempt} : ${gsquerycmd}" + + if [ "${queryattempt}" == "5" ]; then + # Server failed query 4 times confirmed failure + fn_print_fail "Querying port: ${ip}:${port} : ${totalseconds}/${queryattempt} : " + fn_print_fail_eol_nl + fn_scriptlog "Querying port: ${ip}:${port} : ${queryattempt} : FAIL" sleep 1 + + # Send email notification if enabled + if [ "${emailnotification}" == "on" ]; then + subject="${servicename} Monitor - Starting ${servername}" + failurereason="Failed to query ${servicename}: ${gsquerycmd}" + actiontaken="restarted ${servicename}" + email.sh + fi + fn_restart break fi - done - fi - if [ "${queryattempt}" == "4" ]; then - # Server failed query 4 times confirmed failure - fn_print_fail "Querying port: ${ip}:${port} : " - fn_print_fail_eol - fn_scriptlog "Querying port: ${ip}:${port} : ${gsquerycmd}" - fn_scriptlog "Querying port: ${ip}:${port} : FAIL" - sleep 1 - - # Send email notification if enabled - if [ "${emailnotification}" = "on" ]; then - info_config.sh - subject="${servicename} Monitor - Starting ${servername}" - failurereason="Failed to query ${servicename}: ${gsquerycmd}" - actiontaken="restarted ${servicename}" - email.sh + # Seconds counter + for seconds in {1..15}; do + fn_print_fail "Querying port: ${ip}:${port} : ${totalseconds}/${queryattempt} : \e[0;31m${gsquerycmd}\e[0m" + totalseconds=$((totalseconds + 1)) + sleep 1 + if [ "${seconds}" == "15" ]; then + break + fi + done fi - fn_restart - fi -done \ No newline at end of file + done +fi \ No newline at end of file From 248518c3c51b6c79e22dd7f5c600bbaae644fe90 Mon Sep 17 00:00:00 2001 From: Daniel Gibbs Date: Sun, 28 Feb 2016 22:40:56 +0000 Subject: [PATCH 095/117] repaired ut99 fix --- functions/command_install.sh | 2 +- functions/fix_ut99.sh | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/functions/command_install.sh b/functions/command_install.sh index 9c7eb7180..77cf2d359 100644 --- a/functions/command_install.sh +++ b/functions/command_install.sh @@ -26,11 +26,11 @@ elif [ -n "${appid}" ]; then fi # Configuration -fix.sh install_config.sh if [ "${gamename}" == "Counter Strike: Global Offensive" ]||[ "${gamename}" == "Team Fortress 2" ]||[ "${gamename}" == "BrainBread 2" ]; then install_gslt.sh elif [ "${gamename}" == "Teamspeak 3" ]; then install_ts3db.sh fi +fix.sh install_complete.sh diff --git a/functions/fix_ut99.sh b/functions/fix_ut99.sh index aceb37128..f7792fb44 100644 --- a/functions/fix_ut99.sh +++ b/functions/fix_ut99.sh @@ -3,7 +3,7 @@ # Author: Daniel Gibbs # Website: http://gameservermanagers.com lgsm_version="271215" - +echo "${servercfgfullpath}" echo "enabling UdpServerUplink." { echo "[IpServer.UdpServerUplink]" @@ -21,5 +21,5 @@ echo "removing dead mplayer.com master server." sed -i '/master.mplayer.com/d' "${servercfgfullpath}" sleep 1 echo "inserting qtracker.com master server." -sed -i '66i\ServerActors=IpServer.UdpServerUplink MasterServerAddress=master.qtracker.com MasterServerPort=27900' "${servercfgfullpath}" +sed -i '65i\ServerActors=IpServer.UdpServerUplink MasterServerAddress=master.qtracker.com MasterServerPort=27900' "${servercfgfullpath}" echo "" \ No newline at end of file From 995a4c584d738a414c5ef5f2bec870084fd72126 Mon Sep 17 00:00:00 2001 From: Daniel Gibbs Date: Tue, 1 Mar 2016 19:23:58 +0000 Subject: [PATCH 096/117] Optimised fixes removed un-needed code --- functions/fix.sh | 23 ++++++++++++++++++-- functions/fix_arma3.sh | 26 +++------------------- functions/fix_csgo.sh | 44 +++++++++++--------------------------- functions/fix_dst.sh | 28 ++++-------------------- functions/fix_ro.sh | 4 ++-- functions/fix_steamcmd.sh | 45 +++++++++++---------------------------- functions/fix_ut2k4.sh | 15 +++++-------- 7 files changed, 61 insertions(+), 124 deletions(-) diff --git a/functions/fix.sh b/functions/fix.sh index 931f4acbe..86e397ee6 100644 --- a/functions/fix.sh +++ b/functions/fix.sh @@ -2,11 +2,31 @@ # LGSM fix.sh function # Author: Daniel Gibbs # Website: http://gameservermanagers.com -lgsm_version="020116" +lgsm_version="010316" # Description: Overall function for managing fixes. # Runs functions that will fix an issue. +# Messages that are displayed for some fixes +fn_fix_msg_start(){ + fn_print_dots "Applying ${fixname} fix: ${gamename}" + sleep 1 + fn_print_info "Applying ${fixname} fix: ${gamename}" + fn_scriptlog "Applying ${fixname} fix: ${gamename}" + sleep 1 +} + +fn_fix_msg_end(){ + if [ $? -ne 0 ]; then + fn_print_fail_nl "Applying ${fixname} fix: ${gamename}" + fn_scriptlog "Failure! Applying ${fixname} fix: ${gamename}" + else + fn_print_ok_nl "Applying ${fixname} fix: ${gamename}" + fn_scriptlog "Complete! Applying ${fixname} fix: ${gamename}" + fi +} + + # Fixes that are run on start if [ "${function_selfname}" != "command_install.sh" ]; then if [ ! -z "${appid}" ]; then @@ -14,7 +34,6 @@ if [ "${function_selfname}" != "command_install.sh" ]; then fi if [ "${gamename}" == "Counter Strike: Global Offensive" ]; then - startfix=1 fix_csgo.sh elif [ "${gamename}" == "Don't Starve Together" ]; then fix_dst.sh diff --git a/functions/fix_arma3.sh b/functions/fix_arma3.sh index b076fe065..ffc607ed6 100644 --- a/functions/fix_arma3.sh +++ b/functions/fix_arma3.sh @@ -4,30 +4,10 @@ # Website: http://gameservermanagers.com lgsm_version="301215" -# Fixes line 63: 20150 Segmentation fault (core dumped) #488 - -fn_msg_start(){ - fn_print_dots "Applying ${fixname} fix: ${gamename}" - sleep 1 - fn_print_info "Applying ${fixname} fix: ${gamename}" - fn_scriptlog "Applying ${fixname} fix: ${gamename}" - sleep 1 -} - -fn_msg_end(){ - if [ $? -ne 0 ]; then - fn_print_fail_nl "Applying ${fixname} fix: ${gamename}" - fn_scriptlog "Failure! Applying ${fixname} fix: ${gamename}" - else - fn_print_ok_nl "Applying ${fixname} fix: ${gamename}" - fn_scriptlog "Complete! Applying ${fixname} fix: ${gamename}" - fi -} - # Fixes: server not always creating steam_appid.txt file. if [ ! -d "${rootdir}/.local/share/Arma\ 3" ]; then - local fixname="20150 Segmentation fault (core dumped)" - fn_msg_start + fixname="20150 Segmentation fault (core dumped)" + fn_fix_msg_start mkdir -p "${rootdir}/.local/share/Arma\ 3" - fn_msg_end + fn_fix_msg_end fi \ No newline at end of file diff --git a/functions/fix_csgo.sh b/functions/fix_csgo.sh index 33fd7c169..f968640ce 100644 --- a/functions/fix_csgo.sh +++ b/functions/fix_csgo.sh @@ -2,60 +2,42 @@ # LGSM fix_csgo.sh function # Author: Daniel Gibbs # Website: http://gameservermanagers.com -lgsm_version="301215" +lgsm_version="010316" # Description: Resolves various issues with csgo. -fn_msg_start(){ - fn_print_dots "Applying ${fixname} fix: ${gamename}" - sleep 1 - fn_print_info "Applying ${fixname} fix: ${gamename}" - fn_scriptlog "Applying ${fixname} fix: ${gamename}" - sleep 1 -} - -fn_msg_end(){ - if [ $? -ne 0 ]; then - fn_print_fail_nl "Applying ${fixname} fix: ${gamename}" - fn_scriptlog "Failure! Applying ${fixname} fix: ${gamename}" - else - fn_print_ok_nl "Applying ${fixname} fix: ${gamename}" - fn_scriptlog "Complete! Applying ${fixname} fix: ${gamename}" - fi -} - # Fixes: server not always creating steam_appid.txt file. if [ ! -f "${filesdir}/steam_appid.txt" ]; then - local fixname="730 steam_appid.txt" - fn_msg_start + fixname="730 steam_appid.txt" + fn_fix_msg_start echo -n "730" >> "${filesdir}/steam_appid.txt" - fn_msg_end + fn_fix_msg_end fi # Fixes: Error parsing BotProfile.db - unknown attribute 'Rank'". if ! grep -q "//Rank" "${systemdir}/botprofile.db" > /dev/null 2>&1; then - local fixname="botprofile.db" - fn_msg_start + fixname="botprofile.db" + fn_fix_msg_start sed -i 's/\tRank/\t\/\/Rank/g' "${systemdir}/botprofile.db" > /dev/null 2>&1 - fn_msg_end + fn_fix_msg_end fi # Fixes: Unknown command "cl_bobamt_vert". if ! grep -q "//exec default" "${servercfgdir}/valve.rc" > /dev/null 2>&1 || ! grep -q "//exec joystick" "${servercfgdir}/valve.rc" > /dev/null 2>&1; then - local fixname="valve.rc" - fn_msg_start + fixname="valve.rc" + fn_fix_msg_start sed -i 's/exec default.cfg/\/\/exec default.cfg/g' "${servercfgdir}/valve.rc" > /dev/null 2>&1 sed -i 's/exec joystick.cfg/\/\/exec joystick.cfg/g' "${servercfgdir}/valve.rc" > /dev/null 2>&1 - fn_msg_end + fn_fix_msg_end fi # Fixes: workshop map issue. # http://forums.steampowered.com/forums/showthread.php?t=3170366. if [ -f "${systemdir}/subscribed_collection_ids.txt" ]||[ -f "${systemdir}/subscribed_file_ids.txt" ]||[ -f "${systemdir}/ugc_collection_cache.txt" ]; then - local fixname="workshop map" - fn_msg_start + fixname="workshop map" + fn_fix_msg_start rm -f "${systemdir}/subscribed_collection_ids.txt" rm -f "${systemdir}/subscribed_file_ids.txt" rm -f "${systemdir}/ugc_collection_cache.txt" - fn_msg_end + fn_fix_msg_end fi \ No newline at end of file diff --git a/functions/fix_dst.sh b/functions/fix_dst.sh index b860f6d09..feec27b14 100644 --- a/functions/fix_dst.sh +++ b/functions/fix_dst.sh @@ -2,33 +2,13 @@ # LGSM fix_dst.sh function # Author: Daniel Gibbs # Website: http://gameservermanagers.com -lgsm_version="020116" - -# Fixes line 63: 20150 Segmentation fault (core dumped) #488 - -fn_msg_start(){ - fn_print_dots "Applying ${fixname} fix: ${gamename}" - sleep 1 - fn_print_info "Applying ${fixname} fix: ${gamename}" - fn_scriptlog "Applying ${fixname} fix: ${gamename}" - sleep 1 -} - -fn_msg_end(){ - if [ $? -ne 0 ]; then - fn_print_fail_nl "Applying ${fixname} fix: ${gamename}" - fn_scriptlog "Failure! Applying ${fixname} fix: ${gamename}" - else - fn_print_ok_nl "Applying ${fixname} fix: ${gamename}" - fn_scriptlog "Complete! Applying ${fixname} fix: ${gamename}" - fi -} +lgsm_version="010316" # Fixes: ./dontstarve_dedicated_server_nullrenderer: ./lib32/libcurl-gnutls.so.4: no version information available (required by ./dontstarve_dedicated_server_nullrenderer) # Issue only occures on CentOS as libcurl-gnutls.so.4 is called libcurl.so.4 on CentOS. if [ -f "/etc/redhat-release" ] && [ ! -f "${filesdir}/bin/lib32/libcurl-gnutls.so.4" ]; then - local fixname="libcurl-gnutls.so.4 missing" - fn_msg_start + fixname="libcurl-gnutls.so.4 missing" + fn_fix_msg_start ln -s "/usr/lib/libcurl.so.4" "${filesdir}/bin/lib32/libcurl-gnutls.so.4" - fn_msg_end + fn_fix_msg_end fi \ No newline at end of file diff --git a/functions/fix_ro.sh b/functions/fix_ro.sh index d3d0ac0e2..a7c703e1a 100644 --- a/functions/fix_ro.sh +++ b/functions/fix_ro.sh @@ -2,14 +2,14 @@ # LGSM fix_ro.sh function # Author: Daniel Gibbs # Website: http://gameservermanagers.com -lgsm_version="271215" +lgsm_version="010316" echo "Applying WebAdmin ROOst.css fix." echo "http://forums.tripwireinteractive.com/showpost.php?p=585435&postcount=13" sed -i 's/none}/none;/g' "${filesdir}/Web/ServerAdmin/ROOst.css" sed -i 's/underline}/underline;/g' "${filesdir}/Web/ServerAdmin/ROOst.css" sleep 1 -echo "Applying WebAdmin CharSet fix." +echo "Applying WebAdmin CharSet fix." echo "http://forums.tripwireinteractive.com/showpost.php?p=442340&postcount=1" sed -i 's/CharSet="iso-8859-1"/CharSet="utf-8"/g' "${systemdir}/uweb.int" sleep 1 diff --git a/functions/fix_steamcmd.sh b/functions/fix_steamcmd.sh index a05f783c4..46f52e4c8 100644 --- a/functions/fix_steamcmd.sh +++ b/functions/fix_steamcmd.sh @@ -2,60 +2,41 @@ # LGSM fix_steamcmd.sh function # Author: Daniel Gibbs # Website: http://gameservermanagers.com -lgsm_version="010116" +lgsm_version="010316" # Description: fixes various issues related to steamCMD. -fn_msg_start(){ - fn_print_dots "Applying ${fixname} fix: ${gamename}" - sleep 1 - fn_print_info "Applying ${fixname} fix: ${gamename}" - fn_scriptlog "Applying ${fixname} fix: ${gamename}" - sleep 1 -} - -fn_msg_end(){ - if [ $? -ne 0 ]; then - fn_print_fail_nl "Applying ${fixname} fix: ${gamename}" - fn_scriptlog "Failure! Applying ${fixname} fix: ${gamename}" - else - fn_print_ok_nl "Applying ${fixname} fix: ${gamename}" - fn_scriptlog "Complete! Applying ${fixname} fix: ${gamename}" - fi -} - - # Fixes: [S_API FAIL] SteamAPI_Init() failed; unable to locate a running instance of Steam,or a local steamclient.so. if [ ! -f "${HOME}/.steam/sdk32/steamclient.so" ]; then - local fixname="steamclient.so general" - fn_msg_start + fixname="steamclient.so general" + fn_fix_msg_start mkdir -pv "${HOME}/.steam/sdk32" >> "${scriptlog}" cp -v "${rootdir}/steamcmd/linux32/steamclient.so" "${HOME}/.steam/sdk32/steamclient.so" >> "${scriptlog}" - fn_msg_end + fn_fix_msg_end fi if [ "${gamename}" == "Serious Sam 3: BFE" ]; then # Fixes: .steam/bin32/libsteam.so: cannot open shared object file: No such file or directory if [ ! -f "${HOME}/.steam/bin32/libsteam.so" ]; then - local fixname="libsteam.so" - fn_msg_start + fixname="libsteam.so" + fn_fix_msg_start mkdir -pv "${HOME}/.steam/bin32" >> "${scriptlog}" cp -v "${filesdir}/Bin/libsteam.so" "${HOME}/.steam/bin32/libsteam.so" >> "${scriptlog}" - fn_msg_end + fn_fix_msg_end fi elif [ "${gamename}" == "Hurtworld" ]; then # Fixes: [S_API FAIL] SteamAPI_Init() failed; unable to locate a running instance of Steam, or a local steamclient.so. if [ ! -f "${filesdir}/Hurtworld_Data/Plugins/x86/steamclient.so" ]; then - local fixname="steamclient.so x86" - fn_msg_start + fixname="steamclient.so x86" + fn_fix_msg_start cp -v "${rootdir}/steamcmd/linux32/steamclient.so" "${filesdir}/Hurtworld_Data/Plugins/x86/steamclient.so" >> "${scriptlog}" - fn_msg_end + fn_fix_msg_end fi if [ ! -f "${filesdir}/Hurtworld_Data/Plugins/x86_64/steamclient.so" ]; then - local fixname="steamclient.so x86_64" - fn_msg_start + fixname="steamclient.so x86_64" + fn_fix_msg_start cp -v "${rootdir}/steamcmd/linux32/steamclient.so" "${filesdir}/Hurtworld_Data/Plugins/x86_64/steamclient.so" >> "${scriptlog}" - fn_msg_end + fn_fix_msg_end fi fi diff --git a/functions/fix_ut2k4.sh b/functions/fix_ut2k4.sh index b9ec4ad8a..eff67a12c 100644 --- a/functions/fix_ut2k4.sh +++ b/functions/fix_ut2k4.sh @@ -2,7 +2,7 @@ # LGSM fix_ut2k4.sh function # Author: Daniel Gibbs # Website: http://gameservermanagers.com -lgsm_version="271215" +lgsm_version="010316" echo "applying WebAdmin ut2003.css fix." echo "http://forums.tripwireinteractive.com/showpost.php?p=585435&postcount=13" @@ -13,15 +13,10 @@ echo "applying WebAdmin CharSet fix." echo "http://forums.tripwireinteractive.com/showpost.php?p=442340&postcount=1" sed -i 's/CharSet="iso-8859-1"/CharSet="utf-8"/g' "${systemdir}/UWeb.int" sleep 1 -echo "" -echo -en "forcing server restart.\r" -sleep 0.5 -echo -en "forcing server restart..\r" -sleep 0.5 -echo -en "forcing server restart...\r" -sleep 0.5 -echo -en "\n" -sleep 0.5 +echo "applying server name fix." +sleep 1 +echo "forcing server restart..." +sleep 1 command_start.sh sleep 5 command_stop.sh From 5d6cf92630dcc8f75865e4b8332ba3092f4a18d3 Mon Sep 17 00:00:00 2001 From: Daniel Gibbs Date: Tue, 1 Mar 2016 19:32:34 +0000 Subject: [PATCH 097/117] Code tidy --- functions/check.sh | 17 +++-------------- functions/command_install.sh | 3 +++ functions/email.sh | 4 ++-- functions/fix.sh | 2 +- functions/fix_dst.sh | 2 ++ functions/fix_ro.sh | 2 ++ functions/fix_steamcmd.sh | 1 - functions/fix_ut2k4.sh | 2 ++ 8 files changed, 15 insertions(+), 18 deletions(-) diff --git a/functions/check.sh b/functions/check.sh index 0c2fbe7bf..3450794b9 100644 --- a/functions/check.sh +++ b/functions/check.sh @@ -7,17 +7,8 @@ lgsm_version="170216" # Description: Overall function for managing checks. # 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 -} +# Every command that requires checks just references check.sh +# check.sh selects which checks to run by using arrays check_root.sh @@ -53,9 +44,7 @@ local allowed_commands_array=( update_check.sh command_debug.sh command_start.sh for allowed_command in "${allowed_commands_array[@]}" do if [ "${allowed_command}" == "${function_selfname}" ]; then - if [ "${gamename}" == "Unreal Tournament 99" ]||[ "${gamename}" == "Unreal Tournament 2004" ]||[ "${gamename}" == "Mumble" ]||[ "${gamename}" == "Teamspeak 3" ]; then - : # These servers do not require SteamCMD. Check is skipped. - else + if [ -n "${appid}" ]; then check_steamcmd.sh fi fi diff --git a/functions/command_install.sh b/functions/command_install.sh index 77cf2d359..e14e4482e 100644 --- a/functions/command_install.sh +++ b/functions/command_install.sh @@ -4,6 +4,9 @@ # Website: http://gameservermanagers.com lgsm_version="260216" +# Description: Overall function for the installer. + + local modulename="Install" function_selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))" diff --git a/functions/email.sh b/functions/email.sh index 66d5acba7..51b097dd9 100644 --- a/functions/email.sh +++ b/functions/email.sh @@ -55,11 +55,11 @@ fn_parms }| sed -r "s/\x1B\[([0-9]{1,2}(;[0-9]{1,2})?)?[m|K]//g"| tee "${scriptlogdir}/${servicename}-email.log" > /dev/null 2>&1 echo -e "\n\n Script log\n===================" >> "${emaillog}" tail -25 "${scriptlog}" >> "${emaillog}" -if [ ! -z "${consolelog}" ]; then +if [ -n "${consolelog}" ]; then echo -e "\n\n Console log\n====================" >> "${emaillog}" tail -25 "${consolelog}" | awk '{ sub("\r$", ""); print }' >> "${emaillog}" fi -if [ ! -z "${gamelogdir}" ]; then +if [ -n "${gamelogdir}" ]; then echo -e "\n\n Server log\n====================" >> "${emaillog}" tail "${gamelogdir}"/* | grep -v "==>" | sed '/^$/d' | tail -25 >> "${emaillog}" fi diff --git a/functions/fix.sh b/functions/fix.sh index 86e397ee6..e4723e649 100644 --- a/functions/fix.sh +++ b/functions/fix.sh @@ -29,7 +29,7 @@ fn_fix_msg_end(){ # Fixes that are run on start if [ "${function_selfname}" != "command_install.sh" ]; then - if [ ! -z "${appid}" ]; then + if [ -n "${appid}" ]; then fix_steamcmd.sh fi diff --git a/functions/fix_dst.sh b/functions/fix_dst.sh index feec27b14..5dadf4b78 100644 --- a/functions/fix_dst.sh +++ b/functions/fix_dst.sh @@ -4,6 +4,8 @@ # Website: http://gameservermanagers.com lgsm_version="010316" +# Description: Resolves various issues with Dont Starve together. + # Fixes: ./dontstarve_dedicated_server_nullrenderer: ./lib32/libcurl-gnutls.so.4: no version information available (required by ./dontstarve_dedicated_server_nullrenderer) # Issue only occures on CentOS as libcurl-gnutls.so.4 is called libcurl.so.4 on CentOS. if [ -f "/etc/redhat-release" ] && [ ! -f "${filesdir}/bin/lib32/libcurl-gnutls.so.4" ]; then diff --git a/functions/fix_ro.sh b/functions/fix_ro.sh index a7c703e1a..18ceeb433 100644 --- a/functions/fix_ro.sh +++ b/functions/fix_ro.sh @@ -4,6 +4,8 @@ # Website: http://gameservermanagers.com lgsm_version="010316" +# Description: Resolves various issues with red orchestra. + echo "Applying WebAdmin ROOst.css fix." echo "http://forums.tripwireinteractive.com/showpost.php?p=585435&postcount=13" sed -i 's/none}/none;/g' "${filesdir}/Web/ServerAdmin/ROOst.css" diff --git a/functions/fix_steamcmd.sh b/functions/fix_steamcmd.sh index 46f52e4c8..86feb9e2c 100644 --- a/functions/fix_steamcmd.sh +++ b/functions/fix_steamcmd.sh @@ -26,7 +26,6 @@ if [ "${gamename}" == "Serious Sam 3: BFE" ]; then fi elif [ "${gamename}" == "Hurtworld" ]; then # Fixes: [S_API FAIL] SteamAPI_Init() failed; unable to locate a running instance of Steam, or a local steamclient.so. - if [ ! -f "${filesdir}/Hurtworld_Data/Plugins/x86/steamclient.so" ]; then fixname="steamclient.so x86" fn_fix_msg_start diff --git a/functions/fix_ut2k4.sh b/functions/fix_ut2k4.sh index eff67a12c..363aa5d56 100644 --- a/functions/fix_ut2k4.sh +++ b/functions/fix_ut2k4.sh @@ -4,6 +4,8 @@ # Website: http://gameservermanagers.com lgsm_version="010316" +# Description: Resolves various issues with unreal tournament 2004. + echo "applying WebAdmin ut2003.css fix." echo "http://forums.tripwireinteractive.com/showpost.php?p=585435&postcount=13" sed -i 's/none}/none;/g' "${filesdir}/Web/ServerAdmin/ut2003.css" From 3b6e66a5ae8f7348af3023a63e59f13d4691a978 Mon Sep 17 00:00:00 2001 From: Daniel Gibbs Date: Tue, 1 Mar 2016 19:37:59 +0000 Subject: [PATCH 098/117] Code tidy --- functions/check_ip.sh | 4 +--- functions/command_dev_debug.sh | 2 ++ functions/command_install.sh | 1 - 3 files changed, 3 insertions(+), 4 deletions(-) diff --git a/functions/check_ip.sh b/functions/check_ip.sh index c4b5be149..2a5ae5794 100644 --- a/functions/check_ip.sh +++ b/functions/check_ip.sh @@ -7,9 +7,7 @@ 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 [ "${gamename}" == "Teamspeak 3" ]; then - : -else +if [ "${gamename}" != "Teamspeak 3" ]; then if [ ! -f "/bin/ip" ]; then ipcommand="/sbin/ip" else diff --git a/functions/command_dev_debug.sh b/functions/command_dev_debug.sh index 1855f5919..46bae900d 100644 --- a/functions/command_dev_debug.sh +++ b/functions/command_dev_debug.sh @@ -4,6 +4,8 @@ # Website: http://gameservermanagers.com lgsm_version="281215" +# Description: Dev only: enables debuging log to be saved to dev-debug.log. + function_selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))" if [ -f ".dev-debug" ]; then diff --git a/functions/command_install.sh b/functions/command_install.sh index e14e4482e..877896380 100644 --- a/functions/command_install.sh +++ b/functions/command_install.sh @@ -6,7 +6,6 @@ lgsm_version="260216" # Description: Overall function for the installer. - local modulename="Install" function_selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))" From 9d3bbf3a9a547548d059ae3d4952fd784ef2853d Mon Sep 17 00:00:00 2001 From: Daniel Gibbs Date: Tue, 1 Mar 2016 19:58:43 +0000 Subject: [PATCH 099/117] Fixed 7 Days to Die deps not working --- functions/check_deps.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/functions/check_deps.sh b/functions/check_deps.sh index 3cd5d32ce..535a15330 100644 --- a/functions/check_deps.sh +++ b/functions/check_deps.sh @@ -135,7 +135,7 @@ if [ -n "$(command -v dpkg-query)" ]; then if [ "${engine}" == "spark" ]; then array_deps_required+=( speex:i386 libtbb2 ) # 7 Days to Die - elif [ "${executable}" == "./7DaysToDie.sh" ]; then + elif [ "${gamename}" == "7 Days To Die" ]; then array_deps_required+=( telnet expect ) # No More Room in Hell elif [ "${gamename}" == "No More Room in Hell" ]; then From 2fe511007f008025cc1cacd4edd5a21b0c9d625c Mon Sep 17 00:00:00 2001 From: Daniel Gibbs Date: Tue, 1 Mar 2016 20:14:59 +0000 Subject: [PATCH 100/117] Fixed issue #696 --- functions/info_config.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/functions/info_config.sh b/functions/info_config.sh index 3fe13fc0e..91b8ab67a 100644 --- a/functions/info_config.sh +++ b/functions/info_config.sh @@ -2,7 +2,7 @@ # LGSM info_config.sh function # Author: Daniel Gibbs # Website: http://gameservermanagers.com -lgsm_version="060116" +lgsm_version="010316" # Description: Gets specific details from config files. @@ -513,7 +513,7 @@ elif [ "${gamename}" == "7 Days To Die" ]; then # telnet password if [ -f "${servercfgfullpath}" ]; then - telnetpass=$(grep "TelnetEnabled" "${servercfgfullpath}" | sed 's/^.*value="//' | cut -f1 -d"\"") + telnetpass=$(grep "TelnetPassword" "${servercfgfullpath}" | sed 's/^.*value="//' | cut -f1 -d"\"") if [ ! -n "${telnetpass}" ]; then telnetpass="NOT SET" fi From 54895153bc296dcf44fa3f2a01bbb8afce300622 Mon Sep 17 00:00:00 2001 From: Daniel Gibbs Date: Wed, 2 Mar 2016 21:39:53 +0000 Subject: [PATCH 101/117] improvements to stop command improvements to graceful shutdown using functions more for easy reading --- functions/command_stop.sh | 295 ++++++++++++++++++++++---------------- 1 file changed, 169 insertions(+), 126 deletions(-) diff --git a/functions/command_stop.sh b/functions/command_stop.sh index d5d589beb..9d75fbc5a 100644 --- a/functions/command_stop.sh +++ b/functions/command_stop.sh @@ -9,40 +9,146 @@ lgsm_version="271215" local modulename="Stopping" function_selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))" -sdtd_telnet(){ - sdtdshutdown=$( expect -c ' - proc abort {} { - puts "Timeout or EOF\n" - exit 1 - } - spawn telnet '"${telnetip}"' '"${telnetport}"' - expect { - "password:" { send "'"${telnetpass}"'\r" } - default abort - } - expect { - "session." { send "shutdown\r" } - default abort - } - expect { eof } - puts "Completed.\n" - ') +# Attempts Graceful of source using rcon 'quit' command. +fn_stop_graceful_source(){ +fn_print_dots "Graceful: rcon quit" +fn_scriptlog "Graceful: rcon quit" +# sends quit +tmux send -t "${servicename}" quit ENTER > /dev/null 2>&1 +# waits up to 30 seconds giving the server time to shutdown gracefuly +for seconds in {1..30}; do + pid=$(tmux list-sessions 2>&1|awk '{print $1}'|grep -Ec "^${servicename}:") + if [ "${pid}" == "0" ]; then + fn_print_ok_nl "Graceful: rcon quit: ${seconds}" + fn_scriptlog "Graceful: rcon quit: OK: ${seconds} seconds" + break + fi + sleep 1 + fn_print_dots "Graceful: rcon quit: ${seconds}" +done +if [ "${pid}" != "0" ]; then + fn_print_fail_nl "Graceful: rcon quit" + fn_scriptlog "Graceful: rcon quit: FAIL" +fi +sleep 1 +} + +# Attempts Graceful of goldsource using rcon 'quit' command. +# Goldsource 'quit' command restarts rather than shutsdown +# this function will only wait 3 seconds then force a tmux shutdown. +# preventing the server from coming back online. +fn_stop_graceful_goldsource(){ +fn_print_dots "Graceful: rcon quit" +fn_scriptlog "Graceful: rcon quit" +# sends quit +tmux send -t "${servicename}" quit ENTER > /dev/null 2>&1 +# waits 3 seconds as goldsource servers restart with the quit command +for seconds in {1..3}; do + sleep 1 + fn_print_dots "Graceful: rcon quit: ${seconds}" +done +fn_print_ok_nl "Graceful: rcon quit: ${seconds}" +sleep 1 +} + +# Attempts Graceful of 7 Days To Die using telnet. +fn_stop_telnet_sdtd(){ +sdtdshutdown=$( expect -c ' +proc abort {} { + puts "Timeout or EOF\n" + exit 1 +} +spawn telnet '"${telnetip}"' '"${telnetport}"' +expect { + "password:" { send "'"${telnetpass}"'\r" } + default abort +} +expect { + "session." { send "shutdown\r" } + default abort +} +expect { eof } +puts "Completed.\n" +') +} + +fn_stop_graceful_sdtd(){ +# Gets server IP. +info_config.sh + +fn_print_dots "Graceful: telnet" +fn_scriptlog "Graceful: telnet" +sleep 1 + +# uses localhost on first attempt. +telnetip=127.0.0.1 +fn_print_dots "Graceful: telnet: ${telnetip}" +fn_scriptlog "Graceful: telnet: ${telnetip}" +fn_stop_telnet_sdtd +sleep 1 + +# falls back to the server ip if localhost fails. +refused=$(echo -en "\n ${sdtdshutdown}"| grep "Timeout or EOF") +if [ -n "${refused}" ]; then + fn_print_warn_nl "Graceful: telnet: localhost: " + fn_print_fail_eol + fn_scriptlog "Graceful: telnet: localhost: FAIL" + sleep 1 + + telnetip=${ip} + fn_print_dots "Graceful: telnet: ${telnetip}" + fn_scriptlog "Graceful: telnet: ${telnetip}" + fn_stop_telnet_sdtd + refused=$(echo -en "\n ${sdtdshutdown}"| grep "Timeout or EOF") + + fn_print_warnnl "Graceful: telnet: ${telnetip}: " + fn_print_fail_eol + fn_scriptlog "Graceful: telnet: ${telnetip}: FAIL" + sleep 1 +fi + +# Checks if attempts have worked. +completed=$(echo -en "\n ${sdtdshutdown}"| grep "Completed.") +if [ -n "${completed}" ]; then + fn_print_ok_nl "Graceful: telnet: " + fn_print_ok_eol + fn_scriptlog "Graceful: telnet: OK" +elif [ -n "${refused}" ]; then + fn_print_fail_nl "Graceful: telnet: " + fn_print_fail_eol + fn_scriptlog "Graceful: telnet: ${telnetip}: FAIL" + echo -en "\n\n" | tee -a "${scriptlog}" + echo -en "Telnet output:" | tee -a "${scriptlog}" + echo -en "\n ${sdtdshutdown}" | tee -a "${scriptlog}" + echo -en "\n\n" | tee -a "${scriptlog}" +else + fn_print_fail_nl "Graceful: telnet: Unknown error" + fn_scriptlog "Graceful: telnet: Unknown error" + echo -en "\n\n" | tee -a "${scriptlog}" + echo -en "Telnet output:" | tee -a "${scriptlog}" + echo -en "\n ${sdtdshutdown}" | tee -a "${scriptlog}" + echo -en "\n\n" | tee -a "${scriptlog}" +fi +} + +fn_stop_graceful_select(){ +if [ "${gamename}" == "7 Days to Die" ]; then + fn_stop_graceful_sdtd +elif [ "${engine}" == "source" ]; then + fn_stop_graceful_source +elif [ "${engine}" == "goldsource" ]; then + fn_stop_graceful_goldsource +else + fn_stop_tmux } fn_stop_teamspeak3(){ -check.sh fn_print_dots "${servername}" fn_scriptlog "${servername}" sleep 1 -info_ts3status.sh -if [ "${ts3status}" = "No server running (ts3server.pid is missing)" ]; then - fn_print_fail "${servername} is already stopped" - fn_scriptlog "${servername} is already stopped" -else - ${filesdir}/ts3server_startscript.sh stop > /dev/null 2>&1 - fn_print_ok "${servername}" - fn_scriptlog "Stopped ${servername}" -fi +${filesdir}/ts3server_startscript.sh stop > /dev/null 2>&1 +fn_print_ok "${servername}" +fn_scriptlog "Stopped ${servername}" # Remove lock file rm -f "${rootdir}/${lockselfname}" sleep 1 @@ -50,110 +156,47 @@ echo -en "\n" } fn_stop_tmux(){ -check.sh -info_config.sh fn_print_dots "${servername}" fn_scriptlog "${servername}" sleep 1 - -if [ "${gamename}" == "7 Days To Die" ] ; then - # if game is 7 Days To Die, we need special, graceful shutdown via telnet connection. - # Set below variable to be called for expect to operate correctly.. - fn_print_dots "Attempting graceful shutdown via telnet" - fn_scriptlog "Attempting graceful shutdown via telnet" - sleep 1 - telnetip=127.0.0.1 - sdtd_telnet - - # If failed using localhost will use servers ip - refused=$(echo -en "\n ${sdtdshutdown}"| grep "Timeout or EOF") - if [ -n "${refused}" ]; then - telnetip=${ip} - fn_print_warn "Attempting graceful shutdown via telnet: localhost failed" - fn_scriptlog "Warning! Attempting graceful shutdown failed using localhost" - sleep 5 - echo -en "\n" - fn_print_dots "Attempting graceful shutdown via telnet: using ${telnetip}" - fn_scriptlog "Attempting graceful shutdown via telnet using ${telnetip}" - sdtd_telnet - sleep 1 - fi - - refused=$(echo -en "\n ${sdtdshutdown}"| grep "Timeout or EOF") - completed=$(echo -en "\n ${sdtdshutdown}"| grep "Completed.") - if [ -n "${refused}" ]; then - fn_print_fail "Attempting graceful shutdown via telnet" - fn_scriptlog "Attempting graceful shutdown failed" - fn_scriptlog "${refused}" - elif [ -n "${completed}" ]; then - fn_print_ok "Attempting graceful shutdown via telnet" - fn_scriptlog "Attempting graceful shutdown succeeded" - else - fn_print_fail "Attempting graceful shutdown via telnet: Unknown error" - fn_scriptlog "Attempting graceful shutdown failed" - fn_scriptlog "Unknown error" - fi - sleep 1 - echo -en "\n\n" - echo -en "Telnet output:" - echo -en "\n ${sdtdshutdown}" - echo -en "\n\n" - sleep 1 - fn_print_dots "${servername}" - fn_scriptlog "${servername}" - sleep 5 - pid=$(tmux list-sessions 2>&1|awk '{print $1}'|grep -Ec "^${servicename}:") - if [ "${pid}" == "0" ]; then - fn_print_ok "${servername} is already stopped using graceful shutdown" - fn_scriptlog "${servername} is already stopped using graceful shutdown" - else - tmux kill-session -t "${servicename}" - fn_print_ok "${servername}" - fn_scriptlog "Stopped ${servername}" - fi - +# Kill tmux session +tmux kill-session -t "${servicename}" > /dev/null 2>&1 +pid=$(tmux list-sessions 2>&1|awk '{print $1}'|grep -Ec "^${servicename}:") +if [ "${pid}" == "0" ]; then + fn_print_ok_nl "${servername}" + fn_scriptlog "Stopped ${servername}" + sleep 1 + # Remove lock file + rm -f "${rootdir}/${lockselfname}" else - pid=$(tmux list-sessions 2>&1|awk '{print $1}'|grep -Ec "^${servicename}:") - if [ "${pid}" == "0" ]; then - fn_print_fail "${servername} is already stopped" - fn_scriptlog "${servername} is already stopped" - else - - if [ "${engine}" == "source" ]||[ "${engine}" == "goldsource" ]; then - sleep 1 - fn_print_dots "Attempting graceful shutdown" - fn_scriptlog "Attempting graceful shutdown" - tmux send -t "${servicename}" quit ENTER > /dev/null 2>&1 - counter=0 - while [ "${pid}" != "0" -a $counter -lt 30 ]; do - pid=$(tmux list-sessions 2>&1|awk '{print $1}'|grep -Ec "^${servicename}:") - sleep 1 - let counter=counter+1 - if [ "${counter}" -gt "1" ]; then - fn_print_dots "Attempting graceful shutdown: ${counter}" - fi - done - pid=$(tmux list-sessions 2>&1|awk '{print $1}'|grep -Ec "^${servicename}:") - if [ "${pid}" == "0" ]; then - fn_print_ok "Attempting graceful shutdown" - else - fn_print_fail "Attempting graceful shutdown" - fi - fi - - tmux kill-session -t "${servicename}" > /dev/null 2>&1 - fn_print_ok "${servername}" - fn_scriptlog "Stopped ${servername}" - fi + fn_print_fail_nl "Unable to stop${servername}" + fn_scriptlog "Unable to stop${servername}" fi - # Remove lock file - rm -f "${rootdir}/${lockselfname}" - sleep 1 - echo -en "\n" + } +# checks if the server is already stopped before trying to stop. +fn_stop_pre_check(){ if [ "${gamename}" == "Teamspeak 3" ]; then - fn_stop_teamspeak3 + info_ts3status.sh + if [ "${ts3status}" = "No server running (ts3server.pid is missing)" ]; then + fn_print_ok_nl "${servername} is already stopped" + fn_scriptlog "${servername} is already stopped" + else + fn_stop_teamspeak3 + fi else - fn_stop_tmux -fi \ No newline at end of file + pid=$(tmux list-sessions 2>&1|awk '{print $1}'|grep -Ec "^${servicename}:") + if [ "${pid}" == "0" ]; then + fn_print_ok_nl "${servername} is already stopped" + fn_scriptlog "${servername} is already stopped" + else + fn_stop_graceful_select + fi +fi +} + + + +check.sh +fn_stop_pre_check \ No newline at end of file From 7e732a2f6f5adea61cb4f89938993f1360283d85 Mon Sep 17 00:00:00 2001 From: Daniel Gibbs Date: Wed, 2 Mar 2016 21:41:28 +0000 Subject: [PATCH 102/117] missing fi --- functions/command_stop.sh | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/functions/command_stop.sh b/functions/command_stop.sh index 9d75fbc5a..a91bed79d 100644 --- a/functions/command_stop.sh +++ b/functions/command_stop.sh @@ -139,7 +139,8 @@ elif [ "${engine}" == "source" ]; then elif [ "${engine}" == "goldsource" ]; then fn_stop_graceful_goldsource else - fn_stop_tmux + fn_stop_tmux +fi } fn_stop_teamspeak3(){ @@ -196,7 +197,5 @@ else fi } - - check.sh fn_stop_pre_check \ No newline at end of file From c2cf00f74679e03ed610006b20ea0cc6a2316dd3 Mon Sep 17 00:00:00 2001 From: Daniel Gibbs Date: Wed, 2 Mar 2016 21:49:20 +0000 Subject: [PATCH 103/117] added tmux_stop --- functions/command_stop.sh | 2 ++ 1 file changed, 2 insertions(+) diff --git a/functions/command_stop.sh b/functions/command_stop.sh index a91bed79d..a127ebc4b 100644 --- a/functions/command_stop.sh +++ b/functions/command_stop.sh @@ -29,6 +29,7 @@ done if [ "${pid}" != "0" ]; then fn_print_fail_nl "Graceful: rcon quit" fn_scriptlog "Graceful: rcon quit: FAIL" + fn_stop_tmux fi sleep 1 } @@ -49,6 +50,7 @@ for seconds in {1..3}; do done fn_print_ok_nl "Graceful: rcon quit: ${seconds}" sleep 1 +fn_stop_tmux } # Attempts Graceful of 7 Days To Die using telnet. From cbb5bbe170062db001149a8ca1057ca95b33a5e4 Mon Sep 17 00:00:00 2001 From: Daniel Gibbs Date: Wed, 2 Mar 2016 22:12:24 +0000 Subject: [PATCH 104/117] all nl messages will act the same most nl messages already waited 1 second before new line. however all should now do this giving a more consistent feel --- functions/check_logs.sh | 3 +-- functions/command_debug.sh | 4 +--- functions/command_start.sh | 6 +---- functions/command_stop.sh | 11 +++++---- functions/command_validate.sh | 4 +--- functions/core_messages.sh | 44 ++++++++++++++++++++++++----------- functions/email.sh | 6 ++--- functions/logs.sh | 12 +++------- 8 files changed, 46 insertions(+), 44 deletions(-) diff --git a/functions/check_logs.sh b/functions/check_logs.sh index f390eeab4..9b4f41324 100644 --- a/functions/check_logs.sh +++ b/functions/check_logs.sh @@ -10,8 +10,7 @@ lgsm_version="271215" if [ ! -d "${scriptlogdir}" ]; then fn_print_dots "Checking for log files" sleep 1 - fn_print_info "Checking for log files: Creating log files" - echo -en "\n" + fn_print_info_nl "Checking for log files: Creating log files" checklogs=1 install_logs.sh fi diff --git a/functions/command_debug.sh b/functions/command_debug.sh index 7c9aca38b..baa93aec0 100644 --- a/functions/command_debug.sh +++ b/functions/command_debug.sh @@ -48,10 +48,8 @@ sleep 1 command_stop.sh fn_print_dots "Starting debug" sleep 1 -fn_print_ok "Starting debug" +fn_print_ok_nl "Starting debug" fn_scriptlog "Started debug" -sleep 1 -echo -en "\n" cd "${executabledir}" fix.sh if [ "${engine}" == "source" ]||[ "${engine}" == "goldsource" ]; then diff --git a/functions/command_start.sh b/functions/command_start.sh index fd30a17bb..e1e324caf 100644 --- a/functions/command_start.sh +++ b/functions/command_start.sh @@ -104,10 +104,8 @@ if [ "${tmuxwc}" -eq 0 ]; then fi if [ "${tmuxwc}" -eq 1 ]; then - fn_print_info "${servername} is already running" + fn_print_info_nl "${servername} is already running" fn_scriptlog "${servername} is already running" - sleep 1 - echo -en "\n" exit fi @@ -138,8 +136,6 @@ if [ "${tmuxwc}" -eq 0 ]; then if [ -s "${scriptlogdir}/.${servicename}-tmux-error.tmp" ]; then fn_print_fail_nl "Unable to start ${servername}: Tmux error:" fn_scriptlog "Tmux error" - sleep 1 - echo -en "\n" echo "" echo "Command" echo "=================================" diff --git a/functions/command_stop.sh b/functions/command_stop.sh index a127ebc4b..3e6a7e398 100644 --- a/functions/command_stop.sh +++ b/functions/command_stop.sh @@ -150,17 +150,15 @@ fn_print_dots "${servername}" fn_scriptlog "${servername}" sleep 1 ${filesdir}/ts3server_startscript.sh stop > /dev/null 2>&1 -fn_print_ok "${servername}" -fn_scriptlog "Stopped ${servername}" # Remove lock file rm -f "${rootdir}/${lockselfname}" -sleep 1 -echo -en "\n" +fn_print_ok_nl "${servername}" +fn_scriptlog "Stopped ${servername}" } fn_stop_tmux(){ fn_print_dots "${servername}" -fn_scriptlog "${servername}" +fn_scriptlog "tmux kill-session: ${servername}" sleep 1 # Kill tmux session tmux kill-session -t "${servicename}" > /dev/null 2>&1 @@ -200,4 +198,7 @@ fi } check.sh +fn_print_dots "${servername}" +fn_scriptlog "${servername}" +sleep 1 fn_stop_pre_check \ No newline at end of file diff --git a/functions/command_validate.sh b/functions/command_validate.sh index 59c03b6ff..f4c46c071 100644 --- a/functions/command_validate.sh +++ b/functions/command_validate.sh @@ -10,9 +10,7 @@ local modulename="Validate" function_selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))" fn_validation(){ -fn_print_warn "Validating may overwrite some customised files." -sleep 1 -echo -en "\n" +fn_print_warn_nl "Validating may overwrite some customised files." echo -en "https://developer.valvesoftware.com/wiki/SteamCMD#Validate" sleep 5 echo -en "\n" diff --git a/functions/core_messages.sh b/functions/core_messages.sh index eeaac4170..2cbcd08f7 100644 --- a/functions/core_messages.sh +++ b/functions/core_messages.sh @@ -30,10 +30,12 @@ fn_print_fail(){ fn_print_fail_nl(){ if [ -n "${modulename}" ]; then - echo -e "\r\033[K[\e[0;31m FAIL \e[0m] ${modulename} ${servicename}: $@" + echo -en "\r\033[K[\e[0;31m FAIL \e[0m] ${modulename} ${servicename}: $@" else - echo -e "\r\033[K[\e[0;31m FAIL \e[0m] $@" + echo -en "\r\033[K[\e[0;31m FAIL \e[0m] $@" fi + sleep 1 + echo -en "\n" } # [ OK ] @@ -47,10 +49,12 @@ fn_print_ok(){ fn_print_ok_nl(){ if [ -n "${modulename}" ]; then - echo -e "\r\033[K[\e[0;32m OK \e[0m] ${modulename} ${servicename}: $@" + echo -en "\r\033[K[\e[0;32m OK \e[0m] ${modulename} ${servicename}: $@" else - echo -e "\r\033[K[\e[0;32m OK \e[0m] $@" + echo -en "\r\033[K[\e[0;32m OK \e[0m] $@" fi + sleep 1 + echo -en "\n" } # [ INFO ] @@ -64,10 +68,12 @@ fn_print_info(){ fn_print_info_nl(){ if [ -n "${modulename}" ]; then - echo -e "\r\033[K[\e[0;36m INFO \e[0m] ${modulename} ${servicename}: $@" + echo -en "\r\033[K[\e[0;36m INFO \e[0m] ${modulename} ${servicename}: $@" else - echo -e "\r\033[K[\e[0;36m INFO \e[0m] $@" + echo -en "\r\033[K[\e[0;36m INFO \e[0m] $@" fi + sleep 1 + echo -en "\n" } # [ WARN ] @@ -81,10 +87,12 @@ fn_print_warn(){ fn_print_warn_nl(){ if [ -n "${modulename}" ]; then - echo -e "\r\033[K[\e[1;33m WARN \e[0m] ${modulename} ${servicename}: $@" + echo -en "\r\033[K[\e[1;33m WARN \e[0m] ${modulename} ${servicename}: $@" else - echo -e "\r\033[K[\e[1;33m WARN \e[0m] $@" + echo -en "\r\033[K[\e[1;33m WARN \e[0m] $@" fi + sleep 1 + echo -en "\n" } # [ .... ] @@ -120,7 +128,9 @@ fn_print_failure(){ } fn_print_failure_nl(){ - echo -e "\e[0;31mFailure!\e[0m $@" + echo -en "\e[0;31mFailure!\e[0m $@" + sleep 1 + echo -en "\n" } # Error! @@ -129,7 +139,9 @@ fn_print_error(){ } fn_print_error_nl(){ - echo -e "\e[0;31mError!\e[0m $@" + echo -en "\e[0;31mError!\e[0m $@" + sleep 1 + echo -en "\n" } # Info! @@ -138,7 +150,9 @@ fn_print_infomation(){ } fn_print_infomation_nl(){ - echo -e "\e[0;36mInfomation!\e[0m $@" + echo -en "\e[0;36mInfomation!\e[0m $@" + sleep 1 + echo -en "\n" } # FAIL for end of line @@ -147,7 +161,9 @@ fn_print_ok_eol(){ } fn_print_ok_eol_nl(){ - echo -e "\e[0;32mOK\e[0m" + echo -en "\e[0;32mOK\e[0m" + sleep 1 + echo -en "\n" } # FAIL for end of line @@ -156,7 +172,9 @@ fn_print_fail_eol(){ } fn_print_fail_eol_nl(){ - echo -e "\e[0;31mFAIL\e[0m" + echo -en "\e[0;31mFAIL\e[0m" + sleep 1 + echo -en "\n" } # QUERYING for end of line diff --git a/functions/email.sh b/functions/email.sh index 51b097dd9..174ed3ff6 100644 --- a/functions/email.sh +++ b/functions/email.sh @@ -64,7 +64,5 @@ if [ -n "${gamelogdir}" ]; then tail "${gamelogdir}"/* | grep -v "==>" | sed '/^$/d' | tail -25 >> "${emaillog}" fi mail -s "${subject}" ${email} < "${emaillog}" -fn_print_ok "Sending notification to ${email}" -fn_scriptlog "Sent notification to ${email}" -sleep 1 -echo -en "\n" +fn_print_ok_nl "Sending notification to ${email}" +fn_scriptlog "Sent notification to ${email}" \ No newline at end of file diff --git a/functions/logs.sh b/functions/logs.sh index 79d4de462..cb7bd805b 100644 --- a/functions/logs.sh +++ b/functions/logs.sh @@ -27,14 +27,10 @@ if [ $(find "${scriptlogdir}"/ -type f -mtime +"${logdays}"|wc -l) -ne "0" ]; th # Setting up counting variables scriptcount="0" ; consolecount="0" ; gamecount="0" ; srcdscount="0" ; smcount="0" ; ulxcount="0" ; darkrpcount="0" ; legacycount="0" sleep 1 - fn_print_ok "Starting" + fn_print_ok_nl "Starting" fn_scriptlog "Starting" - sleep 1 - echo -en "\n" - fn_print_info "Removing logs older than "${logdays}" days" + fn_print_info_nl "Removing logs older than "${logdays}" days" fn_scriptlog "Removing logs older than "${logdays}" days" - sleep 1 - echo -en "\n" # Logging logfiles to be removed according to "${logdays}", counting and removing them # Script logfiles find "${scriptlogdir}"/ -type f -mtime +"${logdays}"| tee >> "${scriptlog}" @@ -90,8 +86,6 @@ if [ $(find "${scriptlogdir}"/ -type f -mtime +"${logdays}"|wc -l) -ne "0" ]; th # Count total amount of files removed count=$((${scriptcount} + ${consolecount} + ${gamecount} + ${srcdscount} + ${smcount} + ${ulxcount} + ${darkrpcount} + ${legacycount})) # Job done - fn_print_ok "Removed ${count} log files" + fn_print_ok_nl "Removed ${count} log files" fn_scriptlog "Removed ${count} log files" - sleep 1 - echo -en "\n" fi From e8fc3ffcb93162d381c425dc1399ecd0928ff0c4 Mon Sep 17 00:00:00 2001 From: Daniel Gibbs Date: Wed, 2 Mar 2016 22:15:30 +0000 Subject: [PATCH 105/117] removed sleep from eol --- functions/core_messages.sh | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/functions/core_messages.sh b/functions/core_messages.sh index 2cbcd08f7..d8b77305f 100644 --- a/functions/core_messages.sh +++ b/functions/core_messages.sh @@ -129,8 +129,6 @@ fn_print_failure(){ fn_print_failure_nl(){ echo -en "\e[0;31mFailure!\e[0m $@" - sleep 1 - echo -en "\n" } # Error! @@ -140,8 +138,6 @@ fn_print_error(){ fn_print_error_nl(){ echo -en "\e[0;31mError!\e[0m $@" - sleep 1 - echo -en "\n" } # Info! @@ -151,8 +147,6 @@ fn_print_infomation(){ fn_print_infomation_nl(){ echo -en "\e[0;36mInfomation!\e[0m $@" - sleep 1 - echo -en "\n" } # FAIL for end of line @@ -162,8 +156,6 @@ fn_print_ok_eol(){ fn_print_ok_eol_nl(){ echo -en "\e[0;32mOK\e[0m" - sleep 1 - echo -en "\n" } # FAIL for end of line @@ -173,8 +165,6 @@ fn_print_fail_eol(){ fn_print_fail_eol_nl(){ echo -en "\e[0;31mFAIL\e[0m" - sleep 1 - echo -en "\n" } # QUERYING for end of line From 45529e47eed777543217fa1d3616a8cc119d5b4e Mon Sep 17 00:00:00 2001 From: Daniel Gibbs Date: Wed, 2 Mar 2016 22:16:45 +0000 Subject: [PATCH 106/117] nl in trap --- functions/core_dl.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/functions/core_dl.sh b/functions/core_dl.sh index 45f46e1c6..98e6ebee4 100644 --- a/functions/core_dl.sh +++ b/functions/core_dl.sh @@ -74,12 +74,12 @@ fi fn_fetch_trap() { echo "" echo -ne "downloading ${filename}: " - fn_print_canceled_eol + fn_print_canceled_eol_nl fn_scriptlog "downloading ${filename}: CANCELED" sleep 1 rm -f "${filedir}/${filename}" | tee -a "${scriptlog}" echo -ne "downloading ${filename}: " - fn_print_removed_eol + fn_print_removed_eol_nl fn_scriptlog "downloading ${filename}: REMOVED" exit } From 40395338399b1c341e2d10daedb2103fe8d12096 Mon Sep 17 00:00:00 2001 From: Daniel Gibbs Date: Wed, 2 Mar 2016 22:18:56 +0000 Subject: [PATCH 107/117] returned -n to messages --- functions/core_messages.sh | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/functions/core_messages.sh b/functions/core_messages.sh index d8b77305f..f6977f6e8 100644 --- a/functions/core_messages.sh +++ b/functions/core_messages.sh @@ -128,7 +128,7 @@ fn_print_failure(){ } fn_print_failure_nl(){ - echo -en "\e[0;31mFailure!\e[0m $@" + echo -e "\e[0;31mFailure!\e[0m $@" } # Error! @@ -137,7 +137,7 @@ fn_print_error(){ } fn_print_error_nl(){ - echo -en "\e[0;31mError!\e[0m $@" + echo -e "\e[0;31mError!\e[0m $@" } # Info! @@ -146,7 +146,7 @@ fn_print_infomation(){ } fn_print_infomation_nl(){ - echo -en "\e[0;36mInfomation!\e[0m $@" + echo -e "\e[0;36mInfomation!\e[0m $@" } # FAIL for end of line @@ -155,7 +155,7 @@ fn_print_ok_eol(){ } fn_print_ok_eol_nl(){ - echo -en "\e[0;32mOK\e[0m" + echo -e "\e[0;32mOK\e[0m" } # FAIL for end of line @@ -164,7 +164,7 @@ fn_print_fail_eol(){ } fn_print_fail_eol_nl(){ - echo -en "\e[0;31mFAIL\e[0m" + echo -e "\e[0;31mFAIL\e[0m" } # QUERYING for end of line From 4dc0f80d934067394ab852d2d6ee0cff007c7245 Mon Sep 17 00:00:00 2001 From: Daniel Gibbs Date: Thu, 3 Mar 2016 23:00:18 +0000 Subject: [PATCH 108/117] Fixed 7 days to die bug --- functions/check_deps.sh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/functions/check_deps.sh b/functions/check_deps.sh index 535a15330..f433e7298 100644 --- a/functions/check_deps.sh +++ b/functions/check_deps.sh @@ -52,8 +52,8 @@ fn_found_missing_deps(){ if [ "${#array_deps_missing[@]}" != "0" ]; then fn_print_dots "Checking dependencies" sleep 2 - fn_print_warn "Checking dependencies: Dependency missing: \e[0;31m${array_deps_missing[@]}\e[0m" - fn_scriptlog "Checking dependencies: Dependency missing: \e[0;31m${array_deps_missing[@]}\e[0m" + fn_print_warn "Checking dependencies: missing: \e[0;31m${array_deps_missing[@]}\e[0m" + fn_scriptlog "Checking dependencies: missing: \e[0;31m${array_deps_missing[@]}\e[0m" sleep 1 echo -e "" sudo -n true > /dev/null 2>&1 @@ -181,7 +181,7 @@ elif [ -n "$(command -v yum)" ]; then if [ "${engine}" == "spark" ]; then array_deps_required+=( speex.i686 tbb.i686 ) # 7 Days to Die - elif [ "${executable}" == "./7DaysToDie.sh" ]; then + elif [ "${gamename}" == "7 Days To Die" ]; then array_deps_required+=( telnet expect ) # No More Room in Hell elif [ "${gamename}" == "No More Room in Hell" ]; then From 77c5692bd85d4dcee4864cf945d44b2cf720b0e3 Mon Sep 17 00:00:00 2001 From: Daniel Gibbs Date: Fri, 4 Mar 2016 00:34:34 +0000 Subject: [PATCH 109/117] Getting sdtd graceful working better --- functions/command_stop.sh | 313 ++++++++++++++++++++------------------ 1 file changed, 164 insertions(+), 149 deletions(-) diff --git a/functions/command_stop.sh b/functions/command_stop.sh index 3e6a7e398..69b799839 100644 --- a/functions/command_stop.sh +++ b/functions/command_stop.sh @@ -11,27 +11,29 @@ function_selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))" # Attempts Graceful of source using rcon 'quit' command. fn_stop_graceful_source(){ -fn_print_dots "Graceful: rcon quit" -fn_scriptlog "Graceful: rcon quit" -# sends quit -tmux send -t "${servicename}" quit ENTER > /dev/null 2>&1 -# waits up to 30 seconds giving the server time to shutdown gracefuly -for seconds in {1..30}; do - pid=$(tmux list-sessions 2>&1|awk '{print $1}'|grep -Ec "^${servicename}:") - if [ "${pid}" == "0" ]; then - fn_print_ok_nl "Graceful: rcon quit: ${seconds}" - fn_scriptlog "Graceful: rcon quit: OK: ${seconds} seconds" - break + fn_print_dots "Graceful: rcon quit" + fn_scriptlog "Graceful: rcon quit" + # sends quit + tmux send -t "${servicename}" quit ENTER > /dev/null 2>&1 + # waits up to 30 seconds giving the server time to shutdown gracefuly + for seconds in {1..30}; do + pid=$(tmux list-sessions 2>&1|awk '{print $1}'|grep -Ec "^${servicename}:") + if [ "${pid}" == "0" ]; then + fn_print_ok "Graceful: rcon quit: ${seconds}: " + fn_print_ok_eol_nl + fn_scriptlog "Graceful: rcon quit: OK: ${seconds} seconds" + break + fi + sleep 1 + fn_print_dots "Graceful: rcon quit: ${seconds}" + done + if [ "${pid}" != "0" ]; then + fn_print_fail "Graceful: rcon quit" + fn_print_fail_eol_nl + fn_scriptlog "Graceful: rcon quit: FAIL" + fn_stop_tmux fi sleep 1 - fn_print_dots "Graceful: rcon quit: ${seconds}" -done -if [ "${pid}" != "0" ]; then - fn_print_fail_nl "Graceful: rcon quit" - fn_scriptlog "Graceful: rcon quit: FAIL" - fn_stop_tmux -fi -sleep 1 } # Attempts Graceful of goldsource using rcon 'quit' command. @@ -39,162 +41,175 @@ sleep 1 # this function will only wait 3 seconds then force a tmux shutdown. # preventing the server from coming back online. fn_stop_graceful_goldsource(){ -fn_print_dots "Graceful: rcon quit" -fn_scriptlog "Graceful: rcon quit" -# sends quit -tmux send -t "${servicename}" quit ENTER > /dev/null 2>&1 -# waits 3 seconds as goldsource servers restart with the quit command -for seconds in {1..3}; do + fn_print_dots "Graceful: rcon quit" + fn_scriptlog "Graceful: rcon quit" + # sends quit + tmux send -t "${servicename}" quit ENTER > /dev/null 2>&1 + # waits 3 seconds as goldsource servers restart with the quit command + for seconds in {1..3}; do + sleep 1 + fn_print_dots "Graceful: rcon quit: ${seconds}" + done + fn_print_ok "Graceful: rcon quit: ${seconds}: " + fn_print_ok_eol_nl + fn_scriptlog "Graceful: rcon quit: OK: ${seconds} seconds" sleep 1 - fn_print_dots "Graceful: rcon quit: ${seconds}" -done -fn_print_ok_nl "Graceful: rcon quit: ${seconds}" -sleep 1 -fn_stop_tmux + fn_stop_tmux } # Attempts Graceful of 7 Days To Die using telnet. fn_stop_telnet_sdtd(){ -sdtdshutdown=$( expect -c ' -proc abort {} { - puts "Timeout or EOF\n" - exit 1 -} -spawn telnet '"${telnetip}"' '"${telnetport}"' -expect { - "password:" { send "'"${telnetpass}"'\r" } - default abort -} -expect { - "session." { send "shutdown\r" } - default abort -} -expect { eof } -puts "Completed.\n" -') + sdtd_telnet_shutdown=$( expect -c ' + proc abort {} { + puts "Timeout or EOF\n" + exit 1 + } + spawn telnet '"${telnetip}"' '"${telnetport}"' + expect { + "password:" { send "'"${telnetpass}"'\r" } + default abort + } + expect { + "session." { send "shutdown\r" } + default abort + } + expect { eof } + puts "Completed.\n" + ') + } fn_stop_graceful_sdtd(){ -# Gets server IP. -info_config.sh - -fn_print_dots "Graceful: telnet" -fn_scriptlog "Graceful: telnet" -sleep 1 + # Gets server IP. + info_config.sh -# uses localhost on first attempt. -telnetip=127.0.0.1 -fn_print_dots "Graceful: telnet: ${telnetip}" -fn_scriptlog "Graceful: telnet: ${telnetip}" -fn_stop_telnet_sdtd -sleep 1 - -# falls back to the server ip if localhost fails. -refused=$(echo -en "\n ${sdtdshutdown}"| grep "Timeout or EOF") -if [ -n "${refused}" ]; then - fn_print_warn_nl "Graceful: telnet: localhost: " - fn_print_fail_eol - fn_scriptlog "Graceful: telnet: localhost: FAIL" + fn_print_dots "Graceful: telnet" + fn_scriptlog "Graceful: telnet" sleep 1 - - telnetip=${ip} - fn_print_dots "Graceful: telnet: ${telnetip}" - fn_scriptlog "Graceful: telnet: ${telnetip}" - fn_stop_telnet_sdtd - refused=$(echo -en "\n ${sdtdshutdown}"| grep "Timeout or EOF") - - fn_print_warnnl "Graceful: telnet: ${telnetip}: " - fn_print_fail_eol - fn_scriptlog "Graceful: telnet: ${telnetip}: FAIL" - sleep 1 -fi - -# Checks if attempts have worked. -completed=$(echo -en "\n ${sdtdshutdown}"| grep "Completed.") -if [ -n "${completed}" ]; then - fn_print_ok_nl "Graceful: telnet: " - fn_print_ok_eol - fn_scriptlog "Graceful: telnet: OK" -elif [ -n "${refused}" ]; then - fn_print_fail_nl "Graceful: telnet: " - fn_print_fail_eol - fn_scriptlog "Graceful: telnet: ${telnetip}: FAIL" - echo -en "\n\n" | tee -a "${scriptlog}" - echo -en "Telnet output:" | tee -a "${scriptlog}" - echo -en "\n ${sdtdshutdown}" | tee -a "${scriptlog}" - echo -en "\n\n" | tee -a "${scriptlog}" -else - fn_print_fail_nl "Graceful: telnet: Unknown error" - fn_scriptlog "Graceful: telnet: Unknown error" - echo -en "\n\n" | tee -a "${scriptlog}" - echo -en "Telnet output:" | tee -a "${scriptlog}" - echo -en "\n ${sdtdshutdown}" | tee -a "${scriptlog}" - echo -en "\n\n" | tee -a "${scriptlog}" -fi + if [ "${telnetenabled}" == "false" ]; then + fn_print_info_nl "Graceful: telnet: DISABLED: Enable in ${servercfg}" + elif [ "$(command -v expect)" ]||[ "$(which expect >/dev/null 2>&1)" ]; then + # Tries to shutdown with both localhost and server IP. + for telnetip in 127.0.0.1 ${ip}; do + fn_print_dots "Graceful: telnet: ${telnetip}" + fn_scriptlog "Graceful: telnet: ${telnetip}" + sleep 1 + fn_stop_telnet_sdtd + completed=$(echo -en "\n ${sdtd_telnet_shutdown}"|grep "Completed.") + refused=$(echo -en "\n ${sdtd_telnet_shutdown}"|grep "Timeout or EOF") + if [ -n "${refused}" ]; then + fn_print_warn "Graceful: telnet: ${telnetip}: " + fn_print_fail_eol_nl + fn_scriptlog "Graceful: telnet: ${telnetip}: FAIL" + sleep 1 + elif [ -n "${completed}" ]; then + break + fi + done + + # If telnet was successful will use telnet again to check the connection has closed + # This confirms that the tmux session can now be killed. + if [ -n "${completed}" ]; then + for seconds in {1..30}; do + fn_stop_telnet_sdtd + refused=$(echo -en "\n ${sdtd_telnet_shutdown}"|grep "Timeout or EOF") + if [ -n "${refused}" ]; then + fn_print_ok "Graceful: telnet: ${telnetip}: " + fn_print_ok_eol_nl + fn_scriptlog "Graceful: telnet: ${telnetip}: ${seconds} seconds" + break + fi + sleep 1 + fn_print_dots "Graceful: rcon quit: ${seconds}" + done + # If telnet failed will go straight to tmux shutdown. + # If cannot shutdown correctly world save may be lost + else + if [ -n "${refused}" ]; then + fn_print_fail "Graceful: telnet: " + fn_print_fail_eol_nl + fn_scriptlog "Graceful: telnet: ${telnetip}: FAIL" + else + fn_print_fail_nl "Graceful: telnet: Unknown error" + fn_scriptlog "Graceful: telnet: Unknown error" + fi + echo -en "\n\n" | tee -a "${scriptlog}" + echo -en "Telnet output:" | tee -a "${scriptlog}" + echo -en "\n ${sdtd_telnet_shutdown}" | tee -a "${scriptlog}" + echo -en "\n\n" | tee -a "${scriptlog}" + fi + else + fn_print_dots "Graceful: telnet: " + fn_scriptlog "Graceful: telnet: " + fn_print_fail "Graceful: telnet: expect not installed: " + fn_print_fail_eol_nl + fn_scriptlog "Graceful: telnet: expect not installed: FAIL" + fi + sleep 1 + fn_stop_tmux } fn_stop_graceful_select(){ -if [ "${gamename}" == "7 Days to Die" ]; then - fn_stop_graceful_sdtd -elif [ "${engine}" == "source" ]; then - fn_stop_graceful_source -elif [ "${engine}" == "goldsource" ]; then - fn_stop_graceful_goldsource -else - fn_stop_tmux -fi + if [ "${gamename}" == "7 Days To Die" ]; then + fn_stop_graceful_sdtd + elif [ "${engine}" == "source" ]; then + fn_stop_graceful_source + elif [ "${engine}" == "goldsource" ]; then + fn_stop_graceful_goldsource + else + fn_stop_tmux + fi } fn_stop_teamspeak3(){ -fn_print_dots "${servername}" -fn_scriptlog "${servername}" -sleep 1 -${filesdir}/ts3server_startscript.sh stop > /dev/null 2>&1 -# Remove lock file -rm -f "${rootdir}/${lockselfname}" -fn_print_ok_nl "${servername}" -fn_scriptlog "Stopped ${servername}" -} - -fn_stop_tmux(){ -fn_print_dots "${servername}" -fn_scriptlog "tmux kill-session: ${servername}" -sleep 1 -# Kill tmux session -tmux kill-session -t "${servicename}" > /dev/null 2>&1 -pid=$(tmux list-sessions 2>&1|awk '{print $1}'|grep -Ec "^${servicename}:") -if [ "${pid}" == "0" ]; then - fn_print_ok_nl "${servername}" - fn_scriptlog "Stopped ${servername}" + fn_print_dots "${servername}" + fn_scriptlog "${servername}" sleep 1 + ${filesdir}/ts3server_startscript.sh stop > /dev/null 2>&1 # Remove lock file rm -f "${rootdir}/${lockselfname}" -else - fn_print_fail_nl "Unable to stop${servername}" - fn_scriptlog "Unable to stop${servername}" -fi + fn_print_ok_nl "${servername}" + fn_scriptlog "Stopped ${servername}" + } + fn_stop_tmux(){ + fn_print_dots "${servername}" + fn_scriptlog "tmux kill-session: ${servername}" + sleep 1 + # Kill tmux session + tmux kill-session -t "${servicename}" > /dev/null 2>&1 + sleep 0.5 + pid=$(tmux list-sessions 2>&1|awk '{print $1}'|grep -Ec "^${servicename}:") + if [ "${pid}" == "0" ]; then + # Remove lock file + rm -f "${rootdir}/${lockselfname}" + fn_print_ok_nl "${servername}" + fn_scriptlog "Stopped ${servername}" + else + fn_print_fail_nl "Unable to stop${servername}" + fn_scriptlog "Unable to stop${servername}" + fi } # checks if the server is already stopped before trying to stop. fn_stop_pre_check(){ -if [ "${gamename}" == "Teamspeak 3" ]; then - info_ts3status.sh - if [ "${ts3status}" = "No server running (ts3server.pid is missing)" ]; then - fn_print_ok_nl "${servername} is already stopped" - fn_scriptlog "${servername} is already stopped" - else - fn_stop_teamspeak3 - fi -else - pid=$(tmux list-sessions 2>&1|awk '{print $1}'|grep -Ec "^${servicename}:") - if [ "${pid}" == "0" ]; then - fn_print_ok_nl "${servername} is already stopped" - fn_scriptlog "${servername} is already stopped" + if [ "${gamename}" == "Teamspeak 3" ]; then + info_ts3status.sh + if [ "${ts3status}" = "No server running (ts3server.pid is missing)" ]; then + fn_print_ok_nl "${servername} is already stopped" + fn_scriptlog "${servername} is already stopped" + else + fn_stop_teamspeak3 + fi else - fn_stop_graceful_select + pid=$(tmux list-sessions 2>&1|awk '{print $1}'|grep -Ec "^${servicename}:") + if [ "${pid}" == "0" ]; then + fn_print_ok_nl "${servername} is already stopped" + fn_scriptlog "${servername} is already stopped" + else + fn_stop_graceful_select + fi fi -fi } check.sh From b82d0082f6f623a02d5fa0a0ca29645f63becd43 Mon Sep 17 00:00:00 2001 From: Daniel Gibbs Date: Sat, 5 Mar 2016 12:51:27 +0000 Subject: [PATCH 110/117] Moved info_config.sh to the correct place --- functions/command_stop.sh | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/functions/command_stop.sh b/functions/command_stop.sh index 69b799839..ba8400879 100644 --- a/functions/command_stop.sh +++ b/functions/command_stop.sh @@ -80,9 +80,6 @@ fn_stop_telnet_sdtd(){ } fn_stop_graceful_sdtd(){ - # Gets server IP. - info_config.sh - fn_print_dots "Graceful: telnet" fn_scriptlog "Graceful: telnet" sleep 1 @@ -133,7 +130,7 @@ fn_stop_graceful_sdtd(){ fn_print_fail_nl "Graceful: telnet: Unknown error" fn_scriptlog "Graceful: telnet: Unknown error" fi - echo -en "\n\n" | tee -a "${scriptlog}" + echo -en "\n" | tee -a "${scriptlog}" echo -en "Telnet output:" | tee -a "${scriptlog}" echo -en "\n ${sdtd_telnet_shutdown}" | tee -a "${scriptlog}" echo -en "\n\n" | tee -a "${scriptlog}" @@ -213,6 +210,7 @@ fn_stop_pre_check(){ } check.sh +info_config.sh fn_print_dots "${servername}" fn_scriptlog "${servername}" sleep 1 From 4e8920e421ae9394cf56aad61fc7f28be8442e90 Mon Sep 17 00:00:00 2001 From: Daniel Gibbs Date: Sat, 5 Mar 2016 12:51:43 +0000 Subject: [PATCH 111/117] updated monitor function --- functions/command_monitor.sh | 156 +++++++++++++++++------------------ 1 file changed, 75 insertions(+), 81 deletions(-) diff --git a/functions/command_monitor.sh b/functions/command_monitor.sh index e09b6236c..900945603 100644 --- a/functions/command_monitor.sh +++ b/functions/command_monitor.sh @@ -10,104 +10,98 @@ lgsm_version="271215" local modulename="Monitor" function_selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))" -fn_monitor_teamspeak3(){ -check.sh -logs.sh -fn_print_dots "${servername}" -fn_scriptlog "${servername}" -sleep 1 -if [ ! -f "${rootdir}/${lockselfname}" ]; then - fn_print_info "Disabled: No lock file found" - fn_scriptlog "Disabled: No lock file found" - sleep 1 - echo -en "\n" - echo "To enable monitor run ./${selfname} start" - exit 1 -fi -fn_print_dots "Checking session: CHECKING" -fn_scriptlog "Checking session: CHECKING" -sleep 1 -info_ts3status.sh -if [ "${ts3status}" = "Server is running" ]; then - fn_print_ok "Checking session: OK" - fn_scriptlog "Checking session: OK" - sleep 1 - sleep 0.5 - echo -en "\n" - exit -else - fn_print_fail "Checking session: FAIL" - fn_scriptlog "Checking session: FAIL" - sleep 1 - fn_print_fail "Checking session: FAIL: ${ts3status}" - fn_scriptlog "Checking session: FAIL: ${ts3status}" - failurereason="${ts3status}" - if [ "${emailnotification}" = "on" ]; then - subject="${servicename} Monitor - Restarting ${servername}" - actiontaken="restarted ${servername}" - email.sh +fn_monitor_check_lockfile(){ + # Monitor does not run it lockfile is not found + if [ ! -f "${rootdir}/${lockselfname}" ]; then + fn_print_info_nl "Disabled: No lock file found" + fn_scriptlog "Disabled: No lock file found" + echo "To enable monitor run ./${selfname} start" + exit 1 fi -fi -sleep 0.5 -echo -en "\n" -fn_restart } -fn_monitor_tmux(){ -check.sh -info_config.sh -fn_print_dots "${servername}" -fn_scriptlog "${servername}" -sleep 1 -if [ ! -f "${rootdir}/${lockselfname}" ]; then - fn_print_info "Disabled: No lock file found" - fn_scriptlog "Disabled: No lock file found" - sleep 1 - echo -en "\n" - echo "To enable monitor run ./${selfname} start" - exit 1 -fi +fn_monitor_check_update(){ + # Monitor will not check if update is running. + updatecheck=$(ps -ef|grep "${selfname} update"|grep -v grep|wc -l) + if [ "${updatecheck}" >= "0" ]; then + fn_print_info_nl "SteamCMD is currently checking for updates" + fn_scriptlog "SteamCMD is currently checking for updates" + sleep 1 + exit + fi +} -updatecheck=$(ps -ef|grep "${selfname} update"|grep -v grep|wc -l) -if [ "${updatecheck}" = "0" ]||[ "${gamename}" == "Unreal Tournament 99" ]||[ "${gamename}" == "Unreal Tournament 2004" ]; then +fn_monitor_msg_checking(){ fn_print_dots "Checking session: CHECKING" fn_scriptlog "Checking session: CHECKING" + sleep 1 +} + +fn_monitor_email_notification(){ + # Email will be sent if enabled + if [ "${emailnotification}" = "on" ]; then + subject="${servicename} Monitor - Starting ${servername}" + failurereason="${servicename} process not running" + actiontaken="${servicename} has been restarted" + email.sh + fi +} + +fn_monitor_teamspeak3(){ + info_ts3status.sh + if [ "${ts3status}" = "Server is running" ]; then + fn_print_ok "Checking session: " + fn_print_ok_eol_nl + fn_scriptlog "Checking session: OK" + exit + else + fn_print_fail "Checking session: ${ts3status}: " + fn_print_fail_eol_nl + fn_scriptlog "Checking session: ${ts3status}: FAIL" + failurereason="${ts3status}" + fn_monitor_email_notification + fi + fn_scriptlog "Monitor is starting ${servername}" sleep 1 - tmuxwc=$(tmux list-sessions 2>&1|awk '{print $1}'|grep -v failed|grep -Ec "^${servicename}:") - if [ "${tmuxwc}" -eq 1 ]; then + fn_restart +} + +fn_monitor_tmux(){ + # checks that tmux session is running + tmuxwc=$(tmux list-sessions 2>&1|awk '{print $1}'|grep -Ec "^${servicename}:") + if [ "${tmuxwc}" == "1" ]; then fn_print_ok "Checking session: OK" + fn_print_ok_eol_nl fn_scriptlog "Checking session: OK" - sleep 1 - echo -en "\n" - - if [ "${engine}" == "avalanche" ]||[ "${engine}" == "goldsource" ]||[ "${engine}" == "realvirtuality" ]||[ "${engine}" == "source" ]||[ "${engine}" == "spark" ]||[ "${engine}" == "unity3d" ]||[ "${engine}" == "unreal" ]||[ "${engine}" == "unreal2" ]; then - monitor_gsquery.sh - fi - exit $? + # runs gsquery check on game with specific engines. + local allowed_engines_array=( avalanche goldsource realvirtuality source spark unity3d unreal unreal2 ) + for allowed_engine in "${allowed_engines_array[@]}" + do + if [ "${allowed_engine}" == "${function_selfname}" ]; then + monitor_gsquery.sh + fi + done + exit else fn_print_fail "Checking session: FAIL" + fn_print_fail_eol_nl fn_scriptlog "Checking session: FAIL" - sleep 1 - echo -en "\n" - if [ "${emailnotification}" = "on" ]; then - subject="${servicename} Monitor - Starting ${servername}" - failurereason="${servicename} process not running" - actiontaken="${servicename} has been restarted" - email.sh - fi + fn_monitor_email_notification fn_scriptlog "Monitor is starting ${servername}" + sleep 1 command_start.sh fi -else - fn_print_info_nl "SteamCMD is currently checking for updates" - fn_scriptlog "SteamCMD is currently checking for updates" - sleep 1 - fn_print_info_nl "When update is complete ${servicename} will start" - fn_scriptlog "When update is complete ${servicename} will start" - sleep 1 -fi } +check.sh +logs.sh +info_config.sh +fn_print_dots "${servername}" +fn_scriptlog "${servername}" +sleep 1 +fn_monitor_check_lockfile +fn_monitor_check_update +fn_monitor_msg_checking if [ "${gamename}" == "Teamspeak 3" ]; then fn_monitor_teamspeak3 else From 43043ab1c3143d82a05e13e71ae52084b5ae1b20 Mon Sep 17 00:00:00 2001 From: Daniel Gibbs Date: Sat, 5 Mar 2016 12:51:53 +0000 Subject: [PATCH 112/117] Fixed minor issue --- functions/core_functions.sh | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/functions/core_functions.sh b/functions/core_functions.sh index c0490ffcb..6c867b7e6 100644 --- a/functions/core_functions.sh +++ b/functions/core_functions.sh @@ -151,7 +151,9 @@ fn_fetch_function fn_restart(){ local modulename="Restarting" info_config.sh -fn_scriptlog "${servername}" +if [ -d "${scriptlogdir}" ]; then + fn_scriptlog "${servername}" +fi command_stop.sh command_start.sh } From fb97f609ee5f134a37613bcdf86ba01d67ad6fcd Mon Sep 17 00:00:00 2001 From: Daniel Gibbs Date: Sat, 5 Mar 2016 12:52:34 +0000 Subject: [PATCH 113/117] sd2dserver now bypasses sd2d start script --- 7DaysToDie/sdtdserver | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/7DaysToDie/sdtdserver b/7DaysToDie/sdtdserver index b3112820c..6a4bd3d39 100644 --- a/7DaysToDie/sdtdserver +++ b/7DaysToDie/sdtdserver @@ -28,7 +28,7 @@ updateonstart="off" # http://7daystodie.gamepedia.com/Server fn_parms(){ -parms="-configfile=${servercfgfullpath} -dedicated" +parms="-logfile ${gamelogdir}/output_log__`date +%Y-%m-%d__%H-%M-%S`.txt -quit -batchmode -nographics -dedicated -configfile=${servercfgfullpath}" } #### Advanced Variables #### @@ -52,10 +52,12 @@ engine="unity3d" rootdir="$(dirname $(readlink -f "${BASH_SOURCE[0]}"))" selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))" lockselfname=".${servicename}.lock" +lgsmdir="${rootdir}/lgsm" +functionsdir="${lgsmdir}/functions" filesdir="${rootdir}/serverfiles" systemdir="${filesdir}" executabledir="${filesdir}" -executable="./startserver.sh" +executable="./7DaysToDieServer.x86" servercfg="${servicename}.xml" servercfgdir="${filesdir}" servercfgfullpath="${servercfgdir}/${servercfg}" From 7bd6fb9af1f19de52c3f048a6fe816bb4373ffe9 Mon Sep 17 00:00:00 2001 From: Daniel Gibbs Date: Sat, 5 Mar 2016 12:53:46 +0000 Subject: [PATCH 114/117] no longer a requirement for symbolic link the game log dir is set in parms --- functions/install_logs.sh | 7 ------- 1 file changed, 7 deletions(-) diff --git a/functions/install_logs.sh b/functions/install_logs.sh index a1687d962..9f86f7129 100644 --- a/functions/install_logs.sh +++ b/functions/install_logs.sh @@ -33,13 +33,6 @@ if [ "${engine}" == "unreal2" ]||[ "${engine}" == "unity3d" ]||[ "${gamename}" = mkdir -pv "${gamelogdir}" fi -# If a server is 7 Days to Die. -if [ "${gamename}" == "7 Days To Die" ]; then - if [ ! -h "${gamelogdir}/output_log.txt" ]; then - ln -nfsv "${filesdir}/7DaysToDie_Data/output_log.txt" "${gamelogdir}/output_log.txt" - fi -fi - # If server uses SteamCMD create a symbolic link to the Steam logs. if [ -d "${rootdir}/Steam/logs" ]; then if [ ! -h "${rootdir}/log/steamcmd" ]; then From d78ba978a3fab450219f7c706ed4c1b1883ae36c Mon Sep 17 00:00:00 2001 From: Daniel Gibbs Date: Sat, 5 Mar 2016 15:50:56 +0000 Subject: [PATCH 115/117] tab --- functions/check_steamcmd.sh | 100 +++++++++++++++++------------------ functions/command_monitor.sh | 2 +- 2 files changed, 49 insertions(+), 53 deletions(-) diff --git a/functions/check_steamcmd.sh b/functions/check_steamcmd.sh index 4039c4ef8..db1c7969a 100644 --- a/functions/check_steamcmd.sh +++ b/functions/check_steamcmd.sh @@ -8,70 +8,66 @@ lgsm_version="160316" fn_install_steamcmd(){ -if [ ! -d "${steamcmddir}" ]; then - mkdir -v "${steamcmddir}" -fi -fn_fetch_file "http://media.steampowered.com/client/steamcmd_linux.tar.gz" "${lgsmdir}/tmp" "steamcmd_linux.tar.gz" -fn_dl_extract "${lgsmdir}/tmp" "steamcmd_linux.tar.gz" "${steamcmddir}" -chmod +x "${steamcmddir}/steamcmd.sh" + if [ ! -d "${steamcmddir}" ]; then + mkdir -v "${steamcmddir}" + fi + fn_fetch_file "http://media.steampowered.com/client/steamcmd_linux.tar.gz" "${lgsmdir}/tmp" "steamcmd_linux.tar.gz" + fn_dl_extract "${lgsmdir}/tmp" "steamcmd_linux.tar.gz" "${steamcmddir}" + chmod +x "${steamcmddir}/steamcmd.sh" } fn_check_steamcmd_user(){ -# Checks steamuser is setup. -if [ "${steamuser}" == "username" ]; then - fn_print_fail_nl "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 -# Anonymous user is set if steamuser is missing -if [ -z "${steamuser}" ]; then - fn_print_warn_nl "Steam login not set. Using anonymous login." - if [ -d "${scriptlogdir}" ]; then - fn_scriptlog "Steam login not set. Using anonymous login." + # Checks steamuser is setup. + if [ "${steamuser}" == "username" ]; then + fn_print_fail_nl "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 - steamuser="anonymous" - steampass="" - sleep 2 -fi + # Anonymous user is set if steamuser is missing + if [ -z "${steamuser}" ]; then + fn_print_warn_nl "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 } fn_check_steamcmd_sh(){ -# Checks if SteamCMD exists when starting or updating a server. -# Installs if missing. -steamcmddir="${rootdir}/steamcmd" -if [ ! -f "${steamcmddir}/steamcmd.sh" ]; then - if [ "${function_selfname}" == "command_install.sh" ]; then - fn_install_steamcmd - else - fn_print_warn_nl "SteamCMD is missing" - fn_scriptlog "SteamCMD is missing" - sleep 1 - fn_install_steamcmd + # Checks if SteamCMD exists when starting or updating a server. + # Installs if missing. + steamcmddir="${rootdir}/steamcmd" + if [ ! -f "${steamcmddir}/steamcmd.sh" ]; then + if [ "${function_selfname}" == "command_install.sh" ]; then + fn_install_steamcmd + else + fn_print_warn_nl "SteamCMD is missing" + fn_scriptlog "SteamCMD is missing" + sleep 1 + fn_install_steamcmd + fi + elif [ "${function_selfname}" == "command_install.sh" ]; then + fn_print_infomation "SteamCMD is already installed..." + fn_print_ok_eol_nl fi -elif [ "${function_selfname}" == "command_install.sh" ]; then - fn_print_infomation "SteamCMD is already installed..." - fn_print_ok_eol_nl -fi } fn_check_steamcmd_guard(){ -if [ "${function_selfname}" == "command_update.sh" ]||[ "${function_selfname}" == "command_validate.sh" ]; then - # Checks that steamcmd is working correctly and will prompt Steam Guard if required. - "${steamcmddir}"/steamcmd.sh +login "${steamuser}" "${steampass}" +quit - if [ $? -ne 0 ]; then - fn_print_failure_nl "Error running SteamCMD" + if [ "${function_selfname}" == "command_update.sh" ]||[ "${function_selfname}" == "command_validate.sh" ]; then + # Checks that steamcmd is working correctly and will prompt Steam Guard if required. + "${steamcmddir}"/steamcmd.sh +login "${steamuser}" "${steampass}" +quit + if [ $? -ne 0 ]; then + fn_print_failure_nl "Error running SteamCMD" + fi fi -fi } -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 - fn_check_steamcmd_user - fn_check_steamcmd_sh - fn_check_steamcmd_guard -fi +fn_check_steamcmd_user +fn_check_steamcmd_sh +fn_check_steamcmd_guard diff --git a/functions/command_monitor.sh b/functions/command_monitor.sh index 900945603..93c78dcdc 100644 --- a/functions/command_monitor.sh +++ b/functions/command_monitor.sh @@ -15,7 +15,7 @@ fn_monitor_check_lockfile(){ if [ ! -f "${rootdir}/${lockselfname}" ]; then fn_print_info_nl "Disabled: No lock file found" fn_scriptlog "Disabled: No lock file found" - echo "To enable monitor run ./${selfname} start" + echo " * To enable monitor run ./${selfname} start" exit 1 fi } From bad55355a2cf82de0ab8a208355863b58934e3c9 Mon Sep 17 00:00:00 2001 From: Daniel Gibbs Date: Sat, 5 Mar 2016 15:58:58 +0000 Subject: [PATCH 116/117] tab funtions --- functions/check_deps.sh | 140 ++++++++++++++++++++-------------------- 1 file changed, 70 insertions(+), 70 deletions(-) diff --git a/functions/check_deps.sh b/functions/check_deps.sh index f433e7298..71e5236e2 100644 --- a/functions/check_deps.sh +++ b/functions/check_deps.sh @@ -8,85 +8,85 @@ lgsm_version="060216" fn_deps_detector(){ -# 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=$? -elif [ -n "$(command -v yum)" ]; then - yum -q list installed ${deptocheck} > /dev/null 2>&1 - depstatus=$? -fi -if [ "${depstatus}" == "0" ]; then - missingdep=0 - 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 - 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 -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 + # Checks if dependency is missing if [ -n "$(command -v dpkg-query)" ]; then - array_deps_required+=( mailutils postfix ) + dpkg-query -W -f='${Status}' ${deptocheck} 2>/dev/null| grep -q -P '^install ok installed$' + depstatus=$? elif [ -n "$(command -v yum)" ]; then - array_deps_required+=( mailx postfix ) + yum -q list installed ${deptocheck} > /dev/null 2>&1 + depstatus=$? fi -fi + if [ "${depstatus}" == "0" ]; then + missingdep=0 + 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 + 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 + if [ "${missingdep}" == "1" ]; then + array_deps_missing+=("${deptocheck}") + fi } -fn_found_missing_deps(){ -if [ "${#array_deps_missing[@]}" != "0" ]; then - fn_print_dots "Checking dependencies" - sleep 2 - fn_print_warn "Checking dependencies: missing: \e[0;31m${array_deps_missing[@]}\e[0m" - fn_scriptlog "Checking dependencies: 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_print_info_nl "Attempting to install missing dependencies automatically" - echo -en ".\r" - sleep 1 - echo -en "..\r" - sleep 1 - echo -en "...\r" - sleep 1 - echo -en " \r" - if [ -n "$(command -v dpkg-query)" ]; then - 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 - else - echo "" - fn_print_infomation_nl "$(whoami) does not have sudo access. manually install dependencies" - fn_scriptlog "$(whoami) does not have sudo access. manually install dependencies" - echo "" +fn_deps_email(){ + # Adds postfix to required dependencies if email notification is enabled + if [ "${emailnotification}" == "on" ]; then if [ -n "$(command -v dpkg-query)" ]; then - echo "sudo dpkg --add-architecture i386; sudo apt-get install ${array_deps_missing[@]}" + array_deps_required+=( mailutils postfix ) elif [ -n "$(command -v yum)" ]; then - echo "yum install ${array_deps_missing[@]}" + array_deps_required+=( mailx postfix ) fi - echo "" - fi - if [ "${function_selfname}" == "command_install.sh" ]; then - sleep 5 fi -fi +} + +fn_found_missing_deps(){ + if [ "${#array_deps_missing[@]}" != "0" ]; then + fn_print_dots "Checking dependencies" + sleep 2 + fn_print_warn "Checking dependencies: missing: \e[0;31m${array_deps_missing[@]}\e[0m" + fn_scriptlog "Checking dependencies: 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_print_info_nl "Attempting to install missing dependencies automatically" + echo -en ".\r" + sleep 1 + echo -en "..\r" + sleep 1 + echo -en "...\r" + sleep 1 + echo -en " \r" + if [ -n "$(command -v dpkg-query)" ]; then + 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 + else + echo "" + fn_print_infomation_nl "$(whoami) does not have sudo access. manually install dependencies" + fn_scriptlog "$(whoami) does not have sudo access. manually install dependencies" + echo "" + if [ -n "$(command -v dpkg-query)" ]; then + 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 + echo "" + fi + if [ "${function_selfname}" == "command_install.sh" ]; then + sleep 5 + fi + fi } fn_check_loop(){ From d99a7e2b43153bcd12913aa93f1c8809eb1e62a0 Mon Sep 17 00:00:00 2001 From: Daniel Gibbs Date: Sun, 6 Mar 2016 16:54:51 +0000 Subject: [PATCH 117/117] Updated function --- functions/command_monitor.sh | 2 +- functions/command_start.sh | 114 ++++++++++++++++------------------- functions/core_messages.sh | 2 +- 3 files changed, 55 insertions(+), 63 deletions(-) diff --git a/functions/command_monitor.sh b/functions/command_monitor.sh index 93c78dcdc..3dfea8adf 100644 --- a/functions/command_monitor.sh +++ b/functions/command_monitor.sh @@ -83,7 +83,7 @@ fn_monitor_tmux(){ done exit else - fn_print_fail "Checking session: FAIL" + fn_print_fail "Checking session: " fn_print_fail_eol_nl fn_scriptlog "Checking session: FAIL" fn_monitor_email_notification diff --git a/functions/command_start.sh b/functions/command_start.sh index e1e324caf..e9fa5d0d0 100644 --- a/functions/command_start.sh +++ b/functions/command_start.sh @@ -10,69 +10,63 @@ local modulename="Starting" function_selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))" fn_start_teamspeak3(){ -check.sh -info_ts3status.sh + check.sh + info_ts3status.sh + + if [ "${ts3status}" != "Server is running" ]; then + # Will check for updates is updateonstart is yes + if [ "${updateonstart}" == "yes" ]||[ "${updateonstart}" == "1" ]||[ "${updateonstart}" == "on" ]; then + update_check.sh + fi + fi -if [ "${ts3status}" != "Server is running" ]; then - # Will check for updates is updateonstart is yes - if [ "${updateonstart}" == "yes" ]||[ "${updateonstart}" == "1" ]||[ "${updateonstart}" == "on" ]; then - update_check.sh - fi -fi + if [ ! -e "${servercfgfullpath}" ]; then + fn_print_warn_nl "${servercfgfullpath} is missing" + fn_scriptlog "${servercfgfullpath} is missing" + echo " * Creating blank ${servercfg}" + fn_scriptlog "Creating blank ${servercfg}" + sleep 2 + echo " * ${servercfg} can remain blank by default." + fn_scriptlog "${servercfgfullpath} can remain blank by default." + sleep 2 + echo " * ${servercfg} is located in ${servercfgfullpath}." + fn_scriptlog "${servercfg} is located in ${servercfgfullpath}." + sleep 5 + touch "${servercfgfullpath}" + fi -if [ ! -e "${servercfgfullpath}" ]; then - fn_print_warn "${servercfgfullpath} is missing" - fn_scriptlog "${servercfgfullpath} is missing" - sleep 2 - echo -en "\n" - echo " * Creating blank ${servercfg}" - fn_scriptlog "Creating blank ${servercfg}" - sleep 2 - echo " * ${servercfg} can remain blank by default." - fn_scriptlog "${servercfgfullpath} can remain blank by default." - sleep 2 - echo " * ${servercfg} is located in ${servercfgfullpath}." - fn_scriptlog "${servercfg} is located in ${servercfgfullpath}." - sleep 5 - touch "${servercfgfullpath}" -fi + logs.sh -logs.sh + fn_print_dots "${servername}" + fn_scriptlog "${servername}" + sleep 1 -fn_print_dots "${servername}" -fn_scriptlog "${servername}" -sleep 1 + if [ "${ts3status}" == "Server is running" ]; then + fn_print_info_nl "${servername} is already running" + fn_scriptlog "${servername} is already running" + exit + fi -if [ "${ts3status}" == "Server is running" ]; then - fn_print_info "${servername} is already running" - fn_scriptlog "${servername} is already running" + mv "${scriptlog}" "${scriptlogdate}" + # Create lock file + date > "${rootdir}/${lockselfname}" + cd "${executabledir}" + if [ "${ts3serverpass}" == "1" ];then + ./ts3server_startscript.sh start serveradmin_password="${newpassword}" + else + ./ts3server_startscript.sh start inifile="${servercfgfullpath}" > /dev/null 2>&1 + fi sleep 1 - echo -en "\n" - exit -fi - -mv "${scriptlog}" "${scriptlogdate}" -# Create lock file -date > "${rootdir}/${lockselfname}" -cd "${executabledir}" -if [ "${ts3serverpass}" == "1" ];then - ./ts3server_startscript.sh start serveradmin_password="${newpassword}" -else - ./ts3server_startscript.sh start inifile="${servercfgfullpath}" > /dev/null 2>&1 -fi -sleep 1 -info_ts3status.sh -if [ "${ts3status}" = "Server seems to have died" ]||[ "${ts3status}" = "No server running (ts3server.pid is missing)" ]; then - fn_print_fail_nl "Unable to start ${servername}" - fn_scriptlog "Unable to start ${servername}" - echo -e " Check log files: ${rootdir}/log" - exit 1 -else - fn_print_ok "${servername}" - fn_scriptlog "Started ${servername}" -fi -sleep 0.5 -echo -en "\n" + info_ts3status.sh + if [ "${ts3status}" = "Server seems to have died" ]||[ "${ts3status}" = "No server running (ts3server.pid is missing)" ]; then + fn_print_fail_nl "Unable to start ${servername}" + fn_scriptlog "Unable to start ${servername}" + echo -e " Check log files: ${rootdir}/log" + exit 1 + else + fn_print_ok_nl "${servername}" + fn_scriptlog "Started ${servername}" + fi } fn_start_tmux(){ @@ -139,13 +133,11 @@ if [ "${tmuxwc}" -eq 0 ]; then echo "" echo "Command" echo "=================================" - echo "tmux new-session -d -s \"${servicename}\" \"${executable} ${parms}\"" - echo "tmux new-session -d -s \"${servicename}\" \"${executable} ${parms}\"" >> "${scriptlog}" + echo "tmux new-session -d -s \"${servicename}\" \"${executable} ${parms}\"" | tee -a "${scriptlog}" echo "" echo "Error" echo "=================================" - cat "${scriptlogdir}/.${servicename}-tmux-error.tmp" - cat "${scriptlogdir}/.${servicename}-tmux-error.tmp" >> "${scriptlog}" + cat "${scriptlogdir}/.${servicename}-tmux-error.tmp" | tee -a "${scriptlog}" # Detected error http://gameservermanagers.com/issues if [ $(grep -c "Operation not permitted" "${scriptlogdir}/.${servicename}-tmux-error.tmp") ]; then diff --git a/functions/core_messages.sh b/functions/core_messages.sh index f6977f6e8..5e2b269f3 100644 --- a/functions/core_messages.sh +++ b/functions/core_messages.sh @@ -140,7 +140,7 @@ fn_print_error_nl(){ echo -e "\e[0;31mError!\e[0m $@" } -# Info! +# Infomation! fn_print_infomation(){ echo -en "\e[0;36mInfomation!\e[0m $@" }