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(a)redhat.com>
---
kdump-dep-generator.sh | 22 ++++++++++++++++++++++
kexec-tools.spec | 3 +++
2 files changed, 25 insertions(+)
create mode 100644 kdump-dep-generator.sh
diff --git a/kdump-dep-generator.sh b/kdump-dep-generator.sh
new file mode 100644
index 0000000..b6fab2d
--- /dev/null
+++ b/kdump-dep-generator.sh
@@ -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
diff --git a/kexec-tools.spec b/kexec-tools.spec
index cfe14c4..e6ffade 100644
--- a/kexec-tools.spec
+++ b/kexec-tools.spec
@@ -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
--
1.8.5.3