#!/bin/bash
### BEGIN INIT INFO
# Provides:            shell
# Required-Start:
# Should-Start:
# Required-Stop:
# Should-Stop:
# Default-Start:       3 4 5
# Default-Stop:
# Short-Description:   Runs emergency shell
# Description:         Runs emergency shell
### END INIT INFO

. /etc/init.d/template

export RDSHELL_FOREVER=1

NAME=rdshell
ARGS="--lockfile $LOCKFILE --pidfile /var/run/$NAME.pid --name $NAME --displayname shell"

start()
{
	start_daemon $ARGS --background "$NAME"
	RETVAL=$?
	[ "$RETVAL" != 0 ] ||
		/lib/initrd/rootdelay &
	return $RETVAL
}

stop() {
	stop_daemon $ARGS -- "$NAME"
	RETVAL=$?
	{
		local pid=
		read -r pid < /var/run/rootdelay.pid
		[ -z "$pid" ] ||
			kill "$pid"
	} >/dev/null 2>&1
	return $RETVAL
}

switch "${1-}"
