home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
NeXTSTEP 4.0 PR1
/
NeXT_NEXTSTEP_4.0_PR1_(beta).rar
/
Openstep4-Pr1User.iso
/
NextAdmin
/
NetInstallHelper.app
/
delete_netinstall_server
< prev
next >
Wrap
Text File
|
1995-01-31
|
4KB
|
166 lines
#!/bin/csh -f
#
# Delete a NetInstall server configuration
# Copyright (C) 1994 by NeXT Computer, Inc. All rights reserved.
# Trap SIGINT. This keeps the tty from getting messed up if
# someone types ^C while the shell is reading a password.
onintr -
# All command names are stored in variable
set AWK=/bin/awk
set BASENAME=/usr/bin/basename
set CAT=/bin/cat
set DF=/bin/df
set ECHO=/bin/echo
set ERROR=$ECHO
set EXPORTFS=/usr/etc/exportfs
set GREP=/bin/grep
set HOSTNAME=/bin/hostname
set IFCONFIG=/usr/etc/ifconfig
set LS=/bin/ls
set MKDIRS=/bin/mkdirs
set MOUNTD=/usr/etc/rpc.mountd
set NFSD=/usr/etc/nfsd
set NIUTIL=/usr/bin/niutil
set PS=/bin/ps
set RM=/bin/rm
set SLEEP=/usr/bin/sleep
set STTY=/bin/stty
set TAIL=/usr/ucb/tail
set WC=/usr/ucb/wc
set TRUE=1
set FALSE=0
set CONFIG_DOMAIN=/
set HOST_NAME=`$HOSTNAME`
set PROGRAM_NAME=`$BASENAME ${0} .csh`
$ECHO "usage: ${PROGRAM_NAME} [-config_domain name]" > /tmp/_usage_$$
$ECHO 'arguments:' >> /tmp/_usage_$$
$ECHO ' -config_domain Domain where servers are recorded (default is "/")' >> /tmp/_usage_$$
# This program must be run by root
set WHO=`$PS -l $$ | $TAIL -1 | $AWK '{print $2}'`
if (${WHO}x != "0x") then
$ERROR 'You must run this program as "root".'
exit 1
endif
# Parse command-line options
while ($#argv > 0)
switch (${1})
case "-help": # Print help message
$CAT /tmp/_usage_$$
$RM /tmp/_usage_$$
exit 1
breaksw
case "-config_domain": # Where servers are recorded
if ($#argv < 2) then
$ERROR "${PROGRAM_NAME}: missing argument to -config_domain."
$CAT /tmp/_usage_$$
$RM /tmp/_usage_$$
exit 1
endif
set CONFIG_DOMAIN="${2}"
shift
breaksw
default: # Unknown flag
$ERROR "${PROGRAM_NAME}: unknown option ${1}"
$CAT /tmp/_usage_$$
$RM /tmp/_usage_$$
exit 1
breaksw
endsw
shift
end
$RM /tmp/_usage_$$
# Check server configuration
$NIUTIL -read $CONFIG_DOMAIN /locations/install_servers/$HOST_NAME > /tmp/_delete_$$
if ($status == 1) then
$ERROR "Can't get server configuration for $HOST_NAME"
exit 1
endif
set ROOT_IMAGE=`$GREP '^install_root:' /tmp/_delete_$$ | $AWK '{print $2}'`
if (${ROOT_IMAGE}x == x) then
$ERROR "Bad server configuration for $HOST_NAME"
$ERROR "Can't deterimine release image directory name"
exit 1
endif
# Acquire root password for "config" NetInfo domain
set GET_PW=$TRUE
$ECHO -n "Please enter the root password for the NetInfo domain: "
$ECHO -n '"'
$ECHO -n $CONFIG_DOMAIN
$ECHO '"'
while ($GET_PW == $TRUE)
$STTY -echo
$ECHO -n "Password: "
set ROOT_PASSWORD=$<
$STTY echo
$ECHO ""
if (${ROOT_PASSWORD}x == "x") then
set ROOT_PASSWORD='""'
endif
# Check password
$NIUTIL -createprop -P $ROOT_PASSWORD $CONFIG_DOMAIN / _test_$$
set STATUS=`$NIUTIL -read $CONFIG_DOMAIN / | $GREP _test_$$`
if (${STATUS}x == "x") then
$ECHO -n "Password incorrect. Do you wish to retry? [yn] "
set USER_INPUT=$<
if (${USER_INPUT}x == "nx" || ${USER_INPUT}x == "Nx") then
exit 1
endif
$SLEEP 2
else
$NIUTIL -destroyprop -P $ROOT_PASSWORD $CONFIG_DOMAIN / _test_$$
set GET_PW=$FALSE
endif
end
# Delete root domain /locations/install_servers entry
set NIDIR=/locations/install_servers/$HOST_NAME
$NIUTIL -destroy -P $ROOT_PASSWORD $CONFIG_DOMAIN $NIDIR
# Delete root domain /mounts entry if it exists
set NIDIR=`$NIUTIL -list $CONFIG_DOMAIN /mounts | $GREP "${HOST_NAME}:$ROOT_IMAGE" | $AWK '{print $1}'`
if (${NIDIR}x != x) then
$NIUTIL -destroy -P $ROOT_PASSWORD $CONFIG_DOMAIN $NIDIR
endif
# remove local export if it exists
set NIDIR=`$NIUTIL -list . /exports | $GREP "$ROOT_IMAGE" | $AWK '{print $1}'`
if (${NIDIR}x != x) then
$NIUTIL -destroy . $NIDIR
endif
# Remove release image
$ECHO -n "OK to destroy directory ${ROOT_IMAGE}: [ny] "
set USER_INPUT=$<
if (${USER_INPUT}x == "yx" || ${USER_INPUT}x == "Yx") then
$RM -rf $ROOT_IMAGE
endif
# All done
$ECHO "NetInstall server configuration deleted."
exit 0