klogd -c1 # TODO: This should be even earlier. Can it go on the kernel command line? mountroot() { openvt -c 13 sh mkfifo "$MENUFIFO" samizdat_install_udev_rules if [ "${nbdroot%%,*}" ]; then (. common.sh sh /scripts/local-top/nbd >/dev/null 2>&1; bootdone nbd-script) & fi if ! cdrom_has_keys && keys_via_network; then bootwait nbd-script wait_for_gnupghome_tar "$tftp_key_server" fi bootwait samizdat-gpg bootmenu bootwait root-mounted chvt 1 } cdrom_has_keys() { [ ! "$BOOTIF" ] || return bootwait samizdat-cdrom [ -d /cdrom/gnupghome ] } # Sets $tftp_key_server or returns false. keys_via_network() { [ "${nbdroot%%,*}" ] || return local arg cmdline read cmdline < /proc/cmdline for arg in $cmdline; do case "$arg" in netkeys) tftp_key_server="${nbdroot%%/*}" return 0 ;; netkeys=*) tftp_key_server="${arg#netkeys=}" return 0 ;; esac done return 1 } wait_for_gnupghome_tar() { local tftp_server="$1" [ -e /gnupghome.tar ] && return echo -n Waiting to receive GPG keys through the network... (while ! tftp -g -r gnupghome.tar -l /gnupghome.tar.$$ "$tftp_server" 2>/dev/null; do sleep 1; echo -n . done mv /gnupghome.tar.$$ /gnupghome.tar) echo ' done.' (. common.sh && . btrfs-create.sh && init_gpg) } samizdat_install_udev_rules() { mkdir -p /etc/udev/rules.d echo 'ACTION=="add", SUBSYSTEM=="block", RUN+="/bin/grok-block $env{DEVNAME}"' \ > /etc/udev/rules.d/z00_blockdev_mountroot.rules # 'udevadm trigger --action=add' does not work here; need to restard udevd # first. not sure why samizdat_restart_udev udevadm trigger -s block --action add } samizdat_restart_udev() { local LOG_DIR=/run/initramfs/samizdat/log mkdir -p "$LOG_DIR" killall systemd-udevd 2>/dev/null /lib/systemd/systemd-udevd --resolve-names=never --debug >$LOG_DIR/udevd-systemd.log 2>&1 & udevadm hwdb --update # rule is not executed by 'udevadm trigger' otherwise. not sure why } # TODO: do not duplicate these functions from common.sh export MENUFIFO=/menu.fifo addmenu() { cat <>$MENUFIFO # mind the tabs setItem "$1" "dummy" "$2" "$3" END } menutitle() { printf 'setTitle "%s"\n' "$1" >>$MENUFIFO printf 'setWelcomeText "%s"\n' "$2" >>$MENUFIFO } bootmenu() { OpenVT -f -c 7 -- dynmenu "$MENUFIFO" && chvt 7 && 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.' # menutitle 'Samizdat\nfreedom from surveillance\nno trusted authorities' 'Choose an installation target.' addmenu "ramdisk" "[ Boot to RAM without installing anything ]" "menu-select boot-ram" } bootwait() { mkdir -p /bootwait local i=$#; while [ $i -gt 0 ]; do i=$((i-1)) local f="$1"; shift; set -- "$@" "/bootwait/$f" done wait_for_files "$@" }