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}" diff --git a/JustCause2/jc2server b/JustCause2/jc2server index 5435a3121..2d4010e71 100644 --- a/JustCause2/jc2server +++ b/JustCause2/jc2server @@ -4,12 +4,12 @@ # 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 -version="271215" +version="160316" #### Variables #### @@ -36,7 +36,7 @@ parms="" # from a different repo and/or branch. githubuser="dgibbs64" githubrepo="linuxgsm" -githubbranch="master" +githubbranch="dlmanage" # Steam appid="261140" @@ -50,6 +50,8 @@ engine="avalanche" 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}" @@ -76,55 +78,62 @@ 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 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 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 diff --git a/UnrealTournament99/ut99server b/UnrealTournament99/ut99server index a1dd53887..36704e0b2 100644 --- a/UnrealTournament99/ut99server +++ b/UnrealTournament99/ut99server @@ -9,7 +9,7 @@ if [ -f ".dev-debug" ]; then set -x fi -version="121215" +version="260216" #### 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" @@ -37,6 +44,8 @@ engine="unreal" 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}" @@ -50,6 +59,7 @@ backupdir="${rootdir}/backups" # Logging logdays="7" +gamelogdir="${systemdir}/Logs/" scriptlogdir="${rootdir}/log/script" consolelogdir="${rootdir}/log/console" @@ -60,66 +70,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 diff --git a/functions/check.sh b/functions/check.sh index 1af79f5dd..69f62f0ad 100644 --- a/functions/check.sh +++ b/functions/check.sh @@ -2,30 +2,21 @@ # LGSM fn_check function # Author: Daniel Gibbs # Website: http://gameservermanagers.com -lgsm_version="190216" +lgsm_version="060316" # 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 -if [ "${function_selfname}" != "command_install.sh" ] && [ "${function_selfname}" != "update_functions.sh" ]; then - check_systemdir.sh +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 @@ -49,13 +40,11 @@ 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 - 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/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 88f8fb773..df955189c 100644 --- a/functions/check_deps.sh +++ b/functions/check_deps.sh @@ -2,101 +2,103 @@ # LGSM check_deps.sh function # Author: Daniel Gibbs # Website: http://gameservermanagers.com -lgsm_version="190216" +lgsm_version="060316" # Description: Checks that the requires dependencies are installed for LGSM. 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 + # 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 -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 + # 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 - if [ -f /usr/bin/mailx ]; then - if [ -d /etc/exim4 ]; then - array_deps_required+=( exim4 ) - elif [ -d /etc/sendmail ]; then - array_deps_required+=( sendmail ) - elif [ -n "$(command -v dpkg-query)" ]; then - array_deps_required+=( mailutils postfix ) - elif [ -n "$(command -v yum)" ]; then - array_deps_required+=( mailx postfix ) - fi - else - if [ -n "$(command -v dpkg-query)" ]; then - array_deps_required+=( mailutils postfix ) - elif [ -n "$(command -v yum)" ]; then - array_deps_required+=( mailx postfix ) + # Adds postfix to required dependencies if email notification is enabled + if [ "${emailnotification}" == "on" ]; then + if [ -f /usr/bin/mailx ]; then + if [ -d /etc/exim4 ]; then + array_deps_required+=( exim4 ) + elif [ -d /etc/sendmail ]; then + array_deps_required+=( sendmail ) + elif [ -n "$(command -v dpkg-query)" ]; then + array_deps_required+=( mailutils postfix ) + elif [ -n "$(command -v yum)" ]; then + array_deps_required+=( mailx postfix ) + fi + else + if [ -n "$(command -v dpkg-query)" ]; then + array_deps_required+=( mailutils postfix ) + elif [ -n "$(command -v yum)" ]; then + array_deps_required+=( mailx postfix ) + fi fi fi -fi } fn_found_missing_deps(){ -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" - sleep 1 - echo -e "" - sudo -n true > /dev/null 2>&1 - if [ $? -eq 0 ]; then - fn_printinfonl "Attempting to install missing dependencies automatically" - echo -en ".\r" + 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 -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_printinfomationnl "$(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 + 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(){ @@ -145,7 +147,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 @@ -159,7 +161,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 ) @@ -191,7 +193,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 @@ -205,7 +207,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 ) @@ -213,4 +215,4 @@ elif [ -n "$(command -v yum)" ]; then fi fn_deps_email fn_check_loop -fi +fi \ No newline at end of file diff --git a/functions/check_ip.sh b/functions/check_ip.sh index 3e7e86cd3..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 @@ -20,7 +18,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..9b4f41324 100644 --- a/functions/check_logs.sh +++ b/functions/check_logs.sh @@ -8,10 +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" - echo -en "\n" + fn_print_info_nl "Checking for log files: Creating log files" checklogs=1 install_logs.sh fi 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 cd8ab4f39..81e0f31c4 100644 --- a/functions/check_steamcmd.sh +++ b/functions/check_steamcmd.sh @@ -8,83 +8,66 @@ lgsm_version="160316" fn_install_steamcmd(){ -echo "Installing steamCMD" -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" -echo "" + 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_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 -# 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." + # 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_printwarnnl "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_printinfomation "SteamCMD is already installed..." - fn_printokeol -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" + 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 \ No newline at end of file +fn_check_steamcmd_user +fn_check_steamcmd_sh +fn_check_steamcmd_guard \ No newline at end of file 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/check_systemdir.sh b/functions/check_system_dir.sh similarity index 70% rename from functions/check_systemdir.sh rename to functions/check_system_dir.sh index c1f65a0d7..d5d57e75b 100644 --- a/functions/check_systemdir.sh +++ b/functions/check_system_dir.sh @@ -1,11 +1,11 @@ #!/bin/bash -# LGSM check_systemdir.sh function +# LGSM check_system_dir.sh function # Author: Daniel Gibbs # Website: http://gameservermanagers.com 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..baa93aec0 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,16 +42,14 @@ 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_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_details.sh b/functions/command_details.sh index 32965eb2e..5fb446ddb 100644 --- a/functions/command_details.sh +++ b/functions/command_details.sh @@ -678,5 +678,5 @@ elif [ "${gamename}" == "Teamspeak 3" ]; then elif [ "${gamename}" == "Rust" ]; then fn_details_rust 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..46bae900d 100644 --- a/functions/command_dev_debug.sh +++ b/functions/command_dev_debug.sh @@ -4,12 +4,14 @@ # 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 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_install.sh b/functions/command_install.sh index 791cb160d..877896380 100644 --- a/functions/command_install.sh +++ b/functions/command_install.sh @@ -2,37 +2,37 @@ # LGSM fn_install function # Author: Daniel Gibbs # Website: http://gameservermanagers.com -lgsm_version="271215" +lgsm_version="260216" +# Description: Overall function for the installer. + +local modulename="Install" 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 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_dl_ut99.sh - install_ut99.sh + install_server_files.sh elif [ "${gamename}" == "Teamspeak 3" ]; then install_ts3.sh -elif [ ! -z "${appid}" ]; then +elif [ -n "${appid}" ]; then install_steamcmd.sh - install_serverfiles.sh + install_server_files.sh 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 install_gslt.sh elif [ "${gamename}" == "Teamspeak 3" ]; then install_ts3db.sh fi +fix.sh install_complete.sh diff --git a/functions/command_monitor.sh b/functions/command_monitor.sh index 2d98683a3..14e4c3c35 100644 --- a/functions/command_monitor.sh +++ b/functions/command_monitor.sh @@ -10,106 +10,100 @@ lgsm_version="271215" local modulename="Monitor" function_selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))" -fn_monitor_teamspeak3(){ -check.sh -logs.sh -fn_printdots "${servername}" -fn_scriptlog "${servername}" -sleep 1 -if [ ! -f "${rootdir}/${lockselfname}" ]; then - fn_printinfo "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_scriptlog "Checking session: CHECKING" -sleep 1 -info_ts3status.sh -if [ "${ts3status}" = "Server is running" ]; then - fn_printok "Checking session: OK" - fn_scriptlog "Checking session: OK" - sleep 1 - sleep 0.5 - echo -en "\n" - exit -else - fn_printfail "Checking session: FAIL" - fn_scriptlog "Checking session: FAIL" - sleep 1 - fn_printfail "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_printdots "${servername}" -fn_scriptlog "${servername}" -sleep 1 -if [ ! -f "${rootdir}/${lockselfname}" ]; then - fn_printinfo "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_printdots "Checking session: CHECKING" +fn_monitor_msg_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" + 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" - sleep 1 - echo -en "\n" + 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 + fn_restart +} - if [ "${engine}" == "avalanche" ]||[ "${engine}" == "goldsource" ]||[ "${engine}" == "idtech3" ]||[ "${engine}" == "realvirtuality" ]||[ "${engine}" == "source" ]||[ "${engine}" == "spark" ]||[ "${engine}" == "unity3d" ]||[ "${engine}" == "unreal" ]||[ "${engine}" == "unreal2" ]; then - monitor_gsquery.sh - fi - exit $? +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" + # 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_printfail "Checking session: FAIL" + fn_print_fail "Checking session: " + 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_printinfonl "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_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 fn_monitor_tmux -fi +fi \ No newline at end of file diff --git a/functions/command_start.sh b/functions/command_start.sh index 309a8078f..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_printwarn "${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_printdots "${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_printinfo "${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_printfailnl "Unable to start ${servername}" - fn_scriptlog "Unable to start ${servername}" - echo -e " Check log files: ${rootdir}/log" - exit 1 -else - fn_printok "${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(){ @@ -90,7 +84,7 @@ if [ "${tmuxwc}" -eq 0 ]; then fi fi -fn_printdots "${servername}" +fn_print_dots "${servername}" fn_scriptlog "${servername}" sleep 1 @@ -104,10 +98,8 @@ if [ "${tmuxwc}" -eq 0 ]; then fi if [ "${tmuxwc}" -eq 1 ]; then - fn_printinfo "${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 @@ -132,24 +124,20 @@ 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" 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 @@ -180,7 +168,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..ba8400879 100644 --- a/functions/command_stop.sh +++ b/functions/command_stop.sh @@ -9,151 +9,209 @@ 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 "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_stop_teamspeak3(){ -check.sh -fn_printdots "${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_scriptlog "${servername} is already stopped" -else - ${filesdir}/ts3server_startscript.sh stop > /dev/null 2>&1 - fn_printok "${servername}" - fn_scriptlog "Stopped ${servername}" -fi -# Remove lock file -rm -f "${rootdir}/${lockselfname}" -sleep 1 -echo -en "\n" +# 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 "Graceful: rcon quit: ${seconds}: " + fn_print_ok_eol_nl + fn_scriptlog "Graceful: rcon quit: OK: ${seconds} seconds" + sleep 1 + fn_stop_tmux } -fn_stop_tmux(){ -check.sh -info_config.sh -fn_printdots "${servername}" -fn_scriptlog "${servername}" -sleep 1 +# Attempts Graceful of 7 Days To Die using telnet. +fn_stop_telnet_sdtd(){ + 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" + ') + +} -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_scriptlog "Attempting graceful shutdown via telnet" - sleep 1 - telnetip=127.0.0.1 - sdtd_telnet +fn_stop_graceful_sdtd(){ + fn_print_dots "Graceful: telnet" + fn_scriptlog "Graceful: telnet" + sleep 1 + 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 failed using localhost will use servers ip - 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_scriptlog "Warning! Attempting graceful shutdown failed using localhost" - sleep 5 - echo -en "\n" - fn_printdots "Attempting graceful shutdown via telnet: using ${telnetip}" - fn_scriptlog "Attempting graceful shutdown via telnet using ${telnetip}" - sdtd_telnet - sleep 1 - fi + # 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" | 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 +} - 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_scriptlog "Attempting graceful shutdown failed" - fn_scriptlog "${refused}" - elif [ -n "${completed}" ]; then - fn_printok "Attempting graceful shutdown via telnet" - fn_scriptlog "Attempting graceful shutdown succeeded" - else - fn_printfail "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_printdots "${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_scriptlog "${servername} is already stopped using graceful shutdown" - else - tmux kill-session -t "${servicename}" - fn_printok "${servername}" - fn_scriptlog "Stopped ${servername}" - 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 + 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_scriptlog "${servername} is already stopped" - else +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}" + } - if [ "${engine}" == "source" ]||[ "${engine}" == "goldsource" ]; then - sleep 1 - fn_printdots "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_printdots "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" - else - fn_printfail "Attempting graceful shutdown" - fi - fi + 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 +} - tmux kill-session -t "${servicename}" > /dev/null 2>&1 - fn_printok "${servername}" - fn_scriptlog "Stopped ${servername}" - fi -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 + 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" + else + fn_stop_graceful_select + fi + fi } -if [ "${gamename}" == "Teamspeak 3" ]; then - fn_stop_teamspeak3 -else - fn_stop_tmux -fi \ No newline at end of file +check.sh +info_config.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_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/update_functions.sh b/functions/command_update_functions.sh similarity index 52% rename from functions/update_functions.sh rename to functions/command_update_functions.sh index 196b90f75..9c0ac4b90 100644 --- a/functions/update_functions.sh +++ b/functions/command_update_functions.sh @@ -2,23 +2,36 @@ # 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. 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" -rm -rfv "${rootdir}/functions/"* -exitcode=$? + +# Removed legecy functions dir +if [ -d "${rootdir}/functions/" ]; then + rm -rfv "${rootdir}/functions/" + exitcode=$? +fi + +if [ -n "${functionsdir}" ]; then + rm -rfv "${functionsdir}/"* + exitcode=$? +else + 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 b6dc36819..f4c46c071 100644 --- a/functions/command_validate.sh +++ b/functions/command_validate.sh @@ -10,15 +10,13 @@ local modulename="Validate" function_selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))" fn_validation(){ -fn_printwarn "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" -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 @@ -29,9 +27,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/core_dl.sh b/functions/core_dl.sh new file mode 100644 index 000000000..98e6ebee4 --- /dev/null +++ b/functions/core_dl.sh @@ -0,0 +1,202 @@ +#!/bin/bash +# LGSM core_dl.sh function +# Author: Daniel Gibbs +# Website: http://gameservermanagers.com +lgsm_version="050216" + +# Description: Deals with all downloads for LGSM. + +# 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 +if [ "${md5}" != "0" ]&&[ "${md5}" != "nomd5" ]; then + echo -ne "verifying ${filename} with MD5..." + sleep 1 + local md5sumcmd=$(md5sum "${filedir}/${filename}"|awk '{print $1;}') + if [ "${md5sumcmd}" != "${md5}" ]; then + fn_print_fail_eol_nl + echo "${filename} returned MD5 checksum: ${md5sumcmd}" + echo "expected MD5 checksum: ${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_print_ok_eol_nl + fn_scriptlog "verifying ${filename} with MD5: OK" + fn_scriptlog "${filename} returned MD5 checksum: ${md5sumcmd}" + fn_scriptlog "expected MD5 checksum: ${md5}" + fi +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 + 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_print_fail_eol_nl + fn_scriptlog "extracting download: FAIL" + echo "${tarcmd}" | tee -a "${scriptlog}" + exit ${exitcode} +else + fn_print_ok_eol_nl +fi +} + +# Trap to remove file download if canceled before completed +fn_fetch_trap() { + echo "" + echo -ne "downloading ${filename}: " + 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_nl + fn_scriptlog "downloading ${filename}: REMOVED" + exit +} + +fn_fetch_file(){ +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 + 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 + break + fi + done + # If curl exists download file + if [ "$(basename ${curlcmd})" == "curl" ]; then + # trap to remove part downloaded files + trap fn_fetch_trap INT + # if larger file shows progress bar + if [ ${filename##*.} == "bz2" ]; then + 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 + local exitcode=$? + if [ ${exitcode} -ne 0 ]; then + fn_print_fail_eol_nl + if [ -f "${scriptlog}" ]; then + fn_scriptlog "downloading ${filename}: FAIL" + fi + echo "${curlcmd}" | tee -a "${scriptlog}" + echo -e "${fileurl}\n" | tee -a "${scriptlog}" + exit ${exitcode} + else + fn_print_ok_eol_nl + if [ -f "${scriptlog}" ]; then + fn_scriptlog "downloading ${filename}: OK" + fi + fi + # remove trap + trap - INT + else + fn_print_fail_eol_nl + echo "Curl is not installed!" + echo -e "" + exit 1 + fi + # make file executecmd if executecmd is set + if [ "${executecmd}" == "executecmd" ]; then + chmod +x "${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 +} + + + +# 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}" +githuburl="https://raw.githubusercontent.com/${githubuser}/${githubrepo}/${githubbranch}/${github_file_url_dir}/${github_file_url_name}" +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}" +fileurl="${githuburl}" +filedir="${functionsdir}" +filename="${github_file_url_name}" +executecmd="executecmd" +run="run" +force="noforce" +md5="nomd5" +fn_fetch_file "${fileurl}" "${filedir}" "${filename}" "${executecmd}" "${run}" "${force}" "${md5}" +} \ No newline at end of file diff --git a/functions/core_functions.sh b/functions/core_functions.sh index a17a1b898..878763b65 100644 --- a/functions/core_functions.sh +++ b/functions/core_functions.sh @@ -2,87 +2,149 @@ # LGSM core_functions.sh function # Author: Daniel Gibbs # Website: http://gameservermanagers.com +<<<<<<< HEAD lgsm_version="190216" +======= +lgsm_version="270216" +>>>>>>> dlmanage -# 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 +# Code/functions for legacy servers fn_functions(){ functionfile="${FUNCNAME}" -fn_runfunction +fn_fetch_function } fn_getopt(){ functionfile="${FUNCNAME}" -fn_runfunction +fn_fetch_function +} + +# 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 + +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 +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_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_fastdl.sh(){ @@ -92,13 +154,15 @@ fn_runfunction command_ts3_server_pass.sh(){ functionfile="${FUNCNAME}" -fn_runfunction +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 } @@ -108,52 +172,47 @@ 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(){ +check_system_dir.sh(){ functionfile="${FUNCNAME}" -fn_runfunction -} - -check_systemdir.sh(){ -functionfile="${FUNCNAME}" -fn_runfunction +fn_fetch_function } check_tmux.sh(){ functionfile="${FUNCNAME}" -fn_runfunction +fn_fetch_function } @@ -161,12 +220,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 +233,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 +246,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 +299,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 +322,14 @@ fn_runfunction email.sh(){ functionfile="${FUNCNAME}" -fn_runfunction +fn_fetch_function } # Logs logs.sh(){ functionfile="${FUNCNAME}" -fn_runfunction +fn_fetch_function } @@ -278,30 +337,29 @@ fn_runfunction monitor_gsquery.sh(){ functionfile="${FUNCNAME}" -fn_runfunction +fn_fetch_function } - # Update update_check.sh(){ functionfile="${FUNCNAME}" -fn_runfunction +fn_fetch_function } -update_functions.sh(){ +command_update_functions.sh(){ functionfile="${FUNCNAME}" -fn_runfunction +fn_fetch_function } update_dl.sh(){ functionfile="${FUNCNAME}" -fn_runfunction +fn_fetch_function } -update_functions.sh(){ +fn_update_functions.sh(){ functionfile="${FUNCNAME}" -fn_runfunction +fn_fetch_function } @@ -316,92 +374,85 @@ 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(){ +install_server_dir.sh(){ functionfile="${FUNCNAME}" -fn_runfunction +fn_fetch_function } -install_serverfiles.sh(){ +install_server_files.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 -} - -install_ut99.sh(){ -functionfile="${FUNCNAME}" -fn_runfunction -} - -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 core_messages.sh + +#Calls file downloader +core_dl.sh diff --git a/functions/core_getopt.sh b/functions/core_getopt.sh index c9c875656..e035f0c3c 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) @@ -245,7 +245,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) @@ -262,6 +262,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) @@ -284,6 +286,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 @@ -305,7 +308,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 +371,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) @@ -385,6 +388,10 @@ case "$getopt" in command_dev_debug.sh;; i|install) command_install.sh;; + ai|auto-install) + fn_autoinstall;; + sck|server-cd-key) + install_ut2k4_key.sh;; mc|map-compressor) compress_unreal2_maps.sh;; dd|depsdetect) @@ -407,6 +414,8 @@ 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[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 diff --git a/functions/core_messages.sh b/functions/core_messages.sh index 939e73889..5e2b269f3 100644 --- a/functions/core_messages.sh +++ b/functions/core_messages.sh @@ -2,11 +2,15 @@ # 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. -# Date and servicename for log files. +# 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, 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}" @@ -16,7 +20,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,16 +28,18 @@ 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}: $@" + 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 ] -fn_printok(){ +fn_print_ok(){ if [ -n "${modulename}" ]; then echo -en "\r\033[K[\e[0;32m OK \e[0m] ${modulename} ${servicename}: $@" else @@ -41,16 +47,18 @@ 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}: $@" + 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 ] -fn_printinfo(){ +fn_print_info(){ if [ -n "${modulename}" ]; then echo -en "\r\033[K[\e[0;36m INFO \e[0m] ${modulename} ${servicename}: $@" else @@ -58,16 +66,18 @@ 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}: $@" + 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 ] -fn_printwarn(){ +fn_print_warn(){ if [ -n "${modulename}" ]; then echo -en "\r\033[K[\e[1;33m WARN \e[0m] ${modulename} ${servicename}: $@" else @@ -75,16 +85,18 @@ 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}: $@" + 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" } # [ .... ] -fn_printdots(){ +fn_print_dots(){ if [ -n "${modulename}" ]; then echo -en "\r\033[K[ .... ] ${modulename} ${servicename}: $@" else @@ -93,56 +105,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 $@" +# Infomation! +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_print_ok_eol_nl(){ echo -e "\e[0;32mOK\e[0m" } # FAIL for end of line -fn_printfaileol(){ - echo -e "\e[0;31mFAIL\e[0m\n" +fn_print_fail_eol(){ + echo -en "\e[0;31mFAIL\e[0m" +} + +fn_print_fail_eol_nl(){ + echo -e "\e[0;31mFAIL\e[0m" +} + +# QUERYING for end of line +fn_print_querying_eol(){ + echo -en "\e[0;36mQUERYING\e[0m" +} + +fn_print_querying_eol_nl(){ + echo -e "\e[0;36mQUERYING\e[0m" +} + +# CANCELED for end of line +fn_print_canceled_eol(){ + echo -en "\e[0;33mCANCELED\e[0m" +} + +fn_print_canceled_eol_nl(){ + echo -e "\e[0;33mCANCELED\e[0m" +} + +# REMOVED for end of line +fn_print_removed_eol(){ + echo -en "\e[0;31mREMOVED\e[0m" +} + +fn_print_removed_eol_nl(){ + echo -e "\e[0;31mREMOVED\e[0m" } \ No newline at end of file diff --git a/functions/email.sh b/functions/email.sh index 93d259d80..174ed3ff6 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 @@ -55,16 +55,14 @@ 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 mail -s "${subject}" ${email} < "${emaillog}" -fn_printok "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/fix.sh b/functions/fix.sh index 931f4acbe..e4723e649 100644 --- a/functions/fix.sh +++ b/functions/fix.sh @@ -2,19 +2,38 @@ # 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 + if [ -n "${appid}" ]; then fix_steamcmd.sh 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 b0a1317de..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_printdots "Applying ${fixname} fix: ${gamename}" - sleep 1 - fn_printinfo "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_scriptlog "Failure! Applying ${fixname} fix: ${gamename}" - else - fn_printoknl "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 4227d36eb..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_printdots "Applying ${fixname} fix: ${gamename}" - sleep 1 - fn_printinfo "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_scriptlog "Failure! Applying ${fixname} fix: ${gamename}" - else - fn_printoknl "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 7a0028504..5dadf4b78 100644 --- a/functions/fix_dst.sh +++ b/functions/fix_dst.sh @@ -2,33 +2,15 @@ # LGSM fix_dst.sh function # Author: Daniel Gibbs # Website: http://gameservermanagers.com -lgsm_version="020116" +lgsm_version="010316" -# Fixes line 63: 20150 Segmentation fault (core dumped) #488 - -fn_msg_start(){ - fn_printdots "Applying ${fixname} fix: ${gamename}" - sleep 1 - fn_printinfo "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_scriptlog "Failure! Applying ${fixname} fix: ${gamename}" - else - fn_printoknl "Applying ${fixname} fix: ${gamename}" - fn_scriptlog "Complete! Applying ${fixname} fix: ${gamename}" - fi -} +# 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 - 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_glibc.sh b/functions/fix_glibc.sh index 0270788ab..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 @@ -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/fix_ro.sh b/functions/fix_ro.sh index d3d0ac0e2..9364d3e01 100644 --- a/functions/fix_ro.sh +++ b/functions/fix_ro.sh @@ -2,7 +2,9 @@ # LGSM fix_ro.sh function # Author: Daniel Gibbs # Website: http://gameservermanagers.com -lgsm_version="271215" +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" diff --git a/functions/fix_steamcmd.sh b/functions/fix_steamcmd.sh index 862b4736f..86feb9e2c 100644 --- a/functions/fix_steamcmd.sh +++ b/functions/fix_steamcmd.sh @@ -2,60 +2,40 @@ # 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_printdots "Applying ${fixname} fix: ${gamename}" - sleep 1 - fn_printinfo "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_scriptlog "Failure! Applying ${fixname} fix: ${gamename}" - else - fn_printoknl "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..363aa5d56 100644 --- a/functions/fix_ut2k4.sh +++ b/functions/fix_ut2k4.sh @@ -2,7 +2,9 @@ # LGSM fix_ut2k4.sh function # Author: Daniel Gibbs # Website: http://gameservermanagers.com -lgsm_version="271215" +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" @@ -13,15 +15,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 diff --git a/functions/fix_ut99.sh b/functions/fix_ut99.sh index d4ceca37f..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]" @@ -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}" @@ -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 diff --git a/functions/fn_update_functions b/functions/fn_update_functions index 2de9afd6d..5fbb28975 100644 --- a/functions/fn_update_functions +++ b/functions/fn_update_functions @@ -1,22 +1,22 @@ #!/bin/bash -# LGSM update_functions.sh function +# LGSM fn_update_functions.sh function # Author: Daniel Gibbs # Website: http://gameservermanagers.com 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/GameServerQuery/gsquery.py b/functions/gsquery.py similarity index 100% rename from GameServerQuery/gsquery.py rename to functions/gsquery.py diff --git a/functions/info_config.sh b/functions/info_config.sh index 7737cac80..d9d5d4dfb 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="190216" +lgsm_version="010316" # Description: Gets specific details from config files. @@ -258,29 +258,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 @@ -335,7 +335,7 @@ elif [ "${engine}" == "seriousengine35" ]; then # query port if [ -f "${servercfgfullpath}" ]; then - queryport=$((${port} + 1)) + queryport=$((port + 1)) fi if [ ! -n "${queryport}" ]; then queryport="0" diff --git a/functions/info_glibc.sh b/functions/info_glibc.sh index fbef22478..46c45d904 100644 --- a/functions/info_glibc.sh +++ b/functions/info_glibc.sh @@ -2,11 +2,10 @@ # LGSM info_glibc.sh function # Author: Daniel Gibbs # Website: http://gameservermanagers.com -lgsm_version="190216" +lgsm_version="260216" # Description: stores details on servers Glibc requirements. - if [ "${gamename}" == "Blade Symphony" ]; then glibcrequired="2.15" glibcfix="yes" @@ -46,7 +45,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" @@ -54,6 +53,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" diff --git a/functions/install_complete.sh b/functions/install_complete.sh index a782b4f7a..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!" @@ -12,6 +14,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_config.sh b/functions/install_config.sh index 41ccf8cc8..75ca40618 100644 --- a/functions/install_config.sh +++ b/functions/install_config.sh @@ -4,6 +4,8 @@ # Website: http://gameservermanagers.com lgsm_version="220216" +local modulename="Install" + fn_defaultconfig(){ echo "creating ${servercfg} config file." cp -v "${servercfgdefault}" "${servercfgfullpath}" @@ -103,7 +105,7 @@ echo "" } fn_ut99config(){ -echo "${defaultcfg} > ${servercfgfullpath}" +echo "${servercfgdefault} > ${servercfgfullpath}" tr -d '\r' < "${servercfgdefault}" > "${servercfgfullpath}" sleep 1 echo "" 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_dl_ut99.sh b/functions/install_dl_ut99.sh deleted file mode 100644 index c053ca18e..000000000 --- a/functions/install_dl_ut99.sh +++ /dev/null @@ -1,54 +0,0 @@ -#!/bin/bash -# LGSM install_dl_ut99.sh function -# Author: Daniel Gibbs -# Website: http://gameservermanagers.com -lgsm_version="271215" - -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 -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 diff --git a/functions/install_gslt.sh b/functions/install_gslt.sh index 5919fac33..5bd309f28 100644 --- a/functions/install_gslt.sh +++ b/functions/install_gslt.sh @@ -2,41 +2,36 @@ # 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 +local modulename="Install" + +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 diff --git a/functions/install_header.sh b/functions/install_header.sh index e78987561..da8b7bf6c 100644 --- a/functions/install_header.sh +++ b/functions/install_header.sh @@ -4,11 +4,13 @@ # Website: http://gameservermanagers.com lgsm_version="190216" +local modulename="Install" + clear echo "=================================" echo "${gamename}" echo "Linux Game Server Manager" echo "by Daniel Gibbs" +echo "Contributors: http://goo.gl/qLmitD" echo "http://gameservermanagers.com" -echo "Contributors: http://gameservermanagers.com/contib" echo "=================================" diff --git a/functions/install_logs.sh b/functions/install_logs.sh index 6496ad647..9f86f7129 100644 --- a/functions/install_logs.sh +++ b/functions/install_logs.sh @@ -2,7 +2,9 @@ # LGSM install_logs.sh function # Author: Daniel Gibbs # Website: http://gameservermanagers.com -lgsm_version="271215" +lgsm_version="270216" + +local modulename="Install" if [ "${checklogs}" != "1" ]; then echo "" @@ -31,17 +33,11 @@ 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 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_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_serverdir.sh b/functions/install_server_dir.sh similarity index 84% rename from functions/install_serverdir.sh rename to functions/install_server_dir.sh index 2c664e8e3..ab73ecfd2 100644 --- a/functions/install_serverdir.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 "=================================" @@ -12,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_serverfiles.sh b/functions/install_server_files.sh similarity index 51% rename from functions/install_serverfiles.sh rename to functions/install_server_files.sh index 24677da9c..d6655689b 100644 --- a/functions/install_serverfiles.sh +++ b/functions/install_server_files.sh @@ -1,13 +1,24 @@ #!/bin/bash -# LGSM finstall_serverfiles.sh function +# LGSM install_server_files.sh function # Author: Daniel Gibbs # Website: http://gameservermanagers.com -lgsm_version="271215" +lgsm_version="270216" -fn_steaminstallcommand(){ -check.sh +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" +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"; executecmd="noexecute" run="norun"; force="noforce"; md5="67c5e2cd9c2a4b04f163962ee41eff54" +fi +fn_fetch_file "${fileurl}" "${filedir}" "${filename}" "${executecmd}" "${run}" "${force}" "${md5}" +fn_dl_extract "${filedir}" "${filename}" "${filesdir}" +} + +fn_install_server_files_steamcmd(){ 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 +while [ "${counter}" == "0" ]||[ "${exitcode}" != "0" ]; do counter=$((counter+1)) cd "${rootdir}/steamcmd" if [ "${counter}" -le "10" ]; then @@ -18,7 +29,8 @@ while [ "${counter}" == "0" ]||[ "$(grep -wc 0x402 .finstall_serverfiles.sh.tmp) # 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 if [ "${counter}" -ge "7" ]; then @@ -37,42 +49,53 @@ while [ "${counter}" == "0" ]||[ "$(grep -wc 0x402 .finstall_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 .finstall_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 .finstall_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 .finstall_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 .finstall_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 - 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 - 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_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)) - ${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 + ${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 .finstall_serverfiles.sh.tmp } echo "" echo "Installing ${gamename} Server" echo "=================================" sleep 1 -mkdir -pv "${filesdir}" -fn_steaminstallcommand +if [ -n "${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 "=================================" @@ -84,4 +107,4 @@ if [ -z "${autoinstall}" ]; then * ) echo "Please answer yes or no.";; esac done -fi +fi \ No newline at end of file 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..5cf2f0f85 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 @@ -11,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 @@ -41,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 57c87b97d..61e2db7d4 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" @@ -53,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/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_ut2k4_key.sh b/functions/install_ut2k4_key.sh index 35a9599f6..53b603de1 100644 --- a/functions/install_ut2k4_key.sh +++ b/functions/install_ut2k4_key.sh @@ -4,6 +4,8 @@ # Website: http://gameservermanagers.com lgsm_version="271215" +local modulename="Install" + echo "" echo "Enter ${gamename} CD Key" echo "=================================" @@ -12,8 +14,15 @@ 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" + 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" +fi 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 diff --git a/functions/logs.sh b/functions/logs.sh index 68e3d0dcf..30de59ea7 100644 --- a/functions/logs.sh +++ b/functions/logs.sh @@ -29,7 +29,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" @@ -38,28 +38,24 @@ 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_nl "Starting" fn_scriptlog "Starting" - sleep 1 - echo -en "\n" - fn_printinfo "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}" + 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 @@ -67,7 +63,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 @@ -75,13 +71,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 @@ -89,7 +85,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 @@ -101,8 +97,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_printok "Removed ${count} log files" + fn_print_ok_nl "Removed ${count} log files" fn_scriptlog "Removed ${count} log files" - sleep 1 - echo -en "\n" fi diff --git a/functions/monitor_gsquery.sh b/functions/monitor_gsquery.sh index 55e2e9fc2..058351770 100644 --- a/functions/monitor_gsquery.sh +++ b/functions/monitor_gsquery.sh @@ -2,96 +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 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 + +# Forces legecy servers to use gsquery as vat gsquery is not present in legecy +if [ -z "${gsquery}" ]; then + gsquery="yes" +fi + +if [ "${gsquery}" == "yes" ]; then + + # Downloads gsquery.py if missing + if [ ! -f "${functionsdir}/gsquery.py" ]; then + fn_fetch_file_github "functions" "gsquery.py" "${functionsdir}" "executecmd" "norun" "noforce" "nomd5" + fi + + info_config.sh + 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)) + port=$((port + 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=$((port + 1)) + fi + + if [ -z "${queryport}" ]; then 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" + + fn_print_info "Querying port: gsquery.py enabled" + fn_scriptlog "Querying port: gsquery.py enabled" sleep 1 - serverquery=$("${rootdir}/gsquery.py" -a ${ip} -p ${port} -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}" - 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 - if [ "${emailnotification}" = "on" ]; then - info_config.sh - subject="${servicename} Monitor - Starting ${servername}" - failurereason="Failed to query ${servicename}: ${serverquery}" - 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" + + # 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=$? + sleep 1 - echo -en "\n" - echo "Attempting to resolve automatically" - chmod +x -v "${rootdir}/gsquery.py" - if [ $? -eq 0 ]; then - monitor_gsquery.sh + 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 + exit 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 + # 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 + + # 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 - 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 + done +fi \ No newline at end of file diff --git a/functions/update_check.sh b/functions/update_check.sh index 4c631657e..579a84f4b 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 @@ -245,15 +245,15 @@ rm -f ".ts3_version_numbers_sorted.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 @@ -299,14 +299,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 a80caa6d8..f23bd2c64 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 @@ -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