#! /sbin/sh
#Tag 0x00000f00

# SN Partition Config Daemon - mkpd
# "$Revision: 1.5 $"

IS_ON=/sbin/chkconfig
MKPD=/usr/sbin/mkpd

case "$1" in
'start')

    #  (Re)start the partition config daemon.
    #
    #  The following check skips mkpd if running on an Origin200. (for now)

    if [ `ls -d /hw/module/*/slot/MotherBoard 2>/dev/null | wc -l` = 0 ]
    then
	killall -k 3 mkpd

	if $IS_ON mkpd && test -x $MKPD; then
	    if $IS_ON verbose; then
		    echo "Partition Config daemons : mkpd."
	    fi

	    killall mkpd

            MFLAGS=""

	    /sbin/suattr -C CAP_SCHED_MGT,CAP_DEVICE_MGT+ip -c "${MKPD} ${MFLAGS}" 2> /dev/null &
	    sleep 1; echo "\r\c"
	fi
    fi

    exit 0

    ;;

'stop')
    # Stop the partition config daemon
    killall 15 mkpd

    exit 0
    ;;

*)
    echo "usage: $0 {start|stop}"
    ;;

esac
