nixos/stage-2: Added boot.logCommands
This commit is contained in:
parent
142f65e07a
commit
474d5a7bd0
|
@ -155,6 +155,23 @@ mkdir -m 0755 -p /var/setuid-wrappers
|
||||||
mount -t tmpfs -o "mode=0755" tmpfs /var/setuid-wrappers
|
mount -t tmpfs -o "mode=0755" tmpfs /var/setuid-wrappers
|
||||||
|
|
||||||
|
|
||||||
|
# Optionally log the script output to /dev/kmsg or /run/log/stage-2-init.log.
|
||||||
|
# Only at this point are all the necessary prerequisites ready for these commands.
|
||||||
|
if test -n "@logCommands@"; then
|
||||||
|
exec {logOutFd}>&1 {logErrFd}>&2
|
||||||
|
if test -w /dev/kmsg; then
|
||||||
|
exec > >(tee -i /proc/self/fd/"$logOutFd" | while read line; do
|
||||||
|
if test -n "$line"; then
|
||||||
|
echo "stage-2-init: $line" > /dev/kmsg
|
||||||
|
fi
|
||||||
|
done) 2>&1
|
||||||
|
else
|
||||||
|
mkdir -p /run/log
|
||||||
|
exec > >(tee -i /run/log/stage-2-init.log) 2>&1
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
|
||||||
# Run the script that performs all configuration activation that does
|
# Run the script that performs all configuration activation that does
|
||||||
# not have to be done at boot time.
|
# not have to be done at boot time.
|
||||||
echo "running activation script..."
|
echo "running activation script..."
|
||||||
|
@ -182,6 +199,13 @@ ln -sfn /run/booted-system /nix/var/nix/gcroots/booted-system
|
||||||
@shell@ @postBootCommands@
|
@shell@ @postBootCommands@
|
||||||
|
|
||||||
|
|
||||||
|
# Reset the logging file descriptors
|
||||||
|
if test -n "@logCommands@"; then
|
||||||
|
exec 1>&$logOutFd 2>&$logErrFd
|
||||||
|
exec {logOutFd}>&- {logErrFd}>&-
|
||||||
|
fi
|
||||||
|
|
||||||
|
|
||||||
# Start systemd.
|
# Start systemd.
|
||||||
echo "starting systemd..."
|
echo "starting systemd..."
|
||||||
PATH=/run/current-system/systemd/lib/systemd \
|
PATH=/run/current-system/systemd/lib/systemd \
|
||||||
|
|
|
@ -17,7 +17,7 @@ let
|
||||||
src = ./stage-2-init.sh;
|
src = ./stage-2-init.sh;
|
||||||
shellDebug = "${pkgs.bashInteractive}/bin/bash";
|
shellDebug = "${pkgs.bashInteractive}/bin/bash";
|
||||||
isExecutable = true;
|
isExecutable = true;
|
||||||
inherit (config.boot) devShmSize runSize;
|
inherit (config.boot) logCommands devShmSize runSize;
|
||||||
inherit (config.nix) readOnlyStore;
|
inherit (config.nix) readOnlyStore;
|
||||||
inherit (config.networking) useHostResolvConf;
|
inherit (config.networking) useHostResolvConf;
|
||||||
ttyGid = config.ids.gids.tty;
|
ttyGid = config.ids.gids.tty;
|
||||||
|
@ -40,6 +40,14 @@ in
|
||||||
|
|
||||||
boot = {
|
boot = {
|
||||||
|
|
||||||
|
logCommands = mkOption {
|
||||||
|
default = false;
|
||||||
|
type = types.bool;
|
||||||
|
description = ''
|
||||||
|
Whether to replicate command output of stage-1 booting to <filename>/dev/kmsg</filename> or <filename>/run/log/stage-2-init.log</filename> if <filename>/dev/kmsg</filename> is not writable.
|
||||||
|
'';
|
||||||
|
};
|
||||||
|
|
||||||
postBootCommands = mkOption {
|
postBootCommands = mkOption {
|
||||||
default = "";
|
default = "";
|
||||||
example = "rm -f /var/log/messages";
|
example = "rm -f /var/log/messages";
|
||||||
|
|
Loading…
Reference in New Issue