From 73213d64398d688469a74df5156dd7e7c5dfa809 Mon Sep 17 00:00:00 2001 From: Daniel Gibbs Date: Fri, 1 Jul 2016 21:30:10 +0100 Subject: [PATCH] Streamlining ts3 installer --- lgsm/functions/command_install.sh | 5 +- lgsm/functions/install_server_files.sh | 4 + lgsm/functions/update_ts3.sh | 169 ++++++++++++++----------- 3 files changed, 99 insertions(+), 79 deletions(-) diff --git a/lgsm/functions/command_install.sh b/lgsm/functions/command_install.sh index fbf209b81..c9619e210 100644 --- a/lgsm/functions/command_install.sh +++ b/lgsm/functions/command_install.sh @@ -18,10 +18,9 @@ check_deps.sh if [ "${gamename}" == "Unreal Tournament 2004" ]; then install_server_files.sh install_ut2k4_key.sh -elif [ "${gamename}" == "Unreal Tournament 99" ]; then +elif [ "${gamename}" == "Unreal Tournament 99" ]||[ "${gamename}" == "Teamspeak 3" ]; then + installer=1 install_server_files.sh -elif [ "${gamename}" == "Teamspeak 3" ]; then - install_ts3.sh elif [ -n "${appid}" ]; then install_steamcmd.sh install_server_files.sh diff --git a/lgsm/functions/install_server_files.sh b/lgsm/functions/install_server_files.sh index eeef6fd54..88d89486e 100644 --- a/lgsm/functions/install_server_files.sh +++ b/lgsm/functions/install_server_files.sh @@ -98,6 +98,10 @@ if [ -z "${appid}" ]||[ "${gamename}" == "GoldenEye: Source" ]; then fn_install_server_files fi +if [ "${gamename}" == "Teamspeak 3" ]; then + update_ts3.sh +fi + if [ -z "${autoinstall}" ]; then echo "" echo "=================================" diff --git a/lgsm/functions/update_ts3.sh b/lgsm/functions/update_ts3.sh index c11f73dd1..e2344da6b 100644 --- a/lgsm/functions/update_ts3.sh +++ b/lgsm/functions/update_ts3.sh @@ -20,32 +20,35 @@ fn_print_dots "Checking for update: teamspeak.com" fn_script_log_info "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_print_fail "Checking for update: teamspeak.com" - sleep 1 - fn_print_fail_nl "Checking for update: teamspeak.com: No logs with server version found" - fn_script_log_warn "Checking for update: teamspeak.com: No logs with server version found" - sleep 2 - fn_print_info_nl "Checking for update: teamspeak.com: Forcing server restart" - fn_script_log_warn "Checking for update: teamspeak.com: Forcing server restart" - sleep 2 - exitbypass=1 - command_stop.sh - exitbypass=1 - command_start.sh - sleep 1 - # Check again and exit on failure. +fn_update_ts3_currentbuild(){ + # 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_print_fail_nl "Checking for update: teamspeak.com: Still No logs with server version found" - fn_script_log_fatal "Checking for update: teamspeak.com: Still No logs with server version found" - core_exit.sh + fn_print_fail "Checking for update: teamspeak.com" + sleep 1 + fn_print_fail_nl "Checking for update: teamspeak.com: No logs with server version found" + fn_script_log_warn "Checking for update: teamspeak.com: No logs with server version found" + sleep 2 + fn_print_info_nl "Checking for update: teamspeak.com: Forcing server restart" + fn_script_log_warn "Checking for update: teamspeak.com: Forcing server restart" + sleep 2 + exitbypass=1 + command_stop.sh + exitbypass=1 + command_start.sh + sleep 1 + # Check again and exit on failure. + if [ -z "$(find ./* -name 'ts3server*_0.log')" ]; then + fn_print_fail_nl "Checking for update: teamspeak.com: Still No logs with server version found" + fn_script_log_fatal "Checking for update: teamspeak.com: Still No logs with server version found" + core_exit.sh + fi fi -fi -currentbuild=$(cat $(find ./* -name 'ts3server*_0.log' 2> /dev/null | sort | egrep -E -v '${rootdir}/.ts3version' | tail -1) | egrep -o 'TeamSpeak 3 Server ((\.)?[0-9]{1,3}){1,3}\.[0-9]{1,3}' | egrep -o '((\.)?[0-9]{1,3}){1,3}\.[0-9]{1,3}') + currentbuild=$(cat $(find ./* -name 'ts3server*_0.log' 2> /dev/null | sort | egrep -E -v '${rootdir}/.ts3version' | tail -1) | egrep -o 'TeamSpeak 3 Server ((\.)?[0-9]{1,3}){1,3}\.[0-9]{1,3}' | egrep -o '((\.)?[0-9]{1,3}){1,3}\.[0-9]{1,3}') +} +fn_update_ts3_arch(){ # Gets the teamspeak server architecture. info_distro.sh if [ "${arch}" == "x86_64" ]; then @@ -58,14 +61,16 @@ else fn_script_log_fatal "unknown or unsupported architecture: ${arch}" core_exit.sh fi +} +fn_update_ts3_availablebuild(){ # Gets availablebuild info. # Grabs all version numbers but not in correct order. wget "http://dl.4players.de/ts/releases/?C=M;O=D" -q -O -| grep -i dir | egrep -o '.*\/<\/a>' | egrep -o '[0-9\.?]+'|uniq > .ts3_version_numbers_unsorted.tmp # Sort version numbers -cat .ts3_version_numbers_unsorted.tmp | sort -r --version-sort -o .ts3_version_numbers_sorted.tmp +cat "${lgsmdir}/tmp/.ts3_version_numbers_unsorted.tmp" | sort -r --version-sort -o "${lgsmdir}/tmp/.ts3_version_numbers_unsorted.tmp" # Finds directory with most recent server version. while read ts3_version_number; do @@ -75,11 +80,11 @@ while read ts3_version_number; do # Break while-loop, if the latest release could be found. break fi -done < .ts3_version_numbers_sorted.tmp +done < "${lgsmdir}/tmp/.ts3_version_numbers_sorted.tmp" # Tidy up -rm -f ".ts3_version_numbers_unsorted.tmp" -rm -f ".ts3_version_numbers_sorted.tmp" +rm -f "${lgsmdir}/tmp/.ts3_version_numbers_unsorted.tmp" +rm -f "${lgsmdir}/tmp/.ts3_version_numbers_sorted.tmp" # Checks availablebuild info is available if [ -z "${availablebuild}" ]; then @@ -93,57 +98,69 @@ else fn_script_log_pass "Checking for update: teamspeak.com" sleep 1 fi +} -# Removes dots so if can compare version numbers -currentbuilddigit=$(echo "${currentbuild}"|tr -cd '[:digit:]') -availablebuilddigit=$(echo "${availablebuild}"|tr -cd '[:digit:]') - -if [ "${currentbuilddigit}" -ne "${availablebuilddigit}" ]; then - echo -e "\n" - echo -e "Update available:" - sleep 1 - echo -e " Current build: \e[0;31m${currentbuild} ${architecture}\e[0;39m" - echo -e " Available build: \e[0;32m${availablebuild} ${architecture}\e[0;39m" - echo -e "" - sleep 1 - echo "" - echo -en "Applying update.\r" - sleep 1 - echo -en "Applying update..\r" - sleep 1 - echo -en "Applying update...\r" - sleep 1 - echo -en "\n" - fn_script_log "Update available" - fn_script_log "Current build: ${currentbuild}" - fn_script_log "Available build: ${availablebuild}" - fn_script_log "${currentbuild} > ${availablebuild}" - - unset updateonstart - - check_status.sh - if [ "${status}" == "0" ]; then - fn_update_ts3_dl - exitbypass=1 - command_start.sh - exitbypass=1 - command_stop.sh +fn_update_ts3_compare(){ + # Removes dots so if can compare version numbers + currentbuilddigit=$(echo "${currentbuild}"|tr -cd '[:digit:]') + availablebuilddigit=$(echo "${availablebuild}"|tr -cd '[:digit:]') + + if [ "${currentbuilddigit}" -ne "${availablebuilddigit}" ]; then + echo -e "\n" + echo -e "Update available:" + sleep 1 + echo -e " Current build: \e[0;31m${currentbuild} ${architecture}\e[0;39m" + echo -e " Available build: \e[0;32m${availablebuild} ${architecture}\e[0;39m" + echo -e "" + sleep 1 + echo "" + echo -en "Applying update.\r" + sleep 1 + echo -en "Applying update..\r" + sleep 1 + echo -en "Applying update...\r" + sleep 1 + echo -en "\n" + fn_script_log "Update available" + fn_script_log "Current build: ${currentbuild}" + fn_script_log "Available build: ${availablebuild}" + fn_script_log "${currentbuild} > ${availablebuild}" + + unset updateonstart + + check_status.sh + if [ "${status}" == "0" ]; then + fn_update_ts3_dl + exitbypass=1 + command_start.sh + exitbypass=1 + command_stop.sh + else + exitbypass=1 + command_stop.sh + fn_update_ts3_dl + exitbypass=1 + command_start.sh + fi + alert="update" + alert.sh else - exitbypass=1 - command_stop.sh - fn_update_ts3_dl - exitbypass=1 - command_start.sh + echo -e "\n" + echo -e "No update available:" + 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_print_ok_nl "No update available" + fn_script_log_info "Current build: ${currentbuild}" + fn_script_log_info "Available build: ${availablebuild}" fi - alert="update" - alert.sh +} + +if [ "${installer}" == "1"]; then + fn_update_ts3_availablebuild + fn_update_ts3_dl else - echo -e "\n" - echo -e "No update available:" - 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_print_ok_nl "No update available" - fn_script_log_info "Current build: ${currentbuild}" - fn_script_log_info "Available build: ${availablebuild}" -fi + fn_update_ts3_currentbuild + fn_update_ts3_availablebuild + fn_update_ts3_compare +fi \ No newline at end of file