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
}

config etc/tntnet/mime.conf.new
config etc/tntnet/tntnet.conf.new
preserve_perms etc/rc.d/rc.tntnet.new
( cd usr/lib64 ; rm -rf libtntnet.so )
( cd usr/lib64 ; ln -sf libtntnet.so.12.0.0 libtntnet.so )
( cd usr/lib64/tntnet ; rm -rf config.so.0 )
( cd usr/lib64/tntnet ; ln -sf config.so.0.0.0 config.so.0 )
( cd usr/lib64/tntnet ; rm -rf session.so.0 )
( cd usr/lib64/tntnet ; ln -sf session.so.0.0.0 session.so.0 )
( cd usr/lib64/tntnet ; rm -rf controls.so )
( cd usr/lib64/tntnet ; ln -sf controls.so.0.0.0 controls.so )
( cd usr/lib64/tntnet ; rm -rf message.so.0 )
( cd usr/lib64/tntnet ; ln -sf message.so.0.0.0 message.so.0 )
( cd usr/lib64/tntnet ; rm -rf savepoint.so )
( cd usr/lib64/tntnet ; ln -sf savepoint.so.0.0.0 savepoint.so )
( cd usr/lib64/tntnet ; rm -rf tntnet.so.12 )
( cd usr/lib64/tntnet ; ln -sf tntnet.so.12.0.0 tntnet.so.12 )
( cd usr/lib64/tntnet ; rm -rf upload.so.0 )
( cd usr/lib64/tntnet ; ln -sf upload.so.0.0.0 upload.so.0 )
( cd usr/lib64/tntnet ; rm -rf comp.so.0 )
( cd usr/lib64/tntnet ; ln -sf comp.so.0.0.0 comp.so.0 )
( cd usr/lib64/tntnet ; rm -rf calcmvc.so.0 )
( cd usr/lib64/tntnet ; ln -sf calcmvc.so.0.0.0 calcmvc.so.0 )
( cd usr/lib64/tntnet ; rm -rf config.so )
( cd usr/lib64/tntnet ; ln -sf config.so.0.0.0 config.so )
( cd usr/lib64/tntnet ; rm -rf chat.so )
( cd usr/lib64/tntnet ; ln -sf chat.so.0.0.0 chat.so )
( cd usr/lib64/tntnet ; rm -rf cookie.so.0 )
( cd usr/lib64/tntnet ; ln -sf cookie.so.0.0.0 cookie.so.0 )
( cd usr/lib64/tntnet ; rm -rf sprintf.so.0 )
( cd usr/lib64/tntnet ; ln -sf sprintf.so.0.0.0 sprintf.so.0 )
( cd usr/lib64/tntnet ; rm -rf extlib.so.0 )
( cd usr/lib64/tntnet ; ln -sf extlib.so.0.0.0 extlib.so.0 )
( cd usr/lib64/tntnet ; rm -rf cookie.so )
( cd usr/lib64/tntnet ; ln -sf cookie.so.0.0.0 cookie.so )
( cd usr/lib64/tntnet ; rm -rf calcajax.so )
( cd usr/lib64/tntnet ; ln -sf calcajax.so.0.0.0 calcajax.so )
( cd usr/lib64/tntnet ; rm -rf calci18n.so )
( cd usr/lib64/tntnet ; ln -sf calci18n.so.0.0.0 calci18n.so )
( cd usr/lib64/tntnet ; rm -rf alldemos.so )
( cd usr/lib64/tntnet ; ln -sf alldemos.so.0.0.0 alldemos.so )
( cd usr/lib64/tntnet ; rm -rf message.so )
( cd usr/lib64/tntnet ; ln -sf message.so.0.0.0 message.so )
( cd usr/lib64/tntnet ; rm -rf comp.so )
( cd usr/lib64/tntnet ; ln -sf comp.so.0.0.0 comp.so )
( cd usr/lib64/tntnet ; rm -rf calc.so )
( cd usr/lib64/tntnet ; ln -sf calc.so.0.0.0 calc.so )
( cd usr/lib64/tntnet ; rm -rf hello.so )
( cd usr/lib64/tntnet ; ln -sf hello.so.0.0.0 hello.so )
( cd usr/lib64/tntnet ; rm -rf backgroundjob.so.0 )
( cd usr/lib64/tntnet ; ln -sf backgroundjob.so.0.0.0 backgroundjob.so.0 )
( cd usr/lib64/tntnet ; rm -rf sprintf.so )
( cd usr/lib64/tntnet ; ln -sf sprintf.so.0.0.0 sprintf.so )
( cd usr/lib64/tntnet ; rm -rf session.so )
( cd usr/lib64/tntnet ; ln -sf session.so.0.0.0 session.so )
( cd usr/lib64/tntnet ; rm -rf chat.so.0 )
( cd usr/lib64/tntnet ; ln -sf chat.so.0.0.0 chat.so.0 )
( cd usr/lib64/tntnet ; rm -rf strings.so )
( cd usr/lib64/tntnet ; ln -sf strings.so.0.0.0 strings.so )
( cd usr/lib64/tntnet ; rm -rf strings.so.0 )
( cd usr/lib64/tntnet ; ln -sf strings.so.0.0.0 strings.so.0 )
( cd usr/lib64/tntnet ; rm -rf controls.so.0 )
( cd usr/lib64/tntnet ; ln -sf controls.so.0.0.0 controls.so.0 )
( cd usr/lib64/tntnet ; rm -rf calcmvc.so )
( cd usr/lib64/tntnet ; ln -sf calcmvc.so.0.0.0 calcmvc.so )
( cd usr/lib64/tntnet ; rm -rf extlib.so )
( cd usr/lib64/tntnet ; ln -sf extlib.so.0.0.0 extlib.so )
( cd usr/lib64/tntnet ; rm -rf calci18n.so.0 )
( cd usr/lib64/tntnet ; ln -sf calci18n.so.0.0.0 calci18n.so.0 )
( cd usr/lib64/tntnet ; rm -rf tntnet.so )
( cd usr/lib64/tntnet ; ln -sf tntnet.so.12.0.0 tntnet.so )
( cd usr/lib64/tntnet ; rm -rf backgroundjob.so )
( cd usr/lib64/tntnet ; ln -sf backgroundjob.so.0.0.0 backgroundjob.so )
( cd usr/lib64/tntnet ; rm -rf savepoint.so.0 )
( cd usr/lib64/tntnet ; ln -sf savepoint.so.0.0.0 savepoint.so.0 )
( cd usr/lib64/tntnet ; rm -rf calc.so.0 )
( cd usr/lib64/tntnet ; ln -sf calc.so.0.0.0 calc.so.0 )
( cd usr/lib64/tntnet ; rm -rf hello.so.0 )
( cd usr/lib64/tntnet ; ln -sf hello.so.0.0.0 hello.so.0 )
( cd usr/lib64/tntnet ; rm -rf alldemos.so.0 )
( cd usr/lib64/tntnet ; ln -sf alldemos.so.0.0.0 alldemos.so.0 )
( cd usr/lib64/tntnet ; rm -rf upload.so )
( cd usr/lib64/tntnet ; ln -sf upload.so.0.0.0 upload.so )
( cd usr/lib64/tntnet ; rm -rf calcajax.so.0 )
( cd usr/lib64/tntnet ; ln -sf calcajax.so.0.0.0 calcajax.so.0 )
( cd usr/lib64 ; rm -rf libtntnet.so.12 )
( cd usr/lib64 ; ln -sf libtntnet.so.12.0.0 libtntnet.so.12 )
( cd usr/lib64 ; rm -rf libtntnet_sdk.so )
( cd usr/lib64 ; ln -sf libtntnet_sdk.so.12.0.0 libtntnet_sdk.so )
( cd usr/lib64 ; rm -rf libtntnet_sdk.so.12 )
( cd usr/lib64 ; ln -sf libtntnet_sdk.so.12.0.0 libtntnet_sdk.so.12 )
