#!/bin/sh
#
# This hotplug script gets called by udev (xsigo.rules)
#

export PATH=/sbin:/usr/sbin/:/usr/bin:$PATH

if cat /etc/redhat-release |grep "Oracle" > /dev/null
then
	XEN_PLATFORM=oracle
else
        exit 0;
fi

ACTION=add

LOGFILE=/var/log/xsigo-hotplug.log
LCKFILE=/tmp/xsigo-hotplug.lck
IPCONFIG=/sbin/ifconfig



xsvnic=$1



make_if_up()
{
		logger -t xsigo-hotplug "debug:Making interface up: vnic ${xsvnic}"
		${IPCONFIG} "${xsvnic}" up || logger -t xsigo-hotplug "Failed to ip link set ${xsvnic} up"
}


get_vnic_uuid()
{
	#get the vnic uuid
	vnic_uuid=`${XE} pif-list| grep -B 1 -w "device ( RO): ${xsvnic}" | grep uuid | awk ' { print $5 }'`
}

log_print() {
        printf "`date`: $*" >> $LOGFILE
}

#
# Creat log file
#

touch $LOGFILE

exec    8>$LCKFILE

#
# Lock the transaction
# Exit will close the descriptor to release the lock
#

flock -x 8


case "${ACTION}" in
add)
	logger -t xsigo-hotplug "handle xsvnic add"
	make_if_up
	;;

online)
	;;
remove)
	;;
*)
	exit 0
esac
