[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

[Libvir] [patch 3/3] Add libvirt_qemud init script



Add a Red Hat style init script, using the service name
libvirt_qemud.

Also add a --with-init-scripts configure argument to
allow us to add other flavour init scripts.

Signed-off-by: Mark McLoughlin <markmc redhat com>

Index: libvirt/qemud/Makefile.am
===================================================================
--- libvirt.orig/qemud/Makefile.am
+++ libvirt/qemud/Makefile.am
@@ -19,3 +19,24 @@ libvirt_qemud_LDFLAGS = $(LIBXML_LIBS) $
 libvirt_qemud_DEPENDENCIES =
 libvirt_qemud_LDADD =
 
+EXTRA_DIST = libvirt_qemud.init.in
+
+if LIBVIRT_INIT_SCRIPTS_RED_HAT
+libvirt_qemud.init: libvirt_qemud.init.in
+	sed						\
+	    -e s!\ localstatedir\@! localstatedir@!	\
+	    -e s!\ sbindir\@! sbindir@!			\
+	    -e s!\ sysconfdir\@! sysconfdir@!		\
+	    < $< > $@
+	chmod a+x libvirt_qemud.init
+
+install-exec-local: libvirt_qemud.init
+	mkdir -p $(DESTDIR)$(sysconfdir)/rc.d/init.d
+	install -m 0755 $(srcdir)/libvirt_qemud.init $(DESTDIR)$(sysconfdir)/rc.d/init.d/libvirt_qemud
+
+uninstall-local:
+	rm -f $(DESTDIR)$(sysconfdir)/rc.d/init.d/libvirt_qemud
+	rmdir $(DESTDIR)$(sysconfdir)/rc.d/init.d || :
+
+CLEANFILES = libvirt_qemud.init
+endif # DBUS_INIT_SCRIPTS_RED_HAT
Index: libvirt/qemud/libvirt_qemud.init.in
===================================================================
--- /dev/null
+++ libvirt/qemud/libvirt_qemud.init.in
@@ -0,0 +1,75 @@
+#!/bin/sh
+
+# libvirt_qemud:   QEMU and virtual network management daemon
+#
+# chkconfig: 345 97 03
+# description:  This is a daemon for managing QEMU guest instances
+#               and libvirt virtual networks
+#               See http://libvirt.org
+#
+# processname: libvirt_qemud
+# pidfile: @localstatedir@/run/libvirt_qemud.pid
+#
+
+# Sanity checks.
+[ -x @sbindir@/libvirt_qemud ] || exit 0
+
+# Source function library.
+. @sysconfdir@/rc.d/init.d/functions
+
+SERVICE=libvirt_qemud
+
+RETVAL=0
+
+start() {
+    echo -n $"Starting $SERVICE daemon: "
+    daemon $SERVICE --system --daemon
+    RETVAL=$?
+    echo
+    [ $RETVAL -eq 0 ] && touch @localstatedir@/lock/subsys/$SERVICE
+}
+
+stop() {
+    echo -n $"Stopping $SERVICE daemon: "
+
+    killproc $SERVICE -TERM
+    RETVAL=$?
+    echo
+    if [ $RETVAL -eq 0 ]; then
+        rm -f @localstatedir@/lock/subsys/$SERVICE
+        rm -f @localstatedir@/run/$SERVICE.pid
+    fi
+}
+
+restart() {
+    stop
+    start
+}
+
+reload() {
+    echo -n $"Reloading $SERVICE configuration: "
+
+    killproc $SERVICE -HUP
+    RETVAL=$?
+    echo
+    return $RETVAL
+}
+
+# See how we were called.
+case "$1" in
+    start|stop|restart|reload)
+        $1
+        ;;
+    status)
+        status $SERVICE
+        RETVAL=$?
+        ;;
+    condrestart)
+        [ -f @localstatedir@/lock/subsys/$SERVICE ] && restart || :
+        ;;
+    *)
+        echo $"Usage: $0 {start|stop|status|restart|condrestart|reload}"
+	exit 1
+        ;;
+esac
+exit $RETVAL
Index: libvirt/configure.in
===================================================================
--- libvirt.orig/configure.in
+++ libvirt/configure.in
@@ -100,6 +100,23 @@ AC_DEFINE_UNQUOTED(QEMUD_PID_FILE, "$QEM
 AC_MSG_RESULT($QEMUD_PID_FILE)
 
 dnl
+dnl init script flavor
+dnl
+AC_MSG_CHECKING([for init script flavor])
+AC_ARG_WITH(init-script,
+            AC_HELP_STRING([--with-init-scripts=[redhat|auto|none]],
+                           [Style of init scripts to install (defaults to auto)]))
+if test "x$with_init_scripts" = "x" -o "x$with_init_scripts" = "xauto"; then
+    if test -f /etc/redhat-release ; then
+        with_init_scripts=redhat
+    else
+        with_init_scripts=none
+    fi
+fi
+AM_CONDITIONAL(LIBVIRT_INIT_SCRIPTS_RED_HAT, test x$with_init_scripts = xredhat)
+AC_MSG_RESULT($with_init_scripts)
+
+dnl
 dnl allow the creation of iptables rules in chains with a
 dnl specific prefix rather than in the standard toplevel chains
 dnl

-- 


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]