#!/bin/sh
################################################################################
# Name: /IBM/bin/lcmaSNMP
# Purpose: script to initiate the lcma utility through SNMP, including the
#          ability to NFS mount the server to access the IDF/SDF
# Syntax: receives the value of the tc-mib, tclcma oid. The syntax of tclcma is;
#          [file://<serverIP>:/<serverMountPoint> ]<lcma parameters>
# NFS Example: file://9.5.31.99:/nstation/linux -s /IBM/idf/my.idf -c /my.idf
# FTP Example: -C -s ftp://mary:secret@serverName:1234/IBM/idf/my.sdf  	
# See lcma documentation for more about lcma parameters
################################################################################

LCMACMD=/IBM/bin/lcmaStart

NFSNEEDED=`echo $1 | cut -c1-7`
if [ $NFSNEEDED = "file://" ]
then
	NFS=`echo $1 | cut -c8-`
	mount $NFS /mnt/update
	LCMAPARMS=`echo $@ | cut -f2- -d" "`
	$LCMACMD $LCMAPARMS -m /mnt/update
	umount /mnt/update
else
	LCMAPARMS=$@
	$LCMACMD $LCMAPARMS
fi

# echo "$*" > /tmp/snmp/71

# if there is an -x parameter then restart
REBOOT=`echo $@ | sed -n "s/.*\( -x\).*$/\1/p"`
if [ -n "$REBOOT" ]; then
	/IBM/bin/reboot_IBM_NS 5
fi
