#!/bin/sh

# This elim is designed for dynamically detecting ncpus and
# do lsadmin reconfig and badmin reconfig if ncpus is changed
# dummy index is used.  

#poll interval in seconds for ncpus
polltime=30
ncpus_prev=`/usr/sbin/psrinfo | grep on-line | wc -l`
host=`hostname`

while [ 1 ]
do
    ncpus=`/usr/sbin/psrinfo | grep on-line | wc -l`
    master=`lsid | grep master | cut -f 5 -d " "`
    if [ $ncpus -ne $ncpus_prev ] ; then
	# spawn another process to do badmin reconfig in 30 seconds
	reconfigbatch &
	
        # do lim reconfig 
        lsadmin limrestart $host $master

	# reset ncpus_prev
	ncpus_prev=`expr $ncpus`
    fi

    # dummy value for dynamic resource dr_restart 
    echo 1 dr_restart 0

    # wait for the next poll
    sleep $polltime 
done

