lock file name as a constant

one place to check for skip reboot
remove lock file if not rebooting
pull/415/head
Paul Philippov 2022-08-27 08:05:02 -04:00
parent c1e3205a48
commit 3ebeaa88e4
1 changed files with 15 additions and 11 deletions

View File

@ -9,6 +9,8 @@ args=" $@"
set -e set -e
LOCK_FILE=/tmp/sysupgrade.lock
echo_c() { echo_c() {
# 31 red, 32 green, 33 yellow, 34 blue, 35 magenta, 36 cyan, 37 white, 38 grey # 31 red, 32 green, 33 yellow, 34 blue, 35 magenta, 36 cyan, 37 white, 38 grey
[ -z "$HASERLVER" ] && t="\e[1;$1m$2\e[0m" || t="$2" [ -z "$HASERLVER" ] && t="\e[1;$1m$2\e[0m" || t="$2"
@ -148,11 +150,11 @@ check_sdcard() {
} }
create_lock() { create_lock() {
if [ -f /tmp/sysupgrade.lock ]; then if [ -f $LOCK_FILE ]; then
echo_c 31 "\nAnother sysupgrade process is already running!" echo_c 31 "\nAnother sysupgrade process is already running!"
exit 1 exit 1
fi fi
touch /tmp/sysupgrade.lock touch $LOCK_FILE
} }
get_device() { get_device() {
@ -206,9 +208,16 @@ Where:
} }
reboot_system() { reboot_system() {
[ "$skip_reboot" -eq 1 ] && echo_c 31 "\nReboot needed!" && exit 1 if [ "1" = "$skip_reboot" ]; then
echo_c 37 "\nUnconditional reboot" echo_c 33 "\nYou asked me not to reboot, so I won't."
reboot -d 1 -f echo_c 31 "Although a reboot is required to apply the changes."
echo_c 37 "Please reboot the camera manually whenever possible."
rm $LOCK_FILE
exit 1
else
echo_c 37 "\nUnconditional reboot"
reboot -d 1 -f
fi
} }
clear_overlay=0 clear_overlay=0
@ -310,11 +319,6 @@ free_resources
[ "$update_rootfs" -eq 1 ] && do_update_rootfs "$rootfs_file" [ "$update_rootfs" -eq 1 ] && do_update_rootfs "$rootfs_file"
[ "$clear_overlay" -eq 1 ] && do_wipe_overlay [ "$clear_overlay" -eq 1 ] && do_wipe_overlay
if [ "1" = "$skip_reboot" ]; then reboot_system
echo_c 33 "You asked me not to reboot, so I won't."
echo_c 37 "Please reboot the camera manually whenever possible."
else
reboot_system
fi
exit 0 exit 0