Skip to content
This repository has been archived by the owner on Aug 25, 2021. It is now read-only.

Add ignition-virtio-dump.service #146

Merged
merged 1 commit into from
Mar 31, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions dracut/99emergency-timeout/ignition-virtio-dump-journal.service
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
[Unit]
Description=Ignition (virtio dump)
Documentation=https://github.com/coreos/ignition
ConditionPathExists=/etc/initrd-release
DefaultDependencies=false
ConditionVirtualization=|kvm
ConditionVirtualization=|qemu
After=basic.target

[Service]
Type=oneshot
RemainAfterExit=yes
EnvironmentFile=/run/ignition.env
ExecStart=/usr/bin/ignition-virtio-dump-journal

11 changes: 11 additions & 0 deletions dracut/99emergency-timeout/ignition-virtio-dump-journal.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#!/bin/bash
set -euo pipefail

port=/dev/virtio-ports/com.coreos.ignition.journal
if [ -e "${port}" ]; then
journalctl -o json > "${port}"
# And this signals end of stream
echo '{}' > "${port}"
else
echo "Didn't find virtio port ${port}"
fi
12 changes: 12 additions & 0 deletions dracut/99emergency-timeout/module-setup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,22 @@
# -*- mode: shell-script; indent-tabs-mode: nil; sh-basic-offset: 4; -*-
# ex: ts=8 sw=4 sts=4 et filetype=sh

install_unit_wants() {
local unit="$1"; shift
local target="$1"; shift
local instantiated="${1:-$unit}"; shift
inst_simple "$moddir/$unit" "$systemdsystemunitdir/$unit"
mkdir -p "$initdir/$systemdsystemunitdir/$target.wants"
ln_r "../$unit" "$systemdsystemunitdir/$target.wants/$instantiated"
}

install() {
inst_multiple \
cut \
date

inst_hook emergency 99 "${moddir}/timeout.sh"

inst_script "$moddir/ignition-virtio-dump-journal.sh" "/usr/bin/ignition-virtio-dump-journal"
install_unit_wants ignition-virtio-dump-journal.service emergency.target
}