diff options
author | Thomas Bächler <thomas@archlinux.org> | 2013-09-28 23:35:55 +0200 |
---|---|---|
committer | Thomas Bächler <thomas@archlinux.org> | 2013-12-15 19:14:41 +0100 |
commit | ee04cff9d96761c77826cad41f1f22d08577e8b7 (patch) | |
tree | 2d3dd89224b385c1daf8fd7fd73fe98bfb0a76ba /install/sd-vconsole | |
parent | 7f8b4c38dcdd9ec7b95e10684b5f190a45e46531 (diff) | |
download | mkinitcpio-ee04cff9d96761c77826cad41f1f22d08577e8b7.tar.gz mkinitcpio-ee04cff9d96761c77826cad41f1f22d08577e8b7.tar.xz |
Add sd-vconsole hook.
This hook works together with the systemd hook from the systemd
package and requires the add_systemd_unit function.
It launches systemd-vconsole-setup.service in initramfs
and is especially useful to unlock encrypted volumes in
initramfs.
Diffstat (limited to 'install/sd-vconsole')
-rw-r--r-- | install/sd-vconsole | 68 |
1 files changed, 68 insertions, 0 deletions
diff --git a/install/sd-vconsole b/install/sd-vconsole new file mode 100644 index 0000000..c382991 --- /dev/null +++ b/install/sd-vconsole @@ -0,0 +1,68 @@ +#!/bin/bash + +get_decompressor() { + case "$1" in + *.gz) + cat=zcat + of=${f%.gz} + ;; + *.bz2) + cat=bzcat + of=${f%.bz2} + ;; + *) + cat=cat + of=$f + ;; + esac +} + +add_keymap_file() { + local cat cmd file rest f of + + while read f; do + get_decompressor "$f" + while read -r cmd rest; do + if [[ $cmd == include ]]; then + eval set $rest + add_keymap_file "$1" + fi + done < <($cat "$f") + add_dir "${of%/*}" + $cat "$f" > "$BUILDROOT/$of" + done < <(find /usr/share/kbd/keymaps/ -type f -regex ".*/$1\(\.inc\)?\(\.gz\|\.bz2\)?") +} + +build() { + add_systemd_unit systemd-vconsole-setup.service + add_binary loadkeys + add_binary setfont + add_file /etc/vconsole.conf + + # subshell to avoid namespace pollution + ( + shopt -s nullglob + + [[ -s /etc/vconsole.conf ]] && . /etc/vconsole.conf + + [[ $KEYMAP ]] && add_keymap_file $KEYMAP.map + [[ $KEYMAP_TOGGLE ]] && add_keymap_file $KEYMAP_TOGGLE.map + + if [[ $FONT ]]; then + for file in "/usr/share/kbd/consolefonts/$FONT".@(fnt|psf?(u))?(.gz); do + get_decompressor "$file" + add_dir "${of%/*}" + $cat "$file" > "$BUILDROOT/$of" + done + fi + ) +} + +help() { + cat <<HELPEOF +This hook adds the keymap(s) and font specified in vconsole.conf to the image and +loads them during early userspace. +HELPEOF +} + +# vim: set ft=sh ts=4 sw=4 et: |