#!/bin/sh

# on error, bomb out
set -e

# shift config files around
for file in libvga.config libvga.et4000 # libega.config
do
  if [ -L /etc/vga/$file ]
  then
    # if their are symlinks under /etc/vga, remove them
    # this should not happen unless some previous version fucked up
    rm /etc/vga/$file
  fi
  if [ -L /etc/$file ]
  then
    # if there's a symlink directly under /etc, we delete it;
    # we don't want to e.g. move the symlink by accident.
    rm /etc/$file
  elif [ -f /etc/$file ]
  then
    # If there's a regular file under /etc, we move it to the right
    # place
    mv /etc/$file /etc/vga/$file
  elif [ -e /etc/$file ]
  then
    # if there's anything else there then we can't sanely continue
    echo Bogus /etc/$file detected:
    ls -l /etc/$file
    exit 1
  fi
  # make the name under /etc be a symlink to the correct location
  ln -s vga/$file /etc/$file
done
