This commit is contained in:
2024-11-09 05:18:01 -07:00
parent d90e8cf0e6
commit bdc21ccc2a
+8 -6
View File
@@ -1,6 +1,6 @@
#!/bin/bash #!/bin/bash
cronVers=36-live # version of this script cronVers=37-live # version of this script
sleepSecs=180 # seconds of warning to wait for user to log out sleepMins=3 # minutes of warning to wait for user to log out
log=$HOME/esp/install.log log=$HOME/esp/install.log
myUser=$USER myUser=$USER
@@ -32,17 +32,19 @@ function logout_all_users() {
return $? 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 " === $(date '+%d/%m/%Y %H:%M:%S %Z (%s)'): new reinstall ==="
write_to_log "Cron version: ${cronVers}" 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 "$(date '+%d/%m/%Y %H:%M:%S %Z (%s)'): sending warning message to $myUser"
write_to_log "$warningString" write_to_log "$warningString"
echo -e "$warningString" | sudo write $myUser echo -e "$warningString" | sudo write $myUser
return_status 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 sleep $sleepSecs
return_status return_status
@@ -127,12 +129,12 @@ write_to_log $gitDataLog
echo -e $gitDataLog >> $installDir/version-data.txt echo -e $gitDataLog >> $installDir/version-data.txt
return_status 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 write_to_log $rebootMsg
echo $rebootMsg | sudo write princesspi echo $rebootMsg | sudo write princesspi
return_status 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 sleep $sleepSecs
return_status return_status