#!/bin/sh
#
# etc/install-etc 1.18 2001/12/03 03:02:10 (David Hinds)
#
# This handles updating the PCMCIA startup and device configuration
# scripts.  I used to do this in the Makefile, but it is really much
# more of a shell scripty thing.

# Get configuration settings
. ../config.out

if [ $1 ] ; then PREFIX=$1 ; fi
PROBE=../cardmgr/probe
ETC=$PREFIX/etc/pcmcia

install_clients ()
{
    echo "-> Updating client scripts in $ETC"
    mkdir -p $ETC
    CONF=`echo *.conf`
    if [ "$CONF" != "*.conf" ] ; then
	cp *.conf $ETC
    fi
    for f in *.opts ; do
	[ -r $ETC/$f ] || cp $f $ETC/$f
	b=`basename $f .opts`
	cmp -s $b $ETC/$b && continue
	[ -r $ETC/$b ] && mv $ETC/$b $ETC/$b.O
	cp $b $ETC/$b
    done
    for f in shared ; do
	cmp -s $f $ETC/$f && continue
	[ -r $ETC/$f ] && mv $ETC/$f $ETC/$f.O
	cp $f $ETC/$f
    done
}

install_hhl ()
{
	mkdir -p $PREFIX/etc/pcmcia
	CFG=$PREFIX/etc/pcmcia/pcmcia.conf
	if [ -f $CFG ] ; then . $CFG ; fi
	if [ "$PCMCIA" != "yes" ] ; then
	    echo "-> Creating PCMCIA options file $CFG"
	    echo PCMCIA=yes > $CFG
	    PCIC=$MODULE
	    if [ -x $PROBE ] ; then PCIC=`$PROBE -m` ; fi
	    echo "PCIC=i82365" >> $CFG
	    echo "PCIC_OPTS=" >> $CFG
	    echo "CORE_OPTS=" >> $CFG
	    echo "CARDMGR_OPTS=" >> $CFG
	fi
}

install_clients
install_hhl

# Directory to receive cardmgr's 'stab' socket status file
mkdir -p $PREFIX/var/lib/pcmcia
