#!/bin/bash

### commented out
#read host
#read ip

oid=

while read cmd val
do
  oid="$val"
done

logger -p local5.debug -i -- `basename $0` $oid

### commented out. this replaced by authCommunity execute onapp IP_OF_CP
#IPADDRESS=`echo "$ip" | sed -e 's/^[^0-9]*//; s/\(\([0-9]\{1,3\}\.\)\{3\}[0-9]\{1,3\}\).*/\1/'`
#
#ONAPP_CONF='/etc/onapp.conf'
#
#if [ -e $ONAPP_CONF ]; then
#  source $ONAPP_CONF
#fi
#
#if [ "x$IPADDRESS" != "x$HOST" ]
#then
#  echo 'Hello there!'
#  exit 0
#fi

REBOOT="SNMPv2-SMI::enterprises.40442.100"
LOCK="SNMPv2-SMI::enterprises.40442.110"

case "$oid" in
  "$REBOOT")
    /bin/bash /etc/snmp/reboot.sh
    ;;
  "$LOCK")
    /bin/bash /etc/snmp/makelock.sh
    ;;
esac
