alfred: added more information to send, reformatted location
location is object with latitude and longitude added: * firmware * autoupdater status * hardware model * primary mac address * mesh IPv6 addresses
This commit is contained in:
parent
5f976809a1
commit
d0e3cbc8bc
@ -9,14 +9,41 @@ else
|
|||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
. /lib/gluon/functions/model.sh
|
||||||
|
. /lib/gluon/functions/sysconfig.sh
|
||||||
|
|
||||||
[ -z "$ALFRED_DATA_TYPE" ] && ALFRED_DATA_TYPE=158
|
[ -z "$ALFRED_DATA_TYPE" ] && ALFRED_DATA_TYPE=158
|
||||||
|
[ -z "$NET_IF" ] && NET_IF=br-client
|
||||||
|
|
||||||
set -e
|
set -e
|
||||||
|
|
||||||
json_init
|
json_init
|
||||||
json_add_string "name" "$(uci get 'system.@system[0].hostname')"
|
json_add_string "name" "$(uci get 'system.@system[0].hostname')"
|
||||||
if [ "$(uci get 'system.@system[0].share_location')" = 1 ]; then
|
if [ "$(uci -q get 'system.@system[0].share_location')" = 1 ]; then
|
||||||
json_add_string "location" "$(uci get 'system.@system[0].latitude') $(uci get 'system.@system[0].longitude')"
|
json_add_object "location"
|
||||||
|
json_add_double "latitude" "$(uci get 'system.@system[0].latitude')"
|
||||||
|
json_add_double "longitude" "$(uci get 'system.@system[0].longitude')"
|
||||||
|
json_close_object # location
|
||||||
fi
|
fi
|
||||||
|
json_add_object "software"
|
||||||
|
json_add_string "firmware" "gluon $(cat /lib/gluon/release)"
|
||||||
|
if [ -x /usr/sbin/autoupdater ]; then
|
||||||
|
json_add_object "autoupdater"
|
||||||
|
json_add_string "branch" "$(uci -q get autoupdater.settings.branch)"
|
||||||
|
json_add_boolean "enabled" "$(uci -q get autoupdater.settings.enabled)"
|
||||||
|
json_close_object # autoupdater
|
||||||
|
fi
|
||||||
|
json_close_object # software
|
||||||
|
json_add_object "hardware"
|
||||||
|
json_add_string "model" "$(get_model)"
|
||||||
|
json_close_object # hardware
|
||||||
|
json_add_object "network"
|
||||||
|
json_add_string "mac" "$(sysconfig primary_mac)"
|
||||||
|
json_add_array "addresses"
|
||||||
|
for addr in $(ip -o -6 addr show dev "$NET_IF" | grep -oE 'inet6 [0-9a-fA-F:]+' | cut -d' ' -f2); do
|
||||||
|
json_add_string "" "$addr"
|
||||||
|
done
|
||||||
|
json_close_array # adresses
|
||||||
|
json_close_object # network
|
||||||
|
|
||||||
json_dump | tr -d '\n' | alfred -s "$ALFRED_DATA_TYPE"
|
json_dump | tr -d '\n' | alfred -s "$ALFRED_DATA_TYPE"
|
||||||
|
Loading…
Reference in New Issue
Block a user