summaryrefslogtreecommitdiffstats
path: root/lass/2configs/radio/news.nix
diff options
context:
space:
mode:
authorlassulus <lassulus@lassul.us>2022-05-22 20:51:14 +0200
committerlassulus <lassulus@lassul.us>2022-05-22 20:51:14 +0200
commit3b46460fe9f54c1ca06af31cfe715c0cb51ce1c3 (patch)
tree43a20bd17770525befe40dbcbfec6330d342b3b6 /lass/2configs/radio/news.nix
parent5befc5a6f260e2283863212b39749d5ed05afb63 (diff)
l radio: use jc instead of sed/grep
Diffstat (limited to 'lass/2configs/radio/news.nix')
-rw-r--r--lass/2configs/radio/news.nix16
1 files changed, 10 insertions, 6 deletions
diff --git a/lass/2configs/radio/news.nix b/lass/2configs/radio/news.nix
index 6d73f4bb..a3b39a9e 100644
--- a/lass/2configs/radio/news.nix
+++ b/lass/2configs/radio/news.nix
@@ -7,18 +7,22 @@ let
weather_report = pkgs.writers.writeDashBin "weather_report" ''
set -efu
export PATH="${lib.makeBinPath [
- pkgs.iproute2
pkgs.coreutils
pkgs.curl
- pkgs.gnugrep
- pkgs.gnused
+ pkgs.iproute2
+ pkgs.jc
+ pkgs.jq
]}"
curl -z /tmp/GeoLite2-City.mmdb -o /tmp/GeoLite2-City.mmdb http://c.r/GeoLite2-City.mmdb
MAXMIND_GEOIP_DB="/tmp/GeoLite2-City.mmdb"; export MAXMIND_GEOIP_DB
OPENWEATHER_API_KEY=$(cat "$CREDENTIALS_DIRECTORY/openweather_api"); export OPENWEATHER_API_KEY
- ss -Hno state established 'sport = :8000' |
- grep '^tcp' | sed 's/.*\[.*\].*\[\(::ffff:\)\{0,1\}\(.*\)\].*/\2/' |
- sed '/127.0.0.1/d;/::1/d' |
+ ss -no 'sport = :8000' |
+ jc --ss | jq -r '.[] |
+ select(
+ .local_address != "[::ffff:127.0.0.1]"
+ and .local_address != "[::1]"
+ ) | .peer_address | gsub("[\\[\\]]"; "")
+ ' |
${weather_for_ips}/bin/weather_for_ips
'';