summaryrefslogtreecommitdiff
path: root/gnu/services/base.scm
diff options
context:
space:
mode:
authorLudovic Courtès <ludo@gnu.org>2018-09-26 23:01:33 +0200
committerLudovic Courtès <ludo@gnu.org>2018-09-26 23:40:37 +0200
commit09b7300c01a8e7100467c6caae9b2c8d8e673971 (patch)
tree95dc2b933427c79497eef110dface7aa2a936025 /gnu/services/base.scm
parent23784f0c3342a0fab5bf2a1c15c300b9f0856872 (diff)
downloadpatches-09b7300c01a8e7100467c6caae9b2c8d8e673971.tar
patches-09b7300c01a8e7100467c6caae9b2c8d8e673971.tar.gz
services: virtual-terminal: Write to "default_utf8" only if necessary.
Fixes a bug in containers whereby 'virtual-terminal' would always fail to start because writing to /sys/…/default_utf8 would fail with EROFS. * gnu/services/base.scm (virtual-terminal-service-type): Read from "default_utf8" before attempting to write to it.
Diffstat (limited to 'gnu/services/base.scm')
-rw-r--r--gnu/services/base.scm25
1 files changed, 14 insertions, 11 deletions
diff --git a/gnu/services/base.scm b/gnu/services/base.scm
index 9dfabd9807..47c7d8bb27 100644
--- a/gnu/services/base.scm
+++ b/gnu/services/base.scm
@@ -685,17 +685,20 @@ to add @var{device} to the kernel's entropy pool. The service will fail if
(shepherd-service-type
'virtual-terminal
(lambda (utf8?)
- (shepherd-service
- (documentation "Set virtual terminals in UTF-8 module.")
- (provision '(virtual-terminal))
- (requirement '(root-file-system))
- (start #~(lambda _
- (call-with-output-file
- "/sys/module/vt/parameters/default_utf8"
- (lambda (port)
- (display 1 port)))
- #t))
- (stop #~(const #f))))
+ (let ((knob "/sys/module/vt/parameters/default_utf8"))
+ (shepherd-service
+ (documentation "Set virtual terminals in UTF-8 module.")
+ (provision '(virtual-terminal))
+ (requirement '(root-file-system))
+ (start #~(lambda _
+ ;; In containers /sys is read-only so don't insist on
+ ;; writing to this file.
+ (unless (= 1 (call-with-input-file #$knob read))
+ (call-with-output-file #$knob
+ (lambda (port)
+ (display 1 port))))
+ #t))
+ (stop #~(const #f)))))
#t)) ;default to UTF-8
(define console-keymap-service-type