#!/bin/sh
#
# This script installs a network driver, including the MD5 checksum
#
# $Id: instdrv,v 1.3 2002/12/15 10:50:10 gkminix Exp $
#
#
# Check for install program
#
INSTPROG="${INSTALL-install} -o bin -g bin"
#
# Check all parameters
#
DRVFILE="$1"
INSTDIR="$2"
if [ "x$INSTDIR" = "x" -o "x$DRVFILE" = "x" ]; then
echo "usage: $0 <driver file> <netboot install dir>"
exit 1
fi
if [ ! -r "$DRVFILE" ]; then
echo "$0: file $DRVFILE is not readable"
exit 1
fi
if [ ! -d "$INSTDIR" ]; then
echo "$0: directory $INSTDIR does not exist"
exit 1
fi
#
# Make name of driver absolute
#
case "$DRVFILE" in
/*)
ABSDRVFILE="$DRVFILE"
;;
*)
ABSDRVFILE="$PWD/$DRVFILE"
;;
esac
ABSDRVFILE="`echo "$ABSDRVFILE" | sed 's,/\./,,;s,/[^/]\+/\.\./,/,'`"
#
# Get name of driver subdirectory, name of driver file and check for MD5
# checksum file
#
SUBDIR="`echo "$ABSDRVFILE" | sed 's,^.*netdrvr/\([^/].*\)/.*$,\1,'`"
DRVNAME="`echo "$ABSDRVFILE" | sed 's,^.*/\([^/]\+\.[^/]\+\)$,\1,'`"
#
# Generate at least an empty MD5 checksum database file
#
if [ ! -d $INSTDIR ]; then
echo $INSTPROG -d $INSTDIR
$INSTPROG -d $INSTDIR
fi
if [ ! -d $INSTDIR/netdrvr ]; then
echo $INSTPROG -d $INSTDIR/netdrvr
$INSTPROG -d $INSTDIR/netdrvr
fi
#
# Install network driver into destination directory
#
if [ ! -d "$INSTDIR/netdrvr/$SUBDIR" ]; then
echo $INSTPROG -d $INSTDIR/netdrvr/$SUBDIR
$INSTPROG -d $INSTDIR/netdrvr/$SUBDIR
fi
echo $INSTPROG -m 644 $DRVFILE $INSTDIR/netdrvr/$SUBDIR
$INSTPROG -m 644 $DRVFILE $INSTDIR/netdrvr/$SUBDIR
#
# Install MD5 checksum into checksum database. This involves to first
# remove the old entry from the file, and then to append the new entry
#
exit 0
syntax highlighted by Code2HTML, v. 0.9.1