#!/bin/sh # # Edit a NetInfo (NI) database on a NeXT # # Eric Myers 14 October 1995 # Department of Physics, University of Michigan, Ann Arbor, MI, USA # @(#) $Revision: 1.1 $ - $Date: 1997/10/30 16:01:35 $ #======================================================================* PROG=`basename $0` if [ $# -lt 1 ]; then echo -n "Which database do you wish to edit? " read NAME else NAME=$1 fi shift if [ $# -lt 1 ]; then echo "$PROG: Local Domain assummed..." DOMAIN=. else DOMAIN=$1 fi EDITOR=${EDITOR-"/usr/ucb/vi"} TMP=/tmp/$PROG.$NAME # niedit first makes sure another niedit is not running by looking # for the file $TMP. If it already exists, niedit aborts. if [ -f $TMP ]; then echo "$PROG: another niedit appears to be running ($TMP exists)." exit 1 else touch $TMP fi # get database file from NI nidump $NAME $DOMAIN >$TMP ; RC=$? if [ $RC -ne 0 ]; then echo $PROG: Cannot edit $NAME in domain \"$DOMAIN\". exit 2 fi # edit the file $EDITOR $TMP; RC=$? # if edited okay and new file not empty, then load NI database if [ $RC = 0 -a -s $TMP ]; then niload -v -d $NAME $DOMAIN <$TMP ; RC=$? if [ $RC = 0 ]; then /bin/rm $TMP else echo "$PROG: niload failed. Temp file $TMP remains." fi else echo "$PROG: Editor error. $NAME database was NOT updated. " fi