#!/bin/sh

( cd etc/X11/wdm ; rm -rf authdir )
( cd etc/X11/wdm ; ln -sf ../../../var/lib/wdm authdir )
( cd etc/X11/wdm ; rm -rf chooser )
if [ -x etc/X11/xdm/chooser ] ; then
( cd etc/X11/wdm ; ln -sf ../xdm/chooser . )
fi

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/wdm.conf.new
# rc.4 is in sysvinit-scripts so use it.
# config etc/rc.d/rc.4.new

if [ ! -r etc/X11/wdm/wdm-config ] ; then
echo ""
echo -n "Running ConfigureWDM..."
# ( cd etc/X11/wdm ; . ./ConfigureWDM )
( chroot . /usr/sbin/ConfigureWDM )
chmod 600 etc/X11/wdm/wdm-config
echo "Done."
echo "Default settings are quite strict. Be sure to check the"
echo "configuration in /etc/wdm.conf. If needed, edit the file"
echo "and then run /usr/sbin/ConfigureWDM to update all configuration files."
echo "Read the file README.FIRST in /usr/share/doc/wdm-VERSION for more information."
sleep 3
fi