#!/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/sudoers.new
rm -f etc/sudoers.new

# Ensure that there is an /etc/environment file to prevent "sudo -i"
# from complaining:
if [ ! -r etc/environment ]; then
  touch etc/environment
fi
( cd usr/libexec/sudo ; rm -rf libsudo_util.so.0 )
( cd usr/libexec/sudo ; ln -sf libsudo_util.so.0.0.0 libsudo_util.so.0 )
( cd usr/libexec/sudo ; rm -rf libsudo_util.so )
( cd usr/libexec/sudo ; ln -sf libsudo_util.so.0.0.0 libsudo_util.so )
( cd usr/bin ; rm -rf sudoedit )
( cd usr/bin ; ln -sf sudo sudoedit )
( cd usr/man/man8 ; rm -rf sudoedit.8.gz )
( cd usr/man/man8 ; ln -sf sudo.8.gz sudoedit.8.gz )
