Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

nixos/network-interfaces-scripted: fix shellcheck findings with enabl… #348564

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions nixos/modules/tasks/network-interfaces-scripted.nix
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ let
script =
''
state="/run/nixos/network/addresses/${i.name}"
mkdir -p $(dirname "$state")
mkdir -p "$(dirname "$state")"

ip link set dev "${i.name}" up

Expand All @@ -203,17 +203,17 @@ let
''
echo "${cidr}" >> $state
echo -n "adding address ${cidr}... "
if out=$(ip addr replace "${cidr}" dev "${i.name}" 2>&1); then
if out="$(ip addr replace "${cidr}" dev "${i.name}" 2>&1)"; then
echo "done"
else
echo "'ip addr replace "${cidr}" dev "${i.name}"' failed: $out"
echo "'ip addr replace ${cidr} dev ${i.name}' failed: $out"
exit 1
fi
''
)}

state="/run/nixos/network/routes/${i.name}"
mkdir -p $(dirname "$state")
mkdir -p "$(dirname "$state")"

${flip concatMapStrings (i.ipv4.routes ++ i.ipv6.routes) (route:
let
Expand All @@ -237,7 +237,7 @@ let
preStop = ''
state="/run/nixos/network/routes/${i.name}"
if [ -e "$state" ]; then
while read cidr; do
while read -r cidr; do
echo -n "deleting route $cidr... "
ip route del "$cidr" dev "${i.name}" >/dev/null 2>&1 && echo "done" || echo "failed"
done < "$state"
Expand All @@ -246,7 +246,7 @@ let

state="/run/nixos/network/addresses/${i.name}"
if [ -e "$state" ]; then
while read cidr; do
while read -r cidr; do
echo -n "deleting address $cidr... "
ip addr del "$cidr" dev "${i.name}" >/dev/null 2>&1 && echo "done" || echo "failed"
done < "$state"
Expand Down