From mboxrd@z Thu Jan 1 00:00:00 1970 From: Leo Famulari Subject: [PATCH 1/1] services: Add agetty service. Date: Tue, 14 Feb 2017 19:12:44 -0500 Message-ID: <8b9a83141665a7a86aa3d3c9ba6363c1ba2e93cd.1487117562.git.leo@famulari.name> Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:57620) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cdnDL-00006I-2R for guix-devel@gnu.org; Tue, 14 Feb 2017 19:12:56 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1cdnDH-0005CT-So for guix-devel@gnu.org; Tue, 14 Feb 2017 19:12:55 -0500 Received: from out1-smtp.messagingengine.com ([66.111.4.25]:38702) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1cdnDH-0005Bu-MU for guix-devel@gnu.org; Tue, 14 Feb 2017 19:12:51 -0500 Received: from localhost.localdomain (c-73-188-17-148.hsd1.pa.comcast.net [73.188.17.148]) by mail.messagingengine.com (Postfix) with ESMTPA id 4909E2436A for ; Tue, 14 Feb 2017 19:12:49 -0500 (EST) List-Id: "Development of GNU Guix and the GNU System distribution." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guix-devel-bounces+gcggd-guix-devel=m.gmane.org@gnu.org Sender: "Guix-devel" To: guix-devel@gnu.org * gnu/services/base.scm (): New record type. (agetty-shepherd-service, agetty-service): New procedures. (agetty-service-type): New variable. --- gnu/services/base.scm | 72 ++++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 71 insertions(+), 1 deletion(-) diff --git a/gnu/services/base.scm b/gnu/services/base.scm index 57601eab8..58a50e38b 100644 --- a/gnu/services/base.scm +++ b/gnu/services/base.scm @@ -3,7 +3,7 @@ ;;; Copyright © 2015, 2016 Alex Kost ;;; Copyright © 2015, 2016 Mark H Weaver ;;; Copyright © 2015 Sou Bunnbu -;;; Copyright © 2016 Leo Famulari +;;; Copyright © 2016, 2017 Leo Famulari ;;; Copyright © 2016 David Craven ;;; Copyright © 2016 Ricardo Wurmus ;;; @@ -38,6 +38,7 @@ #:select (canonical-package glibc)) #:use-module (gnu packages bash) #:use-module (gnu packages package-management) + #:use-module (gnu packages linux) #:use-module (gnu packages lsof) #:use-module (gnu packages terminals) #:use-module ((gnu build file-systems) @@ -74,6 +75,11 @@ login-service-type login-service + agetty-configuration + agetty-configuration? + agetty-service + agetty-service-type + mingetty-configuration mingetty-configuration? mingetty-service @@ -730,6 +736,70 @@ Return a service that sets up Unicode support in @var{tty} and loads the message of the day, among other things." (service login-service-type config)) +(define-record-type* + agetty-configuration make-agetty-configuration + agetty-configuration? + (agetty agetty-configuration-agetty ; + (default util-linux)) + (tty agetty-configuration-tty) ;string + (term agetty-term ;string + (default #f)) + (extra agetty-extra ;string + (default #f)) + (baud-rate agetty-baud-rate ;string + (default #f)) + (auto-login agetty-auto-login ;string | #f + (default #f)) + (login-program agetty-login-program ;gexp + (default (file-append shadow "/bin/login"))) + (login-pause? agetty-login-pause? ;Boolean + (default #f))) + +(define agetty-shepherd-service + (match-lambda + (($ agetty tty term extra baud-rate auto-login + login-program login-pause?) + (list + (shepherd-service + (documentation "Run agetty on a tty.") + (provision (list (symbol-append 'term- (string->symbol tty)))) + + ;; Same comment as for mingetty-shepherd-service. + (requirement '(user-processes host-name udev)) + + (start #~(make-forkexec-constructor + (list #$ (file-append util-linux "/sbin/agetty") + #$@(if extra + #~(#$extra) + #~()) + "--noclear" #$tty + #$@(if baud-rate + #~(#$baud-rate) + #~()) + #$@(if auto-login + #~("--autologin" #$auto-login) + #~()) + #$@(if login-program + #~("--login-program" #$login-program) + #~()) + #$@(if login-pause? + #~("--login-pause") + #~()) + #$@(if term + #~(#$term) + #~())))) + (stop #~(make-kill-destructor))))))) + +(define agetty-service-type + (service-type (name 'agetty) + (extensions (list (service-extension shepherd-root-service-type + agetty-shepherd-service))))) + +(define* (agetty-service config) + "Return a service to run agetty according to @var{config}, which specifies +the tty to run, among other things." + (service agetty-service-type config)) + (define-record-type* mingetty-configuration make-mingetty-configuration mingetty-configuration? -- 2.11.1