Move scripts dir inside hm
And remove weird path contraptions
This commit is contained in:
parent
050901da2f
commit
edeef96133
49 changed files with 2 additions and 11 deletions
32
hm/scripts/lip
Executable file
32
hm/scripts/lip
Executable file
|
@ -0,0 +1,32 @@
|
|||
#!/usr/bin/env nix-shell
|
||||
#! nix-shell -i bash --pure
|
||||
#! nix-shell -p bash jq curl findutils coreutils
|
||||
|
||||
set -euo pipefail
|
||||
|
||||
url="https://ip.frogeye.fr/json"
|
||||
cachedir="$HOME/.cache/lip"
|
||||
|
||||
ip="${1:-}"
|
||||
jq_sel="del(.user_agent)"
|
||||
|
||||
if [ $# -gt 1 ]
|
||||
then
|
||||
shift
|
||||
jq_sel="$@"
|
||||
fi
|
||||
|
||||
|
||||
if [ -n "$ip" ]
|
||||
then
|
||||
cachefile="$cachedir/$ip"
|
||||
if ! find "$cachefile" -mtime -7 &> /dev/null
|
||||
then
|
||||
mkdir -p "$cachedir"
|
||||
curl --silent "$url?ip=$ip" > "$cachefile"
|
||||
fi
|
||||
cat "$cachefile" | jq $jq_sel
|
||||
else
|
||||
curl --silent "$url" | jq $jq_sel
|
||||
fi
|
||||
|
Loading…
Add table
Add a link
Reference in a new issue