#!/bin/sh
#
# $Id: isi_configwatch_rc 275358 2012-10-18 22:50:59Z cjohnson $
#

# PROVIDE: isi_configwatch
# REQUIRE: syslogd isi_testjournal ldconfig isi_configure_services isi_pre_network isi_verify_hardware isi_create_lni_xml isi_lcd

. /etc/rc.subr

name="isi_configwatch"
start_cmd="isi_configwatch_start"

isi_configwatch_start()
{
	# Run the config watcher
	/usr/sbin/isi_configwatch
	case $? in 
	    0)
		true   ;;
	    *) 
		echo "Config watch exited with an error."
		echo "Aborting boot."
		/usr/sbin/isi_stop_boot "Config watch exited with an error"
		;;
	esac

	# Reset the terminal to sane defaults
	/usr/bin/tset -Q
	/bin/stty sane

	# Blow away the arp cache.
	/usr/sbin/arp -d -a

	# Terminate any sshd which might be running
	# (isi_testjournal may start sshd)
	if [ -e /var/run/sshd.pid ]; then
		/usr/bin/killall sshd > /dev/null 2>&1
	fi

	# The following killall stops connections that may be 
	# using pre-configuration IP address.
	if [ -e /var/run/inetd.pid ]; then
		/usr/bin/killall inetd > /dev/null 2>&1
	fi

	# Kill any telnet services.
	/usr/bin/killall telnetd > /dev/null 2>&1

	# Tell the SAS PHY Monitor to re-check the configuration
	# state of the node to possibly re-enable the sending of
	# alerts.
	if [ -e /var/run/isi_sasphymon.pid ]; then
		/bin/kill -USR1 `cat /var/run/isi_sasphymon.pid` > /dev/null 2>&1
	fi
}

load_rc_config $name
isi_configwatch_start
