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

config etc/dracut.conf.d/elogind.conf.new
config etc/dracut.conf.d/omit_systemd_modules.conf.new
( cd usr/lib/dracut ; rm -rf dracut-functions )
( cd usr/lib/dracut ; ln -sf dracut-functions.sh dracut-functions )
( cd usr/lib/dracut/dracut.conf.d ; rm -rf test )
( cd usr/lib/dracut/dracut.conf.d ; ln -sf ../test/dracut.conf.d/test/ test )
( cd usr/lib/dracut/dracut.conf.d ; rm -rf test-makeroot )
( cd usr/lib/dracut/dracut.conf.d ; ln -sf ../test/dracut.conf.d/test-makeroot/ test-makeroot )
( cd usr/lib/dracut/dracut.conf.d ; rm -rf test-root )
( cd usr/lib/dracut/dracut.conf.d ; ln -sf ../test/dracut.conf.d/test-root test-root )
( cd usr/lib/dracut/modules.d ; rm -rf 80test )
( cd usr/lib/dracut/modules.d ; ln -sf ../test/modules.d/80test 80test )
( cd usr/lib/dracut/modules.d ; rm -rf 80test-makeroot )
( cd usr/lib/dracut/modules.d ; ln -sf ../test/modules.d/80test-makeroot 80test-makeroot )
( cd usr/lib/dracut/modules.d ; rm -rf 80test-root )
( cd usr/lib/dracut/modules.d ; ln -sf ../test/modules.d/80test-root 80test-root )
( cd usr/man/man7 ; rm -rf dracut.kernel.7.gz )
( cd usr/man/man7 ; ln -sf dracut.cmdline.7.gz dracut.kernel.7.gz )
