diff options
-rwxr-xr-x | tbdiff-switch/tbdiff-switch | 12 | ||||
-rwxr-xr-x | tbdiff-update/tbdiff-update | 12 |
2 files changed, 18 insertions, 6 deletions
diff --git a/tbdiff-switch/tbdiff-switch b/tbdiff-switch/tbdiff-switch index 12a00b3..b076354 100755 --- a/tbdiff-switch/tbdiff-switch +++ b/tbdiff-switch/tbdiff-switch @@ -34,7 +34,7 @@ fi # mount the root btrfs file system rootfs="$(busybox mktemp -d)" mount -t btrfs "$device" "$rootfs" -trap "cd /; umount $rootfs; busybox rm -rf $rootfs" EXIT SIGINT SIGTERM +trap "cd /; umount $rootfs && busybox rm -rf $rootfs" EXIT SIGINT SIGTERM # switch into the root file system cd "$rootfs" @@ -67,11 +67,17 @@ echo "Configuring extlinux to boot from \"$target_subvolume-run\"" busybox sed -i -e "s,factory-run,$target_subvolume-run,g" "extlinux.conf" +# clear the traps +trap EXIT SIGINT SIGTERM + # leave the root file system cd / -# perform a sync to make sure everything has been written -busybox sync +# unmount the root file system +umount "$rootfs" + +# remove the temporary directory +rm -rf "$rootfs" # reboot the system busybox reboot diff --git a/tbdiff-update/tbdiff-update b/tbdiff-update/tbdiff-update index 21373d8..1014a3c 100755 --- a/tbdiff-update/tbdiff-update +++ b/tbdiff-update/tbdiff-update @@ -43,7 +43,7 @@ fi # mount the root btrfs file system rootfs="$(busybox mktemp -d)" mount -t btrfs "$device" "$rootfs" -trap "cd /; umount $rootfs; busybox rm -rf $rootfs" EXIT SIGINT SIGTERM +trap "cd /; umount $rootfs && busybox rm -rf $rootfs" EXIT SIGINT SIGTERM # switch into the root file system cd "$rootfs" @@ -107,11 +107,17 @@ echo "Configuring extlinux to boot from \"$target_subvolume-run\"" busybox sed -i -e "s,factory-run,$target_subvolume-run,g" "extlinux.conf" +# clear the traps +trap EXIT SIGINT SIGTERM + # leave the root file system cd / -# perform a sync to make sure everything has been written -busybox sync +# unmount the root file system +umount "$rootfs" + +# remove the temporary directory +rm -rf "$rootfs" # reboot the system busybox reboot |