[PATCH f17-branch 1/4] Let systemd handle terminal setup, fix possible race with NM

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Add a systemd-generator script that puts anaconda on the correct console
tty, then puts shells on tty2 and the first virtualization console
(unless we're using it for anaconda).

Adding "TTYPath" to the systemd services means systemd takes care of
setting up all the terminal stuff - picking the right TERM value,
setting the keyboard mode to K_UNICODE, and all that esoteric weirdness.

Also, move anaconda's dependencies into anaconda.target, and make
anaconda start *after* anaconda.target, just so we can be sure that e.g.
NetworkManager is active before anaconda starts.

(as a bonus, it also shuts off plymouth correctly, just in case we ever
want to have a anaconda-specific bootsplash)
---
 anaconda.spec.in                     |    1 +
 data/systemd/Makefile.am             |    4 +++-
 data/systemd/anaconda-generator      |   34 ++++++++++++++++++++++++++++++++++
 data/systemd/anaconda-shell@.service |    5 ++---
 data/systemd/anaconda.service        |   13 -------------
 data/systemd/anaconda.target         |   12 ++++++++----
 data/systemd/anaconda@.service       |   13 +++++++++++++
 7 files changed, 61 insertions(+), 21 deletions(-)
 create mode 100755 data/systemd/anaconda-generator
 delete mode 100644 data/systemd/anaconda.service
 create mode 100644 data/systemd/anaconda@.service

diff --git a/anaconda.spec.in b/anaconda.spec.in
index 31ea1e2..84882c2 100644
--- a/anaconda.spec.in
+++ b/anaconda.spec.in
@@ -225,6 +225,7 @@ update-desktop-database &> /dev/null || :
 %doc docs/install-methods.txt
 %doc docs/mediacheck.txt
 /lib/systemd/system/*
+/lib/systemd/system-generators/*
 /lib/udev/rules.d/70-anaconda.rules
 %{_bindir}/instperf
 %{_sbindir}/anaconda
diff --git a/data/systemd/Makefile.am b/data/systemd/Makefile.am
index 589854c..ae89c18 100644
--- a/data/systemd/Makefile.am
+++ b/data/systemd/Makefile.am
@@ -18,5 +18,7 @@
 # Author: Chris Lumens <clumens@xxxxxxxxxx>
 
 systemddir = /lib/systemd/system
-dist_systemd_DATA = anaconda-shell@.service anaconda.target anaconda.service instperf.service
+generatordir = /lib/systemd/system-generators
+dist_systemd_DATA = anaconda-shell@.service anaconda.target anaconda@.service instperf.service
+dist_generator_SCRIPTS = anaconda-generator
 MAINTAINERCLEANFILES = Makefile.in
diff --git a/data/systemd/anaconda-generator b/data/systemd/anaconda-generator
new file mode 100755
index 0000000..6545572
--- /dev/null
+++ b/data/systemd/anaconda-generator
@@ -0,0 +1,34 @@
+#!/bin/bash
+# anaconda-generator: generate services needed for anaconda operation
+
+# set up dirs
+systemd_dir=/lib/systemd/system
+target_dir=$systemd_dir/anaconda.target.wants
+mkdir -p $target_dir
+
+# create symlink anaconda.target.wants/SERVICE@TTY.service
+service_on_tty() {
+    local service="$1" tty="$2"
+    local service_instance="${service/@.service/@$tty.service}"
+    ln -sf $systemd_dir/$service $target_dir/$service_instance
+}
+
+# find the real tty for /dev/console
+tty="console"
+while [ -f /sys/class/tty/$tty/active ]; do
+    tty=$(< /sys/class/tty/$tty/active)
+    tty=${tty##* } # last item in the list
+done
+consoletty="$tty"
+
+# put anaconda on the real console
+service_on_tty anaconda@.service $consoletty
+
+# put a shell on tty2 and the first virtualization console we find
+for tty in tty2 hvc0 hvc1 xvc0 hvsi0 hvsi1 hvsi2; do
+    [ "$tty" = "$consoletty" ] && continue
+    if [ -d /sys/class/tty/$tty ]; then
+        service_on_tty anaconda-shell@.service $tty
+        [ "$tty" != "tty2" ] && break
+    fi
+done
diff --git a/data/systemd/anaconda-shell@.service b/data/systemd/anaconda-shell@.service
index ad2141e..52bed74 100644
--- a/data/systemd/anaconda-shell@.service
+++ b/data/systemd/anaconda-shell@.service
@@ -6,14 +6,13 @@ BindTo=dev-%i.device
 After=dev-%i.device systemd-user-sessions.service plymouth-quit-wait.service
 
 [Service]
-Environment=TERM=linux
 WorkingDirectory=/
 ExecStart=-/sbin/agetty -n -l /bin/bash -o '--login' %I 38400
 Restart=always
 RestartSec=0
-TimeoutSec=0
-TTYPath=/dev/%i
+TTYPath=/dev/%I
 TTYReset=yes
 TTYVHangup=yes
 TTYVTDisallocate=yes
+KillMode=process
 KillSignal=SIGHUP
diff --git a/data/systemd/anaconda.service b/data/systemd/anaconda.service
deleted file mode 100644
index 45061cc..0000000
--- a/data/systemd/anaconda.service
+++ /dev/null
@@ -1,13 +0,0 @@
-[Unit]
-Description=the anaconda installation program
-Wants=instperf.service rsyslog.service udev-settle.service NetworkManager.service
-After=instperf.service rsyslog.service udev-settle.service NetworkManager.service
-
-[Service]
-Environment=HOME=/root MALLOC_CHECK_=2 MALLOC_PERTURB_=204 PATH=/usr/bin:/bin:/sbin:/usr/sbin:/mnt/sysimage/bin:/mnt/sysimage/usr/bin:/mnt/sysimage/usr/sbin:/mnt/sysimage/sbin PYTHONPATH=/tmp/updates
-Type=oneshot
-WorkingDirectory=/root
-ExecStart=/usr/sbin/anaconda
-StandardInput=tty-force
-TTYReset=yes
-TimeoutSec=0
diff --git a/data/systemd/anaconda.target b/data/systemd/anaconda.target
index 9f7f3be..983ff3b 100644
--- a/data/systemd/anaconda.target
+++ b/data/systemd/anaconda.target
@@ -1,7 +1,11 @@
 [Unit]
-Description=The anaconda installation program
+Description=Anaconda System Services
 Requires=basic.target
-Conflicts=rescue.service rescue.target
-After=basic.target rescue.service rescue.target
+After=basic.target
 AllowIsolate=yes
-Wants=anaconda.service anaconda-shell@tty2.service anaconda-shell@hvc1.service fedora-import-state.service
+Before=anaconda@.service
+Wants=instperf.service
+Wants=rsyslog.service
+Wants=udev-settle.service
+Wants=NetworkManager.service
+Wants=plymouth-quit.service plymouth-quit-wait.service
diff --git a/data/systemd/anaconda@.service b/data/systemd/anaconda@.service
new file mode 100644
index 0000000..903df7a
--- /dev/null
+++ b/data/systemd/anaconda@.service
@@ -0,0 +1,13 @@
+[Unit]
+Description=Anaconda
+After=anaconda.target
+
+[Service]
+Environment=HOME=/root MALLOC_CHECK_=2 MALLOC_PERTURB_=204 PATH=/usr/bin:/bin:/sbin:/usr/sbin:/mnt/sysimage/bin:/mnt/sysimage/usr/bin:/mnt/sysimage/usr/sbin:/mnt/sysimage/sbin PYTHONPATH=/tmp/updates
+Type=oneshot
+WorkingDirectory=/root
+ExecStart=/usr/sbin/anaconda
+StandardInput=tty-force
+TTYPath=/dev/%I
+TTYReset=yes
+TimeoutSec=0
-- 
1.7.7.6

_______________________________________________
Anaconda-devel-list mailing list
Anaconda-devel-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/anaconda-devel-list


[Index of Archives]     [Kickstart]     [Fedora Users]     [Fedora Legacy List]     [Fedora Maintainers]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [Yosemite Photos]     [KDE Users]     [Fedora Tools]
  Powered by Linux