#!/bin/sh
# Copyright (c) 2009 Alon Swartz <alon@turnkeylinux.org> - all rights reserved

### BEGIN INIT INFO
# Provides:          inithooks
# Required-Start:    $local_fs $network $named
# Required-Stop:     $local_fs $network $named
# Default-Start:     2 3 4 5
# Default-Stop:      0 1 6
# Short-Description: Executes initialization hooks at boot time
# Description:       Executes firstboot and everyboot scripts
### END INIT INFO

DESC="Initialization hooks"
NAME=inithooks

# Exit if openvt is not available
which openvt >/dev/null || exit 0

. /lib/lsb/init-functions
. /etc/default/inithooks

case "$1" in
  start)
    log_begin_msg "Starting $DESC"
    setterm -blank 0
    chvt 1
    openvt -c 8 -s -w -- $INITHOOKS_PATH/run
    log_action_end_msg $?
    ;;

  stop)
    exit 0
    ;;

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

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

exit 0
