| 1 | #!/bin/sh |
| 2 | |
| 3 | prereqs() |
| 4 | { |
| 5 | # cryptroot-unlock needs to be run last among crypt* since other hooks might include askpass |
| 6 | local req script |
| 7 | for req in "${0%/*}"/crypt*; do |
| 8 | script="${req##*/}" |
| 9 | if [ "$script" != "${0##*/}" ]; then |
| 10 | printf '%s\n' "$script" |
| 11 | fi |
| 12 | done |
| 13 | } |
| 14 | |
| 15 | case "$1" in |
| 16 | prereqs) |
| 17 | prereqs |
| 18 | exit 0 |
| 19 | ;; |
| 20 | esac |
| 21 | |
| 22 | if [ ! -f "$DESTDIR/lib/cryptsetup/askpass" ]; then |
| 23 | # cryptroot-unlock is useless without askpass |
| 24 | exit 0 |
| 25 | fi |
| 26 | |
| 27 | . /usr/share/initramfs-tools/hook-functions |
| 28 | if [ ! -f "$DESTDIR/bin/cryptroot-unlock" ] && |
| 29 | ! copy_file script /usr/share/cryptsetup/initramfs/bin/cryptroot-unlock /bin/cryptroot-unlock; then |
| 30 | echo "ERROR: Couldn't copy /bin/cryptroot-unlock" >&2 |
| 31 | exit 1 |
| 32 | fi |
| 33 | |
| 34 | if [ -f /etc/initramfs-tools/etc/motd ]; then |
| 35 | copy_file text /etc/initramfs-tools/etc/motd /etc/motd |
| 36 | else |
| 37 | cat >>"$DESTDIR/etc/motd" <<- EOF |
| 38 | To unlock root partition, and maybe others like swap, run \`cryptroot-unlock\`. |
| 39 | EOF |
| 40 | fi |