Skip to content

Commit

Permalink
treehouses remote reverse unique (fixes #2129) (#2135)
Browse files Browse the repository at this point in the history
Co-authored-by: dogi <[email protected]>
  • Loading branch information
JLKwong and dogi authored Mar 25, 2021
1 parent 3660877 commit e6f025c
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 6 deletions.
17 changes: 12 additions & 5 deletions modules/remote.sh
Original file line number Diff line number Diff line change
Expand Up @@ -71,11 +71,18 @@ function remote {
;;
"reverse")
checkargn $# 2
reverse=$(internet reverse | sed -e 's#",\ "#"\n"#g' | cut -d'"' -f 2,3,4 | sed 's#\:[[:space:]]\"#:\"#g')
while IFS= read -r line; do
cmd_str+="\"$line\","
done <<< "$reverse"
printf "{%s}\n" "${cmd_str::-1}"
reverse=$(internet reverse | sed -e 's#",\ "#"\n"#g' | cut -d'"' -f 2,3,4 | sed 's#\:[[:space:]]\"#:\"#g' | awk '!x[$0]++')
while IFS= read -r line; do
cmd_str+="\"$line\","
done <<< "$reverse"
ip=$(printf "%s\n" "${cmd_str::-1}" | cut -d',' -f 1)
org=$(printf "%s\n" "${cmd_str::-1}" | cut -d',' -f 5)
country=$(printf "%s\n" "${cmd_str::-1}" | cut -d',' -f 4)
city=$(printf "%s\n" "${cmd_str::-1}" | cut -d',' -f 3)
postal=$(printf "%s\n" "${cmd_str::-1}" | cut -d',' -f 2)
timezone=$(printf "%s\n" "${cmd_str::-1}" | cut -d',' -f 6)

echo "{$ip,$org,$country,$city,$postal,$timezone}"
;;
"allservices")
checkargn $# 1
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@treehouses/cli",
"version": "1.25.34",
"version": "1.25.35",
"remote": "4000",
"description": "Thin command-line interface for Raspberry Pi low level configuration.",
"main": "cli.sh",
Expand Down

0 comments on commit e6f025c

Please sign in to comment.