#! /bin/sh # # fix_bootparams : script written to add/delete a client entries from # /etc/bootparams. # # @(#)fix_bootparams 1.1 88/06/08 4.0NFSSRC; from 1.7 88/03/07 D/NFS # @(#) from fix_bootparams 1.10 88/02/08 # # Copyright (c) 1987 by Sun Microsystems, Inc. # HOME=/; export HOME PATH=/bin:/usr/bin:/etc:/usr/etc:/usr/bsd:/usr/etc/netdisk CMDNAME=$0 BOOTPARAMS="/etc/bootparams" USAGE="usage: ${CMDNAME} op name rootpath swappath dumppath where: op = \"add\" or \"remove\" name = name of the client machine rootpath = pathname of nfsroot (for \"add\") swappath = pathname of nfsswap (for \"add\") dumppath = pathname of nfsdump (for \"add\") or \"none\" " # # Verify number of arguments # if [ $# -lt 2 ]; then echo "${CMDNAME}: incorrect number of arguments." echo "${USAGE}" exit 1 fi # # Assign arguments # SERVER=`hostname` OP=${1}; shift NAME=${1}; shift # # Start updating bootparams # if [ ! -f $BOOTPARAMS ]; then touch $BOOTPARAMS chmod 644 $BOOTPARAMS fi case "$OP" in "add" ) if [ $# -lt 3 ]; then echo "${CMDNAME}: incorrect number of arguments." echo "${USAGE}" exit 1 fi ROOTPATH=${1}; shift SWAPPATH=${1}; shift DUMPPATH=${1} case $DUMPPATH in none) echo "$NAME root=$SERVER:$ROOTPATH/$NAME \\" >> $BOOTPARAMS echo " swap=$SERVER:$SWAPPATH/$NAME" >> $BOOTPARAMS ;; *) echo "$NAME root=$SERVER:$ROOTPATH/$NAME \\" >> $BOOTPARAMS echo " swap=$SERVER:$SWAPPATH/$NAME \\" >> $BOOTPARAMS echo " dump=$SERVER:$DUMPPATH/$NAME" >> $BOOTPARAMS ;; esac break ;; "remove" ) # This section is a little confusing. It seems that ed # will not allow the last line to be deleted from a file with # commands being read from stdin. It is possible that we # will want to do so, so we first add a scratch line at the # beginning of the file. When we are done with ed, we check # to see if only one line remains. If so, the file is truncated. # Otherwise, the first line is removed. # In the commands actually deleting $NAME, we are careful to # check that it is not embedded in another name by checking # the preceeding slash and trailing space, tab, backslash, or newline. # ed - $BOOTPARAMS < $BOOTPARAMS else ed - $BOOTPARAMS <