hostname: fall back to /proc/sys/kernel/hostname (linux) if "hostname" is missing

This provides a usable alternative on OpenWrt.
This commit is contained in:
Lars Kruse 2020-02-08 21:31:15 +01:00
parent 0662cfc7e8
commit a0d4d74f8d
1 changed files with 1 additions and 1 deletions

View File

@ -110,7 +110,7 @@ PLUGINS=$(echo "$RES" | xargs -r -n 1 echo | sort | xargs echo)
# ===== MAIN LOOP =====
FUNCTIONS="list nodes config fetch version quit"
HOSTNAME=$(hostname -f 2>/dev/null || hostname)
HOSTNAME=$( { hostname -f || hostname || cat /proc/sys/kernel/hostname || echo "unknown"; } 2>/dev/null )
echo "# munin node at $HOSTNAME"
while read -r arg0 arg1
do