beautysh: re-format
beautysh is enabled in the openbmc-build-scripts on Bash/Zsh/POSIX-sh
files to have a consistent formatting. Re-run the formatter on the
whole repository.
Change-Id: I6a61656dd6033329cba124ac0754152cbd1e9de3
Signed-off-by: Patrick Williams <patrick@stwcx.xyz>
diff --git a/subprojects/ncsid/src/ncsid_udhcpc4.script b/subprojects/ncsid/src/ncsid_udhcpc4.script
index bb6fa6a..fbf90f1 100644
--- a/subprojects/ncsid/src/ncsid_udhcpc4.script
+++ b/subprojects/ncsid/src/ncsid_udhcpc4.script
@@ -1,72 +1,72 @@
#!/bin/bash
source "$(dirname "${BASH_SOURCE[0]}")"/ncsid_lib.sh
-DetermineRouterMac() {
- # Attempt to find the neighbor once, in case our configuration is already
- # valid. Errors are silenced to make the logs more clear. The next call
- # will print any real errors.
- if DetermineNeighbor4 "$interface" "$router" 2>/dev/null; then
- return 0
- fi
-
- # arping might not have a valid source address, so we need to assign
- # the given address so arping has a source to write into the request
- # packet. We don't want a persistent configuration yet so we modify
- # the kernel directly.
- if ! ip -4 addr flush dev "$interface"; then
- echo "Failed to flush $interface" >&2
- return 1
- fi
- if ! ip addr add "$ip/$mask" dev "$interface"; then
- echo "Failed to assign $ip/$mask to $interface" >&2
- # Don't return, because we need to reset networkd
- fi
-
- local rc=0
- DetermineNeighbor4 "$interface" "$router" || rc=$?
-
- # We need to ensure that our old network configuration gets
- # restored, in case our early flushing breaks things.
- systemctl restart systemd-networkd || return $?
- return $rc
-}
-
-HandleDHCP4() {
- local op="$1"
-
- if [ "$op" = "bound" ]; then
- echo "INTF: $interface" >&2
- echo "IP: $ip/$mask" >&2
- echo "GW: $router" >&2
-
- local router_mac
- if ! router_mac="$(DetermineRouterMac "$interface" "$router")"; then
- echo "Failed to acquire gateway mac for $router" >&2
- return 1
+function DetermineRouterMac() {
+ # Attempt to find the neighbor once, in case our configuration is already
+ # valid. Errors are silenced to make the logs more clear. The next call
+ # will print any real errors.
+ if DetermineNeighbor4 "$interface" "$router" 2>/dev/null; then
+ return 0
fi
- echo "GW_MAC: $router_mac" >&2
- SuppressTerm
- local service='xyz.openbmc_project.Network'
+ # arping might not have a valid source address, so we need to assign
+ # the given address so arping has a source to write into the request
+ # packet. We don't want a persistent configuration yet so we modify
+ # the kernel directly.
+ if ! ip -4 addr flush dev "$interface"; then
+ echo "Failed to flush $interface" >&2
+ return 1
+ fi
+ if ! ip addr add "$ip/$mask" dev "$interface"; then
+ echo "Failed to assign $ip/$mask to $interface" >&2
+ # Don't return, because we need to reset networkd
+ fi
+
local rc=0
- SetStatic "$service" "$interface" && \
- UpdateIP "$service" "$interface" "$ip" "$mask" && \
- UpdateGateway "$service" "$interface" "$router" && \
- UpdateNeighbor "$service" "$interface" "$router" "$router_mac" || \
- rc=$?
- UnsuppressTerm
- touch /run/dhcp4.done
+ DetermineNeighbor4 "$interface" "$router" || rc=$?
+
+ # We need to ensure that our old network configuration gets
+ # restored, in case our early flushing breaks things.
+ systemctl restart systemd-networkd || return $?
return $rc
- fi
}
-Main() {
- set -o nounset
- set -o errexit
- set -o pipefail
+function HandleDHCP4() {
+ local op="$1"
- InitTerm
- HandleDHCP4 "$@"
+ if [ "$op" = "bound" ]; then
+ echo "INTF: $interface" >&2
+ echo "IP: $ip/$mask" >&2
+ echo "GW: $router" >&2
+
+ local router_mac
+ if ! router_mac="$(DetermineRouterMac "$interface" "$router")"; then
+ echo "Failed to acquire gateway mac for $router" >&2
+ return 1
+ fi
+ echo "GW_MAC: $router_mac" >&2
+
+ SuppressTerm
+ local service='xyz.openbmc_project.Network'
+ local rc=0
+ SetStatic "$service" "$interface" && \
+ UpdateIP "$service" "$interface" "$ip" "$mask" && \
+ UpdateGateway "$service" "$interface" "$router" && \
+ UpdateNeighbor "$service" "$interface" "$router" "$router_mac" || \
+ rc=$?
+ UnsuppressTerm
+ touch /run/dhcp4.done
+ return $rc
+ fi
+}
+
+function Main() {
+ set -o nounset
+ set -o errexit
+ set -o pipefail
+
+ InitTerm
+ HandleDHCP4 "$@"
}
return 0 2>/dev/null