summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrew Cady <d@jerkface.net>2019-10-17 00:19:12 -0400
committerAndrew Cady <d@jerkface.net>2019-10-17 00:19:12 -0400
commit10e5efaa69c9f0c254db13a84d3312ebaebde5dc (patch)
tree686255f556f929f802c8c97e6f186332a1b7bc9c
parentec5e8ee55440e1e6fc1affe7c502c9f12ffe78bf (diff)
fixup! avoid initrd race condition
-rw-r--r--initramfs-tools/scripts/samizdat52
-rw-r--r--src/initrd/common.sh15
2 files changed, 16 insertions, 51 deletions
diff --git a/initramfs-tools/scripts/samizdat b/initramfs-tools/scripts/samizdat
index 4658278..85fbc7b 100644
--- a/initramfs-tools/scripts/samizdat
+++ b/initramfs-tools/scripts/samizdat
@@ -1,3 +1,4 @@
1#!/bin/sh
1klogd -c1 # TODO: This should be even earlier. Can it go on the kernel command line? 2klogd -c1 # TODO: This should be even earlier. Can it go on the kernel command line?
2 3
3. common.sh 4. common.sh
@@ -64,21 +65,6 @@ wait_for_gnupghome_tar()
64 (. common.sh && . btrfs-create.sh && init_gpg) 65 (. common.sh && . btrfs-create.sh && init_gpg)
65} 66}
66 67
67samizdat_install_udev_rules()
68{
69 local target=/etc/udev/rules.d/z00_blockdev_mountroot.rules
70 [ -e "$target" ] && return
71 mkdir -p /etc/udev/rules.d
72 echo 'ACTION=="add", SUBSYSTEM=="block", RUN+="/bin/grok-block $env{DEVNAME}"' \
73 > "$target"
74
75 # 'udevadm trigger --action=add' does not work here; need to restard udevd
76 # first. not sure why
77 samizdat_restart_udev
78
79 udevadm trigger -s block --action add
80}
81
82samizdat_restart_udev() 68samizdat_restart_udev()
83{ 69{
84 local LOG_DIR=/run/initramfs/samizdat/log 70 local LOG_DIR=/run/initramfs/samizdat/log
@@ -88,39 +74,3 @@ samizdat_restart_udev()
88 udevadm hwdb --update # rule is not executed by 'udevadm trigger' otherwise. not sure why 74 udevadm hwdb --update # rule is not executed by 'udevadm trigger' otherwise. not sure why
89} 75}
90 76
91
92# TODO: do not duplicate these functions from common.sh
93
94export MENUFIFO=/menu.fifo
95
96addmenu()
97{
98 cat <<END >>$MENUFIFO # mind the tabs
99setItem "$1" "dummy" "$2" "$3"
100END
101}
102
103menutitle()
104{
105 printf 'setTitle "%s"\n' "$1" >>$MENUFIFO
106 printf 'setWelcomeText "%s"\n' "$2" >>$MENUFIFO
107}
108
109bootmenu()
110{
111 OpenVT -f -c 7 -- dynmenu "$MENUFIFO" &&
112 chvt 7 &&
113 menutitle 'Samizdat\n\nAs the Internet develops there are\ntransitions in the management arrangements.\nThe time has come to take\na small step in one of those transitions.' 'Choose an installation target.'
114# menutitle 'Samizdat\nfreedom from surveillance\nno trusted authorities' 'Choose an installation target.'
115 addmenu "ramdisk" "[ Boot to RAM without installing anything ]" "menu-select boot-ram"
116}
117
118bootwait()
119{
120 mkdir -p /bootwait
121 local i=$#; while [ $i -gt 0 ]; do
122 i=$((i-1))
123 local f="$1"; shift; set -- "$@" "/bootwait/$f"
124 done
125 wait_for_files "$@"
126}
diff --git a/src/initrd/common.sh b/src/initrd/common.sh
index c38fb77..17c9359 100644
--- a/src/initrd/common.sh
+++ b/src/initrd/common.sh
@@ -36,6 +36,21 @@ force_grok_block()
36 udevadm trigger --subsystem-match=block --action=add 36 udevadm trigger --subsystem-match=block --action=add
37} 37}
38 38
39samizdat_install_udev_rules()
40{
41 local target=/etc/udev/rules.d/z00_blockdev_mountroot.rules
42 [ -e "$target" ] && return
43 mkdir -p /etc/udev/rules.d
44 echo 'ACTION=="add", SUBSYSTEM=="block", RUN+="/bin/grok-block $env{DEVNAME}"' \
45 > "$target"
46
47 # 'udevadm trigger --action=add' does not work here; need to restard udevd
48 # first. not sure why
49 samizdat_restart_udev
50
51 udevadm trigger -s block --action add
52}
53
39bootmenu() 54bootmenu()
40{ 55{
41 local do_trigger="$1" no_panic="$2" 56 local do_trigger="$1" no_panic="$2"