Skip to content

Commit

Permalink
Merge pull request #974 from oalbrigt/systemd-deps-target
Browse files Browse the repository at this point in the history
systemd: add resource-agents-deps target
  • Loading branch information
oalbrigt committed Jun 13, 2017
2 parents c5715c9 + 89af981 commit a56c89a
Show file tree
Hide file tree
Showing 8 changed files with 59 additions and 1 deletion.
2 changes: 1 addition & 1 deletion Makefile.am
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions configure.ac
Expand Up @@ -864,6 +864,7 @@ heartbeat/Makefile \
heartbeat/ocf-directories \
heartbeat/ocf-shellfuncs \
heartbeat/shellfuncs \
systemd/Makefile \
tools/Makefile \
tools/ocf-tester \
tools/ocft/Makefile \
Expand Down
6 changes: 6 additions & 0 deletions heartbeat/LVM
Expand Up @@ -416,6 +416,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
Expand Down
6 changes: 6 additions & 0 deletions heartbeat/clvm
Expand Up @@ -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"
Expand Down
16 changes: 16 additions & 0 deletions heartbeat/ocf-shellfuncs.in
Expand Up @@ -606,6 +606,22 @@ dirname()
return 0
}

# usage: systemd_drop_in <name> <After|Before> <dependency.service>
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" <<EOF
[Unit]
$2=$3
EOF
systemctl daemon-reload
}

#
# pseudo_resource status tracking function...
#
Expand Down
4 changes: 4 additions & 0 deletions resource-agents.spec.in
Expand Up @@ -253,6 +253,10 @@ rm -rf %{buildroot}
/usr/lib/ocf/resource.d/redhat
%endif

%if %{defined _unitdir}
%{_unitdir}/resource-agents-deps.target
%endif

%dir %{_datadir}/%{name}
%dir %{_datadir}/%{name}/ocft
%{_datadir}/%{name}/ocft/configs
Expand Down
23 changes: 23 additions & 0 deletions systemd/Makefile.am
@@ -0,0 +1,23 @@
#
# Copyright (C) 2017 Oyvind Albrigtsen
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#

MAINTAINERCLEANFILES = Makefile.in

if HAVE_SYSTEMD
dist_systemdsystemunit_DATA = resource-agents-deps.target
endif
2 changes: 2 additions & 0 deletions systemd/resource-agents-deps.target
@@ -0,0 +1,2 @@
[Unit]
Description=resource-agents dependencies

0 comments on commit a56c89a

Please sign in to comment.