#!/bin/sh

#
# The script has *no* provision for backing out changes.
#
echo "BayNetworks DM/VM HP Openview install script."

if [ `whoami` != "root" ]; then
	echo "ERROR: $0 must be run as root."
	exit 1
fi

#
# Copy files and bitmaps into OV.
#
cp $DMPATH/hpov/Connector_BayFrameSwitch_* /etc/opt/OV/share/symbols/C/Connector
cp $DMPATH/hpov/bayframeswitch_fields /etc/opt/OV/share/fields/C
cp $DMPATH/hpov/bayframeswitch.reg /etc/opt/OV/share/registration/C
cp $DMPATH/hpov/accelar_connector/* /etc/opt/OV/share/bitmaps/C/connector
cp $DMPATH/hpov/baystack_connector/* /etc/opt/OV/share/bitmaps/C/connector


#
# Copy Accelar MIBs so that they can be found by user when loading.
#
if [ ! -d /var/opt/OV/share/snmp_mibs/Vendor/BayNetworks ]; then
	mkdir /var/opt/OV/share/snmp_mibs/Vendor/BayNetworks
fi

if [ ! -d /var/opt/OV/share/snmp_mibs/Vendor/BayNetworks/Accelar ]; then
        mkdir /var/opt/OV/share/snmp_mibs/Vendor/BayNetworks/Accelar 
fi 

cp $DMPATH/hpov/accelar_mibs/*.mib /var/opt/OV/share/snmp_mibs/Vendor/BayNetworks/Accelar

#
# Copy BayStack MIBs so that they can be found by user when loading.
#
if [ ! -d /var/opt/OV/share/snmp_mibs/Vendor/BayNetworks/BayStack ]; then
        mkdir /var/opt/OV/share/snmp_mibs/Vendor/BayNetworks/BayStack 
fi 

cp $DMPATH/hpov/baystack_mibs/*.mib /var/opt/OV/share/snmp_mibs/Vendor/BayNetworks/BayStack

#
# If we don't see our sysObjectID, then append it to oid_to_sym.
#
if [ `grep -c 1.3.6.1.4.1.2272.2 /etc/opt/OV/share/conf/C/oid_to_sym` = 0 ]; then
	echo "1.3.6.1.4.1.2272.2:Connector:Accelar1100 # Accelar Routing Switch" >> /etc/opt/OV/share/conf/C/oid_to_sym
fi

if [ `grep -c 1.3.6.1.4.1.2272.6 /etc/opt/OV/share/conf/C/oid_to_sym` = 0 ]; then
	echo "1.3.6.1.4.1.2272.6:Connector:Accelar1250 # Accelar Routing Switch" >> /etc/opt/OV/share/conf/C/oid_to_sym
fi

if [ `grep -c 1.3.6.1.4.1.2272.7 /etc/opt/OV/share/conf/C/oid_to_sym` = 0 ]; then
	echo "1.3.6.1.4.1.2272.7:Connector:Accelar1150 # Accelar Routing Switch" >> /etc/opt/OV/share/conf/C/oid_to_sym
fi

if [ `grep -c 1.3.6.1.4.1.2272.8 /etc/opt/OV/share/conf/C/oid_to_sym` = 0 ]; then
	echo "1.3.6.1.4.1.2272.8:Connector:Accelar1200 # Accelar Routing Switch" >> /etc/opt/OV/share/conf/C/oid_to_sym
fi

if [ `grep -c 1.3.6.1.4.1.2272.9 /etc/opt/OV/share/conf/C/oid_to_sym` = 0 ]; then
	echo "1.3.6.1.4.1.2272.9:Connector:Accelar105x # Accelar Routing Switch" >> /etc/opt/OV/share/conf/C/oid_to_sym
fi

if [ `grep -c 1.3.6.1.4.1.45.3.35.1 /etc/opt/OV/share/conf/C/oid_to_sym` = 0 ]; then
	echo "1.3.6.1.4.1.45.3.35.1:Connector:BayStack # BayStack Switch" >> /etc/opt/OV/share/conf/C/oid_to_sym
fi

#
# Merge traps.
#
if [ -d /opt/OV/bin ]
then
        /opt/OV/bin/xnmevents -load $DMPATH/hpov/accelar_trapd.conf
else
        $OV_BIN/xnmevents -load $DMPATH/hpov/accelar_trapd.conf
fi

#
# Prompt user to restart HPOV.
#
echo "Done.  Run:\n1 'ovw -fields' to update fields database\n2 'ovstop netmon' to stop monitoring\n3 'ovtopofix' to recognize bitmaps\n4 'ovstart netmon' to restart monitoring\n5 'ovw' to start OpenView\n6 Load Accelar/450 Mibs (Options->Load Mibs)"

