From d13155c20c0df9595e33c120a68b3544192d6740 Mon Sep 17 00:00:00 2001 From: Cole Robinson Date: Sat, 20 Oct 2012 22:29:51 -0400 Subject: [PATCH] tools: Only install guests init script if --with-init=script=redhat Most of this deals with moving the libvirt-guests.sh script which does all the work to /usr/libexec, so it can be shared by both systemd and traditional init. Previously systemd depended on the script being in /etc/init.d Required to fix https://bugzilla.redhat.com/show_bug.cgi?id=789747 --- .gitignore | 1 + libvirt.spec.in | 6 ++--- po/POTFILES.in | 2 +- tools/Makefile.am | 18 +++++++++---- tools/libvirt-guests.init.in | 27 +++++++++++++++++++ tools/libvirt-guests.service.in | 4 +-- ...rt-guests.init.sh => libvirt-guests.sh.in} | 24 ----------------- 7 files changed, 47 insertions(+), 35 deletions(-) create mode 100644 tools/libvirt-guests.init.in rename tools/{libvirt-guests.init.sh => libvirt-guests.sh.in} (95%) diff --git a/.gitignore b/.gitignore index 0dadd21a45..ca7d07aa2b 100644 --- a/.gitignore +++ b/.gitignore @@ -179,6 +179,7 @@ /tools/*.[18] /tools/libvirt-guests.init /tools/libvirt-guests.service +/tools/libvirt-guests.sh /tools/virsh /tools/virsh-*-edit.c /tools/virt-*-validate diff --git a/libvirt.spec.in b/libvirt.spec.in index d6e1fbe1aa..d463c2773a 100644 --- a/libvirt.spec.in +++ b/libvirt.spec.in @@ -1409,8 +1409,6 @@ rm -rf $RPM_BUILD_ROOT%{_sysconfdir}/logrotate.d/libvirtd.uml mv $RPM_BUILD_ROOT%{_datadir}/doc/libvirt-%{version} \ $RPM_BUILD_ROOT%{_datadir}/doc/libvirt-docs-%{version} -sed -i -e "s|$RPM_BUILD_ROOT||g" $RPM_BUILD_ROOT%{_sysconfdir}/rc.d/init.d/libvirt-guests - %if %{with_dtrace} %ifarch %{power64} s390x x86_64 ia64 alpha sparc64 mv $RPM_BUILD_ROOT%{_datadir}/systemtap/tapset/libvirt_probes.stp \ @@ -1657,10 +1655,13 @@ fi %dir %attr(0700, root, root) %{_sysconfdir}/libvirt/nwfilter/ +%attr(0755, root, root) %{_libexecdir}/libvirt-guests.sh %if %{with_systemd} %{_unitdir}/libvirtd.service +%{_unitdir}/libvirt-guests.service %else %{_sysconfdir}/rc.d/init.d/libvirtd +%{_sysconfdir}/rc.d/init.d/libvirt-guests %endif %doc daemon/libvirtd.upstart %config(noreplace) %{_sysconfdir}/sysconfig/libvirtd @@ -1925,7 +1926,6 @@ rm -f $RPM_BUILD_ROOT%{_sysconfdir}/sysctl.d/libvirtd %{_datadir}/libvirt/cpu_map.xml -%{_sysconfdir}/rc.d/init.d/libvirt-guests %if %{with_systemd} %{_unitdir}/libvirt-guests.service %endif diff --git a/po/POTFILES.in b/po/POTFILES.in index 51a1f5c31b..a6807502da 100644 --- a/po/POTFILES.in +++ b/po/POTFILES.in @@ -197,7 +197,7 @@ src/xenapi/xenapi_utils.c src/xenxs/xen_sxpr.c src/xenxs/xen_xm.c tools/console.c -tools/libvirt-guests.init.sh +tools/libvirt-guests.sh.in tools/virsh.c tools/virsh-domain-monitor.c tools/virsh-domain.c diff --git a/tools/Makefile.am b/tools/Makefile.am index d646bab4b8..605bf3b1f2 100644 --- a/tools/Makefile.am +++ b/tools/Makefile.am @@ -41,6 +41,7 @@ DISTCLEANFILES = bin_SCRIPTS = virt-xml-validate virt-pki-validate bin_PROGRAMS = virsh virt-host-validate +libexec_SCRIPTS = libvirt-guests.sh if HAVE_SANLOCK sbin_SCRIPTS = virt-sanlock-cleanup @@ -187,7 +188,7 @@ uninstall-sysconfig: rm -f $(DESTDIR)$(sysconfdir)/sysconfig/libvirt-guests rmdir $(DESTDIR)$(sysconfdir)/sysconfig ||: -EXTRA_DIST += libvirt-guests.init.sh +EXTRA_DIST += libvirt-guests.sh.in libvirt-guests.init.in install-initscript: libvirt-guests.init $(MKDIR_P) $(DESTDIR)$(sysconfdir)/rc.d/init.d @@ -208,7 +209,7 @@ install-init: uninstall-init: endif # LIBVIRT_INIT_SCRIPT_RED_HAT -libvirt-guests.init: libvirt-guests.init.sh $(top_builddir)/config.status +libvirt-guests.sh: libvirt-guests.sh.in $(top_builddir)/config.status $(AM_V_GEN)sed \ -e 's!\@PACKAGE\@!$(PACKAGE)!g' \ -e 's!\@bindir\@!$(bindir)!g' \ @@ -219,20 +220,26 @@ libvirt-guests.init: libvirt-guests.init.sh $(top_builddir)/config.status < $< > $@-t && \ chmod a+x $@-t && \ mv $@-t $@ +BUILT_SOURCES += libvirt-guests.sh +libvirt-guests.init: libvirt-guests.init.in libvirt-guests.sh + $(AM_V_GEN)sed \ + -e 's!\@libexecdir\@!$(libexecdir)!g' \ + < $< > $@-t && \ + chmod a+x $@-t && \ + mv $@-t $@ EXTRA_DIST += libvirt-guests.service.in - SYSTEMD_UNIT_DIR = /lib/systemd/system if LIBVIRT_INIT_SCRIPT_SYSTEMD -install-systemd: libvirt-guests.service install-initscript install-sysconfig +install-systemd: libvirt-guests.service install-sysconfig libvirt-guests.sh $(MKDIR_P) $(DESTDIR)$(SYSTEMD_UNIT_DIR) $(INSTALL_DATA) libvirt-guests.service \ $(DESTDIR)$(SYSTEMD_UNIT_DIR)/libvirt-guests.service -uninstall-systemd: uninstall-initscript uninstall-sysconfig +uninstall-systemd: uninstall-sysconfig rm -f $(DESTDIR)$(SYSTEMD_UNIT_DIR)/libvirt-guests.service rmdir $(DESTDIR)$(SYSTEMD_UNIT_DIR) ||: @@ -251,6 +258,7 @@ libvirt-guests.service: libvirt-guests.service.in $(top_builddir)/config.status -e 's!\@localstatedir\@!$(localstatedir)!g' \ -e 's!\@sbindir\@!$(sbindir)!g' \ -e 's!\@sysconfdir\@!$(sysconfdir)!g' \ + -e 's!\@libexecdir\@!$(libexecdir)!g' \ < $< > $@-t && \ chmod a+x $@-t && \ mv $@-t $@ diff --git a/tools/libvirt-guests.init.in b/tools/libvirt-guests.init.in new file mode 100644 index 0000000000..5f9a60e81f --- /dev/null +++ b/tools/libvirt-guests.init.in @@ -0,0 +1,27 @@ +#!/bin/sh + +# the following is the LSB init header +# +### BEGIN INIT INFO +# Provides: libvirt-guests +# Required-Start: libvirtd +# Required-Stop: libvirtd +# Default-Start: 2 3 4 5 +# Default-Stop: 0 1 6 +# Short-Description: suspend/resume libvirt guests on shutdown/boot +# Description: This is a script for suspending active libvirt guests +# on shutdown and resuming them on next boot +# See http://libvirt.org +### END INIT INFO + +# the following is chkconfig init header +# +# libvirt-guests: suspend/resume libvirt guests on shutdown/boot +# +# chkconfig: 345 99 01 +# description: This is a script for suspending active libvirt guests \ +# on shutdown and resuming them on next boot \ +# See http://libvirt.org +# + +exec @libexecdir@/libvirt-guests.sh "$@" diff --git a/tools/libvirt-guests.service.in b/tools/libvirt-guests.service.in index 0f0c41c0bf..d41bf2b1de 100644 --- a/tools/libvirt-guests.service.in +++ b/tools/libvirt-guests.service.in @@ -6,8 +6,8 @@ After=syslog.target network.target EnvironmentFile=-/etc/sysconfig/libvirt-guests # Hack just call traditional service until we factor # out the code -ExecStart=/etc/init.d/libvirt-guests start -ExecStop=/etc/init.d/libvirt-guests stop +ExecStart=@libexecdir@/libvirt-guests.sh start +ExecStop=@libexecdir@/libvirt-guests.sh stop Type=oneshot RemainAfterExit=yes StandardOutput=journal+console diff --git a/tools/libvirt-guests.init.sh b/tools/libvirt-guests.sh.in similarity index 95% rename from tools/libvirt-guests.init.sh rename to tools/libvirt-guests.sh.in index 99ef331247..1c9c46b30c 100644 --- a/tools/libvirt-guests.init.sh +++ b/tools/libvirt-guests.sh.in @@ -1,29 +1,5 @@ #!/bin/sh -# the following is the LSB init header -# -### BEGIN INIT INFO -# Provides: libvirt-guests -# Required-Start: libvirtd -# Required-Stop: libvirtd -# Default-Start: 2 3 4 5 -# Default-Stop: 0 1 6 -# Short-Description: suspend/resume libvirt guests on shutdown/boot -# Description: This is a script for suspending active libvirt guests -# on shutdown and resuming them on next boot -# See http://libvirt.org -### END INIT INFO - -# the following is chkconfig init header -# -# libvirt-guests: suspend/resume libvirt guests on shutdown/boot -# -# chkconfig: 345 99 01 -# description: This is a script for suspending active libvirt guests \ -# on shutdown and resuming them on next boot \ -# See http://libvirt.org -# - sysconfdir="@sysconfdir@" localstatedir="@localstatedir@" libvirtd="@sbindir@"/libvirtd