diff --git a/lgsm/functions/alert.sh b/lgsm/functions/alert.sh index b81cc4d0c..f76500105 100644 --- a/lgsm/functions/alert.sh +++ b/lgsm/functions/alert.sh @@ -104,10 +104,10 @@ elif [ "${postalert}" != "on" ]&&[ "${function_selfname}" == "command_test_alert fn_print_warn_nl "More Info not enabled" fn_script_log_warn "More Info alerts not enabled" elif [ -z "${posttarget}" ]&&[ "${function_selfname}" == "command_test_alert.sh" ]; then - fn_print_error "posttarget not set" + fn_print_error_nl "posttarget not set" fn_script_error "posttarget not set" elif [ -z "${postdays}" ]&&[ "${function_selfname}" == "command_test_alert.sh" ]; then - fn_print_error "postdays not set" + fn_print_error_nl "postdays not set" fn_script_error "postdays not set" fi @@ -117,7 +117,7 @@ elif [ "${discordalert}" != "on" ]&&[ "${function_selfname}" == "command_test_al fn_print_warn_nl "Discord alerts not enabled" fn_script_log_warn "Discord alerts not enabled" elif [ -z "${discordtoken}" ]&&[ "${function_selfname}" == "command_test_alert.sh" ]; then - fn_print_error "Discord token not set" + fn_print_error_nl "Discord token not set" echo -e "* https://docs.linuxgsm.com/alerts/discord" fn_script_error "Discord token not set" fi @@ -128,7 +128,7 @@ elif [ "${emailalert}" != "on" ]&&[ "${function_selfname}" == "command_test_aler fn_print_warn_nl "Email alerts not enabled" fn_script_log_warn "Email alerts not enabled" elif [ -z "${email}" ]&&[ "${function_selfname}" == "command_test_alert.sh" ]; then - fn_print_error "Email not set" + fn_print_error_nl "Email not set" fn_script_log_error "Email not set" fi @@ -138,7 +138,7 @@ elif [ "${iftttalert}" != "on" ]&&[ "${function_selfname}" == "command_test_aler fn_print_warn_nl "IFTTT alerts not enabled" fn_script_log_warn "IFTTT alerts not enabled" elif [ -z "${ifttttoken}" ]&&[ "${function_selfname}" == "command_test_alert.sh" ]; then - fn_print_error "IFTTT token not set" + fn_print_error_nl "IFTTT token not set" echo -e "* https://docs.linuxgsm.com/alerts/ifttt" fn_script_error "IFTTT token not set" fi @@ -149,7 +149,7 @@ elif [ "${mailgunalert}" != "on" ]&&[ "${function_selfname}" == "command_test_al fn_print_warn_nl "Mailgun alerts not enabled" fn_script_log_warn "Mailgun alerts not enabled" elif [ -z "${mailguntoken}" ]&&[ "${function_selfname}" == "command_test_alert.sh" ]; then - fn_print_error "Mailgun token not set" + fn_print_error_nl "Mailgun token not set" echo -e "* https://docs.linuxgsm.com/alerts/mailgun" fn_script_error "Mailgun token not set" fi @@ -160,7 +160,7 @@ elif [ "${pushbulletalert}" != "on" ]&&[ "${function_selfname}" == "command_test fn_print_warn_nl "Pushbullet alerts not enabled" fn_script_log_warn "Pushbullet alerts not enabled" elif [ -z "${pushbullettoken}" ]&&[ "${function_selfname}" == "command_test_alert.sh" ]; then - fn_print_error "Pushbullet token not set" + fn_print_error_nl "Pushbullet token not set" echo -e "* https://docs.linuxgsm.com/alerts/pushbullet" fn_script_error "Pushbullet token not set" fi @@ -171,7 +171,7 @@ elif [ "${pushoveralert}" != "on" ]&&[ "${function_selfname}" == "command_test_a fn_print_warn_nl "Pushover alerts not enabled" fn_script_log_warn "Pushover alerts not enabled" elif [ -z "${pushovertoken}" ]&&[ "${function_selfname}" == "command_test_alert.sh" ]; then - fn_print_error "Pushover token not set" + fn_print_error_nl "Pushover token not set" echo -e "* https://docs.linuxgsm.com/alerts/pushover" fn_script_error "Pushover token not set" fi @@ -182,11 +182,11 @@ elif [ "${telegramalert}" != "on" ]&&[ "${function_selfname}" == "command_test_a fn_print_warn_nl "Telegram Messages not enabled" fn_script_log_warn "Telegram Messages not enabled" elif [ -z "${telegramtoken}" ]&&[ "${function_selfname}" == "command_test_alert.sh" ]; then - fn_print_error "Telegram token not set." + fn_print_error_nl "Telegram token not set." echo -e "* https://docs.linuxgsm.com/alerts/telegram" fn_script_error "Telegram token not set." elif [ -z "${telegramchatid}" ]&&[ "${function_selfname}" == "command_test_alert.sh" ]; then - fn_print_error "Telegram chat id not set." + fn_print_error_nl "Telegram chat id not set." echo -e "* https://docs.linuxgsm.com/alerts/telegram" fn_script_error "Telegram chat id not set." fi @@ -197,7 +197,7 @@ elif [ "${slackalert}" != "on" ]&&[ "${function_selfname}" == "command_test_aler fn_print_warn_nl "Slack alerts not enabled" fn_script_log_warn "Slack alerts not enabled" elif [ -z "${slacktoken}" ]&&[ "${function_selfname}" == "command_test_alert.sh" ]; then - fn_print_error "Slack token not set" + fn_print_error_nl "Slack token not set" echo -e "* https://docs.linuxgsm.com/alerts/slack" fn_script_error "Slack token not set" fi diff --git a/lgsm/functions/alert_discord.sh b/lgsm/functions/alert_discord.sh index 87ff4ed5f..c088df281 100644 --- a/lgsm/functions/alert_discord.sh +++ b/lgsm/functions/alert_discord.sh @@ -58,9 +58,9 @@ fn_print_dots "Sending Discord alert" discordsend=$(curl -sSL -H "Content-Type: application/json" -X POST -d "$(echo -n "$json" | jq -c .)" "${discordwebhook}") if [ "${discordsend}" ]; then - fn_print_fail "Sending Discord alert: ${discordsend}" + fn_print_fail_nl "Sending Discord alert: ${discordsend}" fn_script_log_fatal "Sending Discord alert: ${discordsend}" else - fn_print_ok "Sending Discord alert" + fn_print_ok_nl "Sending Discord alert" fn_script_log_pass "Sending Discord alert" fi diff --git a/lgsm/functions/alert_email.sh b/lgsm/functions/alert_email.sh index 1419af5e4..43eddfa58 100644 --- a/lgsm/functions/alert_email.sh +++ b/lgsm/functions/alert_email.sh @@ -18,9 +18,9 @@ else fi exitcode=$? if [ "${exitcode}" == "0" ]; then - fn_print_ok "Sending Email alert: ${email}" + fn_print_ok_nl "Sending Email alert: ${email}" fn_script_log_pass "Sending Email alert: ${email}" else - fn_print_fail "Sending Email alert: ${email}" + fn_print_fail_nl "Sending Email alert: ${email}" fn_script_log_fatal "Sending Email alert: ${email}" fi diff --git a/lgsm/functions/alert_ifttt.sh b/lgsm/functions/alert_ifttt.sh index ccf334141..26a50114f 100644 --- a/lgsm/functions/alert_ifttt.sh +++ b/lgsm/functions/alert_ifttt.sh @@ -21,9 +21,9 @@ fn_print_dots "Sending IFTTT alert" iftttsend=$(curl -sSL -H "Content-Type: application/json" -X POST -d """${json}""" "https://maker.ifttt.com/trigger/${iftttevent}/with/key/${ifttttoken}" | grep "Bad Request") if [ "${iftttsend}" ]; then - fn_print_fail "Sending IFTTT alert: ${pushbulletsend}" + fn_print_fail_nl "Sending IFTTT alert: ${pushbulletsend}" fn_script_log_fatal "Sending IFTTT alert: ${pushbulletsend}" else - fn_print_ok "Sending IFTTT alert" + fn_print_ok_nl "Sending IFTTT alert" fn_script_log_pass "Sent IFTTT alert" fi diff --git a/lgsm/functions/alert_mailgun.sh b/lgsm/functions/alert_mailgun.sh index 8e9036ec5..521a46fb9 100644 --- a/lgsm/functions/alert_mailgun.sh +++ b/lgsm/functions/alert_mailgun.sh @@ -19,9 +19,9 @@ mailgunsend=$(curl -s --user "api:${mailguntoken}" \ -F text="$(cat "${alertlog}")" "https://api.mailgun.net/v3/${mailgundomain}/messages") if [ -z "${mailgunsend}" ]; then - fn_print_fail "Sending Email alert: Mailgun: ${email}" + fn_print_fail_nl "Sending Email alert: Mailgun: ${email}" fn_script_log_fatal "Sending Email alert: Mailgun: ${email}" else - fn_print_ok "Sending Email alert: Mailgun: ${email}" + fn_print_ok_nl "Sending Email alert: Mailgun: ${email}" fn_script_log_pass "Sending Email alert: Mailgun: ${email}" fi diff --git a/lgsm/functions/alert_pushbullet.sh b/lgsm/functions/alert_pushbullet.sh index 5ae4a5b74..2a0947564 100644 --- a/lgsm/functions/alert_pushbullet.sh +++ b/lgsm/functions/alert_pushbullet.sh @@ -22,9 +22,9 @@ fn_print_dots "Sending Pushbullet alert" pushbulletsend=$(curl -sSL -u """${pushbullettoken}"":" -H "Content-Type: application/json" -X POST -d """${json}""" "https://api.pushbullet.com/v2/pushes" | grep "error_code") if [ "${pushbulletsend}" ]; then - fn_print_fail "Sending Pushbullet alert: ${pushbulletsend}" + fn_print_fail_nl "Sending Pushbullet alert: ${pushbulletsend}" fn_script_log_fatal "Sending Pushbullet alert: ${pushbulletsend}" else - fn_print_ok "Sending Pushbullet alert" + fn_print_ok_nl "Sending Pushbullet alert" fn_script_log_pass "Sent Pushbullet alert" fi diff --git a/lgsm/functions/alert_pushover.sh b/lgsm/functions/alert_pushover.sh index 093c4f6a0..a57a5f4b5 100644 --- a/lgsm/functions/alert_pushover.sh +++ b/lgsm/functions/alert_pushover.sh @@ -26,9 +26,9 @@ fi pushoversend=$(curl -sS -F token="${pushovertoken}" -F user="${pushoveruserkey}" -F html="1" -F sound="${alertsound}" -F priority="${alertpriority}" -F title="${alertemoji} ${alertsubject} ${alertemoji}" -F message=" Message
${alertbody}

Game
${gamename}

Server name
${servername}

Hostname
${HOSTNAME}

Server IP
${alertip}:${port}

More info
${alerturl}" "https://api.pushover.net/1/messages.json" | grep errors) if [ "${pushoversend}" ]; then - fn_print_fail "Sending Pushover alert: ${pushoversend}" + fn_print_fail_nl "Sending Pushover alert: ${pushoversend}" fn_script_log_fatal "Sending Pushover alert: ${pushoversend}" else - fn_print_ok "Sending Pushover alert" + fn_print_ok_nl "Sending Pushover alert" fn_script_log_pass "Sent Pushover alert" fi diff --git a/lgsm/functions/alert_slack.sh b/lgsm/functions/alert_slack.sh index aa3aa6636..582043f0c 100644 --- a/lgsm/functions/alert_slack.sh +++ b/lgsm/functions/alert_slack.sh @@ -72,9 +72,9 @@ fn_print_dots "Sending Slack alert" slacksend=$(curl -sSL -H "Content-Type: application/json" -X POST -d "$(echo -n "$json" | jq -c .)" "${slackwebhook}") if [ "${slacksend}" == "ok" ]; then - fn_print_ok "Sending Slack alert" + fn_print_ok_nl "Sending Slack alert" fn_script_log_pass "Sending Slack alert" else - fn_print_fail "Sending Slack alert: ${slacksend}" + fn_print_fail_nl "Sending Slack alert: ${slacksend}" fn_script_log_fatal "Sending Slack alert: ${slacksend}" fi diff --git a/lgsm/functions/alert_telegram.sh b/lgsm/functions/alert_telegram.sh index f868430de..6d7403660 100644 --- a/lgsm/functions/alert_telegram.sh +++ b/lgsm/functions/alert_telegram.sh @@ -21,9 +21,9 @@ fn_print_dots "Sending Telegram alert" telegramsend=$(curl -sSL -H "Content-Type: application/json" -X POST -d """${json}""" "https://api.telegram.org/bot${telegramtoken}/sendMessage" "${curlcustomstring}" | grep "error_code") if [ "${telegramsend}" ]; then - fn_print_fail "Sending Telegram alert: ${telegramsend}" + fn_print_fail_nl "Sending Telegram alert: ${telegramsend}" fn_script_log_fatal "Sending Telegram alert: ${telegramsend}" else - fn_print_ok "Sending Telegram alert" + fn_print_ok_nl "Sending Telegram alert" fn_script_log_pass "Sent Telegram alert" fi diff --git a/lgsm/functions/check_deps.sh b/lgsm/functions/check_deps.sh index 2a8c82ed9..f4499a587 100644 --- a/lgsm/functions/check_deps.sh +++ b/lgsm/functions/check_deps.sh @@ -273,11 +273,11 @@ fn_found_missing_deps(){ if [ "${steamcmdfail}" ]; then echo -e "" if [ "${function_selfname}" == "command_install.sh" ]; then - fn_print_failure "Missing dependencies required to run SteamCMD." + fn_print_failure_nl "Missing dependencies required to run SteamCMD." fn_script_log_fatal "Missing dependencies required to run SteamCMD." core_exit.sh else - fn_print_error "Missing dependencies required to run SteamCMD." + fn_print_error_nl "Missing dependencies required to run SteamCMD." fn_script_log_error "Missing dependencies required to run SteamCMD." fi fi @@ -299,11 +299,11 @@ fn_found_missing_deps(){ if [ "${steamcmdfail}" ]; then echo -e "" if [ "${function_selfname}" == "command_install.sh" ]; then - fn_print_failure "Missing dependencies required to run SteamCMD." + fn_print_failure_nl "Missing dependencies required to run SteamCMD." fn_script_log_fatal "Missing dependencies required to run SteamCMD." core_exit.sh else - fn_print_error "Missing dependencies required to run SteamCMD." + fn_print_error_nl "Missing dependencies required to run SteamCMD." fn_script_log_error "Missing dependencies required to run SteamCMD." fi fi diff --git a/lgsm/functions/check_ip.sh b/lgsm/functions/check_ip.sh index b89a38f07..b421639d3 100644 --- a/lgsm/functions/check_ip.sh +++ b/lgsm/functions/check_ip.sh @@ -80,7 +80,7 @@ if [ "${travistest}" != "1" ]; then core_exit.sh fi else - fn_print_info "Check IP: ${getip}" + fn_print_info_nl "Check IP: ${getip}" fn_script_log_info "IP automatically set as: ${getip}" ip="${getip}" fi diff --git a/lgsm/functions/command_backup.sh b/lgsm/functions/command_backup.sh index 6c195f875..724954a2d 100644 --- a/lgsm/functions/command_backup.sh +++ b/lgsm/functions/command_backup.sh @@ -43,9 +43,9 @@ fn_backup_init(){ info_distro.sh fn_print_dots "Backup starting" fn_script_log_info "Backup starting" - fn_print_ok "Backup starting" + fn_print_ok_nl "Backup starting" if [ ! -d "${backupdir}" ]||[ "${backupcount}" == "0" ]; then - fn_print_info "There are no previous backups" + fn_print_info_nl "There are no previous backups" else if [ "${lastbackupdaysago}" == "0" ]; then daysago="less than 1 day ago" @@ -54,7 +54,6 @@ fn_backup_init(){ else daysago="${lastbackupdaysago} days ago" fi - echo -en "\n" echo -e "* Previous backup was created ${daysago}, total size ${lastbackupsize}" fi } @@ -74,8 +73,7 @@ fn_backup_stop_server(){ fn_script_log_warn "Although unlikely; creating a backup while ${selfname} is running might corrupt the backup" # Server is running and will be stopped if stoponbackup=on or unset. else - fn_print_warn "${selfname} will be stopped during the backup" - fn_script_log_warn "${selfname} will be stopped during the backup" + fn_stop_warning serverstopped="yes" exitbypass=1 command_stop.sh @@ -135,7 +133,7 @@ fn_backup_compression(){ # Check that excludedir is a valid path. if [ ! -d "${excludedir}" ] ; then - fn_print_fail "Problem identifying the previous backup directory for exclusion." + fn_print_fail_nl "Problem identifying the previous backup directory for exclusion." fn_script_log_fatal "Problem identifying the previous backup directory for exclusion" core_exit.sh fi @@ -146,11 +144,11 @@ fn_backup_compression(){ fn_print_fail_eol fn_script_log_fatal "Backup in progress: FAIL" echo -e "${tarcmd}" | tee -a "${lgsmlog}" - fn_print_fail "Starting backup" + fn_print_fail_nl "Starting backup" fn_script_log_fatal "Starting backup" else fn_print_ok_eol - fn_print_ok "Completed: ${backupname}.tar.gz, total size $(du -sh "${backupdir}/${backupname}.tar.gz" | awk '{print $1}')" + fn_print_ok_nl "Completed: ${backupname}.tar.gz, total size $(du -sh "${backupdir}/${backupname}.tar.gz" | awk '{print $1}')" fn_script_log_pass "Backup created: ${backupname}.tar.gz, total size $(du -sh "${backupdir}/${backupname}.tar.gz" | awk '{print $1}')" fi # Remove lock file @@ -171,7 +169,7 @@ fn_backup_prune(){ if [ "${backupquotadiff}" -gt "0" ]||[ "${backupsoudatedcount}" -gt "0" ]; then fn_print_dots "Pruning" fn_script_log_info "Backup pruning activated" - fn_print_ok "Pruning" + fn_print_ok_nl "Pruning" # If maxbackups greater or equal to backupsoutdatedcount, then it is over maxbackupdays. if [ "${backupquotadiff}" -ge "${backupsoudatedcount}" ]; then # Display how many backups will be cleared. @@ -182,7 +180,7 @@ fn_backup_prune(){ fn_script_log_info "Pruning: Clearing ${backupquotadiff} backup(s)" # Clear backups over quota. find "${backupdir}"/ -type f -name "*.tar.gz" -printf '%T@ %p\n' | sort -rn | tail -${backupquotadiff} | cut -f2- -d" " | xargs rm - fn_print_ok "Pruning: Clearing ${backupquotadiff} backup(s)" + fn_print_ok_nl "Pruning: Clearing ${backupquotadiff} backup(s)" fn_script_log_pass "Pruning: Cleared ${backupquotadiff} backup(s)" # If maxbackupdays is used over maxbackups. elif [ "${backupquotadiff}" -lt "${backupsoudatedcount}" ]; then @@ -194,7 +192,7 @@ fn_backup_prune(){ fn_script_log_info "Pruning: Clearing ${backupquotadiff} backup(s)" # Clear backups over quota find "${backupdir}"/ -type f -mtime +"${maxbackupdays}" -exec rm -f {} \; - fn_print_ok "Pruning: Clearing ${backupquotadiff} backup(s)" + fn_print_ok_nl "Pruning: Clearing ${backupquotadiff} backup(s)" fn_script_log_pass "Pruning: Cleared ${backupquotadiff} backup(s)" fi fi @@ -202,11 +200,9 @@ fn_backup_prune(){ } fn_backup_relpath() { - # Written by CedarLUG as a "realpath --relative-to" alternative in bash. - + # Written by CedarLUG as a "realpath --relative-to" alternative in bash. # Populate an array of tokens initialized from the rootdir components. - declare -a rdirtoks=($(readlink -f "${rootdir}" | sed "s/\// /g")) - + declare -a rdirtoks=($(readlink -f "${rootdir}" | sed "s/\// /g")) if [ ${#rdirtoks[@]} -eq 0 ]; then fn_print_fail_nl "Problem assessing rootdir during relative path assessment" fn_script_log_fatal "Problem assessing rootdir during relative path assessment: ${rootdir}" @@ -214,7 +210,7 @@ fn_backup_relpath() { fi # Populate an array of tokens initialized from the backupdir components. - declare -a bdirtoks=($(readlink -f "${backupdir}" | sed "s/\// /g")) + declare -a bdirtoks=($(readlink -f "${backupdir}" | sed "s/\// /g")) if [ ${#bdirtoks[@]} -eq 0 ]; then fn_print_fail_nl "Problem assessing backupdir during relative path assessment" fn_script_log_fatal "Problem assessing backupdir during relative path assessment: ${rootdir}" @@ -223,31 +219,46 @@ fn_backup_relpath() { # Compare the leading entries of each array. These common elements will be clipped off. # for the relative path output. - for ((base=0; base<${#rdirtoks[@]}; base++)) - do - [[ "${rdirtoks[$base]}" != "${bdirtoks[$base]}" ]] && break - done + for ((base=0; base<${#rdirtoks[@]}; base++)) + do + [[ "${rdirtoks[$base]}" != "${bdirtoks[$base]}" ]] && break + done # Next, climb out of the remaining rootdir location with updir references. - for ((x=base;x<${#rdirtoks[@]};x++)) - do - echo -n "../" - done + for ((x=base;x<${#rdirtoks[@]};x++)) + do + echo -n "../" + done # Climb down the remaining components of the backupdir location. - for ((x=base;x<$(( ${#bdirtoks[@]} - 1 ));x++)) - do - echo -n "${bdirtoks[$x]}/" - done + for ((x=base;x<$(( ${#bdirtoks[@]} - 1 ));x++)) + do + echo -n "${bdirtoks[$x]}/" + done # In the event there were no directories left in the backupdir above to # traverse down, just add a newline. Otherwise at this point, there is # one remaining directory component in the backupdir to navigate. - if (( "$base" < "${#bdirtoks[@]}" )) ; then - echo -e "${bdirtoks[ $(( ${#bdirtoks[@]} - 1)) ]}" - else - echo + if (( "$base" < "${#bdirtoks[@]}" )) ; then + echo -e "${bdirtoks[ $(( ${#bdirtoks[@]} - 1)) ]}" + else + echo + fi +} + +fn_stop_warning(){ + fn_print_warn "Updating server: SteamCMD: ${selfname} will be stopped during backup" + fn_script_log_warn "Updating server: SteamCMD: ${selfname} will be stopped during backup" + totalseconds=3 + for seconds in {3..1}; do + fn_print_warn "Updating server: SteamCMD: ${selfname} will be stopped during backup: ${totalseconds}" + totalseconds=$((totalseconds - 1)) + sleep 1 + if [ "${seconds}" == "0" ]; then + break fi + done + fn_print_warn_nl "Updating server: SteamCMD: ${selfname} will be stopped during backup" } # Restart the server if it was stopped for the backup. diff --git a/lgsm/functions/command_debug.sh b/lgsm/functions/command_debug.sh index f3e2a0cc1..1427403ec 100644 --- a/lgsm/functions/command_debug.sh +++ b/lgsm/functions/command_debug.sh @@ -62,14 +62,6 @@ if [ "${extip}" ]; then echo -e "${lightblue}Internet IP:\t${default}${extip}:${port}" fi fi -# Listed on Master Server. -if [ "${displaymasterserver}" ]; then - if [ "${displaymasterserver}" == "true" ]; then - echo -e "${lightblue}Master Server:\t${green}${displaymasterserver}${default}" - else - echo -e "${lightblue}Master Server:\t${red}${displaymasterserver}${default}" - fi -fi # Server password. if [ "${serverpassword}" ]; then echo -e "${lightblue}Server password:\t${default}${serverpassword}" diff --git a/lgsm/functions/command_monitor.sh b/lgsm/functions/command_monitor.sh index a70d185ed..ae7d25388 100644 --- a/lgsm/functions/command_monitor.sh +++ b/lgsm/functions/command_monitor.sh @@ -21,7 +21,7 @@ fn_monitor_check_lockfile(){ fn_print_error_eol_nl fn_script_log_error "Checking lockfile: No lockfile found: ERROR" fn_sleep_time - echo -e "* Start ${selfname} to run monitor." + echo -en "* Start ${selfname} to run monitor." core_exit.sh fi diff --git a/lgsm/functions/command_postdetails.sh b/lgsm/functions/command_postdetails.sh index 12554565f..e6cbcba60 100644 --- a/lgsm/functions/command_postdetails.sh +++ b/lgsm/functions/command_postdetails.sh @@ -78,7 +78,7 @@ else fi if [ "${posttarget}" == "http://pastebin.com" ] ; then - fn_print_dots "Posting details to pastbin.com for ${postexpire}" + fn_print_dots "pastbin.com for ${postexpire}" # grab the return from 'value' from an initial visit to pastebin. csrftoken=$(curl -s "${posttarget}" | sed -n 's/^.*input type="hidden" name="csrf_token_post" value="\(.*\)".*$/\1/p') @@ -93,23 +93,26 @@ if [ "${posttarget}" == "http://pastebin.com" ] ; then awk '/^location: / { print $2 }' | sed "s/\n//g") # Output the resulting link. - fn_print_ok_nl "Posting details to pastbin.com for ${postexpire}" + fn_print_ok_nl "pastbin.com for ${postexpire}" pdurl="${posttarget}${link}" + echo -e "" echo -e " Please share the following url for support: ${pdurl}" elif [ "${posttarget}" == "https://hastebin.com" ] ; then - fn_print_dots "Posting details to hastebin.com" + fn_print_dots "hastebin.com" # hastebin is a bit simpler. If successful, the returned result # should look like: {"something":"key"}, putting the reference that # we need in "key". TODO - error handling. -CedarLUG link=$(curl -H "HTTP_X_REQUESTED_WITH:XMLHttpRequest" -s -d "$(<${postdetailslog})" "${posttarget}/documents" | cut -d\" -f4) - fn_print_ok_nl "Posting details to hastebin.com for ${postexpire}" + fn_print_ok_nl "hastebin.com for ${postexpire}" pdurl="${posttarget}/${link}" + echo -e "" echo -e "Please share the following url for support: ${pdurl}" elif [ "${posttarget}" == "https://termbin.com" ] ; then - fn_print_dots "Posting details to termbin.com" + fn_print_dots "termbin.com" link=$(cat "${postdetailslog}" | nc termbin.com 9999 | tr -d '\n\0') - fn_print_ok_nl "Posting details to termbin.com" + fn_print_ok_nl "termbin.com" pdurl="${link}" + echo -e "" echo -e "Please share the following url for support: " echo -e "${pdurl}" else diff --git a/lgsm/functions/command_start.sh b/lgsm/functions/command_start.sh index 8f60a7314..bf5c65146 100644 --- a/lgsm/functions/command_start.sh +++ b/lgsm/functions/command_start.sh @@ -170,7 +170,7 @@ fn_print_dots "${servername}" # Is the server already started. # $status comes from check_status.sh, which is run by check.sh for this command if [ "${status}" != "0" ]; then - fn_print_info "${servername} is already running" + fn_print_info_nl "${servername} is already running" fn_script_log_error "${servername} is already running" if [ -z "${exitbypass}" ]; then core_exit.sh diff --git a/lgsm/functions/command_stop.sh b/lgsm/functions/command_stop.sh index c7c6ebf3b..40e3f92e3 100644 --- a/lgsm/functions/command_stop.sh +++ b/lgsm/functions/command_stop.sh @@ -211,7 +211,7 @@ fn_stop_tmux(){ fn_sleep_time check_status.sh if [ "${status}" == "0" ]; then - fn_print_ok "${servername}" + fn_print_ok_nl "${servername}" fn_script_log_pass "Stopped ${servername}" else fn_print_fail_nl "Unable to stop ${servername}" diff --git a/lgsm/functions/command_test_alert.sh b/lgsm/functions/command_test_alert.sh index 3bc975949..77ff0d079 100644 --- a/lgsm/functions/command_test_alert.sh +++ b/lgsm/functions/command_test_alert.sh @@ -13,4 +13,5 @@ check.sh info_config.sh alert="test" alert.sh + core_exit.sh diff --git a/lgsm/functions/command_validate.sh b/lgsm/functions/command_validate.sh index 6764831f4..6c0684a3b 100644 --- a/lgsm/functions/command_validate.sh +++ b/lgsm/functions/command_validate.sh @@ -8,13 +8,20 @@ local modulename="VALIDATE" local commandaction="Validate" local function_selfname=$(basename "$(readlink -f "${BASH_SOURCE[0]}")") -fn_validation(){ - fn_print_info "Validating files: SteamCMD" - echo -e "" - echo -e "* Validating may overwrite some customised files." - echo -e "* https://docs.linuxgsm.com/commands/validate" - fn_script_log_info "Validating files: SteamCMD" - sleep 3 +fn_validate(){ + fn_script_log_warn "Validating server: SteamCMD: Validate might overwrite some customised files" + totalseconds=3 + for seconds in {3..1}; do + fn_print_warn "Validating server: SteamCMD: Validate might overwrite some customised files: ${totalseconds}" + totalseconds=$((totalseconds - 1)) + sleep 1 + if [ "${seconds}" == "0" ]; then + break + fi + done + fn_print_warn_nl "Validating server: SteamCMD: Validate might overwrite some customised files" + fn_print_start_nl "Validating server: SteamCMD" + fn_script_log_info "Validating server: SteamCMD" if [ -d "${steamcmddir}" ]; then cd "${steamcmddir}" || exit fi @@ -29,29 +36,44 @@ fn_validation(){ else ${unbuffer} ${steamcmdcommand} +login "${steamuser}" "${steampass}" +force_install_dir "${serverfiles}" +app_update "${appid}" -beta "${branch}" validate +quit | tee -a "${lgsmlog}" fi - if [ $? != 0 ]; then - fn_print_fail "Validating files: SteamCMD" - fn_script_log_fatal "Validating files: SteamCMD: FAIL" + exitcode=$? + fn_print_dots "Validating server: SteamCMD" + if [ "${exitcode}" != "0" ]; then + fn_print_fail_nl "Validating server: SteamCMD" + fn_script_log_fatal "Validating server: SteamCMD: FAIL" else - fn_print_ok "Validating files: SteamCMD" - fn_script_log_pass "Validating files: SteamCMD: OK" + fn_print_ok_nl "Validating server: SteamCMD" + fn_script_log_pass "Validating server: SteamCMD: OK" fi - fix.sh + core_exit.sh +} +fn_stop_warning(){ + fn_print_warn "Validating server: SteamCMD: ${selfname} will be stopped during validation" + fn_script_log_warn "Validating server: SteamCMD: ${selfname} will be stopped during validation" + totalseconds=3 + for seconds in {3..1}; do + fn_print_warn "Validating server: SteamCMD: ${selfname} will be stopped during validation: ${totalseconds}" + totalseconds=$((totalseconds - 1)) + sleep 1 + if [ "${seconds}" == "0" ]; then + break + fi + done + fn_print_warn_nl "Validating server: SteamCMD: ${selfname} will be stopped during validation" } -fn_print_dots "Validating files:" -fn_print_dots "Validating files: SteamCMD" +fn_print_dots "Validating server" +fn_print_dots "Validating server: SteamCMD" check.sh check_status.sh if [ "${status}" != "0" ]; then + fn_stop_warning exitbypass=1 command_stop.sh - fn_validation "${appid}" + fn_validate exitbypass=1 command_start.sh else - fn_validation + fn_validate fi - -core_exit.sh diff --git a/lgsm/functions/core_getopt.sh b/lgsm/functions/core_getopt.sh index 7216dc765..477cd59fc 100644 --- a/lgsm/functions/core_getopt.sh +++ b/lgsm/functions/core_getopt.sh @@ -15,7 +15,7 @@ cmd_start=( "st;start" "command_start.sh" "Start the server." ) cmd_stop=( "sp;stop" "command_stop.sh" "Stop the server." ) cmd_restart=( "r;restart" "command_restart.sh" "Restart the server." ) cmd_details=( "dt;details" "command_details.sh" "Display server information." ) -cmd_postdetails=( "pd;postdetails" "command_postdetails.sh" "Post details to hastebin (removing passwords)." ) +cmd_postdetails=( "pd;postdetails" "command_postdetails.sh" "Post details to termbin.com (removing passwords)." ) cmd_backup=( "b;backup" "command_backup.sh" "Create backup archives of the server." ) cmd_update_linuxgsm=( "ul;update-lgsm;uf;update-functions" "command_update_linuxgsm.sh" "Check and apply any LinuxGSM updates." ) cmd_test_alert=( "ta;test-alert" "command_test_alert.sh" "Send a test alert." ) diff --git a/lgsm/functions/core_messages.sh b/lgsm/functions/core_messages.sh index 71c6eff8b..da90ebc43 100644 --- a/lgsm/functions/core_messages.sh +++ b/lgsm/functions/core_messages.sh @@ -149,9 +149,9 @@ fn_print_ok(){ fn_print_ok_nl(){ if [ "${commandaction}" ]; then - echo -e "${creeol}[${green} OK ${default}] ${commandaction} ${selfname}: $*" + echo -en "${creeol}[${green} OK ${default}] ${commandaction} ${selfname}: $*" else - echo -e "${creeol}[${green} OK ${default}] $*" + echo -en "${creeol}[${green} OK ${default}] $*" fi fn_sleep_time echo -en "\n" @@ -169,9 +169,9 @@ fn_print_fail(){ fn_print_fail_nl(){ if [ "${commandaction}" ]; then - echo -e "${creeol}[${red} FAIL ${default}] ${commandaction} ${selfname}: $*" + echo -en "${creeol}[${red} FAIL ${default}] ${commandaction} ${selfname}: $*" else - echo -e "${creeol}[${red} FAIL ${default}] $*" + echo -en "${creeol}[${red} FAIL ${default}] $*" fi fn_sleep_time echo -en "\n" @@ -180,18 +180,18 @@ fn_print_fail_nl(){ # [ ERROR ] fn_print_error(){ if [ "${commandaction}" ]; then - echo -en "${creeol}[${red}ERROR ${default}] ${commandaction} ${selfname}: $*" + echo -en "${creeol}[${red} ERROR ${default}] ${commandaction} ${selfname}: $*" else - echo -en "${creeol}[${red}ERROR ${default}] $*" + echo -en "${creeol}[${red} ERROR ${default}] $*" fi fn_sleep_time } fn_print_error_nl(){ if [ "${commandaction}" ]; then - echo -e "${creeol}[${red}ERROR ${default}] ${commandaction} ${selfname}: $*" + echo -en "${creeol}[${red} ERROR ${default}] ${commandaction} ${selfname}: $*" else - echo -e "${creeol}[${red}ERROR ${default}] $*" + echo -en "${creeol}[${red} ERROR ${default}] $*" fi fn_sleep_time echo -en "\n" @@ -209,9 +209,9 @@ fn_print_warn(){ fn_print_warn_nl(){ if [ "${commandaction}" ]; then - echo -e "${creeol}[${lightyellow} WARN ${default}] ${commandaction} ${selfname}: $*" + echo -en "${creeol}[${lightyellow} WARN ${default}] ${commandaction} ${selfname}: $*" else - echo -e "${creeol}[${lightyellow} WARN ${default}] $*" + echo -en "${creeol}[${lightyellow} WARN ${default}] $*" fi fn_sleep_time echo -en "\n" @@ -229,9 +229,29 @@ fn_print_info(){ fn_print_info_nl(){ if [ "${commandaction}" ]; then - echo -e "${creeol}[${cyan} INFO ${default}] ${commandaction} ${selfname}: $*" + echo -en "${creeol}[${cyan} INFO ${default}] ${commandaction} ${selfname}: $*" + else + echo -en "${creeol}[${cyan} INFO ${default}] $*" + fi + fn_sleep_time + echo -en "\n" +} + +# [ START ] +fn_print_start(){ + if [ "${commandaction}" ]; then + echo -en "${creeol}[${lightgreen} START ${default}] ${commandaction} ${selfname}: $*" + else + echo -en "${creeol}[${lightgreen} START ${default}] $*" + fi + fn_sleep_time +} + +fn_print_start_nl(){ + if [ "${commandaction}" ]; then + echo -en "${creeol}[${lightgreen} START ${default}] ${commandaction} ${selfname}: $*" else - echo -e "${creeol}[${cyan} INFO ${default}] $*" + echo -en "${creeol}[${lightgreen} START ${default}] $*" fi fn_sleep_time echo -en "\n" diff --git a/lgsm/functions/fix.sh b/lgsm/functions/fix.sh index 7533590de..3b5a58965 100644 --- a/lgsm/functions/fix.sh +++ b/lgsm/functions/fix.sh @@ -17,7 +17,7 @@ fn_fix_msg_start(){ fn_fix_msg_start_nl(){ fn_print_dots "Applying ${fixname} fix: ${gamename}" - fn_print_info_nl "Applying ${fixname} fix: ${gamename}" + fn_print_info "Applying ${fixname} fix: ${gamename}" fn_script_log_info "Applying ${fixname} fix: ${gamename}" } diff --git a/lgsm/functions/update_factorio.sh b/lgsm/functions/update_factorio.sh index 6d520bacf..c6a0383ab 100644 --- a/lgsm/functions/update_factorio.sh +++ b/lgsm/functions/update_factorio.sh @@ -27,7 +27,7 @@ fn_update_factorio_dl(){ fn_update_factorio_localbuild(){ # Gets local build info. - fn_print_dots "Checking for update: ${remotelocation}: checking local build" + fn_print_dots "Checking local build: ${remotelocation}" # Uses executable to find local build. cd "${executabledir}" || exit if [ -f "${executable}" ]; then @@ -45,14 +45,14 @@ fn_update_factorio_remotebuild(){ # Gets remote build info. remotebuild=$(curl -s "https://factorio.com/get-download/${downloadbranch}/headless/${factorioarch}" | grep -o '[0-9]\.[0-9]\{1,\}\.[0-9]\{1,\}' | head -1) if [ "${installer}" != "1" ]; then - fn_print_dots "Checking for update: ${remotelocation}: checking remote build" + fn_print_dots "Checking remote build: ${remotelocation}" # Checks if remotebuild variable has been set. if [ -z "${remotebuild}" ]||[ "${remotebuild}" == "null" ]; then - fn_print_fail "Checking for update: ${remotelocation}: checking remote build" + fn_print_fail "Checking remote build: ${remotelocation}" fn_script_log_fatal "Checking remote build" core_exit.sh else - fn_print_ok "Checking for update: ${remotelocation}: checking remote build" + fn_print_ok "Checking remote build: ${remotelocation}" fn_script_log_pass "Checking remote build" fi else @@ -68,14 +68,16 @@ fn_update_factorio_remotebuild(){ fn_update_factorio_compare(){ fn_print_dots "Checking for update: ${remotelocation}" # Removes dots so if statement can compare version numbers. + fn_print_dots "Checking for update: ${remotelocation}" localbuilddigit=$(echo -e "${localbuild}" | tr -cd '[:digit:]') remotebuilddigit=$(echo -e "${remotebuild}" | tr -cd '[:digit:]') if [ "${localbuilddigit}" -ne "${remotebuilddigit}" ]||[ "${forceupdate}" == "1" ]; then fn_print_ok_nl "Checking for update: ${remotelocation}" + echo -en "\n" echo -e "Update available" echo -e "* Local build: ${red}${localbuild} ${factorioarch}${default}" echo -e "* Remote build: ${green}${remotebuild} ${factorioarch}${default}" - if [ -v "${branch}" ]; then + if [ -n "${branch}" ]; then echo -e "* Branch: ${branch}" fi fn_script_log_info "Update available" @@ -85,18 +87,8 @@ fn_update_factorio_compare(){ fn_script_log_info "Branch: ${branch}" fi fn_script_log_info "${localbuild} > ${remotebuild}" - fn_sleep_time - echo -en "\n" - echo -en "applying update.\r" - sleep 1 - echo -en "applying update..\r" - sleep 1 - echo -en "applying update...\r" - sleep 1 - echo -en "\n" unset updateonstart - check_status.sh # If server stopped. if [ "${status}" == "0" ]; then @@ -108,6 +100,7 @@ fn_update_factorio_compare(){ command_stop.sh # If server started. else + fn_stop_warning exitbypass=1 command_stop.sh exitbypass=1 @@ -119,6 +112,7 @@ fn_update_factorio_compare(){ alert.sh else fn_print_ok_nl "Checking for update: ${remotelocation}" + echo -en "\n" echo -e "No update available" echo -e "* Local build: ${green}${localbuild} ${factorioarch}${default}" echo -e "* Remote build: ${green}${remotebuild} ${factorioarch}${default}" @@ -134,6 +128,21 @@ fn_update_factorio_compare(){ fi } +fn_stop_warning(){ + fn_print_warn "Updating server: SteamCMD: ${selfname} will be stopped during update" + fn_script_log_warn "Updating server: SteamCMD: ${selfname} will be stopped during update" + totalseconds=3 + for seconds in {3..1}; do + fn_print_warn "Updating server: SteamCMD: ${selfname} will be stopped during update: ${totalseconds}" + totalseconds=$((totalseconds - 1)) + sleep 1 + if [ "${seconds}" == "0" ]; then + break + fi + done + fn_print_warn_nl "Updating server: SteamCMD: ${selfname} will be stopped during update" +} + # The location where the builds are checked and downloaded. remotelocation="factorio.com" diff --git a/lgsm/functions/update_minecraft.sh b/lgsm/functions/update_minecraft.sh index d404cb046..f24d44df8 100644 --- a/lgsm/functions/update_minecraft.sh +++ b/lgsm/functions/update_minecraft.sh @@ -34,14 +34,14 @@ fn_update_minecraft_dl(){ fn_update_minecraft_localbuild(){ # Gets local build info. - fn_print_dots "Checking for update: ${remotelocation}: checking local build" + fn_print_dots "Checking local build: ${remotelocation}" # Uses log file to gather info. # Gives time for log file to generate. if [ ! -f "${serverfiles}/logs/latest.log" ]; then - fn_print_error "Checking for update: ${remotelocation}: checking local build" - fn_print_error_nl "Checking for update: ${remotelocation}: checking local build: no log files" - fn_script_log_error "No log file found" - fn_print_info_nl "Checking for update: ${remotelocation}: checking local build: forcing server restart" + fn_print_error "Checking local build: ${remotelocation}" + fn_print_error_nl "Checking local build: ${remotelocation}: no log files containing version info" + fn_print_info_nl "Checking local build: ${remotelocation}: forcing server restart" + fn_script_log_error "No log files containing version info" fn_script_log_info "Forcing server restart" exitbypass=1 command_stop.sh @@ -51,7 +51,7 @@ fn_update_minecraft_localbuild(){ # Check again, allow time to generate logs. while [ ! -f "${serverfiles}/logs/latest.log" ]; do sleep 1 - fn_print_info "Checking for update: ${remotelocation}: checking local build: waiting for log file: ${totalseconds}" + fn_print_info "Checking local build: ${remotelocation}: waiting for log file: ${totalseconds}" if [ -v "${loopignore}" ]; then loopignore=1 fn_script_log_info "Waiting for log file to generate" @@ -59,7 +59,7 @@ fn_update_minecraft_localbuild(){ if [ "${totalseconds}" -gt "120" ]; then localbuild="0" - fn_print_error "Checking for update: ${remotelocation}: waiting for log file: missing log file" + fn_print_error "Checking local build: ${remotelocation}: waiting for log file: missing log file" fn_script_log_error "Missing log file" fn_script_log_error "Set localbuild to 0" fi @@ -76,7 +76,7 @@ fn_update_minecraft_localbuild(){ # Gives time for var to generate. totalseconds=0 for seconds in {1..120}; do - fn_print_info "Checking for update: ${remotelocation}: checking local build: waiting for local build: ${totalseconds}" + fn_print_info "Checking local build: ${remotelocation}: waiting for local build: ${totalseconds}" if [ -z "${loopignore}" ]; then loopignore=1 fn_script_log_info "Waiting for local build to generate" @@ -92,11 +92,11 @@ fn_update_minecraft_localbuild(){ if [ -z "${localbuild}" ]; then localbuild="0" - fn_print_error "Checking for update: ${remotelocation}: waiting for local build: missing local build info" + fn_print_error "Checking local build: ${remotelocation}: waiting for local build: missing local build info" fn_script_log_error "Missing local build info" fn_script_log_error "Set localbuild to 0" else - fn_print_ok "Checking for update: ${remotelocation}: checking local build" + fn_print_ok "Checking local build: ${remotelocation}" fn_script_log_pass "Checking local build" fi } @@ -110,14 +110,14 @@ fn_update_minecraft_remotebuild(){ fi if [ "${installer}" != "1" ]; then - fn_print_dots "Checking for update: ${remotelocation}: checking remote build" + fn_print_dots "Checking remote build: ${remotelocation}" # Checks if remotebuild variable has been set. if [ -z "${remotebuild}" ]||[ "${remotebuild}" == "null" ]; then - fn_print_fail "Checking for update: ${remotelocation}: checking remote build" + fn_print_fail "Checking remote build: ${remotelocation}" fn_script_log_fatal "Checking remote build" core_exit.sh else - fn_print_ok "Checking for update: ${remotelocation}: checking remote build" + fn_print_ok "Checking remote build: ${remotelocation}" fn_script_log_pass "Checking remote build" fi else @@ -135,6 +135,7 @@ fn_update_minecraft_compare(){ fn_print_dots "Checking for update: ${remotelocation}" if [ "${localbuild}" != "${remotebuild}" ]||[ "${forceupdate}" == "1" ]; then fn_print_ok_nl "Checking for update: ${remotelocation}" + echo -en "\n" echo -e "Update available" echo -e "* Local build: ${red}${localbuild}${default}" echo -e "* Remote build: ${green}${remotebuild}${default}" @@ -145,18 +146,8 @@ fn_update_minecraft_compare(){ fn_script_log_info "Local build: ${localbuild}" fn_script_log_info "Remote build: ${remotebuild}" fn_script_log_info "${localbuild} > ${remotebuild}" - fn_sleep_time - echo -en "\n" - echo -en "applying update.\r" - sleep 1 - echo -en "applying update..\r" - sleep 1 - echo -en "applying update...\r" - sleep 1 - echo -en "\n" unset updateonstart - check_status.sh # If server stopped. if [ "${status}" == "0" ]; then @@ -168,6 +159,7 @@ fn_update_minecraft_compare(){ command_stop.sh # If server started. else + fn_stop_warning exitbypass=1 command_stop.sh exitbypass=1 @@ -179,6 +171,7 @@ fn_update_minecraft_compare(){ alert.sh else fn_print_ok_nl "Checking for update: ${remotelocation}" + echo -en "\n" echo -e "No update available" echo -e "* Local build: ${green}${localbuild}${default}" echo -e "* Remote build: ${green}${remotebuild}${default}" @@ -194,6 +187,21 @@ fn_update_minecraft_compare(){ fi } +fn_stop_warning(){ + fn_print_warn "Updating server: SteamCMD: ${selfname} will be stopped during update" + fn_script_log_warn "Updating server: SteamCMD: ${selfname} will be stopped during update" + totalseconds=3 + for seconds in {3..1}; do + fn_print_warn "Updating server: SteamCMD: ${selfname} will be stopped during update: ${totalseconds}" + totalseconds=$((totalseconds - 1)) + sleep 1 + if [ "${seconds}" == "0" ]; then + break + fi + done + fn_print_warn_nl "Updating server: SteamCMD: ${selfname} will be stopped during update" +} + # The location where the builds are checked and downloaded. remotelocation="mojang.com" diff --git a/lgsm/functions/update_minecraft_bedrock.sh b/lgsm/functions/update_minecraft_bedrock.sh index 2dadec7c2..57306f063 100644 --- a/lgsm/functions/update_minecraft_bedrock.sh +++ b/lgsm/functions/update_minecraft_bedrock.sh @@ -6,7 +6,7 @@ local modulename="UPDATE" local commandaction="Update" -local function_selfname="$(basename "$(readlink -f "${BASH_SOURCE[0]}")")" +local function_selfname=$(basename "$(readlink -f "${BASH_SOURCE[0]}")") fn_update_minecraft_dl(){ latestmcbuildurl=$(curl -s "https://www.minecraft.net/en-us/download/server/bedrock/" | grep -o 'https://minecraft.azureedge.net/bin-linux/[^"]*zip') @@ -32,43 +32,43 @@ fn_update_minecraft_dl(){ fn_update_minecraft_localbuild(){ # Gets local build info. - fn_print_dots "Checking for update: ${remotelocation}: checking local build" + fn_print_dots "Checking local build: ${remotelocation}" # Uses log file to gather info. # Log is generated and cleared on startup but filled on shutdown. - - localbuild=$(grep Version $(ls -tr "${consolelogdir}"/* 2>/dev/null) | tail -1 | sed 's/.*Version //') - + localbuild=$(grep Version "$(ls -tr "${consolelogdir}"/* 2>/dev/null)" | tail -1 | sed 's/.*Version //') if [ -z "${localbuild}" ]; then - fn_print_error "Checking for update: ${remotelocation}: checking local build" - fn_print_error_nl "Checking for update: ${remotelocation}: checking local build: no log files containing version info" + fn_print_error "Checking local build: ${remotelocation}" + fn_print_error_nl "Checking local build: ${remotelocation}: no log files containing version info" + fn_print_info_nl "Checking local build: ${remotelocation}: forcing server restart" fn_script_log_error "No log files containing version info" - fn_print_info_nl "Checking for update: ${remotelocation}: checking local build: forcing server restart" fn_script_log_info "Forcing server restart" check_status.sh - if [ "${status}" != "0" ]; then - exitbypass=1 - command_stop.sh - else + # If server stopped. + if [ "${status}" == "0" ]; then exitbypass=1 command_start.sh sleep 3 exitbypass=1 command_stop.sh + # If server started. + else + exitbypass=1 + command_stop.sh fi fi if [ -z "${localbuild}" ]; then - localbuild=$(grep Version $(ls -tr "${consolelogdir}"/* 2>/dev/null) | tail -1 | sed 's/.*Version //') + localbuild=$(grep Version "$(ls -tr "${consolelogdir}"/* 2>/dev/null)" | tail -1 | sed 's/.*Version //') fi if [ -z "${localbuild}" ]; then localbuild="0" - fn_print_error "Checking for update: ${remotelocation}: waiting for local build: missing local build info" + fn_print_error "Checking local build: ${remotelocation}: waiting for local build: missing local build info" fn_script_log_error "Missing local build info" fn_script_log_error "Set localbuild to 0" else - fn_print_ok "Checking for update: ${remotelocation}: checking local build" + fn_print_ok "Checking local build: ${remotelocation}: checking local build" fn_script_log_pass "Checking local build" fi } @@ -77,14 +77,14 @@ fn_update_minecraft_remotebuild(){ # Gets remote build info. remotebuild=$(curl -s "https://www.minecraft.net/en-us/download/server/bedrock/" | grep -o 'https://minecraft.azureedge.net/bin-linux/[^"]*' | sed 's/.*\///' | grep -Eo "[.0-9]+[0-9]") if [ "${installer}" != "1" ]; then - fn_print_dots "Checking for update: ${remotelocation}: checking remote build" + fn_print_dots "Checking remote build: ${remotelocation}" # Checks if remotebuild variable has been set. if [ -z "${remotebuild}" ]||[ "${remotebuild}" == "null" ]; then - fn_print_fail "Checking for update: ${remotelocation}: checking remote build" + fn_print_fail "Checking remote build: ${remotelocation}" fn_script_log_fatal "Checking remote build" core_exit.sh else - fn_print_ok "Checking for update: ${remotelocation}: checking remote build" + fn_print_ok "Checking remote build: ${remotelocation}" fn_script_log_pass "Checking remote build" fi else @@ -104,6 +104,7 @@ fn_update_minecraft_compare(){ remotebuilddigit=$(echo -e "${remotebuild}" | tr -cd '[:digit:]') if [ "${localbuilddigit}" -ne "${remotebuilddigit}" ]||[ "${forceupdate}" == "1" ]; then fn_print_ok_nl "Checking for update: ${remotelocation}" + echo -en "\n" echo -e "Update available" echo -e "* Local build: ${red}${localbuild}${default}" echo -e "* Remote build: ${green}${remotebuild}${default}" @@ -111,18 +112,8 @@ fn_update_minecraft_compare(){ fn_script_log_info "Local build: ${localbuild}" fn_script_log_info "Remote build: ${remotebuild}" fn_script_log_info "${localbuild} > ${remotebuild}" - fn_sleep_time - echo -en "\n" - echo -en "applying update.\r" - sleep 1 - echo -en "applying update..\r" - sleep 1 - echo -en "applying update...\r" - sleep 1 - echo -en "\n" unset updateonstart - check_status.sh # If server stopped. if [ "${status}" == "0" ]; then @@ -134,6 +125,7 @@ fn_update_minecraft_compare(){ command_stop.sh # If server started. else + fn_stop_warning exitbypass=1 command_stop.sh exitbypass=1 @@ -145,6 +137,7 @@ fn_update_minecraft_compare(){ alert.sh else fn_print_ok_nl "Checking for update: ${remotelocation}" + echo -en "\n" echo -e "No update available" echo -e "* Local build: ${green}${localbuild}${default}" echo -e "* Remote build: ${green}${remotebuild}${default}" @@ -154,6 +147,21 @@ fn_update_minecraft_compare(){ fi } +fn_stop_warning(){ + fn_print_warn "Updating server: SteamCMD: ${selfname} will be stopped during update" + fn_script_log_warn "Updating server: SteamCMD: ${selfname} will be stopped during update" + totalseconds=3 + for seconds in {3..1}; do + fn_print_warn "Updating server: SteamCMD: ${selfname} will be stopped during update: ${totalseconds}" + totalseconds=$((totalseconds - 1)) + sleep 1 + if [ "${seconds}" == "0" ]; then + break + fi + done + fn_print_warn_nl "Updating server: SteamCMD: ${selfname} will be stopped during update" +} + # The location where the builds are checked and downloaded. remotelocation="minecraft.net" @@ -161,7 +169,6 @@ if [ "${installer}" == "1" ]; then fn_update_minecraft_remotebuild fn_update_minecraft_dl else - check_status.sh fn_print_dots "Checking for update: ${remotelocation}" fn_script_log_info "Checking for update: ${remotelocation}" fn_update_minecraft_localbuild diff --git a/lgsm/functions/update_mta.sh b/lgsm/functions/update_mta.sh index da0d16fdb..1b8e5304d 100644 --- a/lgsm/functions/update_mta.sh +++ b/lgsm/functions/update_mta.sh @@ -29,14 +29,14 @@ fn_update_mta_dl(){ fn_update_mta_localbuild(){ # Gets local build info. - fn_print_dots "Checking for update: ${remotelocation}: checking local build" + fn_print_dots "Checking local build: ${remotelocation}" # Uses log file to gather info. # Gives time for log file to generate. if [ ! -f "${serverfiles}/mods/deathmatch/logs/server.log" ]; then - fn_print_error "Checking for update: ${remotelocation}: checking local build" - fn_print_error_nl "Checking for update: ${remotelocation}: checking local build: no log files" - fn_script_log_error "No log file found" - fn_print_info_nl "Checking for update: ${remotelocation}: checking local build: forcing server restart" + fn_print_error "Checking local build: ${remotelocation}" + fn_print_error_nl "Checking local build: ${remotelocation}: no log files containing version info" + fn_print_info_nl "Checking local build: ${remotelocation}: forcing server restart" + fn_script_log_error "No log files containing version info" fn_script_log_info "Forcing server restart" exitbypass=1 command_stop.sh @@ -46,7 +46,7 @@ fn_update_mta_localbuild(){ # Check again, allow time to generate logs. while [ ! -f "${serverfiles}/mods/deathmatch/logs/server.log" ]; do sleep 1 - fn_print_info "Checking for update: ${remotelocation}: checking local build: waiting for log file: ${totalseconds}" + fn_print_info "Checking local build: ${remotelocation}: waiting for log file: ${totalseconds}" if [ -v "${loopignore}" ]; then loopignore=1 fn_script_log_info "Waiting for log file to generate" @@ -54,7 +54,7 @@ fn_update_mta_localbuild(){ if [ "${totalseconds}" -gt "120" ]; then localbuild="0" - fn_print_error "Checking for update: ${remotelocation}: waiting for log file: missing log file" + fn_print_error "Checking local build: ${remotelocation}: waiting for log file: missing log file" fn_script_log_error "Missing log file" fn_script_log_error "Set localbuild to 0" fi @@ -69,10 +69,9 @@ fn_update_mta_localbuild(){ if [ -z "${localbuild}" ]; then # Gives time for var to generate. - end=$((SECONDS+120)) totalseconds=0 - while [ "${SECONDS}" -lt "${end}" ]; do - fn_print_info "Checking for update: ${remotelocation}: checking local build: waiting for local build: ${totalseconds}" + for seconds in {1..120}; do + fn_print_info "Checking local build: ${remotelocation}: waiting for local build: ${totalseconds}" if [ -z "${loopignore}" ]; then loopignore=1 fn_script_log_info "Waiting for local build to generate" @@ -88,11 +87,11 @@ fn_update_mta_localbuild(){ if [ -z "${localbuild}" ]; then localbuild="0" - fn_print_error "Checking for update: ${remotelocation}: waiting for local build: missing local build info" + fn_print_error "Checking local build: ${remotelocation}: waiting for local build: missing local build info" fn_script_log_error "Missing local build info" fn_script_log_error "Set localbuild to 0" else - fn_print_ok "Checking for update: ${remotelocation}: checking local build" + fn_print_ok "Checking local build: ${remotelocation}" fn_script_log_pass "Checking local build" fi } @@ -104,14 +103,14 @@ fn_update_mta_remotebuild(){ maintenanceversion=$(curl -s https://raw.githubusercontent.com/multitheftauto/mtasa-blue/master/Server/version.h | grep "#define MTASA_VERSION_MAINTENANCE" | awk '{ print $3 }' | sed 's/\r//g') remotebuild="${majorversion}.${minorversion}.${maintenanceversion}" if [ "${installer}" != "1" ]; then - fn_print_dots "Checking for update: ${remotelocation}: checking remote build" + fn_print_dots "Checking remote build: ${remotelocation}" # Checks if remotebuild variable has been set. if [ -z "${remotebuild}" ]||[ "${remotebuild}" == "null" ]; then - fn_print_fail "Checking for update: ${remotelocation}: checking remote build" + fn_print_fail "Checking remote build: ${remotelocation}" fn_script_log_fatal "Checking remote build" core_exit.sh else - fn_print_ok "Checking for update: ${remotelocation}: checking remote build" + fn_print_ok "Checking remote build: ${remotelocation}" fn_script_log_pass "Checking remote build" fi else @@ -145,18 +144,8 @@ fn_update_mta_compare(){ fn_script_log_info "Local build: ${localbuild}" fn_script_log_info "Remote build: ${remotebuild}" fn_script_log_info "${localbuild} > ${remotebuild}" - fn_sleep_time - echo -en "\n" - echo -en "applying update.\r" - sleep 1 - echo -en "applying update..\r" - sleep 1 - echo -en "applying update...\r" - sleep 1 - echo -en "\n" unset updateonstart - check_status.sh # If server stopped. if [ "${status}" == "0" ]; then @@ -168,6 +157,7 @@ fn_update_mta_compare(){ command_stop.sh # If server started. else + fn_stop_warning exitbypass=1 command_stop.sh exitbypass=1 @@ -179,6 +169,7 @@ fn_update_mta_compare(){ alert.sh else fn_print_ok_nl "Checking for update: ${remotelocation}" + echo -en "\n" echo -e "No update available" echo -e "* Local build: ${green}${localbuild}${default}" echo -e "* Remote build: ${green}${remotebuild}${default}" @@ -188,6 +179,21 @@ fn_update_mta_compare(){ fi } +fn_stop_warning(){ + fn_print_warn "Updating server: SteamCMD: ${selfname} will be stopped during update" + fn_script_log_warn "Updating server: SteamCMD: ${selfname} will be stopped during update" + totalseconds=3 + for seconds in {3..1}; do + fn_print_warn "Updating server: SteamCMD: ${selfname} will be stopped during update: ${totalseconds}" + totalseconds=$((totalseconds - 1)) + sleep 1 + if [ "${seconds}" == "0" ]; then + break + fi + done + fn_print_warn_nl "Updating server: SteamCMD: ${selfname} will be stopped during update" +} + # The location where the builds are checked and downloaded. remotelocation="linux.mtasa.com" diff --git a/lgsm/functions/update_mumble.sh b/lgsm/functions/update_mumble.sh index 097e3c158..7bbfb134b 100644 --- a/lgsm/functions/update_mumble.sh +++ b/lgsm/functions/update_mumble.sh @@ -27,16 +27,16 @@ fn_update_mumble_dl(){ fn_update_mumble_localbuild(){ # Gets local build info. - fn_print_dots "Checking for update: ${remotelocation}: checking local build" + fn_print_dots "Checking local build: ${remotelocation}" # Uses executable to find local build. cd "${executabledir}" || exit if [ -f "${executable}" ]; then localbuild=$(${executable} -version 2>&1 >/dev/null | awk '{print $5}') - fn_print_ok "Checking for update: ${remotelocation}: checking local build" + fn_print_ok "Checking local build: ${remotelocation}" fn_script_log_pass "Checking local build" else localbuild="0" - fn_print_error "Checking for update: ${remotelocation}: checking local build" + fn_print_error "Checking local build: ${remotelocation}" fn_script_log_error "Checking local build" fi } @@ -45,14 +45,14 @@ fn_update_mumble_remotebuild(){ # Gets remote build info. remotebuild=$(curl -s "https://api.github.com/repos/mumble-voip/mumble/releases/latest" | grep 'murmur-static_x86.*\.bz2"' | tail -1 | awk -F"/" '{ print $8 }') if [ "${installer}" != "1" ]; then - fn_print_dots "Checking for update: ${remotelocation}: checking remote build" + fn_print_dots "Checking remote build: ${remotelocation}" # Checks if remotebuild variable has been set. if [ -z "${remotebuild}" ]||[ "${remotebuild}" == "null" ]; then - fn_print_fail "Checking for update: ${remotelocation}: checking remote build" + fn_print_fail "Checking remote build: ${remotelocation}" fn_script_log_fatal "Checking remote build" core_exit.sh else - fn_print_ok "Checking for update: ${remotelocation}: checking remote build" + fn_print_ok "Checking remote build: ${remotelocation}" fn_script_log_pass "Checking remote build" fi else @@ -72,6 +72,7 @@ fn_update_mumble_compare(){ remotebuilddigit=$(echo -e "${remotebuild}" | tr -cd '[:digit:]') if [ "${localbuilddigit}" -ne "${remotebuilddigit}" ]||[ "${forceupdate}" == "1" ]; then fn_print_ok_nl "Checking for update: ${remotelocation}" + echo -en "\n" echo -e "Update available" echo -e "* Local build: ${red}${localbuild} ${mumblearch}${default}" echo -e "* Remote build: ${green}${remotebuild} ${mumblearch}${default}" @@ -79,18 +80,8 @@ fn_update_mumble_compare(){ fn_script_log_info "Local build: ${localbuild} ${mumblearch}" fn_script_log_info "Remote build: ${remotebuild} ${mumblearch}" fn_script_log_info "${localbuild} > ${remotebuild}" - fn_sleep_time - echo -en "\n" - echo -en "applying update.\r" - sleep 1 - echo -en "applying update..\r" - sleep 1 - echo -en "applying update...\r" - sleep 1 - echo -en "\n" unset updateonstart - check_status.sh # If server stopped. if [ "${status}" == "0" ]; then @@ -102,6 +93,7 @@ fn_update_mumble_compare(){ command_stop.sh # If server started. else + fn_stop_warning exitbypass=1 command_stop.sh exitbypass=1 @@ -113,6 +105,7 @@ fn_update_mumble_compare(){ alert.sh else fn_print_ok_nl "Checking for update: ${remotelocation}" + echo -en "\n" echo -e "No update available" echo -e "* Local build: ${green}${localbuild} ${mumblearch}${default}" echo -e "* Remote build: ${green}${remotebuild} ${mumblearch}${default}" @@ -122,6 +115,21 @@ fn_update_mumble_compare(){ fi } +fn_stop_warning(){ + fn_print_warn "Updating server: SteamCMD: ${selfname} will be stopped during update" + fn_script_log_warn "Updating server: SteamCMD: ${selfname} will be stopped during update" + totalseconds=3 + for seconds in {3..1}; do + fn_print_warn "Updating server: SteamCMD: ${selfname} will be stopped during update: ${totalseconds}" + totalseconds=$((totalseconds - 1)) + sleep 1 + if [ "${seconds}" == "0" ]; then + break + fi + done + fn_print_warn_nl "Updating server: SteamCMD: ${selfname} will be stopped during update" +} + # The location where the builds are checked and downloaded. remotelocation="mumble.info" diff --git a/lgsm/functions/update_steamcmd.sh b/lgsm/functions/update_steamcmd.sh index 17006a909..3715ff993 100644 --- a/lgsm/functions/update_steamcmd.sh +++ b/lgsm/functions/update_steamcmd.sh @@ -10,7 +10,6 @@ local function_selfname=$(basename "$(readlink -f "${BASH_SOURCE[0]}")") fn_update_steamcmd_dl(){ info_config.sh - # Detects if unbuffer command is available for 32 bit distributions only. info_distro.sh if [ "$(command -v stdbuf)" ]&&[ "${arch}" != "x86_64" ]; then @@ -29,7 +28,7 @@ fn_update_steamcmd_dl(){ fn_update_steamcmd_localbuild(){ # Gets local build info. - fn_print_dots "Checking for update: ${remotelocation}: checking local build" + fn_print_dots "Checking local build: ${remotelocation}" fn_appmanifest_check # Uses appmanifest to find local build. localbuild=$(grep buildid "${appmanifestfile}" | tr '[:blank:]"' ' ' | tr -s ' ' | cut -d\ -f3) @@ -46,7 +45,16 @@ fn_update_steamcmd_localbuild(){ else branchname="public" fi - fn_sleep_time + + # Checks if localbuild variable has been set. + if [ -z "${localbuild}" ]||[ "${localbuild}" == "null" ]; then + fn_print_fail "Checking local build: ${remotelocation}" + fn_script_log_fatal "Checking local build" + core_exit.sh + else + fn_print_ok "Checking local build: ${remotelocation}" + fn_script_log_pass "Checking local build" + fi } fn_update_steamcmd_remotebuild(){ @@ -56,14 +64,14 @@ fn_update_steamcmd_remotebuild(){ fi remotebuild=$(${steamcmdcommand} +login "${steamuser}" "${steampass}" +app_info_update 1 +app_info_print "${appid}" +quit | sed '1,/branches/d' | sed "1,/${branchname}/d" | grep -m 1 buildid | tr -cd '[:digit:]') if [ "${installer}" != "1" ]; then - fn_print_dots "Checking for update: ${remotelocation}: checking remote build" + fn_print_dots "Checking remote build: ${remotelocation}" # Checks if remotebuild variable has been set. if [ -z "${remotebuild}" ]||[ "${remotebuild}" == "null" ]; then - fn_print_fail "Checking for update: ${remotelocation}: checking remote build" + fn_print_fail "Checking remote build: ${remotelocation}" fn_script_log_fatal "Checking remote build" core_exit.sh else - fn_print_ok "Checking for update: ${remotelocation}: checking remote build" + fn_print_ok "Checking remote build: ${remotelocation}" fn_script_log_pass "Checking remote build" fi else @@ -80,6 +88,7 @@ fn_update_steamcmd_compare(){ fn_print_dots "Checking for update: ${remotelocation}" if [ "${localbuild}" != "${remotebuild}" ]; then fn_print_ok_nl "Checking for update: ${remotelocation}" + echo -en "\n" echo -e "Update available" echo -e "* Local build: ${red}${localbuild}${default}" echo -e "* Remote build: ${green}${remotebuild}${default}" @@ -94,24 +103,15 @@ fn_update_steamcmd_compare(){ fn_script_log_info "Branch: ${branch}" fi fn_script_log_info "${localbuild} > ${remotebuild}" - fn_sleep_time - echo -en "\n" - echo -en "applying update.\r" - sleep 1 - echo -en "applying update..\r" - sleep 1 - echo -en "applying update...\r" - sleep 1 - echo -en "\n" unset updateonstart - check_status.sh # If server stopped. if [ "${status}" == "0" ]; then fn_update_steamcmd_dl # If server started. else + fn_stop_warning exitbypass=1 command_stop.sh exitbypass=1 @@ -123,6 +123,7 @@ fn_update_steamcmd_compare(){ alert.sh else fn_print_ok_nl "Checking for update: ${remotelocation}" + echo -en "\n" echo -e "No update available" echo -e "* Local build: ${green}${localbuild}${default}" echo -e "* Remote build: ${green}${remotebuild}${default}" @@ -149,7 +150,6 @@ fn_appmanifest_check(){ # Multiple or no matching appmanifest files may sometimes be present. # This error is corrected if required. if [ "${appmanifestfilewc}" -ge "2" ]; then - fn_sleep_time fn_print_error "Multiple appmanifest_${appid}.acf files found" fn_script_log_error "Multiple appmanifest_${appid}.acf files found" fn_print_dots "Removing x${appmanifestfilewc} appmanifest_${appid}.acf files" @@ -158,10 +158,11 @@ fn_appmanifest_check(){ done appmanifestfilewc1="${appmanifestfilewc}" fn_appmanifest_info + # if error can not be resolved. if [ "${appmanifestfilewc}" -ge "2" ]; then fn_print_fail "Unable to remove x${appmanifestfilewc} appmanifest_${appid}.acf files" fn_script_log_fatal "Unable to remove x${appmanifestfilewc} appmanifest_${appid}.acf files" - echo -e " * Check user permissions" + echo -e "* Check user permissions" for appfile in ${appmanifestfile}; do echo -e " ${appfile}" done @@ -169,34 +170,48 @@ fn_appmanifest_check(){ else fn_print_ok "Removed x${appmanifestfilewc1} appmanifest_${appid}.acf files" fn_script_log_pass "Removed x${appmanifestfilewc1} appmanifest_${appid}.acf files" - fn_print_info "Forcing update to correct issue" + fn_print_info_nl "Forcing update to correct issue" fn_script_log_info "Forcing update to correct issue" fn_update_steamcmd_dl fi elif [ "${appmanifestfilewc}" -eq "0" ]; then - fn_print_error "No appmanifest_${appid}.acf found" + fn_print_error_nl "No appmanifest_${appid}.acf found" fn_script_log_error "No appmanifest_${appid}.acf found" - fn_print_info "Forcing update to correct issue" + fn_print_info_nl "Forcing update to correct issue" fn_script_log_info "Forcing update to correct issue" fn_update_steamcmd_dl fn_appmanifest_info if [ "${appmanifestfilewc}" -eq "0" ]; then - fn_print_fail "Still no appmanifest_${appid}.acf found" + fn_print_fail_nl "Still no appmanifest_${appid}.acf found" fn_script_log_fatal "Still no appmanifest_${appid}.acf found" core_exit.sh fi fi } +fn_stop_warning(){ + fn_print_warn "Updating server: SteamCMD: ${selfname} will be stopped during update" + fn_script_log_warn "Updating server: SteamCMD: ${selfname} will be stopped during update" + totalseconds=3 + for seconds in {3..1}; do + fn_print_warn "Updating server: SteamCMD: ${selfname} will be stopped during update: ${totalseconds}" + totalseconds=$((totalseconds - 1)) + sleep 1 + if [ "${seconds}" == "0" ]; then + break + fi + done + fn_print_warn_nl "Updating server: SteamCMD: ${selfname} will be stopped during update" +} + # The location where the builds are checked and downloaded. remotelocation="SteamCMD" - check.sh - if [ "${forceupdate}" == "1" ]; then # forceupdate bypasses update checks. check_status.sh if [ "${status}" != "0" ]; then + fn_stop_warning exitbypass=1 command_stop.sh fn_update_steamcmd_dl @@ -206,6 +221,8 @@ if [ "${forceupdate}" == "1" ]; then fn_update_steamcmd_dl fi else + fn_print_dots "Checking for update" + fn_print_dots "Checking for update: ${remotelocation}" fn_update_steamcmd_localbuild fn_update_steamcmd_remotebuild fn_update_steamcmd_compare diff --git a/lgsm/functions/update_ts3.sh b/lgsm/functions/update_ts3.sh index 3c8837214..0ca4b0842 100644 --- a/lgsm/functions/update_ts3.sh +++ b/lgsm/functions/update_ts3.sh @@ -32,15 +32,14 @@ fn_update_ts3_dl(){ fn_update_ts3_localbuild(){ # Gets local build info. - fn_print_dots "Checking for update: ${remotelocation}: checking local build" - fn_sleep_time + fn_print_dots "Checking local build: ${remotelocation}" # Uses log file to gather info. # Gives time for log file to generate. if [ ! -d "${serverfiles}/logs" ]||[ -z "$(find "${serverfiles}/logs/"* -name 'ts3server*_0.log' 2> /dev/null)" ]; then - fn_print_error "Checking for update: ${remotelocation}: checking local build" - fn_print_error_nl "Checking for update: ${remotelocation}: checking local build: no log files" - fn_script_log_error "No log file found" - fn_print_info_nl "Checking for update: ${remotelocation}: checking local build: forcing server restart" + fn_print_error "Checking local build: ${remotelocation}" + fn_print_error_nl "Checking local build: ${remotelocation}: no log files containing version info" + fn_print_info_nl "Checking local build: ${remotelocation}: forcing server restart" + fn_script_log_error "No log files containing version info" fn_script_log_info "Forcing server restart" exitbypass=1 command_stop.sh @@ -50,7 +49,7 @@ fn_update_ts3_localbuild(){ # Check again, allow time to generate logs. while [ ! -d "${serverfiles}/logs" ]||[ -z "$(find "${serverfiles}/logs/"* -name 'ts3server*_0.log' 2> /dev/null)" ]; do sleep 1 - fn_print_info "Checking for update: ${remotelocation}: checking local build: waiting for log file: ${totalseconds}" + fn_print_info "Checking local build: ${remotelocation}: waiting for log file: ${totalseconds}" if [ -v "${loopignore}" ]; then loopignore=1 fn_script_log_info "Waiting for log file to generate" @@ -58,7 +57,7 @@ fn_update_ts3_localbuild(){ if [ "${totalseconds}" -gt "120" ]; then localbuild="0" - fn_print_error "Checking for update: ${remotelocation}: waiting for log file: missing log file" + fn_print_error "Checking local build: ${remotelocation}: waiting for log file: missing log file" fn_script_log_error "Missing log file" fn_script_log_error "Set localbuild to 0" fi @@ -73,16 +72,15 @@ fn_update_ts3_localbuild(){ if [ -z "${localbuild}" ]; then # Gives time for var to generate. - end=$((SECONDS+120)) totalseconds=0 - while [ "${SECONDS}" -lt "${end}" ]; do - fn_print_info "Checking for update: ${remotelocation}: checking local build: waiting for local build: ${totalseconds}" + for seconds in {1..120}; do + fn_print_info "Checking local build: ${remotelocation}: waiting for local build: ${totalseconds}" if [ -z "${loopignore}" ]; then loopignore=1 fn_script_log_info "Waiting for local build to generate" fi localbuild=$(cat "$(find ./* -name "ts3server*_0.log" 2> /dev/null | sort | tail -1)" | grep -Eo "TeamSpeak 3 Server ((\.)?[0-9]{1,3}){1,3}\.[0-9]{1,3}" | grep -Eo "((\.)?[0-9]{1,3}){1,3}\.[0-9]{1,3}" | tail -1) - if [ "${localbuild}" ]; then + if [ "${localbuild}" ]||[ "${seconds}" == "120" ]; then break fi sleep 1 @@ -92,11 +90,11 @@ fn_update_ts3_localbuild(){ if [ -z "${localbuild}" ]; then localbuild="0" - fn_print_error "Checking for update: ${remotelocation}: waiting for local build: missing local build info" + fn_print_error "Checking local build: ${remotelocation}: waiting for local build: missing local build info" fn_script_log_error "Missing local build info" fn_script_log_error "Set localbuild to 0" else - fn_print_ok "Checking for update: ${remotelocation}: checking local build" + fn_print_ok "Checking local build: ${remotelocation}" fn_script_log_pass "Checking local build" fi } @@ -109,14 +107,14 @@ fn_update_ts3_remotebuild(){ remotebuild=$(curl -s "https://www.teamspeak.com/versions/server.json" | jq -r '.linux.x86.version') fi if [ "${installer}" != "1" ]; then - fn_print_dots "Checking for update: ${remotelocation}: checking remote build" + fn_print_dots "Checking remote build: ${remotelocation}" # Checks if remotebuild variable has been set. if [ -z "${remotebuild}" ]||[ "${remotebuild}" == "null" ]; then - fn_print_fail "Checking for update: ${remotelocation}: checking remote build" + fn_print_fail "Checking remote build: ${remotelocation}" fn_script_log_fatal "Checking remote build" core_exit.sh else - fn_print_ok "Checking for update: ${remotelocation}: checking remote build" + fn_print_ok "Checking remote build: ${remotelocation}" fn_script_log_pass "Checking remote build" fi else @@ -136,6 +134,7 @@ fn_update_ts3_compare(){ remotebuilddigit=$(echo -e "${remotebuild}" | tr -cd '[:digit:]') if [ "${localbuilddigit}" -ne "${remotebuilddigit}" ]||[ "${forceupdate}" == "1" ]; then fn_print_ok_nl "Checking for update: ${remotelocation}" + echo -en "\n" echo -e "Update available" echo -e "* Local build: ${red}${localbuild}${default}" echo -e "* Remote build: ${green}${remotebuild}${default}" @@ -143,18 +142,8 @@ fn_update_ts3_compare(){ fn_script_log_info "Local build: ${localbuild}" fn_script_log_info "Remote build: ${remotebuild}" fn_script_log_info "${localbuild} > ${remotebuild}" - fn_sleep_time - echo -en "\n" - echo -en "applying update.\r" - sleep 1 - echo -en "applying update..\r" - sleep 1 - echo -en "applying update...\r" - sleep 1 - echo -en "\n" unset updateonstart - check_status.sh # If server stopped. if [ "${status}" == "0" ]; then @@ -166,6 +155,7 @@ fn_update_ts3_compare(){ command_stop.sh # If server started. else + fn_stop_warning exitbypass=1 command_stop.sh exitbypass=1 @@ -177,6 +167,7 @@ fn_update_ts3_compare(){ alert.sh else fn_print_ok_nl "Checking for update: ${remotelocation}" + echo -en "\n" echo -e "No update available" echo -e "* Local build: ${green}${localbuild}${default}" echo -e "* Remote build: ${green}${remotebuild}${default}" @@ -198,6 +189,21 @@ else core_exit.sh fi +fn_stop_warning(){ + fn_print_warn "Updating server: SteamCMD: ${selfname} will be stopped during update" + fn_script_log_warn "Updating server: SteamCMD: ${selfname} will be stopped during update" + totalseconds=3 + for seconds in {3..1}; do + fn_print_warn "Updating server: SteamCMD: ${selfname} will be stopped during update: ${totalseconds}" + totalseconds=$((totalseconds - 1)) + sleep 1 + if [ "${seconds}" == "0" ]; then + break + fi + done + fn_print_warn_nl "Updating server: SteamCMD: ${selfname} will be stopped during update" +} + # The location where the builds are checked and downloaded. remotelocation="teamspeak.com"