| 1 | #!/bin/shscip-shell filesystem . . `/bin/sh`. |
| 2 | |
| 3 | set -e |
| 4 | |
| 5 | PREREQ="cryptroot" |
| 6 | |
| 7 | prereqsscip-shell shell shell-project 0.0.0 prereqs().() |
| 8 | { |
| 9 | echoscip-shell system . . echo. "$PREREQ" |
| 10 | } |
| 11 | |
| 12 | case "$1" in |
| 13 | prereqs) |
| 14 | prereqsscip-shell shell shell-project 0.0.0 prereqs(). |
| 15 | exit 0 |
| 16 | ;; |
| 17 | esac |
| 18 | |
| 19 | . /usr/share/initramfs-tools/hook-functionsscip-shell source . . `/usr/share/initramfs-tools/hook-functions`. |
| 20 | . /lib/cryptsetup/functionsscip-shell source . . `/lib/cryptsetup/functions`. |
| 21 | |
| 22 | if [scip-shell system . . `[`. ! -x "$DESTDIR/lib/cryptsetup/scripts/decrypt_opensc" ] || [scip-shell system . . `[`. ! -f "$TABFILE" ]; then |
| 23 | exit 0 |
| 24 | fi |
| 25 | |
| 26 | # Hooks for loading smartcard reading software into the initramfs |
| 27 | copy_keysscip-shell shell shell-project 0.0.0 copy_keys().() { |
| 28 | crypttab_parse_options |
| 29 | if [scip-shell system . . `[`. "${CRYPTTAB_OPTION_keyscript-}" = "/lib/cryptsetup/scripts/decrypt_openscscip-shell filesystem . . `/lib/cryptsetup/scripts/decrypt_opensc`." ]; then |
| 30 | if [scip-shell system . . `[`. -f "$CRYPTTAB_KEY" ]; then |
| 31 | [scip-shell system . . `[`. -f "$DESTDIR$CRYPTTAB_KEY" ] || copy_file keyfile "$CRYPTTAB_KEY" || RV=$? |
| 32 | else |
| 33 | cryptsetup_message "ERROR: Target $CRYPTTAB_NAME has a non-existing key file $CRYPTTAB_KEY" |
| 34 | RV=1 |
| 35 | fi |
| 36 | fi |
| 37 | } |
| 38 | |
| 39 | RV=0 |
| 40 | crypttab_foreach_entry copy_keys |
| 41 | |
| 42 | # Install directories needed by smartcard reading daemon, command, and |
| 43 | # key-script |
| 44 | mkdirscip-shell system . . mkdir. -p -- "$DESTDIR/etc/opensc" "$DESTDIR/usr/lib/pcsc" "$DESTDIR/var/run" "$DESTDIR/tmp" |
| 45 | |
| 46 | # Install pcscd daemon, drivers, conf file |
| 47 | copy_exec /usr/sbin/pcscdscip-shell filesystem . . `/usr/sbin/pcscd`. |
| 48 | |
| 49 | cpscip-shell system . . cp. -rt "$DESTDIR/usr/lib" /usr/lib/pcscscip-shell filesystem . . `/usr/lib/pcsc`. |
| 50 | cpscip-shell system . . cp. -t "$DESTDIR/etc" /etc/reader.confscip-shell filesystem . . `/etc/reader.conf`. || truescip-shell system . . true. |
| 51 | cpscip-shell system . . cp. -t "$DESTDIR/etc" /etc/libccid_Info.plistscip-shell filesystem . . `/etc/libccid_Info.plist`. |
| 52 | |
| 53 | for so in $(ldconfigscip-shell system . . ldconfig. -p | sedscip-shell system . . sed. -nr 's/^\s*(libusb-[0-9.-]+|libpcsclite)\.so\.[0-9]+\s.*=>\s*//p'); do |
| 54 | copy_exec "$so" |
| 55 | done |
| 56 | |
| 57 | # Install opensc commands and conf file |
| 58 | copy_exec /usr/bin/opensc-toolscip-shell filesystem . . `/usr/bin/opensc-tool`. |
| 59 | copy_exec /usr/bin/pkcs15-cryptscip-shell filesystem . . `/usr/bin/pkcs15-crypt`. |
| 60 | cpscip-shell system . . cp. -t "$DESTDIR/etc/opensc" /etc/opensc/opensc.confscip-shell filesystem . . `/etc/opensc/opensc.conf`. |
| 61 | |
| 62 | exit $RV |