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

preserve_perms() {
  NEW="$1"
  OLD="$(dirname $NEW)/$(basename $NEW .new)"
  if [ -e $OLD ]; then
    cp -a $OLD ${NEW}.incoming
    cat $NEW > ${NEW}.incoming
    mv ${NEW}.incoming $NEW
  fi
  config $NEW
}

preserve_perms etc/profile.d/ex-vi.sh.new
preserve_perms etc/profile.d/ex-vi.csh.new
( cd opt/ex-vi/man/man1 ; rm -rf edit.1.gz )
( cd opt/ex-vi/man/man1 ; ln -sf ex.1.gz edit.1.gz )
( cd opt/ex-vi/man/man1 ; rm -rf vedit.1.gz )
( cd opt/ex-vi/man/man1 ; ln -sf vi.1.gz vedit.1.gz )
( cd opt/ex-vi/man/man1 ; rm -rf view.1.gz )
( cd opt/ex-vi/man/man1 ; ln -sf vi.1.gz view.1.gz )
( cd opt/ex-vi/bin ; rm -rf vedit )
( cd opt/ex-vi/bin ; ln -sf ex vedit )
( cd opt/ex-vi/bin ; rm -rf vi )
( cd opt/ex-vi/bin ; ln -sf ex vi )
( cd opt/ex-vi/bin ; rm -rf view )
( cd opt/ex-vi/bin ; ln -sf ex view )
( cd opt/ex-vi/bin ; rm -rf edit )
( cd opt/ex-vi/bin ; ln -sf ex edit )
