summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorintrigeri <intrigeri@boum.org>2015-03-09 22:47:53 +0000
committerintrigeri <intrigeri@boum.org>2015-03-10 00:21:08 +0000
commit351e7c08e09f9add3b59ef5aa97a060433f39fa5 (patch)
treed822aa55e80701c08c92da7843030fe649811b1b
parentca870ffc691f8515780336e193cc52c92c215ae4 (diff)
Turn the remote shell into a systemd native service.feature/jessie-remote-shell-systemd
And while I'm it, make it use the sd_notify facility instead of a state file.
-rwxr-xr-xconfig/chroot_local-hooks/52-update-rc.d1
-rwxr-xr-xconfig/chroot_local-includes/etc/init.d/tails-autotest-remote-shell75
-rw-r--r--config/chroot_local-includes/lib/systemd/system/tails-autotest-remote-shell.service11
-rwxr-xr-xconfig/chroot_local-includes/usr/local/lib/tails-autotest-remote-shell8
-rw-r--r--config/chroot_local-packageslists/tails-common.list1
-rw-r--r--wiki/src/contribute/release_process/test/automated_tests.mdwn2
6 files changed, 18 insertions, 80 deletions
diff --git a/config/chroot_local-hooks/52-update-rc.d b/config/chroot_local-hooks/52-update-rc.d
index 2b413a3..86d8236 100755
--- a/config/chroot_local-hooks/52-update-rc.d
+++ b/config/chroot_local-hooks/52-update-rc.d
@@ -37,6 +37,7 @@ insserv $PATCHED_INITSCRIPTS $CUSTOM_INITSCRIPTS
systemctl enable memlockd.service
# Enable our own systemd unit files
+systemctl enable tails-autotest-remote-shell.service
systemctl enable tails-reconfigure-kexec.service
systemctl enable tails-reconfigure-memlockd.service
systemctl enable tails-sdmem-on-media-removal.service
diff --git a/config/chroot_local-includes/etc/init.d/tails-autotest-remote-shell b/config/chroot_local-includes/etc/init.d/tails-autotest-remote-shell
deleted file mode 100755
index d035f74..0000000
--- a/config/chroot_local-includes/etc/init.d/tails-autotest-remote-shell
+++ /dev/null
@@ -1,75 +0,0 @@
-#! /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
-
-:
diff --git a/config/chroot_local-includes/lib/systemd/system/tails-autotest-remote-shell.service b/config/chroot_local-includes/lib/systemd/system/tails-autotest-remote-shell.service
new file mode 100644
index 0000000..2530ec7
--- /dev/null
+++ b/config/chroot_local-includes/lib/systemd/system/tails-autotest-remote-shell.service
@@ -0,0 +1,11 @@
+[Unit]
+Description=Remote shell (over serial link) used in Tails test suite
+ConditionKernelCommandLine=autotest_never_use_this_option
+Before=gdm.service
+
+[Service]
+Type=notify
+ExecStart=/usr/local/lib/tails-autotest-remote-shell /dev/ttyS0
+
+[Install]
+WantedBy=multi-user.target
diff --git a/config/chroot_local-includes/usr/local/lib/tails-autotest-remote-shell b/config/chroot_local-includes/usr/local/lib/tails-autotest-remote-shell
index 02b1f34..3da677c 100755
--- a/config/chroot_local-includes/usr/local/lib/tails-autotest-remote-shell
+++ b/config/chroot_local-includes/usr/local/lib/tails-autotest-remote-shell
@@ -11,6 +11,7 @@ from pwd import getpwnam
from os import setgid, setuid, environ
from glob import glob
import serial
+import systemd.daemon.notify as sd_notify
def mk_switch_user_fn(uid, gid):
def switch_user():
@@ -43,10 +44,9 @@ def main():
if not port.isOpen():
port.open()
- # Create a state file so other applications can know that the remote
- # shell is operational.
- state_file_path = "/var/lib/live/autotest-remote-shell-running"
- open(state_file_path, "w").close()
+ # Notify systemd that we're ready
+ sd_notify('READY=1')
+ sd_notify('STATUS=Processing requests...\n')
while True:
try:
diff --git a/config/chroot_local-packageslists/tails-common.list b/config/chroot_local-packageslists/tails-common.list
index eafa46f..b248bb6 100644
--- a/config/chroot_local-packageslists/tails-common.list
+++ b/config/chroot_local-packageslists/tails-common.list
@@ -408,6 +408,7 @@ wireless-regdb
### Automated test suite
python-serial
+python3-systemd
xdotool
i2p
diff --git a/wiki/src/contribute/release_process/test/automated_tests.mdwn b/wiki/src/contribute/release_process/test/automated_tests.mdwn
index e914bff..ada08a1 100644
--- a/wiki/src/contribute/release_process/test/automated_tests.mdwn
+++ b/wiki/src/contribute/release_process/test/automated_tests.mdwn
@@ -111,7 +111,7 @@ Requirements on the guest (the remote shell server):
Scripts:
* [[!tails_gitweb config/chroot_local-includes/usr/local/lib/tails-autotest-remote-shell]]
-* [[!tails_gitweb config/chroot_local-includes/etc/init.d/tails-autotest-remote-shell]]
+* [[!tails_gitweb config/chroot_local-includes/lib/systemd/system/tails-autotest-remote-shell.service]]
# The art of writing new product test cases