add oncefile in /tmp that's cleared by reboot

Now rebooting will allow the script to run again without needing to
delete autoroot.once on the USB drive.
This commit is contained in:
throwaway96 2024-04-22 21:52:42 -04:00
parent 0f5860dd6a
commit 7be6d81637
1 changed files with 4 additions and 3 deletions

View File

@ -92,11 +92,12 @@ debug "temp dir: ${tempdir}"
log "date: $(date -u -- '+%Y-%m-%d %H:%M:%S UTC')"
log "id: $(id)"
oncefile="${USB_PATH}/autoroot.once"
usb_oncefile="${USB_PATH}/autoroot.once"
tmp_oncefile='/tmp/autoroot.once'
[ -e "${oncefile}" ] && { log 'Script already executed'; exit 3; }
[ -e "${usb_oncefile}" -a -e "${tmp_oncefile}" ] && { log 'Script already executed'; exit 3; }
touch -- "${oncefile}"
touch -- "${usb_oncefile}" "${tmp_oncefile}"
trap -- "cp -f -- '${logfile}' '${USB_PATH}/autoroot.log'" EXIT