packages: abrt/abrt.init - pldize (checkconfig likely needs to be dropped i...

glen glen at pld-linux.org
Fri Oct 16 10:52:11 CEST 2009


Author: glen                         Date: Fri Oct 16 08:52:11 2009 GMT
Module: packages                      Tag: HEAD
---- Log message:
- pldize (checkconfig likely needs to be dropped if app doesn't support it)

---- Files affected:
packages/abrt:
   abrt.init (1.1 -> 1.2) 

---- Diffs:

================================================================
Index: packages/abrt/abrt.init
diff -u packages/abrt/abrt.init:1.1 packages/abrt/abrt.init:1.2
--- packages/abrt/abrt.init:1.1	Wed Oct 14 22:41:44 2009
+++ packages/abrt/abrt.init	Fri Oct 16 10:52:05 2009
@@ -1,4 +1,4 @@
-#!/bin/bash
+#!/bin/sh
 # Starts the abrt daemon
 #
 # chkconfig: 35 82 16
@@ -17,86 +17,125 @@
 # Source function library.
 . /etc/rc.d/init.d/functions
 
-RETVAL=0
-
-#
-# See how we were called.
-#
+# Get network config
+. /etc/sysconfig/network
 
-check() {
-	# Check that we're a privileged user
-	[ `id -u` = 0 ] || exit 4
+# Get service config - may override defaults
+[ -f /etc/sysconfig/abrtd ] && . /etc/sysconfig/abrtd
 
+# Check that networking is up.
+if is_yes "${NETWORKING}"; then
+	if [ ! -f /var/lock/subsys/network -a "$1" != stop -a "$1" != status ]; then
+		msg_network_down "abrt daemon"
+		exit 1
+	fi
+else
+	exit 0
+fi
+
+# configtest itself
+# must return non-zero if check failed
+# output is discarded if checkconfig is ran without details
+configtest() {
 	# Check if abrt is executable
-	test -x /usr/sbin/abrtd || exit 5
+	test -x /usr/sbin/abrtd || return 5
 }
 
-start() {
-
-	check
-
-	# Check if it is already running
-	if [ ! -f /var/lock/subsys/abrt ]; then
-		echo -n $"Starting abrt daemon: "
-		daemon /usr/sbin/abrtd
+# wrapper for configtest
+checkconfig() {
+	local details=${1:-0}
+
+	if [ $details = 1 ]; then
+		# run config test and display report (status action)
+		show "Checking %s configuration" "abrt daemon"; busy
+		local out
+		out=$(configtest 2>&1)
+		RETVAL=$?
+		if [ $RETVAL = 0 ]; then
+			ok
+		else
+			fail
+		fi
+		[ "$out" ] && echo >&2 "$out"
+	else
+		# run config test and abort with nice message if failed
+		# (for actions checking status before action).
+		configtest >/dev/null 2>&1
 		RETVAL=$?
-		[ $RETVAL -eq 0 ] && touch /var/lock/subsys/abrt
-		echo
+		if [ $RETVAL != 0 ]; then
+			show "Checking %s configuration" "abrt daemon"; fail
+			nls 'Configuration test failed. See details with %s "checkconfig"' $0
+			exit $RETVAL
+		fi
 	fi
-	return $RETVAL
 }
 
-stop() {
-
-	check
+start() {
+	# Check if the service is already running?
+	if [ -f /var/lock/subsys/abrtd ]; then
+		msg_already_running "abrt daemon"
+		return
+	fi
 
-	echo -n $"Stopping abrt daemon: "
-	killproc /usr/sbin/abrtd
+	checkconfig
+	msg_starting "abrt daemon"
+	daemon /usr/sbin/abrtd
 	RETVAL=$?
-	[ $RETVAL -eq 0 ] && rm -f /var/lock/subsys/abrt
-	echo
-	return $RETVAL
+	[ $RETVAL -eq 0 ] && touch /var/lock/subsys/abrtd
+}
+
+stop() {
+	if [ ! -f /var/lock/subsys/abrtd ]; then
+		msg_not_running "abrt daemon"
+		return
+	fi
+
+	# Stop daemons.
+	msg_stopping "abrt daemon"
+	killproc abrtd
+	rm -f /var/lock/subsys/abrtd
 }
 
+condrestart() {
+	if [ ! -f /var/lock/subsys/abrtd ]; then
+		msg_not_running "abrt daemon"
+		RETVAL=$1
+		return
+	fi
 
-restart() {
+	checkconfig
 	stop
 	start
 }
 
-reload() {
-	restart
-}
-
+RETVAL=0
+# See how we were called.
 case "$1" in
-start)
-	start
+  start)
+  	start
 	;;
-stop)
+  stop)
+  	stop
+	;;
+  restart)
+	checkconfig
 	stop
+	start
 	;;
-reload)
-	reload
+  try-restart)
+	condrestart 0
 	;;
-force-reload)
-	echo "$0: Unimplemented feature."
-	RETVAL=3
-	;;
-restart)
-	restart
-	;;
-condrestart)
-	if [ -f /var/lock/subsys/abrt ]; then
-	    restart
-	fi
+  force-reload)
+	condrestart 7
+	;;
+  checkconfig|configtest)
+	checkconfig 1
 	;;
-status)
-	status abrt
+  status)
+	status abrtd
 	RETVAL=$?
 	;;
-*)
-	echo $"Usage: $0 {start|stop|status|restart|condrestart|reload|force-reload}"
-	RETVAL=2
+  *)
+	msg_usage "$0 {start|stop|restart|try-restart|force-reload|checkconfig|status}"
+	exit 3
 esac
-
-exit $RETVAL
================================================================

---- CVS-web:
    http://cvs.pld-linux.org/cgi-bin/cvsweb.cgi/packages/abrt/abrt.init?r1=1.1&r2=1.2&f=u



More information about the pld-cvs-commit mailing list