Skip to content

Commit

Permalink
[fix] Fixed register bug when mac_interface is not present
Browse files Browse the repository at this point in the history
If the interface specified in the mac_interface is not
available on the system, the agent should take the
first non-loopback interface available, but this
behavior was broken inadvertently.
  • Loading branch information
nemesifier committed Apr 29, 2024
1 parent 5eae3b7 commit 9ad45d9
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion openwisp-config/files/openwisp.agent
Original file line number Diff line number Diff line change
Expand Up @@ -278,7 +278,7 @@ register() {
params keybase consistent_key exit_code message new prefix
hostname=$(uci get system.@system[0].hostname)
# use macaddr of interface specified in $MAC_INTERFACE
raw=$(ifconfig "$MAC_INTERFACE" 2>/dev/null 2>&1)
raw=$(ifconfig "$MAC_INTERFACE" 2>/dev/null)
# if previous command fails, fallback to first non-loopback interface
if [ -z "$raw" ]; then raw=$(ifconfig); fi
macaddr=$(echo "$raw " | grep -E -v "^(lo|tap[0-9]+)" | awk '/HWaddr/ { print $5 }' | head -n 1)
Expand Down

0 comments on commit 9ad45d9

Please sign in to comment.