[SCM] Debian packaging of Pinto CPAN distribution branch, master, updated. bbb133af9d4b76b84343ab1100f57d16f4f861ba

Oleg Gashev oleg at gashev.net
Mon Jun 3 20:48:27 UTC 2013


The following commit has been merged in the master branch:
commit bbb133af9d4b76b84343ab1100f57d16f4f861ba
Author: Oleg Gashev <oleg at gashev.net>
Date:   Mon Jun 3 20:48:04 2013 +0000

    Updated init script.

diff --git a/debian/pinto.init b/debian/pinto.init
index 0a79116..a40f3a0 100644
--- a/debian/pinto.init
+++ b/debian/pinto.init
@@ -2,8 +2,8 @@
 
 ### BEGIN INIT INFO
 # Provides:          pintod
-# Required-Start:    $network $syslog
-# Required-Stop:     $network $syslog
+# Required-Start:    $remote_fs $syslog
+# Required-Stop:     $remote_fs $syslog
 # Default-Start:     2 3 4 5
 # Default-Stop:      0 1 6
 # Short-Description: pinto perl module repository
@@ -26,7 +26,17 @@ set -e
 
 . /lib/lsb/init-functions
 
-[ "$PINTOD_OPTS" ] && OPTIONS="$PINTOD_OPTS --pid $PIDFILE"
+OPTIONS="$PINTOD_OPTS --pid $PIDFILE"
+
+check_started () {
+	if [ -f "$PIDFILE" ]; then
+		pid="$(cat $PIDFILE)"
+		if [ "$pid" ] && kill -0 $pid >/dev/null 2>/dev/null; then
+			return 0    # Is started
+		fi
+	fi
+	return 1      # Isn't started
+}
 
 start_if_configured() {
 	if [ $START_PINTOD -ne 1 ]; then
@@ -34,8 +44,7 @@ start_if_configured() {
                 exit 0
 	else
 		log_daemon_msg "Starting $DESC" "$NAME"
-		if ! START_ERROR=`start-stop-daemon --oknodo --chuid pinto -u pinto --start --pidfile $PIDFILE --exec $DAEMON -- $OPTIONS 2>&1`; then
-			# don't fail the upgrade if it fails to start
+		if ! START_ERROR=`start-stop-daemon --chuid pinto -u pinto --start --pidfile $PIDFILE --exec $DAEMON -- $OPTIONS 2>&1`; then
 			echo -n " "
 			log_action_end_msg 1 "$START_ERROR"
 			exit 0
@@ -45,28 +54,52 @@ start_if_configured() {
         fi
 }
 
-case "$1" in
-  start)
-	start_if_configured
-	;;
-  stop)
+stop() {
 	log_daemon_msg "Stopping $DESC" "$NAME"
 	killproc -p $PIDFILE /usr/bin/starman
 	RETVAL=$?
 	[ $RETVAL = 0 ] && rm -f $PIDFILE
 	log_end_msg "$RETVAL"
-	;;
-  restart|reload|force-reload)
-	log_daemon_msg "Stopping $DESC" "$NAME"
-	start-stop-daemon --stop --oknodo --quiet --exec $DAEMON
-	log_end_msg 0
+}
+
+restart() {
+	stop
 	sleep 1
 	start_if_configured
-	;;
-  *)
-        log_warning_msg "Usage: $0 {start|stop|restart|reload|force-reload}" >&2
-	exit 1
-	;;
+}
+
+status() {
+	log_action_begin_msg "checking $DAEMON"
+	if check_started; then
+		log_action_end_msg 0 "running"
+	else
+		if [ -e "$PIDFILE" ]; then
+			log_action_end_msg 1 "$DAEMON failed"
+			exit 1
+		else
+			log_action_end_msg 1 "not running"
+			exit 3
+		fi
+	fi
+}
+
+case "$1" in
+	start)
+		start_if_configured
+		;;
+	stop)
+		stop
+		;;
+	restart|reload|force-reload)
+		restart
+		;;
+	status)
+		status
+		;;
+	*)
+		log_warning_msg "Usage: $0 {start|stop|restart|reload|force-reload|status}" >&2
+		exit 1
+		;;
 esac
 
 exit 0

-- 
Debian packaging of Pinto CPAN distribution



More information about the Pkg-perl-cvs-commits mailing list