nps: poci/script/poci.init - huge facelift, almost rewritten PLD s...
baggins
baggins at pld-linux.org
Fri Sep 16 18:12:20 CEST 2005
Author: baggins Date: Fri Sep 16 16:12:20 2005 GMT
Module: nps Tag: HEAD
---- Log message:
- huge facelift, almost rewritten PLD style
---- Files affected:
nps/poci/script:
poci.init (1.2 -> 1.3)
---- Diffs:
================================================================
Index: nps/poci/script/poci.init
diff -u nps/poci/script/poci.init:1.2 nps/poci/script/poci.init:1.3
--- nps/poci/script/poci.init:1.2 Thu Sep 15 20:07:24 2005
+++ nps/poci/script/poci.init Fri Sep 16 18:12:12 2005
@@ -1,10 +1,10 @@
#!/bin/sh
#
-# poci Start/Stop the poci daemon
+# poci Start/Stop the Platform Os Command Interface daemon
#
# chkconfig: 2345 55 25
# description: Poci daemon
-# processname: nws_poci
+# processname: nws_poci nws_hb nws_mc
# Source function library
. /etc/rc.d/init.d/functions
@@ -15,107 +15,127 @@
# Get service config
[ -f /etc/sysconfig/poci ] && . /etc/sysconfig/poci
-# 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 poci
- exit 1
- fi
-else
- exit 0
-fi
-
-
KERNEL_VERSION=$(uname -r | sed "s/\([0-9]*\.[0-9]*\)\..*/\1/")
PLATFORM=$(uname -m)
JNET_INSMOD=jnet_prs
-MC_INSMOD=nws_mc
-if [ "$KERNEL_VERSION" = "2.6" ] ; then
- if [ "$PLATFORM" = "x86_64" ] ; then
- MC_INSMOD=""
- fi
+if [ "$KERNEL_VERSION" != "2.6" -o "$PLATFORM" != "x86_64" ] ; then
+ MC_INSMOD=nws_mc
+else
+ MC_INSMOD=""
fi
+prep_start_poci()
+{
+ # let's remove them to stop any kind of confusion...
+ rm -f /dev/jnet /dev/nws_mc >/dev/null 2>&1
+
+ modprobe $JNET_INSMOD >/dev/null 2>&1
+ [ $? -ne 0 ] && return 1
+ mknod /dev/jnet c $(cat /proc/jnet/major) 0 >/dev/null 2>&1
+ [ $? -ne 0 ] && return 1
+
+ if [ -n "$MC_INSMOD" ] ; then
+ modprobe $MC_INSMOD >/dev/null 2>&1
+ [ $? -ne 0 ] && return 1
+ mknod /dev/nws_mc c $(cat /proc/nws_mc/major) 0 >/dev/null 2>&1
+ [ $? -ne 0 ] && return 1
+ fi
+
+ # there is some concern about configuring jnet too fast
+ sleep 1
+ run_cmd -a "$(nls 'Bringing up interface %s' "jnet0")" /sbin/ifup jnet0
+ return $?
+}
+
RETVAL=0
# See how we were called.
case "$1" in
start)
if [ ! -f /var/lock/subsys/poci ]; then
- msg_starting poci
-
- # let's remove them to stop any kind of confusion...
- rm -f /dev/jnet
- rm -f /dev/nws_mc
-
- modprobe $JNET_INSMOD >/dev/null
- if [ $? -ne 0 ] ; then
- echo "failed"
- exit 1
- fi
-
- if [ "$MC_INSMOD"xx != "xx" ] ; then
- modprobe $MC_INSMOD >/dev/null
- if [ $? -ne 0 ] ; then
- echo "failed"
- exit 1
- fi
- maj_num=`cat /proc/nws_mc/major`
- mknod /dev/nws_mc c ${maj_num} 0
- fi
-
- maj_num=`cat /proc/jnet/major`
- mknod /dev/jnet c ${maj_num} 0
-
- # there is some concern about configuring jnet too fast
- sleep 1
- if /sbin/ifup jnet0 ; then
+ prep_start_poci
+ RETVAL=$?
+ if [ "$RETVAL" -eq 0 ] ; then
+ msg_starting "Platform Os Command Interface"
daemon nws_poci
RETVAL=$?
-
+ msg_starting "Platform Side Heart Beat"
daemon nws_hb
+ RETVAL1=$?
+ msg_starting "Platform Side MC Polling"
daemon nws_mc
- else
- echo "failed"
- exit 1
+ RETVAL2=$?
+ if [ $RETVAL -eq 0 -a $RETVAL1 -eq 0 -a $RETVAL2 -eq 0 ]; then
+ touch /var/lock/subsys/poci
+ else
+ if [ $RETVAL2 -ne 0 ]; then
+ msg_stopping "Platform Side MC Polling"
+ killproc nws_mc
+ fi
+ if [ $RETVAL1 -ne 0 ]; then
+ msg_stopping "Platform Side Heart Beat"
+ killproc nws_hb
+ fi
+ if [ $RETVAL -ne 0 ]; then
+ msg_stopping "Platform Os Command Interface"
+ killproc nws_poci
+ fi
+ RETVAL=1
+ fi
fi
- [ $RETVAL -eq 0 ] && touch /var/lock/subsys/poci
else
- msg_already_running poci
+ msg_already_running "Platform Os Command Interface"
fi
;;
stop)
if [ -f /var/lock/subsys/poci ]; then
- msg_stopping poci
-
+ msg_stopping "Platform Os Command Interface"
killproc nws_poci
RETVAL=$?
+ msg_stopping "Platform Side Heart Beat"
killproc nws_hb
+ msg_stopping "Platform Side MC Polling"
killproc nws_mc
sleep 1
- /sbin/ifdown jnet0
-
- if lsmod | grep -q ^nws_mc ; then
- rmmod nws_mc
- fi
- rmmod jnet_prs
+ run_cmd -a "$(nls 'Shutting down interface %s' "jnet0")" /sbin/ifdown jnet0
- rm -f /dev/jnet
- rm -f /dev/nws_mc
+ rmmod nws_mc >/dev/null 2>&1
+ rmmod jnet_prs >/dev/null 2>&1
+ rm -f /dev/jnet /dev/nws_mc >/dev/null 2>&1
- rm -f /var/lock/subsys/poci
+ rm -f /var/lock/subsys/poci >/dev/null 2>&1
else
- msg_not_running poci
+ msg_not_running "Platform Os Command Interface"
fi
;;
+ reload|force-reload)
+ if [ -f /var/lock/subsys/poci ]; then
+ $0 stop
+ sleep 1
+ $0 start
+ RETVAL=$?
+ else
+ msg_not_running "Platform Os Command Interface"
+ fi
restart)
$0 stop
sleep 1
$0 start
+ RETVAL=$?
+ ;;
+ status)
+ status nws_poci
+ RETVAL=$?
+ status nws_hb
+ RETVAL1=$?
+ status nws_mc
+ RETVAL2=$?
+ [ $RETVAL -eq 0 ] && RETVAL=$RETVAL1
+ [ $RETVAL -eq 0 ] && RETVAL=$RETVAL2
;;
*)
- msg_usage "$0 {start|stop|restart}"
+ msg_usage "$0 {start|stop|restart|reload|force-reload|status}"
exit 3
esac
================================================================
---- CVS-web:
http://cvs.pld-linux.org/nps/poci/script/poci.init?r1=1.2&r2=1.3&f=u
More information about the pld-cvs-commit
mailing list