summaryrefslogtreecommitdiffstats
path: root/data
diff options
context:
space:
mode:
authorWill Woods <wwoods@redhat.com>2012-03-21 20:02:44 -0400
committerBrian C. Lane <bcl@redhat.com>2012-03-21 21:10:08 -0700
commitbabdb092ff02a6ce2300105b9e17734c82edb7ed (patch)
tree80a253676ba05b0ceded6e9293042cc169bdfda3 /data
parentec2655b31b272dbc181ceb9ee663e858e8bda308 (diff)
downloadanaconda-babdb092ff02a6ce2300105b9e17734c82edb7ed.tar.gz
anaconda-babdb092ff02a6ce2300105b9e17734c82edb7ed.tar.xz
anaconda-babdb092ff02a6ce2300105b9e17734c82edb7ed.zip
Let systemd handle terminal setup, fix possible race with NM
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)
Diffstat (limited to 'data')
-rw-r--r--data/systemd/Makefile.am4
-rwxr-xr-xdata/systemd/anaconda-generator34
-rw-r--r--data/systemd/anaconda-shell@.service5
-rw-r--r--data/systemd/anaconda.target12
-rw-r--r--data/systemd/anaconda@.service (renamed from data/systemd/anaconda.service)9
5 files changed, 52 insertions, 12 deletions
diff --git a/data/systemd/Makefile.am b/data/systemd/Makefile.am
index 589854cfa..ae89c1806 100644
--- a/data/systemd/Makefile.am
+++ b/data/systemd/Makefile.am
@@ -18,5 +18,7 @@
# Author: Chris Lumens <clumens@redhat.com>
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 000000000..654557278
--- /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 ad2141ee0..52bed74b5 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.target b/data/systemd/anaconda.target
index 9f7f3be07..983ff3b77 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
index 8e853aae2..903df7a85 100644
--- a/data/systemd/anaconda.service
+++ b/data/systemd/anaconda@.service
@@ -1,12 +1,13 @@
[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
+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 TERM=linux
+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