diff options
author | Andrew Cady <d@jerkface.net> | 2016-04-26 04:08:56 -0400 |
---|---|---|
committer | Andrew Cady <d@jerkface.net> | 2016-04-26 04:08:56 -0400 |
commit | 19fc3ad482a467dbfcd27c8366ba026107498f4f (patch) | |
tree | 215c1290167cd213ed0b82bd9a9d23ea6bac2778 | |
parent | c33cb424ef479a6947395391b3771cc56b2d6161 (diff) |
ejection script for cdrom duplication
included some necessary dependencies
-rw-r--r-- | initrd-dependencies.txt | 3 | ||||
-rw-r--r-- | old-school/lvm-create.sh | 22 | ||||
-rwxr-xr-x | patchroot.sh | 2 | ||||
-rwxr-xr-x | samizdat-eject.sh | 47 |
4 files changed, 69 insertions, 5 deletions
diff --git a/initrd-dependencies.txt b/initrd-dependencies.txt index 6f4f9e6..9265bcb 100644 --- a/initrd-dependencies.txt +++ b/initrd-dependencies.txt | |||
@@ -3,3 +3,6 @@ pgpdump | |||
3 | monkeysphere | 3 | monkeysphere |
4 | libmime-base32-perl | 4 | libmime-base32-perl |
5 | pinentry-curses | 5 | pinentry-curses |
6 | mdadm | ||
7 | ntfs-3g | ||
8 | hfsplus | ||
diff --git a/old-school/lvm-create.sh b/old-school/lvm-create.sh index ecbae49..b6d38d2 100644 --- a/old-school/lvm-create.sh +++ b/old-school/lvm-create.sh | |||
@@ -1,6 +1,4 @@ | |||
1 | #!/bin/sh | 1 | #!/bin/sh |
2 | : ${ROOT_MKFS_CMD:=mkfs.ext4 -q} | ||
3 | : ${ROOT_FS_TYPE:=ext4} | ||
4 | 2 | ||
5 | losetup() { /sbin/losetup "$@"; } | 3 | losetup() { /sbin/losetup "$@"; } |
6 | 4 | ||
@@ -55,12 +53,28 @@ init_samizdat() | |||
55 | 53 | ||
56 | btrfs device add "$blockdev" /root || return | 54 | btrfs device add "$blockdev" /root || return |
57 | mount -o rw,remount /root || return | 55 | mount -o rw,remount /root || return |
58 | btrfs subvolume create /root/gpg || return | 56 | |
59 | mv /gpg/gnupghome /root/gpg/ || return | 57 | initialize_root_filesystem || return |
60 | 58 | ||
61 | bootdone root-mounted | 59 | bootdone root-mounted |
62 | } | 60 | } |
63 | 61 | ||
62 | initialize_root_filesystem() | ||
63 | { | ||
64 | btrfs subvolume create /root/gpg || return | ||
65 | mv /gpg/gnupghome /root/gpg/ || return | ||
66 | |||
67 | rm -r /root/var/cache/apt/archives | ||
68 | btrfs subvolume create /root/var/cache/apt/archives || return | ||
69 | |||
70 | rmdir /root/home | ||
71 | btrfs subvolume create /root/home || return | ||
72 | |||
73 | [ -x /root/sbin/mdadm ] || cp /sbin/mdadm /root/sbin/ | ||
74 | [ -e /root/sbin/mdadm-dup.sh ] || cp /bin/mdadm-dup.sh /root/sbin/ | ||
75 | true | ||
76 | } | ||
77 | |||
64 | # Get the uuid of the filesystem with the most devices, | 78 | # Get the uuid of the filesystem with the most devices, |
65 | # excluding filesystems that don't incorporate loop devices. | 79 | # excluding filesystems that don't incorporate loop devices. |
66 | # This is used to choose the latest seed -- which should have | 80 | # This is used to choose the latest seed -- which should have |
diff --git a/patchroot.sh b/patchroot.sh index e211377..3efa8ec 100755 --- a/patchroot.sh +++ b/patchroot.sh | |||
@@ -1,6 +1,6 @@ | |||
1 | #!/bin/sh | 1 | #!/bin/sh |
2 | 2 | ||
3 | pkgs='avahi-daemon git tmux btrfs-tools/jessie-backports sshfs' | 3 | pkgs='avahi-daemon git tmux btrfs-tools/jessie-backports sshfs eject' |
4 | pkgs="$pkgs $(cat initrd-dependencies.txt)" | 4 | pkgs="$pkgs $(cat initrd-dependencies.txt)" |
5 | pkgs="$pkgs linux-image-$(uname -r)" | 5 | pkgs="$pkgs linux-image-$(uname -r)" |
6 | 6 | ||
diff --git a/samizdat-eject.sh b/samizdat-eject.sh new file mode 100755 index 0000000..04ee610 --- /dev/null +++ b/samizdat-eject.sh | |||
@@ -0,0 +1,47 @@ | |||
1 | #!/bin/sh | ||
2 | |||
3 | . mdadm-dup.sh || exit 1 | ||
4 | |||
5 | btrfs_subdevices() | ||
6 | { | ||
7 | local mountpoint="$1" | ||
8 | btrfs filesystem show "$mountpoint" | sed -ne 's/^[ \t]*devid.* path //p' | ||
9 | } | ||
10 | |||
11 | devices=$(btrfs_subdevices /) || exit 1 | ||
12 | |||
13 | set -- | ||
14 | seen= | ||
15 | for dev in $devices; do | ||
16 | [ -b "$dev" ] || exit 1 | ||
17 | case "$dev" in | ||
18 | /dev/mapper/loop*) set -- "$@" "$dev" ;; | ||
19 | /dev/mapper/samizdatcrypt) seen=y ;; | ||
20 | esac | ||
21 | done | ||
22 | [ "$seen" ] || exit 1 | ||
23 | |||
24 | copy() | ||
25 | { | ||
26 | mdadm_copy_eject /dev/md55 /root/samizdat.iso | ||
27 | } | ||
28 | |||
29 | remove() | ||
30 | { | ||
31 | for dev; do | ||
32 | (set -x; btrfs device remove "$dev" /) | ||
33 | done | ||
34 | } | ||
35 | |||
36 | # Doing the mdadm copy before removing the devices means our filesystem includes | ||
37 | # devices that are ultimately backed by files ON THE SAME FILESYSTEM. As such, it | ||
38 | # might conceivably put btrfs into a deadlock of some kind. | ||
39 | |||
40 | # If it turns out this doesn't work, the order can be reversed. This will | ||
41 | # perform the read IO twice, though, almost doubling the total installation | ||
42 | # time. | ||
43 | |||
44 | copy & remove "$@" | ||
45 | |||
46 | set -x | ||
47 | wait | ||