Author: glen                         Date: Wed Oct  6 08:05:16 2010 GMT
Module: packages                      Tag: HEAD
---- Log message:
- pldize initscripts

---- Files affected:
packages/mysql-mmm:
   mysql-mmm-agent.init (1.1 -> 1.2) , mysql-mmm-monitor.init (1.1 -> 1.2) , 
mysql-mmm.spec (1.2 -> 1.3) 

---- Diffs:

================================================================
Index: packages/mysql-mmm/mysql-mmm-agent.init
diff -u packages/mysql-mmm/mysql-mmm-agent.init:1.1 
packages/mysql-mmm/mysql-mmm-agent.init:1.2
--- packages/mysql-mmm/mysql-mmm-agent.init:1.1 Wed Oct  6 09:50:34 2010
+++ packages/mysql-mmm/mysql-mmm-agent.init     Wed Oct  6 10:05:08 2010
@@ -3,79 +3,144 @@
 # mysql-mmm-agent    This shell script takes care of starting and stopping
 #                    the mmm agent daemon.
 #
-# chkconfig: - 64 36
-# description:  MMM Agent.
+# chkconfig:   - 64 36
+# description: MMM Agent.
 # processname: mmm_agentd
 # config: /etc/mysql-mmm/mmm_agent.conf
 # pidfile: /var/run/mysql-mmm/mmm_agentd.pid
+#
+# $Id$
 
-# Source function library and defaults file.
+# Source function library
 . /etc/rc.d/init.d/functions
-. /etc/default/mysql-mmm-agent
 
-# Paths
-MMMD_AGENT_BIN="/usr/sbin/mmm_agentd"
-MMMD_AGENT_PIDFILE="/var/run/mysql-mmm/mmm_agentd.pid"
-LOCKFILE='/var/lock/subsys/mysql-mmm-agent'
-prog='MMM Agent Daemon'
+# Get network config
+. /etc/sysconfig/network
 
+# 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 "MMM Agent Daemon"
+               exit 1
+       fi
+else
+       exit 0
+fi
+
+# Set defaults
+ENABLED="no"
+
+# Get service config - may override defaults
+[ -f /etc/sysconfig/mysql-mmm-agent ] && . /etc/sysconfig/mysql-mmm-agent
+
+# configtest itself
+# must return non-zero if check failed
+# output is discarded if checkconfig is ran without details
+configtest() {
+       if ! is_yes "${ENABLED}"; then
+               echo "MMM Agent Daemon is disabled!"
+               return 1
+       fi
+       return 0
+}
+
+# wrapper for configtest
+checkconfig() {
+       local details=${1:-0}
+
+       if [ $details = 1 ]; then
+               # run config test and display report (status action)
+               show "Checking %s configuration" "MMM Agent 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=$?
+               if [ $RETVAL != 0 ]; then
+                       show "Checking %s configuration" "MMM Agent Daemon"; 
fail
+                       nls 'Configuration test failed. See details with %s 
"checkconfig"' $0
+                       exit $RETVAL
+               fi
+       fi
+}
 
 start() {
-        if [ "${ENABLED}" != "1" ]; then
-                echo "$prog is disabled!"
-                exit 1
-        fi
-
-        echo -n "Starting $prog: "
-        if [ -s $MMMD_AGENT_PIDFILE ] && kill -0 `cat $MMMD_AGENT_PIDFILE` 2> 
/dev/null; then
-            echo " already running."
-            exit 0
-        fi
-        daemon $MMMD_AGENT_BIN
-        RETVAL=$?
-        echo
-       [ $RETVAL = 0 ] && touch $LOCKFILE
-        return $RETVAL
+       # Check if the service is already running?
+       if [ -f /var/lock/subsys/mysql-mmm-agent ]; then
+               msg_already_running "MMM Agent Daemon"
+               return
+       fi
+
+       checkconfig
+       msg_starting "MMM Agent Daemon"
+       daemon /usr/sbin/mysql-mmm-agent
+       RETVAL=$?
+       [ $RETVAL -eq 0 ] && touch /var/lock/subsys/mysql-mmm-agent
 }
 
 stop() {
-        # Stop daemon.
-        echo -n "Stopping $prog: "
-        killproc -p $MMMD_AGENT_PIDFILE $MMMD_AGENT_BIN
-        RETVAL=$?
-        echo
-        [ $RETVAL = 0 ] && rm -f $LOCKFILE
-        return $RETVAL
+       if [ ! -f /var/lock/subsys/mysql-mmm-agent ]; then
+               msg_not_running "MMM Agent Daemon"
+               return
+       fi
+
+       # Stop daemons.
+       msg_stopping "MMM Agent Daemon"
+       killproc --pidfile /var/run/mysql-mmm-agent.pid mmm_agentd -TERM
+       rm -f /var/lock/subsys/mysql-mmm-agent
 }
 
+condrestart() {
+       if [ ! -f /var/lock/subsys/mysql-mmm-agent ]; then
+               msg_not_running "MMM Agent Daemon"
+               RETVAL=$1
+               return
+       fi
+
+       checkconfig
+       stop
+       start
+}
+
+RETVAL=0
+# See how we were called.
 case "$1" in
   start)
