added error handling to ephemeral.nix
This commit is contained in:
parent
4b5426885c
commit
d655099d76
1 changed files with 12 additions and 2 deletions
|
|
@ -45,8 +45,13 @@ in
|
||||||
RemainAfterExit = true;
|
RemainAfterExit = true;
|
||||||
};
|
};
|
||||||
script = ''
|
script = ''
|
||||||
|
set -euo pipefail
|
||||||
|
|
||||||
mkdir /btrfs_tmp
|
mkdir /btrfs_tmp
|
||||||
mount ${cfg.rootDevice} /btrfs_tmp
|
if ! mount ${cfg.rootDevice} /btrfs_tmp; then
|
||||||
|
echo "ERROR: Failed to mount ${cfg.rootDevice}"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
if [[ -e /btrfs_tmp/${cfg.rootSubvolume} ]]; then
|
if [[ -e /btrfs_tmp/${cfg.rootSubvolume} ]]; then
|
||||||
mkdir -p /btrfs_tmp/old_roots
|
mkdir -p /btrfs_tmp/old_roots
|
||||||
|
|
@ -66,7 +71,12 @@ in
|
||||||
delete_subvolume_recursively "$i"
|
delete_subvolume_recursively "$i"
|
||||||
done
|
done
|
||||||
|
|
||||||
btrfs subvolume create /btrfs_tmp/${cfg.rootSubvolume}
|
if ! btrfs subvolume create /btrfs_tmp/${cfg.rootSubvolume}; then
|
||||||
|
echo "ERROR: Failed to create subvolume ${cfg.rootSubvolume}"
|
||||||
|
umount /btrfs_tmp
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
umount /btrfs_tmp
|
umount /btrfs_tmp
|
||||||
'';
|
'';
|
||||||
};
|
};
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue