nixos/containers: Fix shellcheck issues (#346131)
This commit is contained in:
commit
2d809488f7
@ -109,13 +109,15 @@ let
|
|||||||
|
|
||||||
cp --remove-destination /etc/resolv.conf "$root/etc/resolv.conf"
|
cp --remove-destination /etc/resolv.conf "$root/etc/resolv.conf"
|
||||||
|
|
||||||
|
declare -a extraFlags
|
||||||
|
|
||||||
if [ "$PRIVATE_NETWORK" = 1 ]; then
|
if [ "$PRIVATE_NETWORK" = 1 ]; then
|
||||||
extraFlags+=" --private-network"
|
extraFlags+=("--private-network")
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ -n "$HOST_ADDRESS" ] || [ -n "$LOCAL_ADDRESS" ] ||
|
if [ -n "$HOST_ADDRESS" ] || [ -n "$LOCAL_ADDRESS" ] ||
|
||||||
[ -n "$HOST_ADDRESS6" ] || [ -n "$LOCAL_ADDRESS6" ]; then
|
[ -n "$HOST_ADDRESS6" ] || [ -n "$LOCAL_ADDRESS6" ]; then
|
||||||
extraFlags+=" --network-veth"
|
extraFlags+=("--network-veth")
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ -n "$HOST_PORT" ]; then
|
if [ -n "$HOST_PORT" ]; then
|
||||||
@ -123,30 +125,30 @@ let
|
|||||||
IFS=","
|
IFS=","
|
||||||
for i in $HOST_PORT
|
for i in $HOST_PORT
|
||||||
do
|
do
|
||||||
extraFlags+=" --port=$i"
|
extraFlags+=("--port=$i")
|
||||||
done
|
done
|
||||||
IFS=$OIFS
|
IFS=$OIFS
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ -n "$HOST_BRIDGE" ]; then
|
if [ -n "$HOST_BRIDGE" ]; then
|
||||||
extraFlags+=" --network-bridge=$HOST_BRIDGE"
|
extraFlags+=("--network-bridge=$HOST_BRIDGE")
|
||||||
fi
|
fi
|
||||||
|
|
||||||
extraFlags+=" ${concatStringsSep " " (mapAttrsToList nspawnExtraVethArgs cfg.extraVeths)}"
|
extraFlags+=(${lib.escapeShellArgs (mapAttrsToList nspawnExtraVethArgs cfg.extraVeths)})
|
||||||
|
|
||||||
for iface in $INTERFACES; do
|
for iface in $INTERFACES; do
|
||||||
extraFlags+=" --network-interface=$iface"
|
extraFlags+=("--network-interface=$iface")
|
||||||
done
|
done
|
||||||
|
|
||||||
for iface in $MACVLANS; do
|
for iface in $MACVLANS; do
|
||||||
extraFlags+=" --network-macvlan=$iface"
|
extraFlags+=("--network-macvlan=$iface")
|
||||||
done
|
done
|
||||||
|
|
||||||
# If the host is 64-bit and the container is 32-bit, add a
|
# If the host is 64-bit and the container is 32-bit, add a
|
||||||
# --personality flag.
|
# --personality flag.
|
||||||
${optionalString (pkgs.stdenv.hostPlatform.system == "x86_64-linux") ''
|
${optionalString (pkgs.stdenv.hostPlatform.system == "x86_64-linux") ''
|
||||||
if [ "$(< "''${SYSTEM_PATH:-/nix/var/nix/profiles/per-container/$INSTANCE/system}/system")" = i686-linux ]; then
|
if [ "$(< "''${SYSTEM_PATH:-/nix/var/nix/profiles/per-container/$INSTANCE/system}/system")" = i686-linux ]; then
|
||||||
extraFlags+=" --personality=x86"
|
extraFlags+=("--personality=x86")
|
||||||
fi
|
fi
|
||||||
''}
|
''}
|
||||||
|
|
||||||
@ -157,9 +159,11 @@ let
|
|||||||
# Kill signal handling means systemd-nspawn will pass a system-halt signal
|
# Kill signal handling means systemd-nspawn will pass a system-halt signal
|
||||||
# to the container systemd when it receives SIGTERM for container shutdown;
|
# to the container systemd when it receives SIGTERM for container shutdown;
|
||||||
# containerInit and stage2 have to handle this as well.
|
# containerInit and stage2 have to handle this as well.
|
||||||
|
# TODO: fix shellcheck issue properly
|
||||||
|
# shellcheck disable=SC2086
|
||||||
exec ${config.systemd.package}/bin/systemd-nspawn \
|
exec ${config.systemd.package}/bin/systemd-nspawn \
|
||||||
--keep-unit \
|
--keep-unit \
|
||||||
-M "$INSTANCE" -D "$root" $extraFlags \
|
-M "$INSTANCE" -D "$root" "''${extraFlags[@]}" \
|
||||||
$EXTRA_NSPAWN_FLAGS \
|
$EXTRA_NSPAWN_FLAGS \
|
||||||
--notify-ready=yes \
|
--notify-ready=yes \
|
||||||
--kill-signal=SIGRTMIN+3 \
|
--kill-signal=SIGRTMIN+3 \
|
||||||
|
Loading…
Reference in New Issue
Block a user