#!/bin/sh
args="$#"
if [ $args -ne  1  ]
then
        echo "Usage /opt/egurkha/bin/auto_restart [ install | uninstall ] "
        return
fi

install_mode=$1
if [  $install_mode = "install"  -o    $install_mode = "uninstall" ] 
then
	echo ""
else

	echo "Usage /opt/egurkha/bin/auto_restart [ install | uninstall ] "
	return 
fi
userName=`/usr/bin/whoami`
if [ ! $userName = "root"  ]
then
	echo "Current user '$userName' does not have permission to execute this script"
	echo "Only super user can execute this script .!"
	return
fi

if [ $install_mode = "install"  ] 
then
	cp /opt/egurkha/bin/rc.egurkha /etc/ 
	chmod 755 /etc/rc.egurkha
	mkitab egurkha:2:once:/etc/rc.egurkha 
        echo "Successfully installed the auto-restart feature for the eG agent "
	return
else
	rmitab egurkha
	rm /etc/rc.egurkha
        echo "Successfully uninstalled the auto-restart feature for the eG agent "
fi
