#!/bin/sh
# The script has *no* provision for backing out changes.
echo "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/dmdb/rapidcity/OV/Connector_bridge_rc* /etc/opt/OV/share/symbols/C/Connector
cp $DMPATH/dmdb/rapidcity/OV/RapidCity_fields /etc/opt/OV/share/fields/C
cp $DMPATH/dmdb/rapidcity/OV/dm.reg /etc/opt/OV/share/registration/C
cp $DMPATH/dmdb/rapidcity/OV/connector/* /etc/opt/OV/share/bitmaps/C/connector

# Copy mibs so that they can be found by user when loading.
cp $DMPATH/dmdb/rapidcity/OV/mibs/rfc*.mib /var/opt/OV/share/snmp_mibs/Standard
cp $DMPATH/dmdb/rapidcity/OV/mibs/rfc*.trp /var/opt/OV/share/snmp_mibs/Standard
cp $DMPATH/dmdb/rapidcity/OV/mibs/rapid_city.mib /var/opt/OV/share/snmp_mibs/Vendor

# 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:XLR1100 # Rapid-City Routing Switch" >> /etc/opt/OV/share/conf/C/oid_to_sym
	echo "1.3.6.1.4.1.2272.6:Connector:XLR1150 # Rapid-City Routing Switch" >> /etc/opt/OV/share/conf/C/oid_to_sym
	echo "1.3.6.1.4.1.2272.7:Connector:XLR1250 # Rapid-City Routing Switch" >> /etc/opt/OV/share/conf/C/oid_to_sym
	echo "1.3.6.1.4.1.2272.8:Connector:XLR1200 # Rapid-City Routing Switch" >> /etc/opt/OV/share/conf/C/oid_to_sym
fi

# Merge traps.
xnmevents -load $DMPATH/dmdb/rapidcity/OV/trapd.conf

# 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 Rapid-City Mibs (Options->Load Mibs)"
