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 NEW in etc/openmpi/*.new; do
  config $NEW
done
( cd usr/bin ; rm -rf hwloc-ls )
( cd usr/bin ; ln -sf lstopo-no-graphics hwloc-ls )
( cd usr/bin ; rm -rf mpiCC )
( cd usr/bin ; ln -sf opal_wrapper mpiCC )
( cd usr/bin ; rm -rf mpic++ )
( cd usr/bin ; ln -sf opal_wrapper mpic++ )
( cd usr/bin ; rm -rf mpicc )
( cd usr/bin ; ln -sf opal_wrapper mpicc )
( cd usr/bin ; rm -rf mpicxx )
( cd usr/bin ; ln -sf opal_wrapper mpicxx )
( cd usr/bin ; rm -rf mpiexec )
( cd usr/bin ; ln -sf mpirun mpiexec )
( cd usr/bin ; rm -rf mpif77 )
( cd usr/bin ; ln -sf opal_wrapper mpif77 )
( cd usr/bin ; rm -rf mpif90 )
( cd usr/bin ; ln -sf opal_wrapper mpif90 )
( cd usr/bin ; rm -rf mpifort )
( cd usr/bin ; ln -sf opal_wrapper mpifort )
( cd usr/bin ; rm -rf oshrun )
( cd usr/bin ; ln -sf mpirun oshrun )
( cd usr/bin ; rm -rf prterun )
( cd usr/bin ; ln -sf prte prterun )
( cd usr/lib64 ; rm -rf libhwloc.so )
( cd usr/lib64 ; ln -sf libhwloc.so.15.5.3 libhwloc.so )
( cd usr/lib64 ; rm -rf libhwloc.so.15 )
( cd usr/lib64 ; ln -sf libhwloc.so.15.5.3 libhwloc.so.15 )
( cd usr/lib64 ; rm -rf libmpi.so )
( cd usr/lib64 ; ln -sf libmpi.so.40.40.5 libmpi.so )
( cd usr/lib64 ; rm -rf libmpi.so.40 )
( cd usr/lib64 ; ln -sf libmpi.so.40.40.5 libmpi.so.40 )
( cd usr/lib64 ; rm -rf libmpi_mpifh.so )
( cd usr/lib64 ; ln -sf libmpi_mpifh.so.40.40.0 libmpi_mpifh.so )
( cd usr/lib64 ; rm -rf libmpi_mpifh.so.40 )
( cd usr/lib64 ; ln -sf libmpi_mpifh.so.40.40.0 libmpi_mpifh.so.40 )
( cd usr/lib64 ; rm -rf libmpi_usempi_ignore_tkr.so )
( cd usr/lib64 ; ln -sf libmpi_usempi_ignore_tkr.so.40.40.0 libmpi_usempi_ignore_tkr.so )
( cd usr/lib64 ; rm -rf libmpi_usempi_ignore_tkr.so.40 )
( cd usr/lib64 ; ln -sf libmpi_usempi_ignore_tkr.so.40.40.0 libmpi_usempi_ignore_tkr.so.40 )
( cd usr/lib64 ; rm -rf libmpi_usempif08.so )
( cd usr/lib64 ; ln -sf libmpi_usempif08.so.40.40.2 libmpi_usempif08.so )
( cd usr/lib64 ; rm -rf libmpi_usempif08.so.40 )
( cd usr/lib64 ; ln -sf libmpi_usempif08.so.40.40.2 libmpi_usempif08.so.40 )
( cd usr/lib64 ; rm -rf libopen-pal.so )
( cd usr/lib64 ; ln -sf libopen-pal.so.80.0.4 libopen-pal.so )
( cd usr/lib64 ; rm -rf libopen-pal.so.80 )
( cd usr/lib64 ; ln -sf libopen-pal.so.80.0.4 libopen-pal.so.80 )
( cd usr/lib64 ; rm -rf libpmix.so )
( cd usr/lib64 ; ln -sf libpmix.so.2.13.3 libpmix.so )
( cd usr/lib64 ; rm -rf libpmix.so.2 )
( cd usr/lib64 ; ln -sf libpmix.so.2.13.3 libpmix.so.2 )
( cd usr/lib64 ; rm -rf libprrte.so )
( cd usr/lib64 ; ln -sf libprrte.so.3.0.6 libprrte.so )
( cd usr/lib64 ; rm -rf libprrte.so.3 )
( cd usr/lib64 ; ln -sf libprrte.so.3.0.6 libprrte.so.3 )
( cd usr/lib64/pkgconfig ; rm -rf ompi-f77.pc )
( cd usr/lib64/pkgconfig ; ln -sf ompi-fort.pc ompi-f77.pc )
( cd usr/lib64/pkgconfig ; rm -rf ompi-f90.pc )
( cd usr/lib64/pkgconfig ; ln -sf ompi-fort.pc ompi-f90.pc )
( cd usr/man/man1 ; rm -rf hwloc-ls.1.gz )
( cd usr/man/man1 ; ln -sf lstopo-no-graphics.1.gz hwloc-ls.1.gz )
( cd usr/man/man1 ; rm -rf lstopo.1.gz )
( cd usr/man/man1 ; ln -sf lstopo-no-graphics.1.gz lstopo.1.gz )
( cd usr/share/openmpi ; rm -rf mpiCC-wrapper-data.txt )
( cd usr/share/openmpi ; ln -sf mpic++-wrapper-data.txt mpiCC-wrapper-data.txt )
( cd usr/share/openmpi ; rm -rf mpicxx-wrapper-data.txt )
( cd usr/share/openmpi ; ln -sf mpic++-wrapper-data.txt mpicxx-wrapper-data.txt )
( cd usr/share/openmpi ; rm -rf mpif77-wrapper-data.txt )
( cd usr/share/openmpi ; ln -sf mpifort-wrapper-data.txt mpif77-wrapper-data.txt )
( cd usr/share/openmpi ; rm -rf mpif90-wrapper-data.txt )
( cd usr/share/openmpi ; ln -sf mpifort-wrapper-data.txt mpif90-wrapper-data.txt )
