[BACK]Return to binstall.sh CVS log [TXT][DIR] Up to [local] / sys / arch / sparc / stand / binstall

Annotation of sys/arch/sparc/stand/binstall/binstall.sh, Revision 1.1.1.1

1.1       nbrk        1: #!/bin/sh
                      2: #      $OpenBSD: binstall.sh,v 1.3 1998/02/18 08:17:46 deraadt Exp $
                      3: #      $NetBSD: binstall.sh,v 1.3 1996/04/07 20:00:12 thorpej Exp $
                      4: #
                      5:
                      6: vecho () {
                      7: # echo if VERBOSE on
                      8:        if [ "$VERBOSE" = "1" ]; then
                      9:                echo "$@" 1>&2
                     10:        fi
                     11:        return 0
                     12: }
                     13:
                     14: Usage () {
                     15:        echo "Usage: $0 [-hvt] [-m<path>] net|ffs directory"
                     16:        exit 1
                     17: }
                     18:
                     19: Help () {
                     20:        echo "This script copies the boot programs to one of several"
                     21:        echo "commonly used places. It takes care of stripping the"
                     22:        echo "a.out(5) header off the installed boot program on sun4 machines."
                     23:        echo "When installing an \"ffs\" boot program, this script also runs"
                     24:        echo "installboot(8) which installs the default proto bootblocks into"
                     25:        echo "the appropriate filesystem partition."
                     26:        echo "Options:"
                     27:        echo "  -h              - display this message"
                     28:        echo "  -m<path>        - Look for boot programs in <path> (default: /usr/mdec)"
                     29:        echo "  -v              - verbose mode"
                     30:        echo "  -t              - test mode (implies -v)"
                     31:        exit 0
                     32: }
                     33:
                     34:
                     35: PATH=/bin:/usr/bin:/sbin:/usr/sbin
                     36: MDEC=${MDEC:-/usr/mdec}
                     37:
                     38: set -- `getopt "hm:tv" "$@"`
                     39: if [ $? -gt 0 ]; then
                     40:        Usage
                     41: fi
                     42:
                     43: for a in $*
                     44: do
                     45:        case $1 in
                     46:        -h) Help; shift ;;
                     47:        -m) MDEC=$2; shift 2 ;;
                     48:        -t) TEST=1; VERBOSE=1; shift ;;
                     49:        -v) VERBOSE=1; shift ;;
                     50:        --) shift; break ;;
                     51:        esac
                     52: done
                     53:
                     54: INSTALLBOOT=${INSTALLBOOT:-$MDEC/installboot}
                     55: if [ ! -x $INSTALLBOOT ]; then
                     56:        INSTALLBOOT=/usr/mdec/installboot;
                     57: fi
                     58:
                     59: DOIT=${TEST:+echo "=>"}
                     60:
                     61: if [ $# != 2 ]; then
                     62:        Usage
                     63: fi
                     64:
                     65: WHAT=$1
                     66: DEST=$2
                     67:
                     68: if [ ! -d $DEST ]; then
                     69:        echo "$DEST: not a directory"
                     70:        Usage
                     71: fi
                     72:
                     73:
                     74: SKIP=0
                     75:
                     76: case $WHAT in
                     77: "ffs")
                     78:        DEV=`mount | while read line; do
                     79:                set -- $line
                     80:                vecho "Inspecting \"$line\""
                     81:                if [ "$2" = "on" -a "$3" = "$DEST" ]; then
                     82:                        if [ ! -b $1 ]; then
                     83:                                continue
                     84:                        fi
                     85:                        RAW=\`echo -n "$1" | sed -e 's;/dev/;/dev/r;'\`
                     86:                        if [ ! -c \$RAW ]; then
                     87:                                continue
                     88:                        fi
                     89:                        echo -n $RAW
                     90:                        break;
                     91:                fi
                     92:        done`
                     93:        if [ "$DEV" = "" ]; then
                     94:                echo "Cannot find \"$DEST\" in mount table"
                     95:                exit 1
                     96:        fi
                     97:        TARGET=$DEST/boot
                     98:        DEV=`echo $DEV | sed -e 's/a$/c/'`
                     99:        vecho Boot device: $DEV
                    100:        vecho Target: $TARGET
                    101:        $DOIT dd if=${MDEC}/boot of=$TARGET bs=32 skip=$SKIP
                    102:        sync; sync; sync
                    103:        vecho $INSTALLBOOT ${VERBOSE:+-v} $TARGET ${MDEC}/bootxx $DEV
                    104:        $DOIT $INSTALLBOOT ${VERBOSE:+-v} $TARGET ${MDEC}/bootxx $DEV
                    105:        ;;
                    106:
                    107: "net")
                    108:        TARGET=$DEST/boot.sparc.openbsd
                    109:        TMP=/tmp/boot.$$
                    110:        vecho Target: $TARGET
                    111:        vecho Copying to temporary file.
                    112:        cp ${MDEC}/boot $TMP; chmod +w $TMP
                    113:        vecho Stripping $TMP
                    114:        strip $TMP
                    115:        vecho Creating header magic.
                    116:        printf '\01\03\01\07\060\200\0\07' | dd of=$TARGET bs=32 conv=sync
                    117:        vecho Concatenating boot code.
                    118:        dd if=$TMP of=$TARGET bs=32 skip=1 seek=1
                    119:        rm $TMP
                    120:        ;;
                    121:
                    122: *)
                    123:        echo "$WHAT: not recognised"
                    124:        exit 1
                    125:        ;;
                    126: esac
                    127:
                    128: exit $?

CVSweb