#!/bin/sh
LIB="/lib/modules"
KVER_FROM="$1"
KVER_TO="$2"

is_done() {
  if [ "$?" -eq 0 ] ; then
    echo -e " [ \033[01;32mOK\033[00m ]"
    return 0
  else
    echo -e " [ \033[01;31m!!\033[00m ]"
    return 1
    echo "Something really weird happened!"
    break
  fi
}

if [ -d $LIB/$KVER_FROM/misc -a ! -d $LIB/$KVER_TO/misc ] ; then
  echo
  echo -n "  Relocating VMware modules "
  mv $LIB/$KVER_FROM/misc $LIB/$KVER_TO 2>/dev/null
  is_done

  echo -n "  Removing stale symlinks   "
  rm $LIB/$KVER_TO/misc/*.ko
  is_done

  echo -n "  Creating new symlinks     "
  for file in $LIB/$KVER_TO/misc/*.o; do
	ln -s $file ${file/.o/.ko}
  done
  is_done

  echo
  echo "You might need to run depmod -ae after the next reboot."
  echo
fi

# vim: set tw=80 ts=2 sw=2 et softtabstop=2

