From 89af981050324c3789bd81d9c66f34dd2f36f64a Mon Sep 17 00:00:00 2001 From: Oyvind Albrigtsen Date: Fri, 28 Apr 2017 12:49:55 +0200 Subject: [PATCH] systemd: add resource-agents-deps target --- Makefile.am | 2 +- configure.ac | 1 + heartbeat/LVM | 6 ++++++ heartbeat/clvm | 6 ++++++ heartbeat/ocf-shellfuncs.in | 16 ++++++++++++++++ resource-agents.spec.in | 4 ++++ systemd/Makefile.am | 23 +++++++++++++++++++++++ systemd/resource-agents-deps.target | 2 ++ 8 files changed, 59 insertions(+), 1 deletion(-) create mode 100644 systemd/Makefile.am create mode 100644 systemd/resource-agents-deps.target diff --git a/Makefile.am b/Makefile.am index 1769c6e39a..fccaca4935 100644 --- a/Makefile.am +++ b/Makefile.am @@ -37,7 +37,7 @@ RGMANAGER = with endif if BUILD_LINUX_HA -SUBDIRS += include heartbeat tools ldirectord doc +SUBDIRS += include heartbeat tools ldirectord doc systemd LINUX_HA = without else LINUX_HA = with diff --git a/configure.ac b/configure.ac index 98c58a8955..a050946afc 100644 --- a/configure.ac +++ b/configure.ac @@ -864,6 +864,7 @@ heartbeat/Makefile \ heartbeat/ocf-directories \ heartbeat/ocf-shellfuncs \ heartbeat/shellfuncs \ +systemd/Makefile \ tools/Makefile \ tools/ocf-tester \ tools/ocft/Makefile \ diff --git a/heartbeat/LVM b/heartbeat/LVM index 5b265f58f2..4b9a4e7c4b 100755 --- a/heartbeat/LVM +++ b/heartbeat/LVM @@ -426,6 +426,12 @@ LVM_start() { local vg=$1 local clvmd=0 + # systemd drop-in to stop process before storage services during + # shutdown/reboot + if ps -p 1 | grep -q systemd ; then + systemd_drop_in "99-LVM" "After" "blk-availability.service" + fi + # TODO: This MUST run vgimport as well ocf_log info "Activating volume group $vg" if [ "$LVM_MAJOR" -eq "1" ]; then diff --git a/heartbeat/clvm b/heartbeat/clvm index 8eae6c32cd..43b9302872 100755 --- a/heartbeat/clvm +++ b/heartbeat/clvm @@ -361,6 +361,12 @@ clvmd_start() return $? fi + # systemd drop-in to stop process before storage services during + # shutdown/reboot + if ps -p 1 | grep -q systemd ; then + systemd_drop_in "99-clvmd" "After" "blk-availability.service" + fi + clvmd_status if [ $? -eq $OCF_SUCCESS ]; then ocf_log debug "$DAEMON already started" diff --git a/heartbeat/ocf-shellfuncs.in b/heartbeat/ocf-shellfuncs.in index 87b2adf465..00aca9197f 100644 --- a/heartbeat/ocf-shellfuncs.in +++ b/heartbeat/ocf-shellfuncs.in @@ -606,6 +606,22 @@ dirname() return 0 } +# usage: systemd_drop_in +systemd_drop_in() +{ + if [ $# -ne 3 ]; then + ocf_log err "Incorrect number of arguments [$#] for systemd_drop_in." + fi + + systemdrundir="/run/systemd/system/resource-agents-deps.target.d" + mkdir "$systemdrundir" + cat > "$systemdrundir/$1.conf" <