#! /bin/sh

# Take list of accounts to be deleted, one per line, in the form:
# username jobnumber realname
# and put them in a tar file on stdout with relative pathnames group/user/...

# The current directory should be the one in which the group directories
# reside, and the file of names, sysids and realnames should be called INDEX.
# The INDEX file is added as the first item in the archive.

# generate list of 
pu '-d%h' `sed 's/ .*//' < INDEX` | sed 's:/usr/::' | sort > PATHS

cat PATHS | while read path
do
	test -d "$path" || {
		2>&1 echo "No such directory \"$path\"."
		exit 1
	}
done

cp /etc/passwd Passwd
cp /etc/group Group
tar cf - INDEX Passwd Group `cat PATHS`
