/mandos/trunk

To get this branch, use:
bzr branch http://bzr.recompile.se/loggerhead/mandos/trunk
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
#!/bin/sh
#
# This file should be present in the root file system directory
# /usr/lib/dracut/modules.d/90mandos.  When dracut creates the
# initramfs image, dracut will run the "module-setup.sh" file in the
# same directory, which (when using the "systemd" dracut module) will
# copy this file ("cmdline-mandos-systemd.sh") into the initramfs as
# "/lib/dracut/hooks/cmdline/20-cmdline-mandos-systemd.sh".
# 
# Despite the above #!/bin/sh line and the executable flag, this file
# is not executed; this file is sourced by the /init script in the
# initramfs image created by dracut.

type getarg > /dev/null 2>&1 || . /lib/dracut-lib.sh

if getargbool 1 mandos && [ -e /lib/dracut-crypt-lib.sh ]; then
    if mandos=$(getarg mandos); then
	case "$mandos" in
	    connect:*) mandos_connect="${mandos#connect:}" ;;
	esac
	if [ -n "$mandos_connect" ]; then
	    # systemd >= 254
	    # systemctl edit --runtime ask-password-mandos.service --stdin <<-EOF
	    # ...
	    # EOF
	    mkdir --parents /run/systemd/system/ask-password-mandos.service.d
	    cat > /run/systemd/system/ask-password-mandos.service.d/connect.conf <<-EOF
		[Service]
		Environment="MANDOS_CLIENT_CONNECT=--connect=$mandos_connect"
		EOF
	    systemctl daemon-reload
	fi
    fi
fi