[Pkg-corba-commits] r14 - /trunk/omniorb4/debian/omniorb4-nameserver.init

flub-guest at users.alioth.debian.org flub-guest at users.alioth.debian.org
Sun Sep 30 20:30:02 UTC 2007


Author: flub-guest
Date: Sun Sep 30 20:30:02 2007
New Revision: 14

URL: http://svn.debian.org/wsvn/pkg-corba/?sc=1&rev=14
Log:
* Improve code-reuse.
* Handle failed start when db.bak exists but db.log doesn't.

Modified:
    trunk/omniorb4/debian/omniorb4-nameserver.init

Modified: trunk/omniorb4/debian/omniorb4-nameserver.init
URL: http://svn.debian.org/wsvn/pkg-corba/trunk/omniorb4/debian/omniorb4-nameserver.init?rev=14&op=diff
==============================================================================
--- trunk/omniorb4/debian/omniorb4-nameserver.init (original)
+++ trunk/omniorb4/debian/omniorb4-nameserver.init Sun Sep 30 20:30:02 2007
@@ -1,4 +1,4 @@
-#!/bin/sh -e
+#!/bin/sh
 
 ### BEGIN INIT INFO
 # Provides:          omniNames
@@ -15,54 +15,63 @@
 
 PATH=/sbin:/bin:/usr/sbin:/usr/bin
 DAEMON=/usr/bin/omniNames
-ERRLOG="-errlog /var/log/omniorb4-nameserver"
 NAME=omniNames
 DESC="omniORB name server"
+SCRIPTNAME=/etc/init.d/$NAME
+ERRFILE=/var/log/omniorb4-nameserver
+DBPREFIX=/var/lib/omniorb4-nameserver/omninames-$(uname -n)
+DBFILE=$DBPREFIX.log
+BACKUPDBFILE=$DBPREFIX.bak
+PIDFILE=/var/run/$NAME.pid
 
 test -f $DAEMON || exit 0
 
 . /lib/lsb/init-functions
 
 
+do_start() {
+	startcmd="start-stop-daemon --start --quiet --background --pidfile $PIDFILE --make-pidfile --exec $DAEMON -- -errlog $ERRFILE"
+	if [ -f $DBFILE ]; then
+		$startcmd
+	elif [ -f $BACKUPDBFILE ]; then
+		log_warning_msg "omniNames backup DB found but original missing, using the backup."
+		cp $BACKUPDBFILE $DBFILE
+		$startcmd
+	else
+		$startcmd -start
+	fi
+}
+
+do_stop() {
+	start-stop-daemon --oknodo --stop --quiet \
+	  --pidfile $PIDFILE --exec $DAEMON
+}
+
+
 case "$1" in
   start)
-	log_begin_msg "Starting $DESC"
-	if [ -f /var/lib/omniorb4-nameserver/omninames-`uname -n`.log ] ; then
-		start-stop-daemon --start --quiet --pidfile /var/run/$NAME.pid \
-                  --make-pidfile --background --exec $DAEMON -- $ERRLOG
-	else
-		start-stop-daemon --start --quiet --pidfile /var/run/$NAME.pid \
-                  --make-pidfile --background --exec $DAEMON -- -start $ERRLOG
-	fi
+	log_daemon_msg "Starting $DESC" "omniNames"
+	do_start
 	log_end_msg $?
 	;;
   stop)
-	log_begin_msg "Stopping $DESC"
-	start-stop-daemon --oknodo --stop --quiet --pidfile /var/run/$NAME.pid \
-		--exec $DAEMON
+	log_daemon_msg "Stopping $DESC" "omniNames"
+	do_stop
 	log_end_msg $?
 	;;
   restart|force-reload)
-	log_begin_msg "Restarting $DESC: "
-	start-stop-daemon --stop --quiet --pidfile /var/run/$NAME.pid \
-		--exec $DAEMON
+	log_daemon_msg "Restarting $DESC: " "omniNames"
+	do_stop
 	sleep 1
-	if [ -f /var/lib/omniorb4-nameserver/omninames-`uname -n`.log ] ; then
-		start-stop-daemon --start --quiet --pidfile /var/run/$NAME.pid \
-                  --make-pidfile --background --exec $DAEMON -- $ERRLOG
-	else
-		start-stop-daemon --start --quiet --pidfile /var/run/$NAME.pid \
-                  --make-pidfile --background --exec $DAEMON -- -start $ERRLOG
-	fi
+	do_start
         log_end_msg $?
 	;;
   try-restart|status)
-        log_failure_msg "unimplemented feature"
+        log_failure_msg "Unimplemented feature"
         exit 3
         ;;
   *)
-	N=/etc/init.d/$NAME
-	echo "Usage: $N {start|stop|restart|force-reload}" >&2
+	echo "Usage: $SCRIPTNAME {start|stop|restart|force-reload}" >&2
 	exit 2
 	;;
 esac




More information about the Pkg-corba-commits mailing list