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.kadmind.new
preserve_perms etc/rc.d/rc.kpropd.new
preserve_perms etc/rc.d/rc.krb5kdc.new
config etc/default/kadmind.new
config etc/default/kpropd.new
config etc/default/krb5kdc.new
( cd lib64 ; rm -rf libgssapi_krb5.so.2 )
( cd lib64 ; ln -sf libgssapi_krb5.so.2.2 libgssapi_krb5.so.2 )
( cd lib64 ; rm -rf libk5crypto.so.3 )
( cd lib64 ; ln -sf libk5crypto.so.3.1 libk5crypto.so.3 )
( cd lib64 ; rm -rf libkrb5.so.3 )
( cd lib64 ; ln -sf libkrb5.so.3.3 libkrb5.so.3 )
( cd lib64 ; rm -rf libkrb5support.so.0 )
( cd lib64 ; ln -sf libkrb5support.so.0.1 libkrb5support.so.0 )
( cd usr/lib64 ; rm -rf libgssapi_krb5.so )
( cd usr/lib64 ; ln -sf libgssapi_krb5.so.2.2 libgssapi_krb5.so )
( cd usr/lib64 ; rm -rf libgssapi_krb5.so.2 )
( cd usr/lib64 ; ln -sf libgssapi_krb5.so.2.2 libgssapi_krb5.so.2 )
( cd usr/lib64 ; rm -rf libgssapi_krb5.so.2.2 )
( cd usr/lib64 ; ln -sf ../../lib64/libgssapi_krb5.so.2.2 libgssapi_krb5.so.2.2 )
( cd usr/lib64 ; rm -rf libgssrpc.so )
( cd usr/lib64 ; ln -sf libgssrpc.so.4.2 libgssrpc.so )
( cd usr/lib64 ; rm -rf libgssrpc.so.4 )
( cd usr/lib64 ; ln -sf libgssrpc.so.4.2 libgssrpc.so.4 )
( cd usr/lib64 ; rm -rf libk5crypto.so )
( cd usr/lib64 ; ln -sf libk5crypto.so.3.1 libk5crypto.so )
( cd usr/lib64 ; rm -rf libk5crypto.so.3 )
( cd usr/lib64 ; ln -sf libk5crypto.so.3.1 libk5crypto.so.3 )
( cd usr/lib64 ; rm -rf libk5crypto.so.3.1 )
( cd usr/lib64 ; ln -sf ../../lib64/libk5crypto.so.3.1 libk5crypto.so.3.1 )
( cd usr/lib64 ; rm -rf libkadm5clnt.so )
( cd usr/lib64 ; ln -sf libkadm5clnt_mit.so libkadm5clnt.so )
( cd usr/lib64 ; rm -rf libkadm5clnt_mit.so )
( cd usr/lib64 ; ln -sf libkadm5clnt_mit.so.12.0 libkadm5clnt_mit.so )
( cd usr/lib64 ; rm -rf libkadm5clnt_mit.so.12 )
( cd usr/lib64 ; ln -sf libkadm5clnt_mit.so.12.0 libkadm5clnt_mit.so.12 )
( cd usr/lib64 ; rm -rf libkadm5srv.so )
( cd usr/lib64 ; ln -sf libkadm5srv_mit.so libkadm5srv.so )
( cd usr/lib64 ; rm -rf libkadm5srv_mit.so )
( cd usr/lib64 ; ln -sf libkadm5srv_mit.so.12.0 libkadm5srv_mit.so )
( cd usr/lib64 ; rm -rf libkadm5srv_mit.so.12 )
( cd usr/lib64 ; ln -sf libkadm5srv_mit.so.12.0 libkadm5srv_mit.so.12 )
( cd usr/lib64 ; rm -rf libkdb5.so )
( cd usr/lib64 ; ln -sf libkdb5.so.10.0 libkdb5.so )
( cd usr/lib64 ; rm -rf libkdb5.so.10 )
( cd usr/lib64 ; ln -sf libkdb5.so.10.0 libkdb5.so.10 )
( cd usr/lib64 ; rm -rf libkdb_ldap.so )
( cd usr/lib64 ; ln -sf libkdb_ldap.so.1.0 libkdb_ldap.so )
( cd usr/lib64 ; rm -rf libkdb_ldap.so.1 )
( cd usr/lib64 ; ln -sf libkdb_ldap.so.1.0 libkdb_ldap.so.1 )
( cd usr/lib64 ; rm -rf libkrad.so )
( cd usr/lib64 ; ln -sf libkrad.so.0.0 libkrad.so )
( cd usr/lib64 ; rm -rf libkrad.so.0 )
( cd usr/lib64 ; ln -sf libkrad.so.0.0 libkrad.so.0 )
( cd usr/lib64 ; rm -rf libkrb5.so )
( cd usr/lib64 ; ln -sf libkrb5.so.3.3 libkrb5.so )
( cd usr/lib64 ; rm -rf libkrb5.so.3 )
( cd usr/lib64 ; ln -sf libkrb5.so.3.3 libkrb5.so.3 )
( cd usr/lib64 ; rm -rf libkrb5.so.3.3 )
( cd usr/lib64 ; ln -sf ../../lib64/libkrb5.so.3.3 libkrb5.so.3.3 )
( cd usr/lib64 ; rm -rf libkrb5support.so )
( cd usr/lib64 ; ln -sf libkrb5support.so.0.1 libkrb5support.so )
( cd usr/lib64 ; rm -rf libkrb5support.so.0 )
( cd usr/lib64 ; ln -sf libkrb5support.so.0.1 libkrb5support.so.0 )
( cd usr/lib64 ; rm -rf libkrb5support.so.0.1 )
( cd usr/lib64 ; ln -sf ../../lib64/libkrb5support.so.0.1 libkrb5support.so.0.1 )
( cd usr/lib64 ; rm -rf libverto.so )
( cd usr/lib64 ; ln -sf libverto.so.0.0 libverto.so )
( cd usr/lib64 ; rm -rf libverto.so.0 )
( cd usr/lib64 ; ln -sf libverto.so.0.0 libverto.so.0 )
