config() {
  NEW="$1"
  OLD="`dirname $NEW`/`basename $NEW .new`"
  # If there's no config file by that name, mv it over:
  if [ ! -r $OLD ]; then
    mv $NEW $OLD
  elif [ "`cat $OLD | md5sum`" = "`cat $NEW | md5sum`" ]; then # toss the redundant copy
    rm $NEW
  fi
  # Otherwise, we leave the .new copy for the admin to consider...
}

config etc/sagator.conf.new
config etc/rc.d/rc.sagator.new

# Check for the users

if ! grep -q vscan /etc/group; then
    groupadd vscan
fi

if ! grep -q vscan /etc/passwd; then
    useradd -g vscan -d /var/spool/vscan -c "Sagator Mail Scanner User" -s /bin/false vscan
fi

# Now perms

( chown -R vscan:vscan /var/spool/vscan )


echo "WARNING! You must populate the chroot directory"
echo "by running  /usr/sbin/mkchroot.sagator!"

# Create links

( cd usr/bin ; rm -rf sgscan )
( cd usr/bin ; ln -sf ../lib/sagator/sgscan.py sgscan )
( cd usr/lib/sagator ; rm -rf config.py )
( cd usr/lib/sagator ; ln -sf ../../../etc/sagator.conf config.py )
( cd usr/sbin ; rm -rf sagator )
( cd usr/sbin ; ln -sf ../lib/sagator/sagator.py sagator )
( cd usr/sbin ; rm -rf sqback )
( cd usr/sbin ; ln -sf ../lib/sagator/sqback.py sqback )
