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.drbd.new
preserve_perms etc/drbd.conf.new
preserve_perms etc/drbd.d/global_common.conf.new

( cd usr/lib/drbd ; rm -rf notify-emergency-reboot.sh )
( cd usr/lib/drbd ; ln -sf notify.sh notify-emergency-reboot.sh )
( cd usr/lib/drbd ; rm -rf unsnapshot-resync-target-lvm.sh )
( cd usr/lib/drbd ; ln -sf snapshot-resync-target-lvm.sh unsnapshot-resync-target-lvm.sh )
( cd usr/lib/drbd ; rm -rf notify-pri-lost-after-sb.sh )
( cd usr/lib/drbd ; ln -sf notify.sh notify-pri-lost-after-sb.sh )
( cd usr/lib/drbd ; rm -rf notify-emergency-shutdown.sh )
( cd usr/lib/drbd ; ln -sf notify.sh notify-emergency-shutdown.sh )
( cd usr/lib/drbd ; rm -rf notify-split-brain.sh )
( cd usr/lib/drbd ; ln -sf notify.sh notify-split-brain.sh )
( cd usr/lib/drbd ; rm -rf crm-unfence-peer.sh )
( cd usr/lib/drbd ; ln -sf crm-fence-peer.sh crm-unfence-peer.sh )
( cd usr/lib/drbd ; rm -rf notify-out-of-sync.sh )
( cd usr/lib/drbd ; ln -sf notify.sh notify-out-of-sync.sh )
( cd usr/lib/drbd ; rm -rf notify-pri-lost.sh )
( cd usr/lib/drbd ; ln -sf notify.sh notify-pri-lost.sh )
( cd usr/lib/drbd ; rm -rf notify-io-error.sh )
( cd usr/lib/drbd ; ln -sf notify.sh notify-io-error.sh )
( cd usr/lib/drbd ; rm -rf notify-pri-on-incon-degr.sh )
( cd usr/lib/drbd ; ln -sf notify.sh notify-pri-on-incon-degr.sh )
