From 5dbaf8454aab16caabcc26b009655018f5a4e64d Mon Sep 17 00:00:00 2001 From: PrincessPi3 Date: Sat, 9 Nov 2024 08:17:08 -0700 Subject: [PATCH] 53-rc4.1 --- cron-reinstall-esp-idf.sh | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/cron-reinstall-esp-idf.sh b/cron-reinstall-esp-idf.sh index 80781d4..d6bb225 100644 --- a/cron-reinstall-esp-idf.sh +++ b/cron-reinstall-esp-idf.sh @@ -13,7 +13,7 @@ startTime=$(date '+%s') # crontab -e # 0 8 * * * bash $HOME/esp/esp-install-custom/cron-reinstall-esp-idf.sh -cronVers=53-rc4 # version of this script +cronVers=53-rc4.1 # version of this script myUser=princesspi gitJobs=5 @@ -38,9 +38,9 @@ function write_to_log() { echo -e "$1" >> $log } -# function warn_all_users() { -# who | sudo awk '$1 !~ /root/{ cmd="echo '$1' | /usr/bin/write " $1; system(cmd)}' -# } +function warn_all_users() { + who | sudo awk '$1 !~ /root/{ cmd="echo '$1' | /usr/bin/write " $1; system(cmd)}' + } write_to_log " === $(date '+%d/%m/%Y %H:%M:%S %Z (%s)'): new reinstall ===" write_to_log "Cron version: ${cronVers}" @@ -80,7 +80,8 @@ warningString="\nWARNING:\n\tReinstalling esp-idf in ${sleepMins} minutes! You w write_to_log "$(date '+%d/%m/%Y %H:%M:%S %Z (%s)'): sending warning message to $myUser" write_to_log "$warningString" -echo -e "$warningString" | sudo write "$myUser" +# echo -e "$warningString" | sudo write "$myUser" +warn_all_users "$warningString" return_status write_to_log "$(date '+%d/%m/%Y %H:%M:%S %Z (%s)'): sleeping ${sleepMins} minutes" @@ -161,7 +162,8 @@ return_status rebootMsg="$(date '+%d/%m/%Y %H:%M:%S %Z (%s)'): rebooting in $sleepMins minutes. save and log out" write_to_log "$rebootMsg" -echo "$rebootMsg" | sudo write "$myUser" +warn_all_users "$rebootMsg" +# echo "$rebootMsg" | sudo write "$myUser" return_status write_to_log "$(date '+%d/%m/%Y %H:%M:%S %Z (%s)'): sleeping ${sleepMins} minutes" @@ -175,7 +177,6 @@ return_status endTime=$(date '+%s') timeElapsed=$(($endTime-$startTime)) write_to_log "reinstall completed in $timeElapsed seconds" - write_to_log " === $(date '+%d/%m/%Y %H:%M:%S %Z (%s)'): finished ===\n\n" if [ "$1" == "test" ]; then