-        start
-        ;;
-
+       start
+       ;;
   stop)
-        stop
-        ;;
-
+       stop
+       ;;
+  restart)
+       checkconfig
+       stop
+       start
+       ;;
+  try-restart)
+       condrestart 0
+       ;;
+  force-reload)
+       condrestart 7
+       ;;
+  checkconfig|configtest)
+       checkconfig 1
+       ;;
   status)
-        status -p $MMMD_AGENT_PIDFILE $MMMD_AGENT_BIN
-        RETVAL=$?
-        ;;
-
-  restart|reload)
-        stop
-        start
-        ;;
-
-  condrestart)
-        if [ -f $LOCKFILE ]; then
-                stop
-                start
-        fi
-        ;;
+       status --pidfile /var/run/mysql-mmm-agent.pid mysql-mmm-agent mmm_agentd
+       RETVAL=$?
+       ;;
   *)
-        echo "Usage: $0 {start|stop|restart|condrestart|status}"
-        ;;
+       msg_usage "$0 
{start|stop|restart|try-restart|force-reload|checkconfig|status}"
+       exit 3
 esac
 
-exit $RETVAL 
+exit $RETVAL

================================================================
Index: packages/mysql-mmm/mysql-mmm-monitor.init
diff -u packages/mysql-mmm/mysql-mmm-monitor.init:1.1 
packages/mysql-mmm/mysql-mmm-monitor.init:1.2
--- packages/mysql-mmm/mysql-mmm-monitor.init:1.1       Wed Oct  6 09:50:34 2010
+++ packages/mysql-mmm/mysql-mmm-monitor.init   Wed Oct  6 10:05:08 2010
@@ -3,84 +3,146 @@
 # mysql-mmm-monitor  This shell script takes care of starting and stopping
 #                    the mmm monitoring daemon.
 #
-# chkconfig: - 64 36
-# description:  MMM Monitor.
+# chkconfig:   - 64 36
+# description: MMM Monitor.
 # processname: mmm_mond
 # config: /etc/mysql-mmm/mmm_mon.conf
 # pidfile: /var/run/mysql-mmm/mmm_mond.pid
+#
+# $Id$
 
-# Source function library and defaults file.
+# Source function library
 . /etc/rc.d/init.d/functions
-. /etc/default/mysql-mmm-monitor
 
-# Cluster name (it can be empty for default cases)
-CLUSTER=''
-LOCKFILE='/var/lock/subsys/mysql-mmm-monitor'
-prog='MMM Monitor Daemon'
-
-if [ "$CLUSTER" != "" ]; then
-        MMMD_MON_BIN="/usr/sbin/mmm_mond @$CLUSTER"
-        MMMD_MON_PIDFILE="/var/run/mysql-mmm/mmm_mond-$CLUSTER.pid"
-else 
-        MMMD_MON_BIN="/usr/sbin/mmm_mond"
-        MMMD_MON_PIDFILE="/var/run/mysql-mmm/mmm_mond.pid"
+# Get network config
+. /etc/sysconfig/network
+
+# 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 "MMM Monitor Daemon"
+               exit 1
+       fi
+else
+       exit 0
 fi
 
+# Set defaults
+# Cluster name (it can be empty for default cases)
+# FIXME: not implemented properly yet
+CLUSTER=""
+
+# Get service config - may override defaults
+[ -f /etc/sysconfig/mysql-mmm-monitor ] && . /etc/sysconfig/mysql-mmm-monitor
+
+# configtest itself
+# must return non-zero if check failed
+# output is discarded if checkconfig is ran without details
+configtest() {
+       if ! is_yes "${ENABLED}"; then
+               echo "MMM Monitor Daemon is disabled!"
+               return 1
+       fi
+       return 0
+}
+
+# wrapper for configtest
+checkconfig() {
+       local details=${1:-0}
+
+       if [ $details = 1 ]; then
+               # run config test and display report (status action)
+               show "Checking %s configuration" "MMM Monitor 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=$?
+               if [ $RETVAL != 0 ]; then
+                       show "Checking %s configuration" "MMM Monitor Daemon"; 
fail
+                       nls 'Configuration test failed. See details with %s 
"checkconfig"' $0
+                       exit $RETVAL
+               fi
+       fi
+}
+
 start() {
-        if [ "${ENABLED}" != "1" ]; then
-                echo "$prog is disabled!"
-                exit 1
-        fi
-        echo -n "Starting $prog: "
-        if [ -s $MMMD_MON_PIDFILE ] && kill -0 `cat $MMMD_MON_PIDFILE` 2> 
/dev/null; then
-            echo " already running."
-            exit 0
-        fi
-        daemon $MMMD_MON_BIN
-        RETVAL=$?
-        echo
-        [ $RETVAL = 0 ] && touch $LOCKFILE
-        return $RETVAL
+       # Check if the service is already running?
+       if [ -f /var/lock/subsys/mysql-mmm-monitor ]; then
+               msg_already_running "MMM Monitor Daemon"
+               return
+       fi
+
+       checkconfig
+       msg_starting "MMM Monitor Daemon"
+       daemon /usr/sbin/mmm_mond
+       RETVAL=$?
+       [ $RETVAL -eq 0 ] && touch /var/lock/subsys/mysql-mmm-monitor
 }
 
 stop() {
-        # Stop daemon.
-        echo -n "Stopping $prog: "
-        killproc -p $MMMD_MON_PIDFILE $MMMD_MON_BIN
-        RETVAL=$?
-        echo
-        [ $RETVAL = 0 ] && rm -f $LOCKFILE
-        return $RETVAL
+       if [ ! -f /var/lock/subsys/mysql-mmm-monitor ]; then
+               msg_not_running "MMM Monitor Daemon"
+               return
+       fi
+
+       # Stop daemons.
+       msg_stopping "MMM Monitor Daemon"
+       killproc --pidfile /var/run/mysql-mmm-monitor.pid mmm_mond -TERM
+       rm -f /var/lock/subsys/mysql-mmm-monitor
+}
+
+condrestart() {
+       if [ ! -f /var/lock/subsys/mysql-mmm-monitor ]; then
+               msg_not_running "MMM Monitor Daemon"
+               RETVAL=$1
+               return
+       fi
+
+       checkconfig
+       stop
+       start
 }
 
