Skip to content

Commit

Permalink
setup-ip: Don't hardcode path of ip binary
Browse files Browse the repository at this point in the history
Debian recently [1] removed the symlink in /sbin which breaks our
setup-ip script.

Instead of hardcoding the new path, rely on normal $PATH resolution.
Saving a few file existence checks isn't worth such breakage, I think
(or if that really matters here, shell is the wrong tool in the first
place).

[1]: https://salsa.debian.org/kernel-team/iproute2/-/commit/c4bb148dd4ed0601ca32ee8a458007d0c348d6c3
  • Loading branch information
HW42 committed Jul 24, 2024
1 parent 0f346ad commit 22cb2e1
Showing 1 changed file with 10 additions and 10 deletions.
20 changes: 10 additions & 10 deletions network/setup-ip
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@
set -ueo pipefail

add_link_route () {
/sbin/ip -- route replace to unicast "$1" dev "$2" scope link
ip -- route replace to unicast "$1" dev "$2" scope link
}

add_default_route () {
/sbin/ip -- route replace to unicast default via "$1" dev "$2" onlink
ip -- route replace to unicast default via "$1" dev "$2" onlink
}

readonly netvm_mac=fe:ff:ff:ff:ff:ff
Expand All @@ -27,19 +27,19 @@ configure_network () {
local secondary_dns="${10}"
local custom="${11}"

/sbin/ip -- address replace "$ip/$netmask" dev "$INTERFACE"
ip -- address replace "$ip/$netmask" dev "$INTERFACE"
if [[ "$custom" = false ]]; then
/sbin/ip -- neighbour replace to "$gateway" dev "$INTERFACE" \
ip -- neighbour replace to "$gateway" dev "$INTERFACE" \
lladdr "$netvm_mac" nud permanent
fi
if [ -n "$ip6" ]; then
/sbin/ip -- address replace "$ip6/$netmask6" dev "$INTERFACE"
ip -- address replace "$ip6/$netmask6" dev "$INTERFACE"
if [ -n "$gateway6" ] && [[ "$custom" = false ]]; then
/sbin/ip -- neighbour replace to "$gateway6" dev "$INTERFACE" \
ip -- neighbour replace to "$gateway6" dev "$INTERFACE" \
lladdr "$netvm_mac" nud permanent
fi
fi
/sbin/ip link set dev "$INTERFACE" group 1 up
ip link set dev "$INTERFACE" group 1 up

if [ -n "$gateway" ]; then
add_link_route "$gateway" "$INTERFACE"
Expand Down Expand Up @@ -96,7 +96,7 @@ configure_network_nm () {
local ip4_nm_config
local ip6_nm_config
local uuid
/sbin/ip link set dev "$INTERFACE" group 1
ip link set dev "$INTERFACE" group 1

prefix="$(get_prefix_from_subnet "$netmask")"
prefix6="$netmask6"
Expand Down Expand Up @@ -167,12 +167,12 @@ __EOF__
# reload connection
nmcli connection load "$nm_config" || :
if [[ "$custom" = false ]]; then
/sbin/ip -- neighbour replace to "$gateway" dev "$INTERFACE" \
ip -- neighbour replace to "$gateway" dev "$INTERFACE" \
lladdr "$netvm_mac" nud permanent
fi
if [ -n "$gateway6" ]; then
if [[ "$custom" = false ]]; then
/sbin/ip -- neighbour replace to "$gateway6" dev "$INTERFACE" \
ip -- neighbour replace to "$gateway6" dev "$INTERFACE" \
lladdr "$netvm_mac" nud permanent
fi
fi
Expand Down

0 comments on commit 22cb2e1

Please sign in to comment.