summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xsamizdat-eject.sh20
1 files changed, 18 insertions, 2 deletions
diff --git a/samizdat-eject.sh b/samizdat-eject.sh
index e9e71e5..0f4e117 100755
--- a/samizdat-eject.sh
+++ b/samizdat-eject.sh
@@ -7,9 +7,18 @@ die()
7 7
8target=$1 8target=$1
9 9
10if [ ! "$target" ] && mountpoint -q /srv && [ ! -e /srv/samizdat.iso ]; then
11 target=/srv/samizdat.iso
12fi
13
10[ "$target" ] || die "Usage: $0 <target filename>" 14[ "$target" ] || die "Usage: $0 <target filename>"
11[ ! -e "$target" ] || die "Error: file exists: $target" 15[ ! -e "$target" ] || die "Error: file exists: $target"
12 16
17if mountpoint -q /outerfs; then
18 temp_target=$(mktemp --tmpdir=/outerfs)
19else
20 die "Error: /outerfs is not a mountpoint. Please mount a safe filesystem to temporarily store the ISO on /outerfs"
21fi
13 22
14. mdadm-dup.sh || exit 1 23. mdadm-dup.sh || exit 1
15 24
@@ -34,14 +43,21 @@ done
34 43
35copy() 44copy()
36{ 45{
37 mdadm_copy_eject_crypt /dev/md55 "$target" 46 mdadm_copy_eject_crypt /dev/md55 "$temp_target" &&
47 dd if=/dev/md55 of="$target".part &&
48 mv "$target".part "$target"
49
50 # I suppose at this point $target should be made the backing device of
51 # /dev/md55
52
53 # Alternatively: mdadm --stop /dev/md55
38} 54}
39 55
40remove() 56remove()
41{ 57{
42 for dev; do 58 for dev; do
43 (set -x; btrfs device remove "$dev" /) 59 (set -x; btrfs device remove "$dev" /)
44 dmsetup remove "$dev" 60 dmsetup remove "$dev" 2>/dev/null
45 losetup -D 61 losetup -D
46 done 62 done
47} 63}