#!/bin/bash
# Copyright (c) 2008 Alon Swartz <alon@turnkeylinux.org> - all rights reserved
### BEGIN INIT INFO
# Provides:          di-live
# Required-Start:    $syslog
# Required-Stop:
# Should-Start:      $local_fs
# Should-Stop:       halt reboot
# Default-Start:     S
# Default-Stop:      0 6
# Short-Description: TurnKey Linux installer (di-live)
# Description:       On 'start' will launch di-live, if set as boot option
#                    On 'stop' will eject disc and prompt user, if post install
### END INIT INFO

NAME=di-live

set -e
. /lib/lsb/init-functions

case "$1" in
  start)
        grep -qs di-live /proc/cmdline || exit 0

        log_begin_msg "Starting $NAME"
        FGCONSOLE=$(fgconsole)
        FGVT=$FGCONSOLE openvt -f -c 8 -s -w -- di-live
        chvt $FGCONSOLE
        log_action_end_msg $?
        ;;

  stop)
        # Nothing to do
        exit 0
        ;;

  restart|reload|force-reload)
        echo "Error: argument '$1' not supported" >&2
        exit 3
        ;;

  *)
    N=/etc/init.d/$NAME
    echo "Usage: $N {start|stop}" >&2
    exit 1
  ;;
esac

exit 0
