diff options
author | Thomas Deutschmann <whissi@gentoo.org> | 2019-08-06 19:45:19 +0200 |
---|---|---|
committer | Thomas Deutschmann <whissi@gentoo.org> | 2019-08-07 17:03:40 +0200 |
commit | e7735c6b2e2cbfb44ce550fa8e7f4359ab5f073c (patch) | |
tree | c37b73084bd7d8ecb70fc7505b44e3959f7604ba /defaults/unlock-luks.sh | |
parent | unlock-luks.sh: Make shellcheck happy (diff) | |
download | genkernel-e7735c6b2e2cbfb44ce550fa8e7f4359ab5f073c.tar.gz genkernel-e7735c6b2e2cbfb44ce550fa8e7f4359ab5f073c.tar.bz2 genkernel-e7735c6b2e2cbfb44ce550fa8e7f4359ab5f073c.zip |
linuxrc: Log initramfs output/commands
By default, any {bad,good,warn}_msg output and external command calls
will now be logged to /tmp/init.log in initramfs. This can be turned
off via gk.log.disabled={1,yes} kernel command-line argument.
This is especially helpful when working with remote servers when you
can access initramfs system through SSH.
In addition, initramfs' log file can be preserved, i.e. copied to
real system just before switch_root call. This can be controlled
via gk.log.keep kernel command-line argument: When just enabled,
initramfs will copy log to $NEWROOT/genkernel-boot.log. Keep in my
that the file path must be accessible for initramfs and by default,
initramfs will only mount / as $NEWROOT and no additional mountpoints.
Signed-off-by: Thomas Deutschmann <whissi@gentoo.org>
Diffstat (limited to 'defaults/unlock-luks.sh')
-rw-r--r-- | defaults/unlock-luks.sh | 18 |
1 files changed, 12 insertions, 6 deletions
diff --git a/defaults/unlock-luks.sh b/defaults/unlock-luks.sh index ebcd2ca5..457aa544 100644 --- a/defaults/unlock-luks.sh +++ b/defaults/unlock-luks.sh @@ -30,6 +30,12 @@ esac . /etc/initrd.scripts . "${CRYPT_ENV_FILE}" +GK_INIT_LOG_PREFIX=${0} +if [ -n "${SSH_CLIENT_IP}" ] && [ -n "${SSH_CLIENT_PORT}" ] +then + GK_INIT_LOG_PREFIX="${0}[${SSH_CLIENT_IP}:${SSH_CLIENT_PORT}]" +fi + main() { if [ ! -x /sbin/cryptsetup ] then @@ -58,7 +64,7 @@ main() { fi setup_md_device "${LUKS_DEVICE}" - if ! cryptsetup isLuks "${LUKS_DEVICE}" + if ! run cryptsetup isLuks "${LUKS_DEVICE}" then bad_msg "The LUKS device ${LUKS_DEVICE} does not contain a LUKS header" "${CRYPT_SILENT}" @@ -84,12 +90,12 @@ main() { crypt_filter_ret=$? [ -e /dev/tty.org ] \ - && rm -f /dev/tty \ - && mv /dev/tty.org /dev/tty + && run rm -f /dev/tty \ + && run mv /dev/tty.org /dev/tty if [ ${crypt_filter_ret} -eq 0 ] then - touch "${OPENED_LOCKFILE}" + run touch "${OPENED_LOCKFILE}" good_msg "LUKS device ${LUKS_DEVICE} opened" "${CRYPT_SILENT}" break else @@ -107,7 +113,7 @@ main() { then if ! is_debug then - rm -f "${LUKS_KEY}" + run rm -f "${LUKS_KEY}" else warn_msg "LUKS key file '${LUKS_KEY}' not deleted because DEBUG mode is enabled!" fi @@ -117,7 +123,7 @@ main() { then # Kill any running cryptsetup prompt for this device. # But SIGINT only to keep shell functional. - pkill -2 -f "luksOpen.*${LUKS_NAME}\$" >/dev/null 2>&1 + run pkill -2 -f "luksOpen.*${LUKS_NAME}\$" >/dev/null 2>&1 fi } |