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

for FILE in etc/ggi/*.new ; do
  config $FILE
done
for FILE in etc/ggi/filter/*.new ; do
  config $FILE
done
for FILE in etc/ggi/targets/*.new ; do
  config $FILE
done

( cd usr/lib ; rm -rf libggi.so )
( cd usr/lib ; ln -sf libggi.so.2.0.2 libggi.so )
( cd usr/lib ; rm -rf libgii.so )
( cd usr/lib ; ln -sf libgii.so.1.0.0 libgii.so )
( cd usr/lib ; rm -rf libgg.so.1 )
( cd usr/lib ; ln -sf libgg.so.1.0.0 libgg.so.1 )
( cd usr/lib ; rm -rf libvga.so.1 )
( cd usr/lib ; ln -sf libvga.so.1.0.0 libvga.so.1 )
( cd usr/lib ; rm -rf libvga.so )
( cd usr/lib ; ln -sf libvga.so.1.0.0 libvga.so )
( cd usr/lib ; rm -rf libggi.so.2 )
( cd usr/lib ; ln -sf libggi.so.2.0.2 libggi.so.2 )
( cd usr/lib ; rm -rf libgii.so.1 )
( cd usr/lib ; ln -sf libgii.so.1.0.0 libgii.so.1 )
( cd usr/lib ; rm -rf libgg.so )
( cd usr/lib ; ln -sf libgg.so.1.0.0 libgg.so )