+RETVAL=0
+# See how we were called.
 case "$1" in
   start)
-        start
-        ;;
-
+       start
+       ;;
   stop)
-        stop
-        ;;
-
+       stop
+       ;;
+  restart)
+       checkconfig
+       stop
+       start
+       ;;
+  try-restart)
+       condrestart 0
+       ;;
+  force-reload)
+       condrestart 7
+       ;;
+  checkconfig|configtest)
+       checkconfig 1
+       ;;
   status)
-        status -p $MMMD_MON_PIDFILE $MMMD_MON_BIN
-        RETVAL=$?
-        ;;
-
-  restart|reload)
-        stop
-        start
-        ;;
-
-  condrestart)
-        if [ -f $LOCKFILE ]; then
-                stop
-                start
-        fi
-        ;;
+       status --pidfile /var/run/mysql-mmm-monitor.pid mysql-mmm-monitor 
mmm_mond
+       RETVAL=$?
+       ;;
   *)
-        echo "Usage: $0 {start|stop|restart|condrestart|status}"
-        ;;
+       msg_usage "$0 
{start|stop|restart|try-restart|force-reload|checkconfig|status}"
+       exit 3
 esac
 
-exit $RETVAL 
+exit $RETVAL

================================================================
Index: packages/mysql-mmm/mysql-mmm.spec
diff -u packages/mysql-mmm/mysql-mmm.spec:1.2 
packages/mysql-mmm/mysql-mmm.spec:1.3
--- packages/mysql-mmm/mysql-mmm.spec:1.2       Wed Oct  6 09:50:34 2010
+++ packages/mysql-mmm/mysql-mmm.spec   Wed Oct  6 10:05:08 2010
@@ -1,4 +1,6 @@
 # $Revision$, $Date$
+# TODO
+# - implement clusters in pld way
 Summary:       Multi-Master Replication Manager for MySQL
 Name:          mysql-mmm
 Version:       2.2.1
@@ -131,7 +133,7 @@
        /sbin/chkconfig --add mysql-mmm-agent
        /sbin/chkconfig mysql-mmm-agent off
 elif [ "$1" -ge 2 ]; then
-       %service mysql-mmm-agent condrestart
+       %service mysql-mmm-agent try-restart
 fi
 
 %post monitor
@@ -139,7 +141,7 @@
        /sbin/chkconfig --add mysql-mmm-monitor
        /sbin/chkconfig mysql-mmm-monitor off
 elif [ "$1" -ge 2 ]; then
-       %service mysql-mmm-monitor condrestart
+       %service mysql-mmm-monitor try-restart
 fi
 
 %preun agent
@@ -204,6 +206,9 @@
 All persons listed below can be reached at <cvs_login>@pld-linux.org
 
 $Log$
+Revision 1.3  2010/10/06 08:05:08  glen
+- pldize initscripts
+
 Revision 1.2  2010/10/06 07:50:34  glen
 - re-init package, from fc spec, version 2.2.1
 
================================================================

---- CVS-web:
    
http://cvs.pld-linux.org/cgi-bin/cvsweb.cgi/packages/mysql-mmm/mysql-mmm-agent.init?r1=1.1&r2=1.2&f=u
    
http://cvs.pld-linux.org/cgi-bin/cvsweb.cgi/packages/mysql-mmm/mysql-mmm-monitor.init?r1=1.1&r2=1.2&f=u
    
http://cvs.pld-linux.org/cgi-bin/cvsweb.cgi/packages/mysql-mmm/mysql-mmm.spec?r1=1.2&r2=1.3&f=u

_______________________________________________
pld-cvs-commit mailing list
[email protected]
http://lists.pld-linux.org/mailman/listinfo/pld-cvs-commit

Reply via email to