CRON=/usr/spool/cron/crontabs/root
RC=/etc/rc
UNDELETE="/usr/deleted"
TOUCH="/bin/touch"
MAXDAYS=1

if [ $USER != 'root' ]
then
  echo Only superuser root should install the undelete-pacckage
  exit 1
fi

for file in del undelete cleanup do
 if cc -DUNDELETE=\"$UNDELETE -DMAXDAYS=$MAXDAYS -DTOUCH=\"$TOUCH $file.c -lmisc -o /bin/$file
  then
    echo /bin/$file created
  else
   echo Error creating /bin$file - Abort . . .
   exit 1
  fi
done

if chmog 4755 root root /bin/del
then
 echo Permission of del changed to 4755 root root
else
 echo Error changing permissions of del - Abort . . .
 exit 1
fi

for file in undelete cleanup do
 if chmog 511 bin bin /bin/$file
 then
  echo Permission of $file changed to 511 bin bin
 else
  echo Error changing permissions of $file - Abort . . .
  exit 1
 fi
done

strip /bin/del /bin/undelete /bin/cleanup
l /bin/del /bin/undelete /bin/cleanup

if [ -d $UNDELETE ]
then
  echo Directory $UNDELETE alraedy exists
else
  echo Creating directory $UNDELETE
  if mkdir $UNDELETE
  then
    if chmog 777 bin bin $UNDELETE
  then
  else
  fi
  else
    echo Error creating $UNDELETE - Abort . . .
    exit 1
  fi
fi

echo	Do you want to start cleanup from $CRON ?
read	ans
case	$ans in
  y|Y|Yes|yes)
  if grep /bin/cleanup $CRON
  then
    echo $CRON already contains a cleanup-entry
  else
    if echo "# Execute cleanup at 2 PM daily\n0 14 * * * /bin/cleanup">>$CRON
    then
    else
      echo Cannot write to $CRON - Abort . . .
    fi
  fi
  ;;
  *)
  ;;
esac

echo	Do you want to start cleanup from $RC ?
read	ans
case	$ans in
  y|Y|Yes|yes)
  if grep /bin/cleanup $RC
  then
    echo $RC already contains a cleanup-entry
  else
    if echo ": Remove deleted files\n/bin/cleanup">>$RC
    then
    else
      echo Cannot write to $RC - Abort . . .
    fi
  fi
  ;;
  *)
  ;;
esac
