Skip to content

Commit

Permalink
Merge pull request #2071 from valentindavid/valentindavid/rework-cons…
Browse files Browse the repository at this point in the history
…ole-conf-systemd-jammy

Simplify systemd configuration for console-conf
  • Loading branch information
dbungert authored Aug 29, 2024
2 parents c6452b9 + 508a737 commit 639b5ec
Show file tree
Hide file tree
Showing 8 changed files with 32 additions and 22 deletions.
7 changes: 1 addition & 6 deletions console_conf/controllers/identity.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
from subiquitycore.ssh import host_key_info, get_ips_standalone
from subiquitycore.snapd import SnapdConnection
from subiquitycore.tuicontroller import TuiController
from subiquitycore.utils import disable_console_conf, run_command
from subiquitycore.utils import run_command

from console_conf.ui.views import IdentityView, LoginView

Expand Down Expand Up @@ -213,9 +213,4 @@ def login(self):
self.ui.set_body(self.make_login_view())

def login_done(self):
if not self.opts.dry_run:
# stop the console-conf services (this will kill the
# current process).
disable_console_conf()

self.app.exit()
4 changes: 2 additions & 2 deletions debian/console-conf-serial.conf
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
[Service]
ExecStartPre=/bin/systemctl start serial-console-conf@%i.service
[Unit]
ConditionPathExists=/var/lib/console-conf/complete
5 changes: 3 additions & 2 deletions debian/console-conf.conf
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
[Service]
ExecStartPre=/bin/systemctl start console-conf@%i.service
[Unit]
ConditionPathExists=/var/lib/console-conf/complete
ConditionPathExists=!/run/snapd-recovery-chooser-triggered
7 changes: 5 additions & 2 deletions debian/[email protected]
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,11 @@ ConditionPathExists=/dev/tty0
ConditionPathExists=|!/var/lib/console-conf/complete
ConditionPathExists=|/run/snapd-recovery-chooser-triggered
StartLimitInterval=0
Conflicts=getty@%i.service

[Service]
Environment=PYTHONPATH=/usr/share/subiquity
ExecStartPre=/bin/systemctl stop getty@%I
ExecStart=/sbin/agetty -i -n --noclear -l /usr/share/subiquity/console-conf-wrapper %I $TERM
ExecStopPost=/bin/systemctl start getty@%I
Type=idle
Restart=always
RestartSec=0
Expand All @@ -36,3 +35,7 @@ SendSIGHUP=yes
#StandardInput=tty-force
#StandardOutput=tty
#StandardError=tty

[Install]
WantedBy=getty.target
DefaultInstance=tty1
3 changes: 1 addition & 2 deletions debian/[email protected]
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,11 @@ After=core18.start-snapd.service core.start-snapd.service
After=snapd.recovery-chooser-trigger.service
ConditionPathExists=!/var/lib/console-conf/complete
StartLimitInterval=0
Conflicts=serial-getty@%i.service

[Service]
Environment=PYTHONPATH=/usr/share/subiquity
ExecStartPre=/bin/systemctl stop serial-getty@%I
ExecStart=/sbin/agetty -i -n --keep-baud -l /usr/share/subiquity/console-conf-wrapper --login-options "--serial" 115200,38400,9600 %I $TERM
ExecStopPost=/bin/systemctl start serial-getty@%I
Type=idle
Restart=always
RestartSec=0
Expand Down
1 change: 1 addition & 0 deletions debian/rules
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ override_dh_installinit:
install -m 0644 $(CURDIR)/debian/console-conf.conf $(CURDIR)/debian/console-conf/lib/systemd/system/[email protected]/
mkdir $(CURDIR)/debian/console-conf/lib/systemd/system/[email protected]/
install -m 0644 $(CURDIR)/debian/console-conf-serial.conf $(CURDIR)/debian/console-conf/lib/systemd/system/[email protected]/
install -D -m 0755 -t $(CURDIR)/debian/console-conf/lib/systemd/system-generators $(CURDIR)/debian/serial-console-generator

override_dh_auto_test:
@echo "No tests."
19 changes: 19 additions & 0 deletions debian/serial-console-generator
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#!/bin/sh

set -eux

NORMAL_DIR="${1}"
EARLY_DIR="${2}"
LATE_DIR="${3}"

for tty in $(cat /sys/class/tty/console/active); do
case "${tty}" in
tty[0-9]*)
;;
*)
mkdir -p "${NORMAL_DIR}/getty.target.wants"
ln -sf /usr/lib/systemd/system/[email protected] "${NORMAL_DIR}/getty.target.wants/serial-console-conf@${tty}.service"

;;
esac
done
8 changes: 0 additions & 8 deletions subiquitycore/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -148,14 +148,6 @@ def crypt_password(passwd, algo='SHA-512'):
return crypt.crypt(passwd, algos[algo] + salt)


def disable_console_conf():
""" Stop console-conf service; which also restores getty service """
log.info('disabling console-conf service')
run_command(["systemctl", "stop", "--no-block", "console-conf@*.service",
"serial-console-conf@*.service"])
return


def disable_subiquity():
""" Stop subiquity service; which also restores getty service """
log.info('disabling subiquity service')
Expand Down

0 comments on commit 639b5ec

Please sign in to comment.