#!/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
config etc/dracut.conf.d/hostonly_cmdline_yes.conf.new
config etc/dracut.conf.d/i18n_vars.conf.new
( cd usr/lib/systemd/system ; rm -rf dracut-cmdline.service )
( cd usr/lib/systemd/system ; ln -sf ../../../lib64/dracut/modules.d/77dracut-systemd/dracut-cmdline.service dracut-cmdline.service )
( cd usr/lib/systemd/system ; rm -rf dracut-initqueue.service )
( cd usr/lib/systemd/system ; ln -sf ../../../lib64/dracut/modules.d/77initqueue/dracut-initqueue.service dracut-initqueue.service )
( cd usr/lib/systemd/system ; rm -rf dracut-mount.service )
( cd usr/lib/systemd/system ; ln -sf ../../../lib64/dracut/modules.d/77dracut-systemd/dracut-mount.service dracut-mount.service )
( cd usr/lib/systemd/system ; rm -rf dracut-pre-mount.service )
( cd usr/lib/systemd/system ; ln -sf ../../../lib64/dracut/modules.d/77dracut-systemd/dracut-pre-mount.service dracut-pre-mount.service )
( cd usr/lib/systemd/system ; rm -rf dracut-pre-pivot.service )
( cd usr/lib/systemd/system ; ln -sf ../../../lib64/dracut/modules.d/77dracut-systemd/dracut-pre-pivot.service dracut-pre-pivot.service )
( cd usr/lib/systemd/system ; rm -rf dracut-pre-trigger.service )
( cd usr/lib/systemd/system ; ln -sf ../../../lib64/dracut/modules.d/77dracut-systemd/dracut-pre-trigger.service dracut-pre-trigger.service )
( cd usr/lib/systemd/system ; rm -rf dracut-pre-udev.service )
( cd usr/lib/systemd/system ; ln -sf ../../../lib64/dracut/modules.d/77dracut-systemd/dracut-pre-udev.service dracut-pre-udev.service )
( cd usr/lib/systemd/system ; rm -rf dracut-shutdown-onfailure.service )
( cd usr/lib/systemd/system ; ln -sf ../../../lib64/dracut/modules.d/77dracut-systemd/dracut-shutdown-onfailure.service dracut-shutdown-onfailure.service )
( cd usr/lib/systemd/system ; rm -rf dracut-shutdown.service )
( cd usr/lib/systemd/system ; ln -sf ../../../lib64/dracut/modules.d/77dracut-systemd/dracut-shutdown.service dracut-shutdown.service )
( cd usr/lib/systemd/system/initrd.target.wants ; rm -rf dracut-cmdline.service )
( cd usr/lib/systemd/system/initrd.target.wants ; ln -sf ../dracut-cmdline.service dracut-cmdline.service )
( cd usr/lib/systemd/system/initrd.target.wants ; rm -rf dracut-initqueue.service )
( cd usr/lib/systemd/system/initrd.target.wants ; ln -sf ../dracut-initqueue.service dracut-initqueue.service )
( cd usr/lib/systemd/system/initrd.target.wants ; rm -rf dracut-mount.service )
( cd usr/lib/systemd/system/initrd.target.wants ; ln -sf ../dracut-mount.service dracut-mount.service )
( cd usr/lib/systemd/system/initrd.target.wants ; rm -rf dracut-pre-mount.service )
( cd usr/lib/systemd/system/initrd.target.wants ; ln -sf ../dracut-pre-mount.service dracut-pre-mount.service )
( cd usr/lib/systemd/system/initrd.target.wants ; rm -rf dracut-pre-pivot.service )
( cd usr/lib/systemd/system/initrd.target.wants ; ln -sf ../dracut-pre-pivot.service dracut-pre-pivot.service )
( cd usr/lib/systemd/system/initrd.target.wants ; rm -rf dracut-pre-trigger.service )
( cd usr/lib/systemd/system/initrd.target.wants ; ln -sf ../dracut-pre-trigger.service dracut-pre-trigger.service )
( cd usr/lib/systemd/system/initrd.target.wants ; rm -rf dracut-pre-udev.service )
( cd usr/lib/systemd/system/initrd.target.wants ; ln -sf ../dracut-pre-udev.service dracut-pre-udev.service )
( cd usr/lib/systemd/system/sysinit.target.wants ; rm -rf dracut-shutdown.service )
( cd usr/lib/systemd/system/sysinit.target.wants ; ln -sf ../dracut-shutdown.service dracut-shutdown.service )
( cd usr/lib64/dracut ; rm -rf dracut-functions )
( cd usr/lib64/dracut ; ln -sf dracut-functions.sh dracut-functions )
( cd usr/man/man7 ; rm -rf dracut.kernel.7.gz )
( cd usr/man/man7 ; ln -sf dracut.cmdline.7.gz dracut.kernel.7.gz )
