#!/bin/sh
# Kiran Kamity, 05/11/2004
# Any Netapp additions to the initial sequence of events that must run on
# the RLM go in this file
# Example: Adding user 'admin', etc...

case "$1" in
	start|"")

		# create NetApp proc fs entries
		insmod /usr/local/module/procfsfile.o

		# install the ECC handler
		insmod /usr/local/module/ecc.o

		# Loading the agent driver module
		insmod /usr/local/module/agentdrv.o
		chmod 666 /dev/agentdrv
		chmod 666 /dev/i2c/0
        
		if [ -f /var/run/InTestFixture ]; then
			# If in DIAG mode
			echo "DIAGS MODE"
			/usr/local/bin/set_debugmode.sh
			/usr/local/bin/diag
		else 
			# If in normal mode
			echo "NORMAL MODE"

                        
			# Older ONTAP version do not always do a CONFIG_START
			# In those cases, we will need to up-convert dns config
			# file.
			/usr/local/bin/rlm_conf.sh dns_config
			
			# Starting the agentd, eventd and seld
			/usr/local/bin/agentd 
			/usr/local/bin/eventd
			/usr/local/bin/seld

			# Starting the pktd_reader and pktd_writer	
			/usr/local/bin/pktd_reader 
			/usr/local/bin/pktd_writer 

			# Starting the selpktd
			/usr/local/bin/selpktd

			# Starting the console logger
			/usr/local/bin/logger
	
			# Starting the orftp daemons
			/usr/local/bin/orftp_sender
			/usr/local/bin/orftp_rcvr
			/usr/local/bin/fud_sp
			
			# Starting the trap daemon
			/usr/local/bin/trapd

			/usr/local/bin/configd

			# Starting the diagd 
			/usr/local/bin/diagd

			# Starting the loopd
			/usr/local/bin/loopd

			# Starting the downbeat
			/usr/local/bin/f2rbeat

			# Starting the upbeat
			/usr/local/bin/r2fbeat

			# Starting the asupd
			/usr/local/bin/asupd
	
			# Starting the collect diagnostics
			/usr/local/bin/coll_diags

                        # Starting RSAD
                        /usr/local/bin/rsad

			# Starting healthd
			/usr/local/bin/healthd

			
			# Enabling root login & priv test for Golden RLM
			# Golden RLM has /mnt/logs/var/RLM_debugmode present
                	if [ -f "/mnt/logs/var/RLM_debugmode" ] ; then
			    sleep 10
                  	    /usr/local/bin/set_debugmode.sh
			fi
			if ! [ -f /mnt/logs/etc/ssh/ssh_host_key ]; then
				touch /mnt/logs/etc/copyStart;
				cp -f /etc/ssh/ssh_host_key /mnt/logs/etc/ssh/ssh_host_key;
				cp -f /etc/ssh/ssh_host_key.pub /mnt/logs/etc/ssh/ssh_host_key.pub;
				cp -f /etc/ssh/ssh_host_dsa_key /mnt/logs/etc/ssh/ssh_host_dsa_key;
				cp -f /etc/ssh/ssh_host_dsa_key.pub /mnt/logs/etc/ssh/ssh_host_dsa_key.pub;
				cp -f /etc/ssh/ssh_host_rsa_key /mnt/logs/etc/ssh/ssh_host_rsa_key;
				cp -f /etc/ssh/ssh_host_rsa_key.pub /mnt/logs/etc/ssh/ssh_host_rsa_key.pub;
				rm -f /mnt/logs/etc/copyStart;
			fi
																							
		fi
		;;
	stop)
            ;;  
        *)
	    echo "Usage: local {start|stop}" >&2
	    exit 1
	    ;; 
esac
