#!/bin/sh
# Startup script for fnfxd
#
# chkconfig: - 10 90
# description: Toshiba ACPI hot-key daemon

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

prog="fnfxd"

start() {
    if [ ! -f /var/lock/subsys/fnfxd ]; then
	if [ ! -d /proc/acpi/toshiba ] || [ ! -f /proc/acpi/toshiba/keys ]; then
	    modprobe -s toshiba_acpi
	fi
	echo -n $"Starting $prog: "
	daemon fnfxd
	RETVAL=$?
	echo
	[ $RETVAL = 0 ] && touch /var/lock/subsys/fnfxd
    else
	return 0
    fi
    return $RETVAL
}

stop() {
    if test "x`pidof fnfxd`" != x; then
	echo -n $"Stopping $prog: "
	killproc fnfxd
	echo
    fi
    RETVAL=$?
    [ $RETVAL = 0 ] && rm -f /var/lock/subsys/fnfxd
    return $RETVAL
}

case "$1" in
	start)
	    start
	    ;;
	
	stop)
	    stop
	    ;;
	
	status)
	    status fnfxd
	    ;;
	restart)
	    stop
	    start
	    ;;
	condrestart)
	    if test "x`pidof fnfxd`" != x; then
		stop
		start
	    fi
	    ;;
	
	*)
	    echo $"Usage: $0 {start|stop|restart|condrestart|status}"
	    exit 1

esac

exit $RETVAL
