Skip to content

Commit

Permalink
[agent] made default hostname check case insensitive
Browse files Browse the repository at this point in the history
  • Loading branch information
nemesifier committed Mar 2, 2017
1 parent b54c952 commit ade89b2
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion openwisp-config/files/openwisp.agent
Original file line number Diff line number Diff line change
Expand Up @@ -103,8 +103,10 @@ register() {
# if previous command fails, fallback to first non-loopback interface
if [ -z "$raw" ]; then raw=$(ifconfig); fi
local macaddr=$(echo "$raw " | egrep -v "^(lo|br-|tap[0-9]+)" | awk '/HWaddr/ { print $5 }' | head -n 1)
# convert hostname to lowercase for case insensitive check
local name=$(echo $hostname | awk '{print tolower($0)}')
# use macaddress if hostname is the default one or empty
if [ "$hostname" == "OpenWrt" ] || [ "$hostname" == "lede" ] || [ -z "$hostname" ]; then
if [ "$name" == "openwrt" ] || [ "$name" == "lede" ] || [ -z "$name" ]; then
hostname="$macaddr"
fi
local backend="netjsonconfig.OpenWrt"
Expand Down

0 comments on commit ade89b2

Please sign in to comment.