#!/bin/sh
# @(#)mkafppasswd.sh	1.4 revision of 97/04/23  11:19:31
# This is an unpublished work copyright (c) 1989 HELIOS Software GmbH
# 30159 Hannover, Germany

ESDIR=/usr/local/es
export ESDIR

firstid=100		# all below are assumed not to be afp users

PWFILE="$ESDIR/conf/afppasswd"

if test -f "$PWFILE"
then
	echo "$0: $PWFILE already exists" >&2
	exit 1
fi

echo "Creating $PWFILE lookaside password file"

awk -F: "{ if (\$3 >= $firstid || (\$3 == 0 && \$1 != \"+\")) printf \"%s:\\n\", \$1 }" /etc/passwd >$PWFILE
$ESDIR/etc/procstat | grep ypbind >/dev/null 2>&1
if test $? -eq 0
then
	echo "+:" >>$PWFILE
fi
chown root $PWFILE
chmod 0644 $PWFILE

cat <<eof

The lookaside password file has been setup, but the EtherShare
processes will only recognize the new file after the next stop-atalk
followed by start-atalk. All users on this system will have no password
(i.e. may log in without entering a password) when using the EtherShare
services. Please urge your users to change their passwords as soon as
possible using the Macintosh chooser or by running the program
$ESDIR/afppasswd. This will change both the Unix password as well as
the EtherShare password.

To give the root user a password, this script runs $ESDIR/afppasswd for
the root user directly after displaying this text. Please type just
return when asked for the old afp password.

eof

$ESDIR/afppasswd root
