[FIRSTBOOT] add safet_shutdown() with log_firstboot.txt

- increase sleep time before shutdown
- show unallocated space left in MB
- dry a bit code
This commit is contained in:
Apaczer
2023-08-08 21:51:19 +02:00
parent 40099a142e
commit bb60713390

View File

@@ -53,28 +53,26 @@ console_var_func(){
fi
}
# write logs, sync & unmount MAIN then reboot/poweroff
safe_reboot_func(){
# write logs, sync & unmount MAIN before reboot/poweroff
safe_shutdown_func(){
echo "please wait a few seconds for a reboot...." | tee -a ${LOG}
dmesg > ${HOME}/dmesg.txt
mv ${LOG} ${HOME}/log_firstboot.txt
sync
sleep 1
mount -o remount,ro "${MOUNTDIR}" | tee -a ${LOG}
umount /dev/mmcblk0p4 | tee -a ${LOG}
#umount /dev/mmcblk0p1 | tee -a ${LOG} # this fails
sleep 2
sleep 4
}
safe_reboot_func(){
safe_shutdown_func
reboot
}
safe_poweroff_func(){
echo "please wait a few seconds for a shutdown...." | tee -a ${LOG}
dmesg > ${HOME}/dmesg.txt
sync
sleep 1
mount -o remount,ro "${MOUNTDIR}" | tee -a ${LOG}
umount /dev/mmcblk0p4 | tee -a ${LOG}
#umount /dev/mmcblk0p1 | tee -a ${LOG} # this fails
sleep 2
safe_shutdown_func
poweroff
}
@@ -494,7 +492,8 @@ if (dialog --clear --stdout --ok-label YES --cancel-label NO --title " AUTO-RE
\n\n \ZbWARNING:\Zn\n After 10s auto-resize\n of FAT32 partition will begin." 15 60 10); then
clear
echo "The full size of your SD is ${SD_SIZE_IN_MiB}MiB large" | tee -a ${LOG}
echo "Unallocated space available for resizing equals ${SD_MAX_UNALL_SIZE_IN_GB}GB" | tee -a ${LOG}
echo "Unallocated space available for resizing equals ${SD_MAX_UNALL_SIZE_IN_GB}GB," | tee -a ${LOG}
echo "and more precisely it's ${SD_MAX_UNALL_SIZE_IN_MB}MB big" | tee -a ${LOG}
echo "Going to resize the MAIN partition." | tee -a ${LOG}
echo "This can take A LONG TIME, so be patient." | tee -a ${LOG}
umount /dev/mmcblk0p4 | tee -a ${LOG}
@@ -544,8 +543,7 @@ echo
sync
echo "firstboot script finished." | tee -a ${LOG}
#grep logs from temp directory
mv ${LOG} ${HOME}/log_firstboot.txt
echo
# Reboot device if CONSOLE_VARIANT was overwritten from $CHOICE so that it could be applied in u-boot by readID
@@ -553,4 +551,7 @@ echo
if ($CONSOLE_OVERWRITE || $RESIZE_COMMENCED || test -r "${BASEDIR}/firstboot.custom.sh"); then
touch ${HOME}/firstboot.completed
safe_reboot_func
else
#just grep logs from temp directory before continuing
mv ${LOG} ${HOME}/log_firstboot.txt
fi