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...
}

# Keep same perms on rc.cpupower.new:
if [ -e etc/rc.d/rc.cpupower ]; then
  cp -a etc/rc.d/rc.cpupower etc/rc.d/rc.cpupower.new.incoming
  cat etc/rc.d/rc.cpupower.new > etc/rc.d/rc.cpupower.new.incoming
  mv etc/rc.d/rc.cpupower.new.incoming etc/rc.d/rc.cpupower.new
fi

# Keep same perms on rc.usbipd.new:
if [ -e etc/rc.d/rc.usbipd ]; then
  cp -a etc/rc.d/rc.usbipd etc/rc.d/rc.usbipd.new.incoming
  cat etc/rc.d/rc.usbipd.new > etc/rc.d/rc.usbipd.new.incoming
  mv etc/rc.d/rc.usbipd.new.incoming etc/rc.d/rc.usbipd.new
fi

config etc/cpufreq-bench.conf.new
config etc/default/cpupower.new
config etc/rc.d/rc.cpupower.new
config etc/rc.d/rc.usbipd.new

( cd usr/bin ; rm -rf bootgraph )
( cd usr/bin ; ln -sf ../lib64/pm-graph/bootgraph.py bootgraph )
( cd usr/bin ; rm -rf sleepgraph )
( cd usr/bin ; ln -sf ../lib64/pm-graph/sleepgraph.py sleepgraph )
( cd usr/lib64 ; rm -rf libcpupower.so )
( cd usr/lib64 ; ln -sf libcpupower.so.0.0.1 libcpupower.so )
( cd usr/lib64 ; rm -rf libcpupower.so.0 )
( cd usr/lib64 ; ln -sf libcpupower.so.0.0.1 libcpupower.so.0 )
( cd usr/lib64 ; rm -rf libtraceevent.so )
( cd usr/lib64 ; ln -sf libtraceevent.so.1.1.0 libtraceevent.so )
( cd usr/lib64 ; rm -rf libtraceevent.so.1 )
( cd usr/lib64 ; ln -sf libtraceevent.so.1.1.0 libtraceevent.so.1 )
( cd usr/lib64 ; rm -rf libusbip.so )
( cd usr/lib64 ; ln -sf libusbip.so.0.0.1 libusbip.so )
( cd usr/lib64 ; rm -rf libusbip.so.0 )
( cd usr/lib64 ; ln -sf libusbip.so.0.0.1 libusbip.so.0 )
