#!/bin/sh
#CHS V3.0 PATCH 17

echo "Starting install for CHS patch #17 scripts"
cd /usr/spool/uucppublic
if ! [ -e /usr/spool/chsdata ] ; then
  echo "Creating directory: /usr/spool/chsdata"
  mkdir /usr/spool/chsdata
  chmod ugo+x /usr/spool/chsdata
fi
#
if ! [ -e /usr/spool/chsdata/xmitted ] ; then
  echo "Creating directory: /usr/spool/chsdata/xmitted"
  mkdir /usr/spool/chsdata/xmitted
  chmod ugo+x /usr/spool/chsdata/xmitted
fi
#
#now move the tar file to the directory, move US to the directory,
#and kill the old scripts
#
ROOTDIR=/usr/spool/chsdata
echo "moving achs0300.17s2 tar file to $ROOTDIR"
mv achs0300.17s2 $ROOTDIR/scripts.tar
cd $ROOTDIR
#
rm -f chsftp_main
rm -f chsftpepo_core
rm -f chsftpepo_fi
rm -f chsftpeobr
rm -f chschg_password
#
echo "untarring the scripts from achs0300.17s2"
tar -x -f scripts.tar
rm scripts.tar
#
echo "setting up crontab processes"
if [ "`grep chsftp_main /var/spool/cron/crontabs/root`" = "" ] ; then
  echo "creating crontab entries ...."
  cat chsftpcrontab >> /var/spool/cron/crontabs/root
  crontab /var/spool/cron/crontabs/root
fi
#
#set protection on the scripts
chmod 770 chsftp_main
chmod 770 chsftpepo_core
chmod 770 chsftpepo_fi
chmod 770 chsftpeobr
chmod 770 chschg_password

echo
echo "Done!"
