#! /bin/sh
### BEGIN INIT INFO
# Provides:          hurd-console
# Required-Start:    $remote_fs
# Required-Stop:     $remote_fs
# Default-Start:     1 2 3 4 5
# Default-Stop:      
# Short-Description: Hurd console
# Description:       The Hurd console.
### END INIT INFO

# Author: Pino Toscano <pino@debian.org>

PATH=/sbin:/usr/sbin:/bin:/usr/bin
DESC="Hurd console"
NAME=console
LONGNAME=hurd-console
DAEMON=/bin/$NAME
PIDFILE=/var/run/$LONGNAME.pid
SCRIPTNAME=/etc/init.d/$LONGNAME

# Exit if the package is not installed
[ -x "$DAEMON" ] || exit 0

# Read configuration variable file if it is present
if [ -e /etc/default/$LONGNAME ]; then
	unset DISPLAY KBD KBD_REPEAT MOUSE MOUSE_REPEAT SPEAKER
	. /etc/default/$LONGNAME
fi

# Load the VERBOSE setting and other rcS variables
. /lib/init/vars.sh

# Define LSB log_* functions.
. /lib/lsb/init-functions

#
# Function that starts the daemon/service
#
do_start()
{
	# Return
	#   0 if daemon has been started
	#   1 if daemon was already running
	#   2 if daemon could not be started
	start-stop-daemon --start --quiet --pidfile $PIDFILE --exec $DAEMON --test > /dev/null \
		|| return 1
	start-stop-daemon --start --quiet --pidfile $PIDFILE --exec $DAEMON \
		--background --make-pidfile -- \
		${DISPLAY} ${KBD} ${KBD_REPEAT} ${SPEAKER} ${MOUSE} ${MOUSE_REPEAT} \
		-d current_vcs -c /dev/vcs \
		|| return 2
}

case "$1" in
  start)
	[ "$ENABLE" = "true" ] || exit 0
	[ "$VERBOSE" != no ] && log_daemon_msg "Starting $DESC" "$NAME"
	do_start
	case "$?" in
		0|1) [ "$VERBOSE" != no ] && log_end_msg 0 ;;
		2) [ "$VERBOSE" != no ] && log_end_msg 1 ;;
	esac
	;;
  stop)
	;;
  status)
       status_of_proc "$DAEMON" "$NAME" && exit 0 || exit $?
       ;;
  restart|force-reload)
	;;
  *)
	echo "Usage: $SCRIPTNAME {start|stop|status|restart|force-reload}" >&2
	exit 3
	;;
esac

:
