#! /bin/sh

# Author: Alok Kumar <alok@cumulusnetworks.com>

PATH=/bin:/usr/bin:/sbin:/usr/sbin:/usr/cumulus/bin

case "$1" in
  start)
        ipmitool raw 0x34 0x60
        sleep 1 # this is needed for the above command to complete
        if ipmitool raw 0x34 0x63 | grep -q '01'; then
            echo "Disabled BMC control over SMBUS"
        else
            echo "Error: Failed to Disable BMC control over SMBUS"
        fi
	;;
  stop)
       ipmitool raw 0x34 0x61
       echo "Enabled BMC control over SMBUS"
    ;;
  *)
	;;
esac

exit 0 # no errors if ls finds nothing for start or stop, or if scripts fail.
