diff options
author | Andrew Cady <d@jerkface.net> | 2019-06-18 22:30:10 -0400 |
---|---|---|
committer | Andrew Cady <d@jerkface.net> | 2019-06-18 22:30:10 -0400 |
commit | 6535dbeb4c025fe68c4c2700149dc49de0ba553c (patch) | |
tree | b0cb1ef211d2cf7fe304e825c8b8bfc6149bdedf | |
parent | 35d9a3d16fadcc96cf328ac2df0b2587c898dc14 (diff) |
avoid hard-coded IP address for nbd server
-rw-r--r-- | initramfs-tools/scripts/samizdat | 40 | ||||
-rw-r--r-- | isolinux/pxelinux.cfg/default | 2 | ||||
-rwxr-xr-x | src/qemu.sh | 2 |
3 files changed, 14 insertions, 30 deletions
diff --git a/initramfs-tools/scripts/samizdat b/initramfs-tools/scripts/samizdat index 1e333f4..0abe902 100644 --- a/initramfs-tools/scripts/samizdat +++ b/initramfs-tools/scripts/samizdat | |||
@@ -1,5 +1,8 @@ | |||
1 | klogd -c1 # TODO: This should be even earlier. Can it go on the kernel command line? | 1 | klogd -c1 # TODO: This should be even earlier. Can it go on the kernel command line? |
2 | 2 | ||
3 | . common.sh | ||
4 | debug_log samizdat.init | ||
5 | |||
3 | mountroot() | 6 | mountroot() |
4 | { | 7 | { |
5 | openvt -c 13 sh | 8 | openvt -c 13 sh |
@@ -7,15 +10,17 @@ mountroot() | |||
7 | mkfifo "$MENUFIFO" | 10 | mkfifo "$MENUFIFO" |
8 | samizdat_install_udev_rules | 11 | samizdat_install_udev_rules |
9 | 12 | ||
10 | if [ "${nbdroot%%,*}" ]; then | 13 | if [ "$nbdroot" ]; then |
14 | configure_networking | ||
15 | export ROOTSERVER | ||
16 | |||
11 | (. common.sh | 17 | (. common.sh |
12 | sh /scripts/local-top/nbd >/dev/null 2>&1; | 18 | debug_log samizdat.nbd |
19 | . /scripts/local-top/nbd | ||
13 | bootdone nbd-script) & | 20 | bootdone nbd-script) & |
14 | fi | ||
15 | 21 | ||
16 | if ! cdrom_has_keys && keys_via_network; then | ||
17 | bootwait nbd-script | 22 | bootwait nbd-script |
18 | wait_for_gnupghome_tar "$tftp_key_server" | 23 | wait_for_gnupghome_tar |
19 | fi | 24 | fi |
20 | 25 | ||
21 | bootwait samizdat-gpg | 26 | bootwait samizdat-gpg |
@@ -31,38 +36,17 @@ cdrom_has_keys() | |||
31 | [ -d /cdrom/gnupghome ] | 36 | [ -d /cdrom/gnupghome ] |
32 | } | 37 | } |
33 | 38 | ||
34 | # Sets $tftp_key_server or returns false. | ||
35 | keys_via_network() | ||
36 | { | ||
37 | [ "${nbdroot%%,*}" ] || return | ||
38 | local arg cmdline | ||
39 | read cmdline < /proc/cmdline | ||
40 | for arg in $cmdline; do | ||
41 | case "$arg" in | ||
42 | netkeys) | ||
43 | tftp_key_server="${nbdroot%%/*}" | ||
44 | return 0 | ||
45 | ;; | ||
46 | netkeys=*) | ||
47 | tftp_key_server="${arg#netkeys=}" | ||
48 | return 0 | ||
49 | ;; | ||
50 | esac | ||
51 | done | ||
52 | return 1 | ||
53 | } | ||
54 | |||
55 | wait_for_gnupghome_tar() | 39 | wait_for_gnupghome_tar() |
56 | { | 40 | { |
57 | local tftp_server="$1" | ||
58 | [ -e /gnupghome.tar ] && return | 41 | [ -e /gnupghome.tar ] && return |
59 | echo -n Waiting to receive GPG keys through the network... | 42 | echo -n Waiting to receive GPG keys through the network... |
60 | (while ! tftp -g -r gnupghome.tar -l /gnupghome.tar.$$ "$tftp_server" 2>/dev/null; do | 43 | (while ! tftp -g -r gnupghome.tar -l /gnupghome.tar.$$ "$ROOTSERVER" 2>/run/initramfs/samizdat/log/tftp.$$.log; do |
61 | sleep 1; | 44 | sleep 1; |
62 | echo -n . | 45 | echo -n . |
63 | done | 46 | done |
64 | mv /gnupghome.tar.$$ /gnupghome.tar) | 47 | mv /gnupghome.tar.$$ /gnupghome.tar) |
65 | echo ' done.' | 48 | echo ' done.' |
49 | (sleep 5; echo ) & | ||
66 | (. common.sh && . btrfs-create.sh && init_gpg) | 50 | (. common.sh && . btrfs-create.sh && init_gpg) |
67 | } | 51 | } |
68 | 52 | ||
diff --git a/isolinux/pxelinux.cfg/default b/isolinux/pxelinux.cfg/default index 738769e..782a24b 100644 --- a/isolinux/pxelinux.cfg/default +++ b/isolinux/pxelinux.cfg/default | |||
@@ -3,4 +3,4 @@ label samizdat | |||
3 | linux linux/vmlinuz | 3 | linux linux/vmlinuz |
4 | initrd linux/initrd.img | 4 | initrd linux/initrd.img |
5 | ipappend 0x3 | 5 | ipappend 0x3 |
6 | append boot=samizdat components quiet splash nbdroot=192.168.10.1/samizdat.btrfs nbddev=/dev/nbd0 netkeys | 6 | append boot=samizdat components quiet splash nbdroot=,samizdat.btrfs, nbddev=/dev/nbd0 netkeys |
diff --git a/src/qemu.sh b/src/qemu.sh index 8f53490..36c0bdf 100755 --- a/src/qemu.sh +++ b/src/qemu.sh | |||
@@ -27,7 +27,7 @@ nbd_filename=samizdat.btrfs | |||
27 | initrd=${samizdat_isolinux_dir}/linux/initrd.img | 27 | initrd=${samizdat_isolinux_dir}/linux/initrd.img |
28 | kernel=${samizdat_isolinux_dir}/linux/vmlinuz | 28 | kernel=${samizdat_isolinux_dir}/linux/vmlinuz |
29 | kcmdline_CDROM='boot=samizdat components quiet splash' | 29 | kcmdline_CDROM='boot=samizdat components quiet splash' |
30 | kcmdline_CDROM_NET="${kcmdline_CDROM} nbdroot=192.168.10.1/${nbd_filename} nbddev=/dev/nbd0 ip=dhcp" | 30 | kcmdline_CDROM_NET="${kcmdline_CDROM} nbdroot=,${nbd_filename}, nbddev=/dev/nbd0 ip=dhcp" |
31 | kcmdline_NET="${kcmdline_CDROM_NET} netkeys" | 31 | kcmdline_NET="${kcmdline_CDROM_NET} netkeys" |
32 | 32 | ||
33 | MAC='52-54-00-12-34-56' | 33 | MAC='52-54-00-12-34-56' |