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...
}

preserve_perms() {
  NEW="$1"
  OLD="$(dirname $NEW)/$(basename $NEW .new)"
  if [ -e $OLD ]; then
    cp -a $OLD ${NEW}.incoming
    cat $NEW > ${NEW}.incoming
    mv ${NEW}.incoming $NEW
  fi
  config $NEW
}

preserve_perms etc/rc.d/rc.squid.new
preserve_perms etc/squid/mime.conf.new
preserve_perms etc/squid/squid.conf.new
preserve_perms etc/squid/cachemgr.conf.new

( cd usr/share/squid/errors ; rm -rf da-dk )
( cd usr/share/squid/errors ; ln -sf da da-dk )
( cd usr/share/squid/errors ; rm -rf ar-eg )
( cd usr/share/squid/errors ; ln -sf ar ar-eg )
( cd usr/share/squid/errors ; rm -rf es-ar )
( cd usr/share/squid/errors ; ln -sf es es-ar )
( cd usr/share/squid/errors ; rm -rf ar-dz )
( cd usr/share/squid/errors ; ln -sf ar ar-dz )
( cd usr/share/squid/errors ; rm -rf zh-hk )
( cd usr/share/squid/errors ; ln -sf zh-hant zh-hk )
( cd usr/share/squid/errors ; rm -rf sr-rs )
( cd usr/share/squid/errors ; ln -sf sr-cyrl sr-rs )
( cd usr/share/squid/errors ; rm -rf fr-ch )
( cd usr/share/squid/errors ; ln -sf fr fr-ch )
( cd usr/share/squid/errors ; rm -rf zh-hant-mo )
( cd usr/share/squid/errors ; ln -sf zh-hant zh-hant-mo )
( cd usr/share/squid/errors ; rm -rf sr-cyrl-me )
( cd usr/share/squid/errors ; ln -sf sr-cyrl sr-cyrl-me )
( cd usr/share/squid/errors ; rm -rf en-ca )
( cd usr/share/squid/errors ; ln -sf en en-ca )
( cd usr/share/squid/errors ; rm -rf es-ec )
( cd usr/share/squid/errors ; ln -sf es es-ec )
( cd usr/share/squid/errors ; rm -rf es-cl )
( cd usr/share/squid/errors ; ln -sf es es-cl )
( cd usr/share/squid/errors ; rm -rf zh-tw )
( cd usr/share/squid/errors ; ln -sf zh-hant zh-tw )
( cd usr/share/squid/errors ; rm -rf es-ve )
( cd usr/share/squid/errors ; ln -sf es es-ve )
( cd usr/share/squid/errors ; rm -rf es-pe )
( cd usr/share/squid/errors ; ln -sf es es-pe )
( cd usr/share/squid/errors ; rm -rf fr-be )
( cd usr/share/squid/errors ; ln -sf fr fr-be )
( cd usr/share/squid/errors ; rm -rf sr-cyrl-rs )
( cd usr/share/squid/errors ; ln -sf sr-cyrl sr-cyrl-rs )
( cd usr/share/squid/errors ; rm -rf en-sg )
( cd usr/share/squid/errors ; ln -sf en en-sg )
( cd usr/share/squid/errors ; rm -rf fr-fr )
( cd usr/share/squid/errors ; ln -sf fr fr-fr )
( cd usr/share/squid/errors ; rm -rf ar-ma )
( cd usr/share/squid/errors ; ln -sf ar ar-ma )
( cd usr/share/squid/errors ; rm -rf cs-cz )
( cd usr/share/squid/errors ; ln -sf cs cs-cz )
( cd usr/share/squid/errors ; rm -rf en-tt )
( cd usr/share/squid/errors ; ln -sf en en-tt )
( cd usr/share/squid/errors ; rm -rf ko-kp )
( cd usr/share/squid/errors ; ln -sf ko ko-kp )
( cd usr/share/squid/errors ; rm -rf hy-armn )
( cd usr/share/squid/errors ; ln -sf hy hy-armn )
( cd usr/share/squid/errors ; rm -rf ar-sa )
( cd usr/share/squid/errors ; ln -sf ar ar-sa )
( cd usr/share/squid/errors ; rm -rf el-gr )
( cd usr/share/squid/errors ; ln -sf el el-gr )
( cd usr/share/squid/errors ; rm -rf sr-latn-rs )
( cd usr/share/squid/errors ; ln -sf sr-latn sr-latn-rs )
( cd usr/share/squid/errors ; rm -rf es-do )
( cd usr/share/squid/errors ; ln -sf es es-do )
( cd usr/share/squid/errors ; rm -rf ar-lb )
( cd usr/share/squid/errors ; ln -sf ar ar-lb )
( cd usr/share/squid/errors ; rm -rf bg-bg )
( cd usr/share/squid/errors ; ln -sf bg bg-bg )
( cd usr/share/squid/errors ; rm -rf ar-iq )
( cd usr/share/squid/errors ; ln -sf ar ar-iq )
( cd usr/share/squid/errors ; rm -rf et-ee )
( cd usr/share/squid/errors ; ln -sf et et-ee )
( cd usr/share/squid/errors ; rm -rf id-id )
( cd usr/share/squid/errors ; ln -sf id id-id )
( cd usr/share/squid/errors ; rm -rf fi-fi )
( cd usr/share/squid/errors ; ln -sf fi fi-fi )
( cd usr/share/squid/errors ; rm -rf fr-ca )
( cd usr/share/squid/errors ; ln -sf fr fr-ca )
( cd usr/share/squid/errors ; rm -rf lv-lv )
( cd usr/share/squid/errors ; ln -sf lv lv-lv )
( cd usr/share/squid/errors ; rm -rf vi-vn )
( cd usr/share/squid/errors ; ln -sf vi vi-vn )
( cd usr/share/squid/errors ; rm -rf az-az )
( cd usr/share/squid/errors ; ln -sf az az-az )
( cd usr/share/squid/errors ; rm -rf es-ni )
( cd usr/share/squid/errors ; ln -sf es es-ni )
( cd usr/share/squid/errors ; rm -rf de-at )
( cd usr/share/squid/errors ; ln -sf de de-at )
( cd usr/share/squid/errors ; rm -rf ar-sy )
( cd usr/share/squid/errors ; ln -sf ar ar-sy )
( cd usr/share/squid/errors ; rm -rf fa-ir )
( cd usr/share/squid/errors ; ln -sf fa fa-ir )
( cd usr/share/squid/errors ; rm -rf zh-mo )
( cd usr/share/squid/errors ; ln -sf zh-hant zh-mo )
( cd usr/share/squid/errors ; rm -rf sr-sp )
( cd usr/share/squid/errors ; ln -sf sr-latn sr-sp )
( cd usr/share/squid/errors ; rm -rf ar-ly )
( cd usr/share/squid/errors ; ln -sf ar ar-ly )
( cd usr/share/squid/errors ; rm -rf es-cr )
( cd usr/share/squid/errors ; ln -sf es es-cr )
( cd usr/share/squid/errors ; rm -rf en-zw )
( cd usr/share/squid/errors ; ln -sf en en-zw )
( cd usr/share/squid/errors ; rm -rf pt-bz )
( cd usr/share/squid/errors ; ln -sf pt-br pt-bz )
( cd usr/share/squid/errors ; rm -rf es-es )
( cd usr/share/squid/errors ; ln -sf es es-es )
( cd usr/share/squid/errors ; rm -rf es-uy )
( cd usr/share/squid/errors ; ln -sf es es-uy )
( cd usr/share/squid/errors ; rm -rf ro-md )
( cd usr/share/squid/errors ; ln -sf ro ro-md )
( cd usr/share/squid/errors ; rm -rf ka-ge )
( cd usr/share/squid/errors ; ln -sf ka ka-ge )
( cd usr/share/squid/errors ; rm -rf de-de )
( cd usr/share/squid/errors ; ln -sf de de-de )
( cd usr/share/squid/errors ; rm -rf he-il )
( cd usr/share/squid/errors ; ln -sf he he-il )
( cd usr/share/squid/errors ; rm -rf es-sv )
( cd usr/share/squid/errors ; ln -sf es es-sv )
( cd usr/share/squid/errors ; rm -rf es-pa )
( cd usr/share/squid/errors ; ln -sf es es-pa )
( cd usr/share/squid/errors ; rm -rf es-pr )
( cd usr/share/squid/errors ; ln -sf es es-pr )
( cd usr/share/squid/errors ; rm -rf es-us )
( cd usr/share/squid/errors ; ln -sf es es-us )
( cd usr/share/squid/errors ; rm -rf en-bz )
( cd usr/share/squid/errors ; ln -sf en en-bz )
( cd usr/share/squid/errors ; rm -rf th-th )
( cd usr/share/squid/errors ; ln -sf th th-th )
( cd usr/share/squid/errors ; rm -rf de-li )
( cd usr/share/squid/errors ; ln -sf de de-li )
( cd usr/share/squid/errors ; rm -rf ar-ye )
( cd usr/share/squid/errors ; ln -sf ar ar-ye )
( cd usr/share/squid/errors ; rm -rf de-lu )
( cd usr/share/squid/errors ; ln -sf de de-lu )
( cd usr/share/squid/errors ; rm -rf lt-lt )
( cd usr/share/squid/errors ; ln -sf lt lt-lt )
( cd usr/share/squid/errors ; rm -rf ar-bh )
( cd usr/share/squid/errors ; ln -sf ar ar-bh )
( cd usr/share/squid/errors ; rm -rf fr-mc )
( cd usr/share/squid/errors ; ln -sf fr fr-mc )
( cd usr/share/squid/errors ; rm -rf en-gb )
( cd usr/share/squid/errors ; ln -sf en en-gb )
( cd usr/share/squid/errors ; rm -rf zh-hans-cn )
( cd usr/share/squid/errors ; ln -sf zh-hans zh-hans-cn )
( cd usr/share/squid/errors ; rm -rf pl-pl )
( cd usr/share/squid/errors ; ln -sf pl pl-pl )
( cd usr/share/squid/errors ; rm -rf es-gt )
( cd usr/share/squid/errors ; ln -sf es es-gt )
( cd usr/share/squid/errors ; rm -rf zh-sg )
( cd usr/share/squid/errors ; ln -sf zh-hans zh-sg )
( cd usr/share/squid/errors ; rm -rf fa-fa )
( cd usr/share/squid/errors ; ln -sf fa fa-fa )
( cd usr/share/squid/errors ; rm -rf en-us )
( cd usr/share/squid/errors ; ln -sf en en-us )
( cd usr/share/squid/errors ; rm -rf sr-latn-cs )
( cd usr/share/squid/errors ; ln -sf sr-latn sr-latn-cs )
( cd usr/share/squid/errors ; rm -rf ko-kr )
( cd usr/share/squid/errors ; ln -sf ko ko-kr )
( cd usr/share/squid/errors ; rm -rf en-au )
( cd usr/share/squid/errors ; ln -sf en en-au )
( cd usr/share/squid/errors ; rm -rf es-py )
( cd usr/share/squid/errors ; ln -sf es es-py )
( cd usr/share/squid/errors ; rm -rf en-jm )
( cd usr/share/squid/errors ; ln -sf en en-jm )
( cd usr/share/squid/errors ; rm -rf uk-ua )
( cd usr/share/squid/errors ; ln -sf uk uk-ua )
( cd usr/share/squid/errors ; rm -rf sr )
( cd usr/share/squid/errors ; ln -sf sr-latn sr )
( cd usr/share/squid/errors ; rm -rf en-uk )
( cd usr/share/squid/errors ; ln -sf en en-uk )
( cd usr/share/squid/errors ; rm -rf sr-latn-me )
( cd usr/share/squid/errors ; ln -sf sr-latn sr-latn-me )
( cd usr/share/squid/errors ; rm -rf ar-kw )
( cd usr/share/squid/errors ; ln -sf ar ar-kw )
( cd usr/share/squid/errors ; rm -rf hy-am )
( cd usr/share/squid/errors ; ln -sf hy hy-am )
( cd usr/share/squid/errors ; rm -rf zh-hant-tw )
( cd usr/share/squid/errors ; ln -sf zh-hant zh-hant-tw )
( cd usr/share/squid/errors ; rm -rf ro-ro )
( cd usr/share/squid/errors ; ln -sf ro ro-ro )
( cd usr/share/squid/errors ; rm -rf ar-ae )
( cd usr/share/squid/errors ; ln -sf ar ar-ae )
( cd usr/share/squid/errors ; rm -rf en-nz )
( cd usr/share/squid/errors ; ln -sf en en-nz )
( cd usr/share/squid/errors ; rm -rf it-it )
( cd usr/share/squid/errors ; ln -sf it it-it )
( cd usr/share/squid/errors ; rm -rf ar-om )
( cd usr/share/squid/errors ; ln -sf ar ar-om )
( cd usr/share/squid/errors ; rm -rf pt-pt )
( cd usr/share/squid/errors ; ln -sf pt pt-pt )
( cd usr/share/squid/errors ; rm -rf sk-sk )
( cd usr/share/squid/errors ; ln -sf sk sk-sk )
( cd usr/share/squid/errors ; rm -rf sl-si )
( cd usr/share/squid/errors ; ln -sf sl sl-si )
( cd usr/share/squid/errors ; rm -rf ar-jo )
( cd usr/share/squid/errors ; ln -sf ar ar-jo )
( cd usr/share/squid/errors ; rm -rf ru-ru )
( cd usr/share/squid/errors ; ln -sf ru ru-ru )
( cd usr/share/squid/errors ; rm -rf sv-se )
( cd usr/share/squid/errors ; ln -sf sv sv-se )
( cd usr/share/squid/errors ; rm -rf en-za )
( cd usr/share/squid/errors ; ln -sf en en-za )
( cd usr/share/squid/errors ; rm -rf en-ie )
( cd usr/share/squid/errors ; ln -sf en en-ie )
( cd usr/share/squid/errors ; rm -rf zh-hant-hk )
( cd usr/share/squid/errors ; ln -sf zh-hant zh-hant-hk )
( cd usr/share/squid/errors ; rm -rf ar-tn )
( cd usr/share/squid/errors ; ln -sf ar ar-tn )
( cd usr/share/squid/errors ; rm -rf es-mx )
( cd usr/share/squid/errors ; ln -sf es es-mx )
( cd usr/share/squid/errors ; rm -rf nl-nl )
( cd usr/share/squid/errors ; ln -sf nl nl-nl )
( cd usr/share/squid/errors ; rm -rf ja-jp )
( cd usr/share/squid/errors ; ln -sf ja ja-jp )
( cd usr/share/squid/errors ; rm -rf sr-cyrl-cs )
( cd usr/share/squid/errors ; ln -sf sr-cyrl sr-cyrl-cs )
( cd usr/share/squid/errors ; rm -rf it-ch )
( cd usr/share/squid/errors ; ln -sf it it-ch )
( cd usr/share/squid/errors ; rm -rf hu-hu )
( cd usr/share/squid/errors ; ln -sf hu hu-hu )
( cd usr/share/squid/errors ; rm -rf sv-fi )
( cd usr/share/squid/errors ; ln -sf sv sv-fi )
( cd usr/share/squid/errors ; rm -rf de-ch )
( cd usr/share/squid/errors ; ln -sf de de-ch )
( cd usr/share/squid/errors ; rm -rf es-bo )
( cd usr/share/squid/errors ; ln -sf es es-bo )
( cd usr/share/squid/errors ; rm -rf zh-hans-sg )
( cd usr/share/squid/errors ; ln -sf zh-hans zh-hans-sg )
( cd usr/share/squid/errors ; rm -rf ar-qa )
( cd usr/share/squid/errors ; ln -sf ar ar-qa )
( cd usr/share/squid/errors ; rm -rf es-co )
( cd usr/share/squid/errors ; ln -sf es es-co )
( cd usr/share/squid/errors ; rm -rf es-hn )
( cd usr/share/squid/errors ; ln -sf es es-hn )
( cd usr/share/squid/errors ; rm -rf fr-lu )
( cd usr/share/squid/errors ; ln -sf fr fr-lu )
( cd usr/share/squid/errors ; rm -rf tr-tr )
( cd usr/share/squid/errors ; ln -sf tr tr-tr )
( cd usr/share/squid/errors ; rm -rf en-in )
( cd usr/share/squid/errors ; ln -sf en en-in )
( cd usr/share/squid/errors ; rm -rf zh-cn )
( cd usr/share/squid/errors ; ln -sf zh-hans zh-cn )
( cd usr/share/squid/errors ; rm -rf ms-my )
( cd usr/share/squid/errors ; ln -sf ms ms-my )
( cd usr/share/squid/errors ; rm -rf en-ph )
( cd usr/share/squid/errors ; ln -sf en en-ph )
