From 390e1142f5d090eef9a0569b1b7571486c3fca4b Mon Sep 17 00:00:00 2001 From: JLKwong <61807745+JLKwong@users.noreply.github.com> Date: Mon, 8 Mar 2021 12:44:02 -0800 Subject: [PATCH] `treehouses remote reverse` (fixes #2068) (#2071) Co-authored-by: dogi --- README.md | 5 +++-- _treehouses | 1 + modules/help.sh | 5 +++-- modules/remote.sh | 15 +++++++++++++-- package.json | 2 +- 5 files changed, 21 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index b0b58eb1e4..d68174e589 100644 --- a/README.md +++ b/README.md @@ -147,8 +147,9 @@ cron [list|add|delete|deleteall] adds, deletes a custom cron job or del usb [on|off] turns usb ports on or off redirect [add|list|remove|start] redirects internet hostnames to rpi remote helps with treehouses remote android app - - + + + log <0|1|2|3|4|show|max> gets/sets log level and shows log blocker <0|1|2|3|4||max> website blocking levels using /etc/hosts sdbench displays read and write speed of micro SD card diff --git a/_treehouses b/_treehouses index 7212c088ea..d406bb2c9e 100644 --- a/_treehouses +++ b/_treehouses @@ -294,6 +294,7 @@ treehouses remote commands treehouses remote help treehouses remote key receive treehouses remote key send +treehouses remote reverse treehouses remote services available treehouses remote services installed treehouses remote services running diff --git a/modules/help.sh b/modules/help.sh index 29a5e1f6d1..162406fe2f 100644 --- a/modules/help.sh +++ b/modules/help.sh @@ -123,8 +123,9 @@ cron [list|add|delete|deleteall] adds, deletes a custom cron job or del usb [on|off] turns usb ports on or off redirect [add|list|remove|start] redirects internet hostnames to rpi remote helps with treehouses remote android app - - + + + log <0|1|2|3|4|show|max> gets/sets log level and shows log blocker <0|1|2|3|4||max> website blocking levels using /etc/hosts sdbench displays read and write speed of micro SD card diff --git a/modules/remote.sh b/modules/remote.sh index bad3523934..ae8a2693ee 100644 --- a/modules/remote.sh +++ b/modules/remote.sh @@ -69,6 +69,14 @@ function remote { log_and_exit1 "Usage: $BASENAME remote commands [json]" fi ;; + "reverse") + checkargn $# 2 + reverse=$(internet reverse | sed -e 's#",\ "#"\n"#g' | cut -d'"' -f4) + while IFS= read -r line; do + cmd_str+="\"$line\"," + done <<< "$reverse" + printf "[%s]\n" "${cmd_str::-1}" + ;; "allservices") checkargn $# 1 json_fmt="{\"available\":["%s"],\"installed\":["%s"],\"running\":["%s"],\"icon\":{"%s"},\"info\":{"%s"},\"autorun\":{"%s"},\"usesEnv\":{"%s"},\"size\":{"%s"}}\n" @@ -168,7 +176,7 @@ function remote { ;; *) echo "Unknown command option" - echo "Usage: $BASENAME remote " + echo "Usage: $BASENAME remote " ;; esac } @@ -194,7 +202,7 @@ function autorun_helper { function remote_help { echo - echo "Usage: $BASENAME remote " + echo "Usage: $BASENAME remote " echo echo "Returns a string representation of the current status of the Raspberry Pi" echo "Used for Treehouses Remote" @@ -230,6 +238,9 @@ function remote_help { echo "$BASENAME remote commands [json]" echo "returns a list of all commands for tab completion" echo + echo "$BASENAME remote reverse" + echo "returns the device's internet location information" + echo echo "$BASENAME remote allservices" echo "returns json string of services" echo diff --git a/package.json b/package.json index 52c3b8c783..52f53a42c8 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@treehouses/cli", - "version": "1.25.13", + "version": "1.25.14", "remote": "4000", "description": "Thin command-line interface for Raspberry Pi low level configuration.", "main": "cli.sh",