summaryrefslogtreecommitdiff
path: root/initramfs-tools
diff options
context:
space:
mode:
Diffstat (limited to 'initramfs-tools')
-rw-r--r--initramfs-tools/scripts/samizdat40
1 files changed, 12 insertions, 28 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 @@
1klogd -c1 # TODO: This should be even earlier. Can it go on the kernel command line? 1klogd -c1 # TODO: This should be even earlier. Can it go on the kernel command line?
2 2
3. common.sh
4debug_log samizdat.init
5
3mountroot() 6mountroot()
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.
35keys_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
55wait_for_gnupghome_tar() 39wait_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