summaryrefslogtreecommitdiffstats
path: root/config/chroot_local-includes/etc/init.d/tails-autotest-remote-shell
blob: d035f74cc608938f2dcae5612bb6f55246690759 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
#! /bin/sh
### BEGIN INIT INFO
# Provides:          tails-autotest-remote-shell
# Required-Start:    mountkernfs $local_fs
# Required-Stop:     
# Default-Start:     2 3 4 5
# Default-Stop:      
# X-Start-Before:    $x-display-manager gdm gdm3
# Short-Description: Remote shell (over serial link) used in Tails test suite
# Description:       Remote shell (over serial link) used in Tails test suite
### END INIT INFO

# Author: Tails Developers <tails@boum.org>

# PATH should only include /usr/* if it runs after the mountnfs.sh script
PATH="/usr/sbin:/usr/bin:/sbin:/bin"
DESC="Remote shell (over serial link) used in Tails test suite"
NAME="tails-autotest-remote-shell"
SCRIPTNAME="/etc/init.d/${NAME}"
DAEMON="/usr/local/lib/${NAME}"
DAEMON_ARGS="/dev/ttyS0"

# Exit if not run by Tails automated test suite. The if-construction
# below may seem silly but we really want to only continue running
# this script this if the expected kernel command-line option is
# present. Fail safe, not open, and all that.
if grep -qw "autotest_never_use_this_option" /proc/cmdline
then
	:
else
	exit 0
fi

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

# Define LSB log_* functions.
# Depend on lsb-base (>= 3.2-14) to ensure that this file is present
# and status_of_proc is working.
. /lib/lsb/init-functions

wait_until_remote_shell_is_listening()
{
	REMOTE_SHELL_STATE_FILE=/var/lib/live/autotest-remote-shell-running
	until [ -e "${REMOTE_SHELL_STATE_FILE}" ]; do
		sleep 1
	done
}

do_start()
{
	start-stop-daemon \
		--start \
		--quiet \
		--background \
		--exec ${DAEMON} -- ${DAEMON_ARGS}
	wait_until_remote_shell_is_listening
}

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

: