[PATCH] Gentoo init script

Steven Walter srwalt2@uky.edu
Fri, 23 Jan 2004 23:33:18 -0500


This is a multi-part message in MIME format.
--------------070200070404070104000205
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 7bit

I wrote a Gentoo init script to start dbus-daemon-1 on my system.  The 
attached patch includes the file, which I named messagebus-gentoo.in, as 
well as some mucking with the (appropriate?) autoconf stuff.  I can only 
vouch that the script itself works; the automake stuff is a completely 
black art to me.

Hopefully you and others will find this script useful.  If anyone thinks 
they can enlighten me on autconf, please do, or if they'd like to fix it 
up, more power to them.

-- 
--Steven
"I'd never ask you to trust me.  It's the cry of a guilty soul."
		-Dagny Taggart, "Atlas Shrugged"


--------------070200070404070104000205
Content-Type: text/x-patch;
 name="dbus-gentoo.diff"
Content-Transfer-Encoding: 7bit
Content-Disposition: inline;
 filename="dbus-gentoo.diff"

diff -Nru dbus-0.20/bus/Makefile.am dbus-new/bus/Makefile.am
--- dbus-0.20/bus/Makefile.am	2003-10-12 17:31:13.000000000 -0400
+++ dbus-new/bus/Makefile.am	2004-01-23 21:33:54.085022616 -0500
@@ -93,19 +93,32 @@
 	$(mkinstalldirs) $(DESTDIR)/$(libdir)/dbus-1.0/services
 
 #### Init scripts fun
-SCRIPT_IN_FILES=messagebus.in
 
 ## Red Hat start
 if DBUS_INIT_SCRIPTS_RED_HAT
 
+SCRIPT_IN_FILES=messagebus-redhat.in
+
 initddir=$(sysconfdir)/rc.d/init.d
 
 initd_SCRIPTS= 	\
-	messagebus
+	messagebus-redhat
 
 endif
  ## Red Hat end
 
+# Gentoo start
+if DBUS_INIT_SCRIPTS_GENTOO
+
+SCRIPT_IN_FILES=messagebus-gentoo.in
+
+initddir=/etc/init.d
+
+initd_SCRIPTS= messagebus-gentoo
+
+endif
+#Gentoo end
+
 MAN_IN_FILES=dbus-daemon-1.1.in
 man_MANS = dbus-daemon-1.1
 
