#!/bin/sh
#
# chkconfig: 2345 60 60
# description: Sony Vaio (FS series) laptop hotkey handler
#
# Copy this script to /etc/init.d/fsfn then run as root:
#
#   chkconfig --add fsfn
#
# You probably also want to add fsfn to your desktop start-up process.
# For Gnome, 
#
#   Desktop -> Preferences -> More Preferences -> Sessions
#
# then add fsfn to the Startup Programs tab as
#
#   /usr/local/bin/fsfn -o

[ -x /usr/local/bin/fsfn ] || exit 0

# Source function library.
. /etc/rc.d/init.d/functions

RETVAL=0

start() {
	# Check if it is already running
	if [ ! -f /var/lock/subsys/fsfn ]; then
	    echo -n $"Starting fsfn daemon: "
	    daemon /usr/local/bin/fsfn
	    RETVAL=$?
	    [ $RETVAL -eq 0 ] && touch /var/lock/subsys/fsfn
	    echo
	fi
	return $RETVAL
}

stop() {
	echo -n $"Stopping fsfn daemon: "
	killproc /usr/local/bin/fsfn
	RETVAL=$?
	[ $RETVAL -eq 0 ] && rm -f /var/lock/subsys/fsfn
	echo
        return $RETVAL
}

restart() {
	stop
	start
}	

#
# See how we were called.
#

case "$1" in
start)
	start
	;;
stop)
	stop
	;;
restart)
	restart
	;;
condrestart)
	if [ -f /var/lock/subsys/fsfn ]; then
	    restart
	fi
	;;
status)
	status fsfn
	;;
*)
	echo $"Usage: $0 {start|stop|status|restart|condrestart}"
	exit 1
esac

exit $RETVAL
