#!/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/rc.d/rc.kea.new
config etc/kea/kea-dhcp-ddns.conf.new
config etc/kea/kea-dhcp4.conf.new
config etc/kea/kea-dhcp6.conf.new
config etc/kea/keactrl.conf.new

( cd usr/lib ; rm -rf libkea-asiodns.so )
( cd usr/lib ; ln -sf libkea-asiodns.so.75 libkea-asiodns.so )
( cd usr/lib ; rm -rf libkea-asiodns.so.75 )
( cd usr/lib ; ln -sf libkea-asiodns.so.75.0.0 libkea-asiodns.so.75 )
( cd usr/lib ; rm -rf libkea-asiolink.so )
( cd usr/lib ; ln -sf libkea-asiolink.so.105 libkea-asiolink.so )
( cd usr/lib ; rm -rf libkea-asiolink.so.105 )
( cd usr/lib ; ln -sf libkea-asiolink.so.105.0.0 libkea-asiolink.so.105 )
( cd usr/lib ; rm -rf libkea-cc.so )
( cd usr/lib ; ln -sf libkea-cc.so.98 libkea-cc.so )
( cd usr/lib ; rm -rf libkea-cc.so.98 )
( cd usr/lib ; ln -sf libkea-cc.so.98.0.0 libkea-cc.so.98 )
( cd usr/lib ; rm -rf libkea-cfgrpt.so )
( cd usr/lib ; ln -sf libkea-cfgrpt.so.3 libkea-cfgrpt.so )
( cd usr/lib ; rm -rf libkea-cfgrpt.so.3 )
( cd usr/lib ; ln -sf libkea-cfgrpt.so.3.0.0 libkea-cfgrpt.so.3 )
( cd usr/lib ; rm -rf libkea-config.so )
( cd usr/lib ; ln -sf libkea-config.so.98 libkea-config.so )
( cd usr/lib ; rm -rf libkea-config.so.98 )
( cd usr/lib ; ln -sf libkea-config.so.98.0.0 libkea-config.so.98 )
( cd usr/lib ; rm -rf libkea-cryptolink.so )
( cd usr/lib ; ln -sf libkea-cryptolink.so.76 libkea-cryptolink.so )
( cd usr/lib ; rm -rf libkea-cryptolink.so.76 )
( cd usr/lib ; ln -sf libkea-cryptolink.so.76.0.0 libkea-cryptolink.so.76 )
( cd usr/lib ; rm -rf libkea-d2srv.so )
( cd usr/lib ; ln -sf libkea-d2srv.so.75 libkea-d2srv.so )
( cd usr/lib ; rm -rf libkea-d2srv.so.75 )
( cd usr/lib ; ln -sf libkea-d2srv.so.75.0.0 libkea-d2srv.so.75 )
( cd usr/lib ; rm -rf libkea-database.so )
( cd usr/lib ; ln -sf libkea-database.so.88 libkea-database.so )
( cd usr/lib ; rm -rf libkea-database.so.88 )
( cd usr/lib ; ln -sf libkea-database.so.88.0.0 libkea-database.so.88 )
( cd usr/lib ; rm -rf libkea-dhcp.so )
( cd usr/lib ; ln -sf libkea-dhcp.so.129 libkea-dhcp.so )
( cd usr/lib ; rm -rf libkea-dhcp.so.129 )
( cd usr/lib ; ln -sf libkea-dhcp.so.129.0.0 libkea-dhcp.so.129 )
( cd usr/lib ; rm -rf libkea-dhcp_ddns.so )
( cd usr/lib ; ln -sf libkea-dhcp_ddns.so.82 libkea-dhcp_ddns.so )
( cd usr/lib ; rm -rf libkea-dhcp_ddns.so.82 )
( cd usr/lib ; ln -sf libkea-dhcp_ddns.so.82.0.0 libkea-dhcp_ddns.so.82 )
( cd usr/lib ; rm -rf libkea-dhcpsrv.so )
( cd usr/lib ; ln -sf libkea-dhcpsrv.so.149 libkea-dhcpsrv.so )
( cd usr/lib ; rm -rf libkea-dhcpsrv.so.149 )
( cd usr/lib ; ln -sf libkea-dhcpsrv.so.149.0.0 libkea-dhcpsrv.so.149 )
( cd usr/lib ; rm -rf libkea-dns.so )
( cd usr/lib ; ln -sf libkea-dns.so.84 libkea-dns.so )
( cd usr/lib ; rm -rf libkea-dns.so.84 )
( cd usr/lib ; ln -sf libkea-dns.so.84.0.0 libkea-dns.so.84 )
( cd usr/lib ; rm -rf libkea-eval.so )
( cd usr/lib ; ln -sf libkea-eval.so.97 libkea-eval.so )
( cd usr/lib ; rm -rf libkea-eval.so.97 )
( cd usr/lib ; ln -sf libkea-eval.so.97.0.0 libkea-eval.so.97 )
( cd usr/lib ; rm -rf libkea-exceptions.so )
( cd usr/lib ; ln -sf libkea-exceptions.so.55 libkea-exceptions.so )
( cd usr/lib ; rm -rf libkea-exceptions.so.55 )
( cd usr/lib ; ln -sf libkea-exceptions.so.55.0.0 libkea-exceptions.so.55 )
( cd usr/lib ; rm -rf libkea-hooks.so )
( cd usr/lib ; ln -sf libkea-hooks.so.139 libkea-hooks.so )
( cd usr/lib ; rm -rf libkea-hooks.so.139 )
( cd usr/lib ; ln -sf libkea-hooks.so.139.0.0 libkea-hooks.so.139 )
( cd usr/lib ; rm -rf libkea-http.so )
( cd usr/lib ; ln -sf libkea-http.so.100 libkea-http.so )
( cd usr/lib ; rm -rf libkea-http.so.100 )
( cd usr/lib ; ln -sf libkea-http.so.100.0.0 libkea-http.so.100 )
( cd usr/lib ; rm -rf libkea-log-interprocess.so )
( cd usr/lib ; ln -sf libkea-log-interprocess.so.4 libkea-log-interprocess.so )
( cd usr/lib ; rm -rf libkea-log-interprocess.so.4 )
( cd usr/lib ; ln -sf libkea-log-interprocess.so.4.0.0 libkea-log-interprocess.so.4 )
( cd usr/lib ; rm -rf libkea-log.so )
( cd usr/lib ; ln -sf libkea-log.so.86 libkea-log.so )
( cd usr/lib ; rm -rf libkea-log.so.86 )
( cd usr/lib ; ln -sf libkea-log.so.86.0.0 libkea-log.so.86 )
( cd usr/lib ; rm -rf libkea-mysql.so )
( cd usr/lib ; ln -sf libkea-mysql.so.106 libkea-mysql.so )
( cd usr/lib ; rm -rf libkea-mysql.so.106 )
( cd usr/lib ; ln -sf libkea-mysql.so.106.0.0 libkea-mysql.so.106 )
( cd usr/lib ; rm -rf libkea-process.so )
( cd usr/lib ; ln -sf libkea-process.so.105 libkea-process.so )
( cd usr/lib ; rm -rf libkea-process.so.105 )
( cd usr/lib ; ln -sf libkea-process.so.105.0.0 libkea-process.so.105 )
( cd usr/lib ; rm -rf libkea-stats.so )
( cd usr/lib ; ln -sf libkea-stats.so.64 libkea-stats.so )
( cd usr/lib ; rm -rf libkea-stats.so.64 )
( cd usr/lib ; ln -sf libkea-stats.so.64.0.0 libkea-stats.so.64 )
( cd usr/lib ; rm -rf libkea-tcp.so )
( cd usr/lib ; ln -sf libkea-tcp.so.45 libkea-tcp.so )
( cd usr/lib ; rm -rf libkea-tcp.so.45 )
( cd usr/lib ; ln -sf libkea-tcp.so.45.0.0 libkea-tcp.so.45 )
( cd usr/lib ; rm -rf libkea-util-io.so )
( cd usr/lib ; ln -sf libkea-util-io.so.12 libkea-util-io.so )
( cd usr/lib ; rm -rf libkea-util-io.so.12 )
( cd usr/lib ; ln -sf libkea-util-io.so.12.0.0 libkea-util-io.so.12 )
( cd usr/lib ; rm -rf libkea-util.so )
( cd usr/lib ; ln -sf libkea-util.so.118 libkea-util.so )
( cd usr/lib ; rm -rf libkea-util.so.118 )
( cd usr/lib ; ln -sf libkea-util.so.118.0.0 libkea-util.so.118 )
