#! /bin/sh
#
# keytouch - a program to configure the extra function keys of the keyboard

PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
DAEMON=/usr/bin/keytouch-init
DAEMONACPI=/usr/bin/keytouch-acpid
KEYBOARD_FILE=/etc/keytouch/current_keyboard.xml
NAME=keytouch-init
NAMEACPI=keytouch-acpid
DESC=keytouch

test -f $KEYBOARD_FILE || exit 0
test -x $DAEMON || exit 0

. /lib/lsb/init-functions

set -e

case "$1" in
  start)
	log_begin_msg "Starting $NAME..."
	start-stop-daemon --start --quiet --exec $DAEMON -- $DAEMON_OPTS
	log_end_msg $?
      if [ -x $DAEMONACPI ]; then
	   log_begin_msg "Starting $NAMEACPI..."
	   start-stop-daemon -b --oknodo --start --quiet --exec $DAEMONACPI -- $DAEMON_OPTS
	   log_end_msg $?
      fi
	;;
  stop)
      log_begin_msg "Stopping $NAME: Nothing to do"
      log_end_msg 0
      if [ -x $DAEMONACPI ]; then
         log_begin_msg "Stopping $NAMEACPI: "
         start-stop-daemon --oknodo --stop --quiet --exec $DAEMONACPI
	   log_end_msg $?
      fi
	;;
  restart|force-reload)
      $0 stop
      exec $0 start
      ;;
  *)
	echo "Usage: $0 {start|stop|restart|force-reload}" >&2
	exit 1
	;;
esac

exit 0
