#!/sbin/sh
# Check for dangling links to old nonexistant files and fix them up so
# that captive accounts stay captive.
DIRS=""
if [ -d /data/IASS_Usr ] ; then
  DIRS="/data/IASS_Usr"
fi
if [ -d /data/Lkr_Usr_ ] ; then
  DIRS="$DIRS /data/Lkr_Usr_"
fi
IASS_Home=`awk -F: '$1=="iass" {print $6 }' < /etc/passwd`
if [ -d "$IASS_Home" ] ; then
  IASS_Home=`(cd $IASS_Home; pwd)`
  DIRS="$DIRS $IASS_Home"
fi

if [ "$DIRS" = "" ] ; then
  exit 0
fi

find $DIRS -type l | while read File
do
  if [ ! -f $File ] ; then
    SkelFile=/usr/internet/admin/skel/`basename $File`
    if [ -f $SkelFile ] ; then
      rm $File
      ln -s $SkelFile $File
    fi
  fi
done
exit 0
