#!/bin/sh

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/squid/mime.conf.new
config /etc/squid/squid.conf.new
config /etc/squid/cachemgr.conf.new


echo
echo
echo "    You may now edit the /etc/squid/squid.conf file and set"
echo "    to 755 the permissions of the file /etc/rc.d/rc.squid."
echo "    This script will parse your config file, set the owner"
echo "    and create the needed files at its the first run."
echo
echo
( cd usr/sbin ; rm -rf proxy )
( cd usr/sbin ; ln -sf /etc/rc.d/rc.squid proxy )
