#!/bin/sh
# @(#)rmnode.sh  2004-07-15  A.J.Travis

#
# Remove ClusterNFS files for diskless node
#

if [ $# -ne 1 ]; then
	echo usage: rmnode n
	exit 1
fi

NET=192.168
IPC=$NET.0.$1
NFS=$NET.1.$1
TAG='$$'IP=$NFS'$$'

cd /etc

# update hosts database
fgrep -v $IPC hosts | fgrep -v $NFS > hosts.new
mv hosts hosts.bak
mv hosts.new hosts

#
# Node-specific tag files and directories
#
cd /
if [ -h dev$TAG ]; then
	rm -rf dev$TAG
fi
if [ -h tmp$TAG ]; then
	rm -rf tmp$TAG
fi
if [ -h root$TAG ]; then
        rm -rf root$TAG
fi
if [ -d var$TAG ]; then
	rm -rf var$TAG
fi

# Hostname and gateway
cd /etc/sysconfig
if [ -f network$TAG ]; then
	rm -f network$TAG
fi

# Writeable directories for each client
cd /export/root
if [ -d $NFS ]; then
        rm -rf $NFS
fi
