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:
Adrian Schmutzler 2020-01-07 14:40:22 +01:00 committed by Fabian Bläse
parent 1c3243dd18
commit 18e00a4e70
3 changed files with 7 additions and 11 deletions

View File

@ -7,7 +7,7 @@ debug() {
}
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
for iface in $(batctl if | sed 's/ //'); do
status=${iface##*:}

View File

@ -12,25 +12,21 @@ debug() {
inArray() {
local value
for value in $1; do
if [ "$value" = "$2" ]; then
return 0
fi
[ "$value" = "$2" ] && return 0
done
return 1
}
debug "$(date): Collecting information from network interfaces"
#Get interfaces
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
ifpath=${filename%/operstate*}
iface=${ifpath#/sys/class/net/}
if inArray "$IFACEBLACKLIST" "$iface"; then
continue
fi
inArray "$IFACEBLACKLIST" "$iface" && continue
#Get interface data for whitelisted interfaces
# shellcheck disable=SC2016

View File

@ -9,8 +9,8 @@ debug() {
(>&2 echo "$1")
}
#Get system data from other locations
debug "$(date): Collecting basic system status data"
hostname="$(cat /proc/sys/kernel/hostname)"
mac=$(awk '{ mac=toupper($1); gsub(":", "", mac); print mac }' /sys/class/net/br-mesh/address 2>/dev/null)
[ "$hostname" = "OpenWrt" ] && hostname="$mac"