diff -Nru dbus-0.20/bus/messagebus-gentoo.in dbus-new/bus/messagebus-gentoo.in
--- dbus-0.20/bus/messagebus-gentoo.in	1969-12-31 19:00:00.000000000 -0500
+++ dbus-new/bus/messagebus-gentoo.in	2004-01-23 21:34:10.309556112 -0500
@@ -0,0 +1,35 @@
+#!/sbin/runscript
+# Gentoo init script for D-Bus
+# Written by Steven Walter <srwalter@yahoo.com>
+# Distributed under the terms of the GNU GPL v2
+
+depend () {
+	need hotplug
+}
+
+checkconfig () {
+	if [ ! -x @EXPANDED_BINDIR@/dbus-daemon-1 ]; then
+		return 1
+    fi
+}
+
+start () {
+	ebegin "Starting messagebus"
+	checkconfig() || eend 1
+	
+	start-stop-daemon --start --quiet --exec /usr/bin/dbus-daemon-1 -- --system
+	RETVAL=$?
+	[ $RETVAL -eq 0 ] && touch @EXPANDED_LOCALSTATEDIR@/lock/subsys/messagebus
+	eend $RETVAL
+}
+
+stop () {
+	ebegin "Stopping messagebus"
+	start-stop-daemon --stop --quiet --pidfile @DBUS_SYSTEM_PIDFILE@ 
+	RETVAL=$?
+	if [ $RETVAL -eq 0 ]; then
+		rm -f @EXPANDED_LOCALSTATEDIR@/lock/subsys/messagebus
+		rm -f @DBUS_SYSTEM_PIDFILE@
+	fi
+	eend $RETVAL
+}
diff -Nru dbus-0.20/bus/messagebus.in dbus-new/bus/messagebus.in
--- dbus-0.20/bus/messagebus.in	2003-07-28 10:04:51.000000000 -0400
+++ dbus-new/bus/messagebus.in	1969-12-31 19:00:00.000000000 -0500
@@ -1,78 +0,0 @@
-#!/bin/sh
-#
-# messagebus:   The D-BUS systemwide message bus
-#
-# chkconfig: 345 97 03
-# description:  This is a daemon which broadcasts notifications of system events \
-#               and other messages. See http://www.freedesktop.org/software/dbus/
-#
-# processname: dbus-daemon-1
-# pidfile: @DBUS_SYSTEM_PID_FILE@
-#
-
-# Sanity checks.
-[ -x @EXPANDED_BINDIR@/dbus-daemon-1 ] || exit 0
-
-# Source function library.
-. @EXPANDED_SYSCONFDIR@/rc.d/init.d/functions
-
-# so we can rearrange this easily
-processname=dbus-daemon-1
-servicename=messagebus
-
-RETVAL=0
-
-start() {
-    echo -n $"Starting system message bus: "
-    daemon --check $servicename $processname --system
-    RETVAL=$?
-    echo
-    [ $RETVAL -eq 0 ] && touch @EXPANDED_LOCALSTATEDIR@/lock/subsys/$servicename
-}
-
-stop() {
-    echo -n $"Stopping system message bus: "
-
-    ## we don't want to kill all the per-user $processname, we want
-    ## to use the pid file *only*; because we use the fake nonexistent 
-    ## program name "$servicename" that should be safe-ish
-    killproc $servicename -TERM
-    RETVAL=$?
-    echo
-    if [ $RETVAL -eq 0 ]; then
-        rm -f @EXPANDED_LOCALSTATEDIR@/lock/subsys/$servicename
-        rm -f @DBUS_SYSTEM_PID_FILE@
-    fi
-}
-
-# See how we were called.
-case "$1" in
-    start)
-        start
-        ;;
-    stop)
-        stop
-        ;;
-    status)
-        status $processname
-        RETVAL=$?
-        ;;
-    restart)
-        stop
-        start
-        ;;
-    condrestart)
-        if [ -f @EXPANDED_LOCALSTATEDIR@/lock/subsys/$servicename ]; then
-            stop
-            start
-        fi
-        ;;
-    reload)
-        echo "Message bus can't reload its configuration, you have to restart it"
-        RETVAL=$?
-        ;;
-    *)
-        echo $"Usage: $0 {start|stop|status|restart|condrestart|reload}"
-        ;;
-esac
-exit $RETVAL
diff -Nru dbus-0.20/bus/messagebus-redhat.in dbus-new/bus/messagebus-redhat.in
--- dbus-0.20/bus/messagebus-redhat.in	1969-12-31 19:00:00.000000000 -0500
+++ dbus-new/bus/messagebus-redhat.in	2003-07-28 10:04:51.000000000 -0400
@@ -0,0 +1,78 @@
+#!/bin/sh
+#
+# messagebus:   The D-BUS systemwide message bus
+#
+# chkconfig: 345 97 03
+# description:  This is a daemon which broadcasts notifications of system events \
+#               and other messages. See http://www.freedesktop.org/software/dbus/
+#
+# processname: dbus-daemon-1
+# pidfile: @DBUS_SYSTEM_PID_FILE@
+#
+
+# Sanity checks.
+[ -x @EXPANDED_BINDIR@/dbus-daemon-1 ] || exit 0
+
+# Source function library.
+. @EXPANDED_SYSCONFDIR@/rc.d/init.d/functions
+
+# so we can rearrange this easily
+processname=dbus-daemon-1
+servicename=messagebus
+
+RETVAL=0
+
+start() {
+    echo -n $"Starting system message bus: "
+    daemon --check $servicename $processname --system
+    RETVAL=$?
+    echo
+    [ $RETVAL -eq 0 ] && touch @EXPANDED_LOCALSTATEDIR@/lock/subsys/$servicename
+}
+
+stop() {
+    echo -n $"Stopping system message bus: "
+
+    ## we don't want to kill all the per-user $processname, we want
+    ## to use the pid file *only*; because we use the fake nonexistent 
+    ## program name "$servicename" that should be safe-ish
+    killproc $servicename -TERM
+    RETVAL=$?
+    echo
+    if [ $RETVAL -eq 0 ]; then
+        rm -f @EXPANDED_LOCALSTATEDIR@/lock/subsys/$servicename
+        rm -f @DBUS_SYSTEM_PID_FILE@
+    fi
+}
+
+# See how we were called.
+case "$1" in
+    start)
+        start
+        ;;
+    stop)
+        stop
+        ;;
+    status)
+        status $processname
+        RETVAL=$?
+        ;;
+    restart)
+        stop
+        start
+        ;;
+    condrestart)
+        if [ -f @EXPANDED_LOCALSTATEDIR@/lock/subsys/$servicename ]; then
+            stop
+            start
+        fi
+        ;;
+    reload)
+        echo "Message bus can't reload its configuration, you have to restart it"
+        RETVAL=$?
+        ;;
+    *)
+        echo $"Usage: $0 {start|stop|status|restart|condrestart|reload}"
+        ;;
+esac
+exit $RETVAL
diff -Nru dbus-0.20/configure.in dbus-new/configure.in
--- dbus-0.20/configure.in	2003-11-19 13:41:57.000000000 -0500
+++ dbus-new/configure.in	2004-01-23 23:08:49.269223016 -0500
@@ -804,19 +804,27 @@
 if test -f /etc/redhat-release || test -f $EXPANDED_SYSCONFDIR/redhat-release ; then
    operating_system=redhat
 fi
+if test -f /etc/gentoo-release
+then
+   operating_system=gentoo
+fi
 
 #### Sort out init scripts
 
 if test x$with_init_scripts = x; then
     if test xredhat = x$operating_system ; then
         with_init_scripts=redhat
-    else
+    else if test xgentoo = x$operating_system ; then
+		with_init_scripts=gentoo
+	else
         with_init_scripts=none
     fi
 fi
 
 AM_CONDITIONAL(DBUS_INIT_SCRIPTS_RED_HAT, test x$with_init_scripts = xredhat)
 
+AM_CONDITIONAL(DBUS_INIT_SCRIPTS_GENTOO, test x$with_init_scripts = xgentoo)
+
 
 ##### Set up location for system bus socket
 if ! test -z "$with_system_socket"; then
@@ -932,7 +940,8 @@
 dbus/dbus-arch-deps.h
 bus/system.conf
 bus/session.conf
-bus/messagebus
+bus/messagebus-redhat
+bus/messagebus-gentoo
 bus/dbus-daemon-1.1
 Makefile
 dbus/Makefile

--------------070200070404070104000205--