summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xarchsetup9
1 files changed, 9 insertions, 0 deletions
diff --git a/archsetup b/archsetup
index c656e25..a44295e 100755
--- a/archsetup
+++ b/archsetup
@@ -94,6 +94,15 @@ min_disk_space_gb=20
state_dir="/var/lib/archsetup/state"
error_messages=()
+### Cleanup Trap
+# Ensures tmpfs is unmounted if script exits unexpectedly
+cleanup() {
+ if mountpoint -q "$source_dir" 2>/dev/null; then
+ umount "$source_dir" 2>/dev/null
+ fi
+}
+trap cleanup EXIT
+
### State Tracking
# Enables resuming from where the script left off if interrupted.
# State is stored as marker files in $state_dir.