#!/usr/bin/env bash
#
# Copyright (C) 2008 VMware, Inc.  All Rights Reserved.
#

# Manages the configuration and deconfiguration of vmxnet.

# Must come before set -e.
. "`dirname $0`"/functions

set -e

configure()
{
   if [ -e /etc/fonts/fonts.conf ]; then
      # Create a hard link just in case theirs goes away.
      ln /etc/fonts/fonts.conf $LIBDIR/libconf/etc/fonts/fonts.conf
   else
      ln -s $LIBDIR/libconf/etc/fonts/fonts.conf{.local,}
   fi
}

deconfigure()
{
   rm $LIBDIR/libconf/etc/fonts/fonts.conf

   # Try to kill vmware-user, but it may not be started
   # so this can fail gracefully.
   killall vmware-user || /bin/true
}

# See how we were called.
case "$1" in
   install)
      configure
      ;;
   uninstall)
      deconfigure
      ;;
   *)
      error "Usage: `basename "$0"` {install|uninstall}"
      ;;
esac
