forked from freifunk-franken/firmware
nodewatcher.d: Tiny cosmetic improvements
This applies some tiny improvements to just-moved nodewatcher.d code: - Remove comments about obvious things - Introduce newlines to make code easier to read - Use shorter conditional syntax for easy cases Signed-off-by: Adrian Schmutzler <freifunk@adrianschmutzler.de> Reviewed-by: Fabian Bläse <fabian@blaese.de>
This commit is contained in:
parent
1c3243dd18
commit
18e00a4e70
|
@ -7,7 +7,7 @@ debug() {
|
||||||
}
|
}
|
||||||
|
|
||||||
debug "$(date): Collecting information from batman advanced and its interfaces"
|
debug "$(date): Collecting information from batman advanced and its interfaces"
|
||||||
#B.A.T.M.A.N. advanced
|
|
||||||
if [ -f /sys/module/batman_adv/version ]; then
|
if [ -f /sys/module/batman_adv/version ]; then
|
||||||
for iface in $(batctl if | sed 's/ //'); do
|
for iface in $(batctl if | sed 's/ //'); do
|
||||||
status=${iface##*:}
|
status=${iface##*:}
|
||||||
|
|
|
@ -12,25 +12,21 @@ debug() {
|
||||||
inArray() {
|
inArray() {
|
||||||
local value
|
local value
|
||||||
for value in $1; do
|
for value in $1; do
|
||||||
if [ "$value" = "$2" ]; then
|
[ "$value" = "$2" ] && return 0
|
||||||
return 0
|
|
||||||
fi
|
|
||||||
done
|
done
|
||||||
return 1
|
return 1
|
||||||
}
|
}
|
||||||
|
|
||||||
debug "$(date): Collecting information from network interfaces"
|
debug "$(date): Collecting information from network interfaces"
|
||||||
|
|
||||||
#Get interfaces
|
|
||||||
interface_data=""
|
interface_data=""
|
||||||
#Loop interfaces
|
|
||||||
#for entry in $IFACES; do
|
# Loop through interfaces: for entry in $IFACES; do
|
||||||
for filename in $(grep 'up\|unknown' /sys/class/net/*/operstate); do
|
for filename in $(grep 'up\|unknown' /sys/class/net/*/operstate); do
|
||||||
ifpath=${filename%/operstate*}
|
ifpath=${filename%/operstate*}
|
||||||
iface=${ifpath#/sys/class/net/}
|
iface=${ifpath#/sys/class/net/}
|
||||||
if inArray "$IFACEBLACKLIST" "$iface"; then
|
|
||||||
continue
|
inArray "$IFACEBLACKLIST" "$iface" && continue
|
||||||
fi
|
|
||||||
|
|
||||||
#Get interface data for whitelisted interfaces
|
#Get interface data for whitelisted interfaces
|
||||||
# shellcheck disable=SC2016
|
# shellcheck disable=SC2016
|
||||||
|
|
|
@ -9,8 +9,8 @@ debug() {
|
||||||
(>&2 echo "$1")
|
(>&2 echo "$1")
|
||||||
}
|
}
|
||||||
|
|
||||||
#Get system data from other locations
|
|
||||||
debug "$(date): Collecting basic system status data"
|
debug "$(date): Collecting basic system status data"
|
||||||
|
|
||||||
hostname="$(cat /proc/sys/kernel/hostname)"
|
hostname="$(cat /proc/sys/kernel/hostname)"
|
||||||
mac=$(awk '{ mac=toupper($1); gsub(":", "", mac); print mac }' /sys/class/net/br-mesh/address 2>/dev/null)
|
mac=$(awk '{ mac=toupper($1); gsub(":", "", mac); print mac }' /sys/class/net/br-mesh/address 2>/dev/null)
|
||||||
[ "$hostname" = "OpenWrt" ] && hostname="$mac"
|
[ "$hostname" = "OpenWrt" ] && hostname="$mac"
|
||||||
|
|
Loading…
Reference in New Issue