Here's two patches to simplify anaconda-generator, and fix inst.noshell.
Both patches move the commandline checking stuff out of anaconda-generator and into the systemd unit files themselves. This should make the behavior easier for other people to understand (and control).
The first patch fixes inst.noshell by disabling tmux when inst.noshell or noshell is present, since it lets you create new shells. See commit ad34bcdc for the other half of the inst.noshell fix.
The second patch just moves the anaconda-sshd console logic out of anaconda-generator and into the unit files. No behavior changes are expected there.
I've tested to confirm that everything works as expected: tmux and tty2 show up normally, inst.noshell suppresses both, and inst.sshd starts sshd.
-w
If we're running with 'inst.noshell', then the system administrator wants this to be a hands-off install. And tmux is very hands-on, and it lets you create new shells if you want. So we should probably disable tmux when running with inst.noshell.
This patch moves the logic for deciding when to use anaconda-direct.service or anaconda.service out of anaconda-generator and into the units themselves. The behavior should mostly be the same as before, i.e.:
anaconda-direct on s390, otherwise anaconda+tmux
But now we want to use anaconda-direct instead of tmux when we have inst.noshell, so it's:
anaconda-direct on s390 or with inst.noshell, otherwise anaconda+tmux --- data/systemd/anaconda-direct.service | 4 ++++ data/systemd/anaconda-generator | 8 ++------ data/systemd/anaconda-tmux@.service | 10 ++++++++-- data/systemd/anaconda.service | 2 ++ data/systemd/anaconda.target | 1 + 5 files changed, 17 insertions(+), 8 deletions(-)
diff --git a/data/systemd/anaconda-direct.service b/data/systemd/anaconda-direct.service index 61df8ca..b4c1f2f 100644 --- a/data/systemd/anaconda-direct.service +++ b/data/systemd/anaconda-direct.service @@ -6,6 +6,10 @@ Description=the anaconda installation program Wants=instperf.service rsyslog.service systemd-udev-settle.service NetworkManager.service After=instperf.service rsyslog.service systemd-udev-settle.service NetworkManager.service anaconda-sshd.service Requires=anaconda.service +# TODO: use ConditionArchitecture in systemd v210 or later +ConditionPathIsDirectory=|/sys/hypervisor/s390 +ConditionKernelCommandLine=|noshell +ConditionKernelCommandLine=|inst.noshell
[Service] Environment=HOME=/root MALLOC_CHECK_=2 MALLOC_PERTURB_=204 PATH=/usr/bin:/bin:/sbin:/usr diff --git a/data/systemd/anaconda-generator b/data/systemd/anaconda-generator index 1118d92..3f89fcf 100755 --- a/data/systemd/anaconda-generator +++ b/data/systemd/anaconda-generator @@ -24,12 +24,8 @@ while [ -f /sys/class/tty/$tty/active ]; do done consoletty="$tty"
-# put anaconda on the real console if not s390x, otherwise put anaconda direct -if [ $(uname -m) = "s390x" ]; then - ln -sf $systemd_dir/anaconda-direct.service $target_dir/ -else - service_on_tty anaconda-tmux@.service $consoletty -fi +# put anaconda's tmux session on the console +service_on_tty anaconda-tmux@.service $consoletty
# put a shell on the first virtualization console we find for tty in hvc0 hvc1 xvc0 hvsi0 hvsi1 hvsi2; do diff --git a/data/systemd/anaconda-tmux@.service b/data/systemd/anaconda-tmux@.service index 0b83765..6a3f58d 100644 --- a/data/systemd/anaconda-tmux@.service +++ b/data/systemd/anaconda-tmux@.service @@ -2,14 +2,20 @@ Description=Anaconda Text Console Requires=anaconda.service After=anaconda.target anaconda.service +ConditionKernelCommandLine=!noshell +ConditionKernelCommandLine=!inst.noshell
[Service] -Type=simple +Type=idle WorkingDirectory=/root Environment=LANG=en_US.UTF-8 ExecStartPre=/usr/bin/echo -e \033%G ExecStart=/usr/bin/tmux -u attach -t anaconda -StandardInput=tty-force +StandardInput=tty +StandardOutput=tty TTYPath=/dev/%I TTYReset=yes +TTYVHangup=yes +TTYVTDisallocate=yes Restart=always +RestartSec=0 diff --git a/data/systemd/anaconda.service b/data/systemd/anaconda.service index 0946d70..e6104b0 100644 --- a/data/systemd/anaconda.service +++ b/data/systemd/anaconda.service @@ -1,6 +1,8 @@ [Unit] Description=Anaconda After=anaconda.target +ConditionKernelCommandLine=!noshell +ConditionKernelCommandLine=!inst.noshell
[Service] Type=forking diff --git a/data/systemd/anaconda.target b/data/systemd/anaconda.target index 77e42ff..a5c8724 100644 --- a/data/systemd/anaconda.target +++ b/data/systemd/anaconda.target @@ -8,3 +8,4 @@ Wants=rsyslog.service Wants=systemd-udev-settle.service Wants=NetworkManager.service Wants=plymouth-quit.service plymouth-quit-wait.service +Wants=anaconda-direct.service anaconda.service
This just moves the logic for starting anaconda-sshd into the systemd unit file(s), so there's less stuff for us to maintain.
Note the '/sys/hypervisor/s390' test to see if we're on s390 (and therefore our console is probably bunk). Later we can change that to ConditionArchitecture, which is slightly cleaner; Ideally we'd want to actually check the console capabilities but that's way trickier than you'd think. --- data/systemd/anaconda-generator | 12 ------------ data/systemd/anaconda-sshd.service | 4 ++++ data/systemd/anaconda.target | 1 + 3 files changed, 5 insertions(+), 12 deletions(-)
diff --git a/data/systemd/anaconda-generator b/data/systemd/anaconda-generator index 3f89fcf..f09cb3b 100755 --- a/data/systemd/anaconda-generator +++ b/data/systemd/anaconda-generator @@ -1,9 +1,6 @@ #!/bin/bash # anaconda-generator: generate services needed for anaconda operation
-# Source in the dracut lib so we can parse cmd line arguments -. /usr/lib/dracut/modules.d/99base/dracut-lib.sh - # set up dirs systemd_dir=/lib/systemd/system target_dir=$systemd_dir/anaconda.target.wants @@ -34,12 +31,3 @@ for tty in hvc0 hvc1 xvc0 hvsi0 hvsi1 hvsi2; do service_on_tty anaconda-shell@.service $tty fi done - -# enable the ssh service -# NOTE: We have a match for s390x here because the console sucks on that -# platform. Really any platform with a crappy console that can't do curses -# or have multiple VTs should get sshd spawned automatically, but we don't -# yet have a good way of detecting these platforms. -if getargbool 0 sshd inst.sshd || [ $(uname -m) = "s390x" ]; then - ln -sf $systemd_dir/anaconda-sshd.service $target_dir/anaconda-sshd.service -fi diff --git a/data/systemd/anaconda-sshd.service b/data/systemd/anaconda-sshd.service index 2588a53..5209200 100644 --- a/data/systemd/anaconda-sshd.service +++ b/data/systemd/anaconda-sshd.service @@ -2,6 +2,10 @@ Description=OpenSSH server daemon Before=anaconda.target After=syslog.target network.target +ConditionKernelCommandLine=|sshd +ConditionKernelCommandLine=|inst.sshd +# TODO: use ConditionArchitecture in systemd v210 or later +ConditionPathIsDirectory=|/sys/hypervisor/s390
[Service] EnvironmentFile=/etc/sysconfig/sshd diff --git a/data/systemd/anaconda.target b/data/systemd/anaconda.target index a5c8724..bafad64 100644 --- a/data/systemd/anaconda.target +++ b/data/systemd/anaconda.target @@ -9,3 +9,4 @@ Wants=systemd-udev-settle.service Wants=NetworkManager.service Wants=plymouth-quit.service plymouth-quit-wait.service Wants=anaconda-direct.service anaconda.service +Wants=anaconda-sshd.service
On Mon, 2014-02-24 at 11:20 -0500, Will Woods wrote:
Here's two patches to simplify anaconda-generator, and fix inst.noshell.
Both patches move the commandline checking stuff out of anaconda-generator and into the systemd unit files themselves. This should make the behavior easier for other people to understand (and control).
The first patch fixes inst.noshell by disabling tmux when inst.noshell or noshell is present, since it lets you create new shells. See commit ad34bcdc for the other half of the inst.noshell fix.
The second patch just moves the anaconda-sshd console logic out of anaconda-generator and into the unit files. No behavior changes are expected there.
I've tested to confirm that everything works as expected: tmux and tty2 show up normally, inst.noshell suppresses both, and inst.sshd starts sshd.
-w
These both look good to me.
anaconda-patches@lists.fedorahosted.org