#! /sbin/sh
# Start or stop an the myrinet network mapper
IS_ON=/etc/chkconfig
if $IS_ON verbose; then
    ECHO=echo
else
    ECHO=:
fi
CONFIG=/etc/config
MYRINET_ROOT=/usr/myricom
export MYRINET_ROOT
MYRINET_MAPPER=${MYRINET_ROOT}/sbin/mapper
MYRINET_LOGS=${MYRINET_ROOT}/var/logs
case "$1" in
   'stop')
      $ECHO killing $MYRINET_MAPPER
      /sbin/killall -TERM $MYRINET_MAPPER
      ;;
   'start')
      if $IS_ON myrinet_mapper; then
         $ECHO "Myrinet Mapper: \c"
         if test -s /etc/config/myrinet_mapper.options; then
            mmopt="`cat /etc/config/myrinet_mapper.options`"
         else
            $ECHO "no options file, /etc/config/myrinet_mapper.options"
         fi
         cd ${MYRINET_LOGS}
         $MYRINET_MAPPER $mmopt > mapper.log 2>&1 &
         $ECHO "mapper."
      else
         $ECHO "myrinet mapper: not chkconfiged."
      fi
      ;;
   'restart')
      /etc/init.d/myrinet stop
      /etc/init.d/myrinet start
      ;;
   *)
      echo "usage: $0 {start|stop|restart}"
      ;;
esac
