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.ccpd.new
config etc/ccpd.conf.new
( cd usr/lib ; rm -rf libcaiocaptnet.so )
( cd usr/lib ; ln -sf libcaiocaptnet.so.1.0.0 libcaiocaptnet.so )
( cd usr/lib ; rm -rf libcaiocaptnet.so.1 )
( cd usr/lib ; ln -sf libcaiocaptnet.so.1.0.0 libcaiocaptnet.so.1 )
( cd usr/lib ; rm -rf libcanoncapt.so )
( cd usr/lib ; ln -sf libcanoncapt.so.1.0.0 libcanoncapt.so )
( cd usr/lib ; rm -rf libcanoncapt.so.1 )
( cd usr/lib ; ln -sf libcanoncapt.so.1.0.0 libcanoncapt.so.1 )
( cd usr/lib ; rm -rf libcaptfilter.so )
( cd usr/lib ; ln -sf libcaptfilter.so.1.0.0 libcaptfilter.so )
( cd usr/lib ; rm -rf libcaptfilter.so.1 )
( cd usr/lib ; ln -sf libcaptfilter.so.1.0.0 libcaptfilter.so.1 )
( cd usr/lib ; rm -rf libcnaccm.so )
( cd usr/lib ; ln -sf libcnaccm.so.1.0 libcnaccm.so )
( cd usr/lib ; rm -rf libcnaccm.so.1 )
( cd usr/lib ; ln -sf libcnaccm.so.1.0 libcnaccm.so.1 )
( cd usr/lib ; rm -rf libcncaptnpm.so )
( cd usr/lib ; ln -sf libcncaptnpm.so.2.0.1 libcncaptnpm.so )
( cd usr/lib ; rm -rf libcncaptnpm.so.2 )
( cd usr/lib ; ln -sf libcncaptnpm.so.2.0.1 libcncaptnpm.so.2 )
( cd usr/lib ; rm -rf libuictlcapt.so )
( cd usr/lib ; ln -sf libuictlcapt.so.1.0.0 libuictlcapt.so )
( cd usr/lib ; rm -rf libuictlcapt.so.1 )
( cd usr/lib ; ln -sf libuictlcapt.so.1.0.0 libuictlcapt.so.1 )
