Skip to content

Commit

Permalink
CA-184364: Convert snapwatchd init script to systemd unit file
Browse files Browse the repository at this point in the history
Signed-off-by: Chandrika Srinivasan <chandrika.srinivasan@citrix.com>
Reviewed-by: Germano Percossi <germano.percossi@citrix.com>

GitHub: closes #291
  • Loading branch information
chandrikas committed Feb 8, 2016
1 parent 9f64621 commit 2fdd3ed
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 112 deletions.
2 changes: 2 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,8 @@ install: precheck
$(SM_STAGING)/$(INIT_DIR)/updatempppathd
install -m 644 etc/make-dummy-sr.service \
$(SM_STAGING)/$(SYSTEMD_SERVICE_DIR)
install -m 644 snapwatchd/snapwatchd.service \
$(SM_STAGING)/$(SYSTEMD_SERVICE_DIR)
for i in $(UDEV_RULES); do \
install -m 644 udev/$$i.rules \
$(SM_STAGING)$(UDEV_RULES_DIR); done
Expand Down
5 changes: 4 additions & 1 deletion mk/sm.spec.in
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ rm -rf $RPM_BUILD_ROOT
[ ! -x /sbin/chkconfig ] || chkconfig --add sm-multipath
service sm-multipath start
%systemd_post make-dummy-sr.service
%systemd_post snapwatchd.service

[ -f /etc/lvm/lvm.conf.orig ] || cp /etc/lvm/lvm.conf /etc/lvm/lvm.conf.orig || exit $?
[ -d /etc/lvm/master ] || mkdir /etc/lvm/master || exit $?
Expand All @@ -55,6 +56,7 @@ update-alternatives --install /etc/multipath.conf multipath.conf /etc/multipath.
%preun
[ ! -x /sbin/chkconfig ] || chkconfig --del sm-multipath
%systemd_preun make-dummy-sr.service
%systemd_preun snapwatchd.service
#only remove in case of erase (but not at upgrade)
if [ $1 -eq 0 ] ; then
update-alternatives --remove multipath.conf /etc/multipath.xenserver/multipath.conf
Expand All @@ -63,6 +65,7 @@ exit 0

%postun
%systemd_postun make-dummy-sr.service
%systemd_postun_with_restart snapwatchd.service
if [ $1 -eq 0 ]; then
[ ! -d /etc/lvm/master ] || rm -Rf /etc/lvm/master || exit $?
cp -f /etc/lvm/lvm.conf.orig /etc/lvm/lvm.conf || exit $?
Expand All @@ -72,7 +75,6 @@ fi

%files
%defattr(-,root,root,-)
/etc/rc.d/init.d/snapwatchd
/etc/rc.d/init.d/mpathroot
/etc/rc.d/init.d/updatempppathd
/etc/udev/scripts/xs-mpath-scsidev.sh
Expand Down Expand Up @@ -293,6 +295,7 @@ fi
/sbin/mpathutil
/etc/rc.d/init.d/sm-multipath
%{_unitdir}/make-dummy-sr.service
%{_unitdir}/snapwatchd.service
%config /etc/udev/rules.d/40-multipath.rules
%config /etc/udev/rules.d/55-xs-mpath-scsidev.rules
%config /etc/udev/rules.d/58-xapi.rules
Expand Down
7 changes: 4 additions & 3 deletions snapwatchd/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ XS_INCLUDE ?= /usr/include

PREFIX ?= /opt/xensource/sm/snapwatchd
INITDIR ?= /etc/rc.d/init.d
SYSTEMD_SERVICE_DIR ?= /usr/lib/systemd/system
DESTDIR ?=

.PHONY: install
Expand All @@ -11,9 +12,9 @@ install: xslib.py snapwatchd snapdebug.py
chmod +x $(DESTDIR)$(PREFIX)/snapwatchd
chmod +x $(DESTDIR)$(PREFIX)/xslib.py
chmod +x $(DESTDIR)$(PREFIX)/snapdebug.py
mkdir -p $(DESTDIR)$(INITDIR)
cp snapwatchd.init $(DESTDIR)$(INITDIR)/snapwatchd
chmod +x $(DESTDIR)$(INITDIR)/snapwatchd
mkdir -p $(DESTDIR)$(SYSTEMD_SERVICE_DIR)
cp snapwatchd.service $(DESTDIR)$(SYSTEMD_SERVICE_DIR)/.
chmod +x $(DESTDIR)$(SYSTEMD_SERVICE_DIR)/snapwatchd.service

.PHONY: clean
clean:
Expand Down
108 changes: 0 additions & 108 deletions snapwatchd/snapwatchd.init

This file was deleted.

10 changes: 10 additions & 0 deletions snapwatchd/snapwatchd.service
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
[Unit]
Description=Snapshot manager daemon
After=syslog.target network.target

[Service]
Type=simple
ExecStart=/opt/xensource/sm/snapwatchd/snapwatchd -f

[Install]
WantedBy=multi-user.target

0 comments on commit 2fdd3ed

Please sign in to comment.