kdump-dep-generator: Add kdump service dependencies on the fly

kdump-dep-generator is a systemd generator, used to write out kdump
service dependencies.

Currently it's only useful for ssh dump case. And in ssh dump case, it
writes out a dependency which kdump.service "Wants"
network-online.target:

  # ls -l /run/systemd/generator/kdump.service.wants/
  [..] network-online.target -> /usr/lib/systemd/system/network-online.target

So that kdump.service will pull in network-online.target and delayed
start until network-online.target is reached.

In the future, we could use generator to write out kdump.service
dynamically and get rid of the static defined kdump.service at all.

v1->v2:
Vivek: not using hardcoded run time generator path, use what systemd pass in.

Signed-off-by: WANG Chao <chaowang@redhat.com>
Acked-by: Vivek Goyal <vgoyal@redhat.com>
This commit is contained in:
WANG Chao 2014-04-08 17:17:20 +08:00
parent 9546c93e6b
commit ed12e00218
2 changed files with 25 additions and 0 deletions

22
kdump-dep-generator.sh Normal file
View File

@ -0,0 +1,22 @@
#!/bin/sh
# More details about systemd generator:
# http://www.freedesktop.org/wiki/Software/systemd/Generators/
. /usr/lib/kdump/kdump-lib.sh
# If invokded with no arguments for testing purpose, output to /tmp to
# avoid overriding the existing.
dest_dir="/tmp"
if [ -n "$1" ]; then
dest_dir=$1
fi
systemd_dir=/usr/lib/systemd/system
kdump_wants=$dest_dir/kdump.service.wants
if is_ssh_dump_target; then
mkdir -p $kdump_wants
ln -sf $systemd_dir/network-online.target $kdump_wants/
fi

View File

@ -26,6 +26,7 @@ Source18: kdump.sysconfig.s390x
Source19: eppic_030413.tar.gz
Source20: kdump-lib.sh
Source21: kdump-in-cluster-environment.txt
Source22: kdump-dep-generator.sh
#######################################
# These are sources for mkdumpramfs
@ -181,6 +182,7 @@ install -m 644 %{SOURCE14} $RPM_BUILD_ROOT%{_sysconfdir}/udev/rules.d/98-kexec.r
%endif
install -m 644 %{SOURCE15} $RPM_BUILD_ROOT%{_mandir}/man5/kdump.conf.5
install -m 644 %{SOURCE16} $RPM_BUILD_ROOT%{_unitdir}/kdump.service
install -m 755 -D %{SOURCE22} $RPM_BUILD_ROOT%{_prefix}/lib/systemd/system-generators/kdump-dep-generator.sh
mkdir -p $RPM_BUILD_ROOT/usr/sbin
install -m 755 %{SOURCE17} $RPM_BUILD_ROOT/usr/sbin/rhcrashkernel-param
@ -320,6 +322,7 @@ done
%{_mandir}/man8/*
%{_mandir}/man5/*
%{_unitdir}/kdump.service
%{_prefix}/lib/systemd/system-generators/kdump-dep-generator.sh
%doc News
%doc COPYING
%doc TODO