#!/bin/sh
#
#  Copyright (C) 2000-2009 Astaro AG
#  For copyright information look at /doc/astaro-license.txt
#  or http://www.astaro.com/doc/astaro-license.txt
#
# Maintainer: Ulrich Weber <uweber@astaro.com>
#
### BEGIN INIT INFO
# Provides: vmware-tools
# Required-Start: 
# Required-Stop:
# Default-Start: 3
# Default-Stop: 0 1 2 3 4 6
# Description: Start vmware-tools
### END INIT INFO

. /lib/lsb/init-functions

PATH=/bin:/sbin:/usr/bin:/usr/sbin
PNAME="VMware Tools"

# Exit on non VMWare systems
/usr/bin/vmware-checkvm >/dev/null 2>&1 || exit 0

case "$1" in

  start)
	echo -n ":: Starting $PNAME"
	modprobe vmmemctl >/dev/null 2>&1
	startproc /usr/bin/vmtoolsd >/dev/null 2>&1
	rc_status -v
	;;

  stop)
	echo -n ":: Stopping $PNAME"
	killall vmtoolsd >/dev/null 2>&1
	rc_status -v
	;;

  status)
	echo -n ":: Status $PNAME"
	if checkproc vmtoolsd; then
	  rc_failed 0
	else
	  rc_failed 3
	fi
	rc_status -v
	;;

  restart)
	echo -e ${attn}":: Restarting $PNAME"${norm}
	$0 stop
	$0 start
	rc_status -v
	;;

  *)
	echo "Usage: $N {start|stop|status|restart}" >&2
	exit 1
	;;

esac

rc_exit
