Skip to content

Commit

Permalink
treehouses remote reverse (fixes #2068) (#2071)
Browse files Browse the repository at this point in the history
Co-authored-by: dogi <dogi@users.noreply.github.com>
  • Loading branch information
JLKwong and dogi authored Mar 8, 2021
1 parent b1927c4 commit 390e114
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 7 deletions.
5 changes: 3 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 <check|status|upgrade|services> helps with treehouses remote android app
<version|commands|allservices>
<statuspage|ssh2fa|help|key>
<version|commands|reverse>
<allservices|statuspage|ssh2fa>
<help|key>
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
Expand Down
1 change: 1 addition & 0 deletions _treehouses
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
5 changes: 3 additions & 2 deletions modules/help.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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 <check|status|upgrade|services> helps with treehouses remote android app
<version|commands|allservices>
<statuspage|ssh2fa|help|key>
<version|commands|reverse>
<allservices|statuspage|ssh2fa>
<help|key>
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
Expand Down
15 changes: 13 additions & 2 deletions modules/remote.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -168,7 +176,7 @@ function remote {
;;
*)
echo "Unknown command option"
echo "Usage: $BASENAME remote <check | status | upgrade | services | version | commands | allservices | statuspage | ssh2fa | help | key>"
echo "Usage: $BASENAME remote <check | status | upgrade | services | version | commands | reverse | allservices | statuspage | ssh2fa | help | key>"
;;
esac
}
Expand All @@ -194,7 +202,7 @@ function autorun_helper {

function remote_help {
echo
echo "Usage: $BASENAME remote <check | status | upgrade | services | version | commands | allservices | statuspage | ssh2fa | help | key>"
echo "Usage: $BASENAME remote <check | status | upgrade | services | version | commands | reverse | allservices | statuspage | ssh2fa | help | key>"
echo
echo "Returns a string representation of the current status of the Raspberry Pi"
echo "Used for Treehouses Remote"
Expand Down Expand Up @@ -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
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.13",
"version": "1.25.14",
"remote": "4000",
"description": "Thin command-line interface for Raspberry Pi low level configuration.",
"main": "cli.sh",
Expand Down

0 comments on commit 390e114

Please sign in to comment.