From 3bb7cdde0705cb8d6850da6ba8bbd0fd4ee1d7de Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Szymon=20Karpi=C5=84ski?= Date: Tue, 4 Feb 2020 12:44:46 +0100 Subject: [PATCH] root autologin --- linux/Makefile | 8 ++++++ linux/getty@.service | 58 ++++++++++++++++++++++++++++++++++++++++++++ linux/logind.conf | 2 ++ 3 files changed, 68 insertions(+) create mode 100644 linux/getty@.service create mode 100644 linux/logind.conf diff --git a/linux/Makefile b/linux/Makefile index 5077b1a..2b2872a 100644 --- a/linux/Makefile +++ b/linux/Makefile @@ -1,6 +1,14 @@ CHROOT_CMD := chroot build/rootfs /bin/bash -c ITDIR := build/rootfs/etc/initramfs-tools +all: build/rootfs/initrd.img build/rootfs/lib/systemd/system/getty@.service build/rootfs/etc/systemd/logind.conf + +build/rootfs/lib/systemd/system/getty@.service: getty@.service + cp getty@.service build/rootfs/lib/systemd/system/getty@.service + +build/rootfs/etc/systemd/logind.conf: logind.conf + cp logind.conf build/rootfs/etc/systemd/logind.conf + build/rootfs/initrd.img: build/rootfs initramfs/modules initramfs/download.sh $(CHROOT_CMD) "apt update && apt install -y linux-image-4.19.0-6-amd64" cp initramfs/download.sh $(ITDIR)/scripts/local-top diff --git a/linux/getty@.service b/linux/getty@.service new file mode 100644 index 0000000..3936fdc --- /dev/null +++ b/linux/getty@.service @@ -0,0 +1,58 @@ +# SPDX-License-Identifier: LGPL-2.1+ +# +# This file is part of systemd. +# +# systemd is free software; you can redistribute it and/or modify it +# under the terms of the GNU Lesser General Public License as published by +# the Free Software Foundation; either version 2.1 of the License, or +# (at your option) any later version. + +[Unit] +Description=Getty on %I +Documentation=man:agetty(8) man:systemd-getty-generator(8) +Documentation=http://0pointer.de/blog/projects/serial-console.html +After=systemd-user-sessions.service plymouth-quit-wait.service getty-pre.target +After=rc-local.service + +# If additional gettys are spawned during boot then we should make +# sure that this is synchronized before getty.target, even though +# getty.target didn't actually pull it in. +Before=getty.target +IgnoreOnIsolate=yes + +# IgnoreOnIsolate causes issues with sulogin, if someone isolates +# rescue.target or starts rescue.service from multi-user.target or +# graphical.target. +Conflicts=rescue.service +Before=rescue.service + +# On systems without virtual consoles, don't start any getty. Note +# that serial gettys are covered by serial-getty@.service, not this +# unit. +ConditionPathExists=/dev/tty0 + +[Service] +# the VT is cleared by TTYVTDisallocate +# The '-o' option value tells agetty to replace 'login' arguments with an +# option to preserve environment (-p), followed by '--' for safety, and then +# the entered username. +ExecStart=-/sbin/agetty --autologin root --noclear %I 38400 linux +Type=idle +Restart=always +RestartSec=0 +UtmpIdentifier=%I +TTYPath=/dev/%I +TTYReset=yes +TTYVHangup=yes +TTYVTDisallocate=yes +KillMode=process +IgnoreSIGPIPE=no +SendSIGHUP=yes + +# Unset locale for the console getty since the console has problems +# displaying some internationalized messages. +UnsetEnvironment=LANG LANGUAGE LC_CTYPE LC_NUMERIC LC_TIME LC_COLLATE LC_MONETARY LC_MESSAGES LC_PAPER LC_NAME LC_ADDRESS LC_TELEPHONE LC_MEASUREMENT LC_IDENTIFICATION + +[Install] +WantedBy=getty.target +DefaultInstance=tty1 diff --git a/linux/logind.conf b/linux/logind.conf new file mode 100644 index 0000000..736338d --- /dev/null +++ b/linux/logind.conf @@ -0,0 +1,2 @@ +[Login] +NAutoVTs=1