diff --git a/cron-reinstall-esp-idf.sh b/cron-reinstall-esp-idf.sh index 82539ef..c1398a6 100644 --- a/cron-reinstall-esp-idf.sh +++ b/cron-reinstall-esp-idf.sh @@ -1,6 +1,6 @@ #!/bin/bash -cronVers=36-live # version of this script -sleepSecs=180 # seconds of warning to wait for user to log out +cronVers=37-live # version of this script +sleepMins=3 # minutes of warning to wait for user to log out log=$HOME/esp/install.log myUser=$USER @@ -32,17 +32,19 @@ function logout_all_users() { return $? } +sleepSecs=$((sleepMins*60)) # calculated seconds of warning to wait for user to log out + write_to_log " === $(date '+%d/%m/%Y %H:%M:%S %Z (%s)'): new reinstall ===" write_to_log "Cron version: ${cronVers}" -warningString="\nWARNING:\n\tReinstalling esp-idf in ${sleepSecs} seconds! You will be logged out in ${sleepSecs}! Save and log out!\n\tmonitor with \`tail -f -n 50 $HOME/esp/install.log\`\n\tterminate with \`sudo killall cron-reinstall-esp-idf.sh\`\n\t$(date '+%d/%m/%Y %H:%M:%S %Z (%s)')\n" +warningString="\nWARNING:\n\tReinstalling esp-idf in ${sleepSecs} minutes! You will be force logged out in ${sleepSecs} minutes! Save and log out!\n\tmonitor with \`tail -f -n 50 $HOME/esp/install.log\`\n\tterminate with \`sudo killall cron-reinstall-esp-idf.sh\`\n\t$(date '+%d/%m/%Y %H:%M:%S %Z (%s)')\n" 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 return_status -write_to_log "$(date '+%d/%m/%Y %H:%M:%S %Z (%s)'): sleeping ${sleepSecs} seconds" +write_to_log "$(date '+%d/%m/%Y %H:%M:%S %Z (%s)'): sleeping ${sleepSecs} minutes" sleep $sleepSecs return_status @@ -127,12 +129,12 @@ write_to_log $gitDataLog echo -e $gitDataLog >> $installDir/version-data.txt return_status -rebootMsg="$(date '+%d/%m/%Y %H:%M:%S %Z (%s)'): rebooting in ${sleepSecs} seconds. seave and log out" +rebootMsg="$(date '+%d/%m/%Y %H:%M:%S %Z (%s)'): rebooting in ${sleepSecs} minutes. seave and log out" write_to_log $rebootMsg echo $rebootMsg | sudo write princesspi return_status -write_to_log "$(date '+%d/%m/%Y %H:%M:%S %Z (%s)'): sleeping ${sleepSecs} seconds" +write_to_log "$(date '+%d/%m/%Y %H:%M:%S %Z (%s)'): sleeping ${sleepSecs} minutes" sleep $sleepSecs return_status