SOURCES: mysqlard.init - use functions, unify

glen glen at pld-linux.org
Wed Oct 4 11:57:40 CEST 2006


Author: glen                         Date: Wed Oct  4 09:57:40 2006 GMT
Module: SOURCES                       Tag: HEAD
---- Log message:
- use functions, unify

---- Files affected:
SOURCES:
   mysqlard.init (1.1 -> 1.2) 

---- Diffs:

================================================================
Index: SOURCES/mysqlard.init
diff -u SOURCES/mysqlard.init:1.1 SOURCES/mysqlard.init:1.2
--- SOURCES/mysqlard.init:1.1	Wed Oct  4 00:31:12 2006
+++ SOURCES/mysqlard.init	Wed Oct  4 11:57:35 2006
@@ -147,52 +147,60 @@
 	chmod 640 ${slavefile} ${queryfile} ${keyfile} ${confile} ${tabfile}
 }
 
-case "$1" in
-	start)
-		if [ ! -f "${confile}" -o ! -f "${tabfile}" -o ! -f "${keyfile}" -o ! -f "${queryfile}" -o ! -f "${slavefile}" ]; then
-			nls "Try \`%s init' before start %s." "$0" "mysqlard"
+start() {
+	if [ ! -f "${confile}" -o ! -f "${tabfile}" -o ! -f "${keyfile}" -o ! -f "${queryfile}" -o ! -f "${slavefile}" ]; then
+		nls "Try \`%s init' before start %s." "$0" "mysqlard"
+	else
+		if [ ! -f /var/lock/subsys/mysqlard ]; then
+			msg_starting mysqlard
+			daemon --user stats \
+				${MYSQLARD} \
+				--step=${step} \
+				--datadir=${datadir} \
+				--user=${MYSQLUSER} $MYSQLHOST \
+				--pidfile=${pidfile} \
+				${slaveopt}
+			RETVAL=$?
+			[ $RETVAL -eq 0 ] && touch /var/lock/subsys/mysqlard
 		else
-			if [ ! -f /var/lock/subsys/mysqlard ]; then
-				msg_starting mysqlard
-				daemon --user stats \
-					${MYSQLARD} \
-					--step=${step} \
-					--datadir=${datadir} \
-					--user=${MYSQLUSER} $MYSQLHOST \
-					--pidfile=${pidfile} \
-					${slaveopt}
-				RETVAL=$?
-				[ $RETVAL -eq 0 ] && touch /var/lock/subsys/mysqlard
-			else
-				msg_already_running mysqlard
-			fi
+			msg_already_running mysqlard
 		fi
+	fi
+}
+
+stop() {
+	if [ -f /var/lock/subsys/mysqlard ]; then
+		msg_stopping mysqlard
+		killproc --pidfile ${pidfile} mysqlard
+		rm -f ${pidfile}
+		rm -f /var/lock/subsys/mysqlard
+	else
+		msg_not_running mysqlard
+	fi
+}
+
+RETVAL=0
+case "$1" in
+start)
+	start
 	;;
-	stop)
-		if [ -f /var/lock/subsys/mysqlard ]; then
-			msg_stopping mysqlard
-			killproc --pidfile ${pidfile} mysqlard
-			rm -f ${pidfile}
-			rm -f /var/lock/subsys/mysqlard
-		else
-			msg_not_running mysqlard
-		fi
+stop)
+	stop
 	;;
-	restart|force-reload)
-		$0 stop
-		$0 start
-		exit $?
+restart|force-reload)
+	stop
+	start
 	;;
-	init)
-		initrrd
+init)
+	initrrd
 	;;
-	status)
-		status mysqlard
-		RETVAL=$?
+status)
+	status mysqlard
+	RETVAL=$?
 	;;
-	*)
-		msg_usage "Usage: $0 {start|stop|restart|force-reload|status|init}"
-		exit 1
+*)
+	msg_usage "Usage: $0 {start|stop|restart|force-reload|status|init}"
+	exit 1
 esac
 
-exit $?
+exit $RETVAL
================================================================

---- CVS-web:
    http://cvs.pld-linux.org/SOURCES/mysqlard.init?r1=1.1&r2=1.2&f=u



More information about the pld-cvs-commit mailing list