summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJannis Pohlmann <jannis.pohlmann@codethink.co.uk>2012-03-26 13:28:34 +0000
committerJannis Pohlmann <jannis.pohlmann@codethink.co.uk>2012-03-26 13:28:34 +0000
commit93a1461ba77603e51fe8fc9fa0c021e81b84917d (patch)
treeee494aaff927e2dabaf4fbc8c9a5c537485ecc72
parent92d128b405a16a14aba2348117c263672f93c706 (diff)
downloadtbdiff-93a1461ba77603e51fe8fc9fa0c021e81b84917d.tar.gz
Clear traps before exiting, explicitly umount before reboot.
The sync calls should not be needed, so I'm dropping them as well.
-rwxr-xr-xtbdiff-switch/tbdiff-switch12
-rwxr-xr-xtbdiff-update/tbdiff-update12
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