#!/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...
}

# Process all .new config files:
for file in etc/ImageMagick*/*.new ; do
  config $file
done
( cd usr/lib64 ; rm -rf libMagickWand-6.Q16.so.2 )
( cd usr/lib64 ; ln -sf libMagickWand-6.Q16.so.2.0.0 libMagickWand-6.Q16.so.2 )
( cd usr/lib64 ; rm -rf libMagickCore-6.Q16.so )
( cd usr/lib64 ; ln -sf libMagickCore-6.Q16.so.2.0.0 libMagickCore-6.Q16.so )
( cd usr/lib64 ; rm -rf libMagickWand-6.Q16.so )
( cd usr/lib64 ; ln -sf libMagickWand-6.Q16.so.2.0.0 libMagickWand-6.Q16.so )
( cd usr/lib64 ; rm -rf libMagick++-6.Q16.so )
( cd usr/lib64 ; ln -sf libMagick++-6.Q16.so.6.0.0 libMagick++-6.Q16.so )
( cd usr/lib64 ; rm -rf libMagick++-6.Q16.so.6 )
( cd usr/lib64 ; ln -sf libMagick++-6.Q16.so.6.0.0 libMagick++-6.Q16.so.6 )
( cd usr/lib64 ; rm -rf libMagickCore-6.Q16.so.2 )
( cd usr/lib64 ; ln -sf libMagickCore-6.Q16.so.2.0.0 libMagickCore-6.Q16.so.2 )
