#!/bin/sh
echo "Create U_PATH and SU_PATH in the working directory before running this."
rm -rf shadow-3.3.1+
if test -d shadow-3.3.1+; then
   cat << EOF

Hmm...  Looks as though you have done this before.
We start by removing the old shadow-3.3.1+ directory if it exits.
If you have done make save in it you must be root to delete it.
Suggest that, as root, you remove shadow-3.3.1+.  Then run me again.
But first of all, squirrel away the save subdirectory somewhere. :-)
EOF
   exit 1
fi
mv shadow-3.3.1 shadow-3.3.1+
cd shadow-3.3.1+
echo "Now patching....this should be silent (no complaints or prompts)..."
patch -p1 <../shadaut-3.3.1.df3 2>../patch.errs
echo "You should see: ls: *.rej: no such file or directory...."
ls *.rej
rm *.orig
mv Makefile Makefile.in
mv config.h config.h.in
echo "Running configure."
PATH=`cat ../SU_PATH`
/bin/sh ./configure
echo "Now doing make.  Messages to make.errs"
make >../make.errs 2>&1
echo "Make complete."
echo "Look at make.errs.  If all is okay, su root, cd shadow-3.3.1+,"
echo "make save and make install."
echo "DO NOT EXIT FROM THE ROOT SHELL.  Switch to another tty and try to log"
echo "in and su.  If this succeeds, use the session for long enough to"
echo "be sure there are no serious problems.  Make restore (and confirm"
echo "that this has worked before relinquishing root) only if you have to."
