Commit ee11890a authored by Tails developers's avatar Tails developers
Browse files

Patch initscripts headers instead of fiddling with update-rc.d

Calling update-rc.d manually is quite error prone: for example, 'ttdnsd' is
actually required to be started after 'tor', but this was not reflected in the
number sequence.

Instead, we now patch the initscripts and rely on insserv to figure out the
correct ordering for the startup and shutdown sequence.

The patch to kexec-load is adjusted for consistency.
parent 38f21060
#!/bin/sh
CUSTOM_INITSCRIPTS="
tails-detect-virtualization
tails-kexec
tails-reconfigure-kexec
tails-reconfigure-memlockd
tails-sdmem-on-media-removal
"
PATCHED_INITSCRIPTS="
gdomap
hdparm
i2p
kexec
kexec-load
memlockd
network-manager
plymouth
tor
ttdnsd
"
# Ensure that we are using dependency based boot
if ! dpkg -s insserv >/dev/null 2>&1 || [ -f /etc/init.d/.legacy-bootordering ]; then
echo "Dependency based boot sequencing is not configured. Aborting." >&2
exit 1
fi
echo "managing initscripts"
# enable custom initscripts
update-rc.d tails-detect-virtualization start 17 S .
update-rc.d tails-kexec stop 85 0 6 .
update-rc.d tails-reconfigure-kexec start 23 2 3 4 5 .
update-rc.d tails-reconfigure-memlockd start 23 2 3 4 5 .
update-rc.d tails-sdmem-on-media-removal start 24 2 3 4 5 . stop 01 0 6
# Start memlockd before media removal watchdog and skip stop on shutdown to
# keep files needed by tails-kexec properly in memory.
update-rc.d -f memlockd remove
sed -e '/^### BEGIN INIT INFO$/,/^### END INIT INFO$/ {
s/^\(# Required-Stop:\).*$/\1/
s/^\(# Default-Stop:\).*$/\1/
}' -i /etc/init.d/memlockd
update-rc.d memlockd start 22 2 3 4 5 .
# we run Tor ourselves after HTP via NetworkManager hooks
update-rc.d tor disable
# we provide our own tails-kexec initscript (more friendly to ejected CD/USB)
update-rc.d -f kexec remove
# we use kexec on halt too => enable kexec-load initscript on runlevel 0 as well
update-rc.d -f kexec-load remove
update-rc.d kexec-load stop 18 0 6 .
# i2p should not start per default. At some point we want some script to start
# i2p during init if so selected in tails-greeter, but ATM users have to start
# the i2p script manually.
update-rc.d i2p disable
# we only want hdparm so that laptop-mode-tools can use it
update-rc.d hdparm disable
# don't use plymouth at shutdown/reboot
# (plymouth.postinst creates links using update-rc.d,
# so we cannot disable the links it creates by using LSB headers)
rm -f /etc/rc[06].d/*plymouth
echo "configuring boot sequence"
# gdomap is not used between processes running as the same user on the same host
update-rc.d gdomap disable
# The patches to adjust the runlevels are applied to the chroot
# after the packages have been installed. So we need to remove them first,
# to re-install them with our settings.
insserv -r $PATCHED_INITSCRIPTS
# we start NetworkManager ourselves, via tails-greeter, at PostLogin time
update-rc.d network-manager disable
# Re-install overriden initscripts and install our custom ones.
insserv $PATCHED_INITSCRIPTS $CUSTOM_INITSCRIPTS
Tails specific: we provide our own tails-kexec initscript
(more friendly to ejected CD/USB).
--- chroot.orig/etc/init.d/kexec 2012-09-24 10:05:13.065048881 +0200
+++ chroot/etc/init.d/kexec 2012-09-24 10:03:30.638108333 +0200
@@ -8,1 +8,1 @@
-# Default-Stop: 6
+# Default-Stop:
Tails specific: we don't use Plymouth on shutdown/reboot.
--- chroot.orig/etc/init.d/plymouth 2012-09-24 10:05:13.161051646 +0200
+++ chroot/etc/init.d/plymouth 2012-09-24 10:03:30.638108333 +0200
@@ -8,3 +8,3 @@
-# Should-Stop: gdm gdm3 kdm xdm slim nodm
+# Should-Stop:
# Default-Start: 2 3 4 5
-# Default-Stop: 0 6
+# Default-Stop:
Tails specific: gdomap is not used between processes running as the same user
on the same host.
--- chroot.orig/etc/init.d/gdomap 2012-09-24 10:10:20.733885443 +0200
+++ chroot/etc/init.d/gdomap 2012-09-24 10:05:12.829042105 +0200
@@ -6,2 +6,2 @@
-# Default-Start: 2 3 4 5
+# Default-Start:
-# Default-Stop: 0 1 6
+# Default-Stop: 0 1 6 2 3 4 5
Tails specific: we only want hdparm so that laptop-mode-tools can use it.
--- chroot.orig/etc/init.d/hdparm 2012-09-24 10:05:12.877043486 +0200
+++ chroot/etc/init.d/hdparm 2012-09-24 10:03:30.638108333 +0200
@@ -8,2 +8,2 @@
-# Default-Start: S
+# Default-Start:
-# Default-Stop:
+# Default-Stop: S
Tails specific: i2p sould not start per default. At some point we want
some script to start i2p during init if so selected in tails-greeter,
but at the moment users have to start the i2p script manually.
--- chroot.orig/etc/init.d/i2p 2012-09-24 10:05:13.021047615 +0200
+++ chroot/etc/init.d/i2p 2012-09-24 10:03:30.638108333 +0200
@@ -7,2 +7,2 @@
-# Default-Start: 2 3 4 5
+# Default-Start:
-# Default-Stop: 0 1 6
+# Default-Stop: 0 1 6 2 3 4 5
Tails specific: we start NetworkManager ourselves, via tails-greeter, at
PostLogin time.
--- chroot.orig/etc/init.d/network-manager 2012-09-24 10:05:13.157051525 +0200
+++ chroot/etc/init.d/network-manager 2012-09-24 10:03:30.638108333 +0200
@@ -8,2 +8,2 @@
-# Default-Start: 2 3 4 5
+# Default-Start:
-# Default-Stop: 0 1 6
+# Default-Stop: 0 1 6 2 3 4 5
Tails specific: Tor is started after HTP via NetworkManager hooks.
--- chroot.orig/etc/init.d/tor 2012-09-24 10:05:13.329056459 +0200
+++ chroot/etc/init.d/tor 2012-09-24 10:03:30.638108333 +0200
@@ -9,2 +9,2 @@
-# Default-Start: 2 3 4 5
+# Default-Start:
-# Default-Stop: 0 1 6
+# Default-Stop: 0 1 6 2 3 4 5
Tails specific: ttdnsd is started via NetworkManager hooks
--- chroot.orig/etc/init.d/ttdnsd 2012-09-24 10:05:13.333056580 +0200
+++ chroot/etc/init.d/ttdnsd 2012-09-24 10:03:30.638108333 +0200
@@ -6,2 +6,2 @@
-# Default-Start: 2 3 4 5
+# Default-Start:
-# Default-Stop: 0 1 6
+# Default-Stop: 0 1 6 2 3 4 5
Tails specific: do not stop memlockd on shutdown to keep files needed
by tails-kexec properly loaded in memory.
--- chroot.orig/etc/init.d/memlockd 2012-09-24 10:05:13.085049457 +0200
+++ chroot/etc/init.d/memlockd 2012-09-24 10:03:30.638108333 +0200
@@ -5,3 +5,3 @@
-# Required-Stop: $remote_fs $syslog
+# Required-Stop:
# Default-Start: 2 3 4 5
-# Default-Stop: 0 1 6
+# Default-Stop:
--- chroot.orig/etc/init.d/kexec-load 2011-01-14 12:30:05.089859516 +0100
+++ chroot/etc/init.d/kexec-load 2011-01-14 12:30:29.159667183 +0100
@@ -5,7 +5,7 @@
# Required-Stop: $local_fs $remote_fs kexec
# Should-Stop: autofs
# Default-Start:
Tails specific: we use kexec on both halt (runlevel 0) on top of reboot
(runlevel 6).
--- chroot.orig/etc/init.d/kexec-load 2011-01-14 12:30:05.089859516 +0100
+++ chroot/etc/init.d/kexec-load 2011-01-14 12:30:29.159667183 +0100
@@ -8,1 +8,1 @@
-# Default-Stop: 6
+# Default-Stop: 0 6
# Short-Description: Load kernel image with kexec
# Description:
### END INIT INFO
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment