forked from mirrors/nixpkgs
Merge pull request #66588 from lschuermann/nixos-enter-silent
nixos-enter: add --silent to suppress activation script output
This commit is contained in:
commit
08749c4860
|
@ -34,6 +34,12 @@
|
||||||
</arg>
|
</arg>
|
||||||
<replaceable>shell-command</replaceable>
|
<replaceable>shell-command</replaceable>
|
||||||
</arg>
|
</arg>
|
||||||
|
|
||||||
|
<arg>
|
||||||
|
<arg choice='plain'>
|
||||||
|
<option>--silent</option>
|
||||||
|
</arg>
|
||||||
|
</arg>
|
||||||
|
|
||||||
<arg>
|
<arg>
|
||||||
<arg choice='plain'>
|
<arg choice='plain'>
|
||||||
|
@ -100,6 +106,16 @@
|
||||||
</para>
|
</para>
|
||||||
</listitem>
|
</listitem>
|
||||||
</varlistentry>
|
</varlistentry>
|
||||||
|
<varlistentry>
|
||||||
|
<term>
|
||||||
|
<option>--silent</option>
|
||||||
|
</term>
|
||||||
|
<listitem>
|
||||||
|
<para>
|
||||||
|
Suppresses all output from the activation script of the target system.
|
||||||
|
</para>
|
||||||
|
</listitem>
|
||||||
|
</varlistentry>
|
||||||
<varlistentry>
|
<varlistentry>
|
||||||
<term>
|
<term>
|
||||||
<option>--</option>
|
<option>--</option>
|
||||||
|
|
|
@ -16,7 +16,8 @@ fi
|
||||||
|
|
||||||
mountPoint=/mnt
|
mountPoint=/mnt
|
||||||
system=/nix/var/nix/profiles/system
|
system=/nix/var/nix/profiles/system
|
||||||
command=($system/sw/bin/bash "--login")
|
command=("$system/sw/bin/bash" "--login")
|
||||||
|
silent=0
|
||||||
|
|
||||||
while [ "$#" -gt 0 ]; do
|
while [ "$#" -gt 0 ]; do
|
||||||
i="$1"; shift 1
|
i="$1"; shift 1
|
||||||
|
@ -32,9 +33,12 @@ while [ "$#" -gt 0 ]; do
|
||||||
exit 1
|
exit 1
|
||||||
;;
|
;;
|
||||||
--command|-c)
|
--command|-c)
|
||||||
command=($system/sw/bin/bash "-c" "$1")
|
command=("$system/sw/bin/bash" "-c" "$1")
|
||||||
shift 1
|
shift 1
|
||||||
;;
|
;;
|
||||||
|
--silent)
|
||||||
|
silent=1
|
||||||
|
;;
|
||||||
--)
|
--)
|
||||||
command=("$@")
|
command=("$@")
|
||||||
break
|
break
|
||||||
|
@ -51,11 +55,20 @@ if [[ ! -e $mountPoint/etc/NIXOS ]]; then
|
||||||
exit 126
|
exit 126
|
||||||
fi
|
fi
|
||||||
|
|
||||||
mkdir -m 0755 -p "$mountPoint/dev" "$mountPoint/sys"
|
mkdir -p "$mountPoint/dev" "$mountPoint/sys"
|
||||||
|
chmod 0755 "$mountPoint/dev" "$mountPoint/sys"
|
||||||
mount --rbind /dev "$mountPoint/dev"
|
mount --rbind /dev "$mountPoint/dev"
|
||||||
mount --rbind /sys "$mountPoint/sys"
|
mount --rbind /sys "$mountPoint/sys"
|
||||||
|
|
||||||
|
# If silent, write both stdout and stderr of activation script to /dev/null
|
||||||
|
# otherwise, write both streams to stderr of this process
|
||||||
|
if [ "$silent" -eq 0 ]; then
|
||||||
|
PIPE_TARGET="/dev/stderr"
|
||||||
|
else
|
||||||
|
PIPE_TARGET="/dev/null"
|
||||||
|
fi
|
||||||
|
|
||||||
# Run the activation script. Set $LOCALE_ARCHIVE to supress some Perl locale warnings.
|
# Run the activation script. Set $LOCALE_ARCHIVE to supress some Perl locale warnings.
|
||||||
LOCALE_ARCHIVE=$system/sw/lib/locale/locale-archive chroot "$mountPoint" "$system/activate" >&2 || true
|
LOCALE_ARCHIVE="$system/sw/lib/locale/locale-archive" chroot "$mountPoint" "$system/activate" >>$PIPE_TARGET 2>&1 || true
|
||||||
|
|
||||||
exec chroot "$mountPoint" "${command[@]}"
|
exec chroot "$mountPoint" "${command[@]}"
|
||||||
|
|
Loading…
Reference in a new issue