Skip to content

Commit 390e114

Browse files
JLKwongdogi
andauthored
treehouses remote reverse (fixes #2068) (#2071)
Co-authored-by: dogi <dogi@users.noreply.github.com>
1 parent b1927c4 commit 390e114

File tree

5 files changed

+21
-7
lines changed

5 files changed

+21
-7
lines changed

README.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -147,8 +147,9 @@ cron [list|add|delete|deleteall] adds, deletes a custom cron job or del
147147
usb [on|off] turns usb ports on or off
148148
redirect [add|list|remove|start] redirects internet hostnames to rpi
149149
remote <check|status|upgrade|services> helps with treehouses remote android app
150-
<version|commands|allservices>
151-
<statuspage|ssh2fa|help|key>
150+
<version|commands|reverse>
151+
<allservices|statuspage|ssh2fa>
152+
<help|key>
152153
log <0|1|2|3|4|show|max> gets/sets log level and shows log
153154
blocker <0|1|2|3|4||max> website blocking levels using /etc/hosts
154155
sdbench displays read and write speed of micro SD card

_treehouses

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -294,6 +294,7 @@ treehouses remote commands
294294
treehouses remote help
295295
treehouses remote key receive
296296
treehouses remote key send
297+
treehouses remote reverse
297298
treehouses remote services available
298299
treehouses remote services installed
299300
treehouses remote services running

modules/help.sh

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -123,8 +123,9 @@ cron [list|add|delete|deleteall] adds, deletes a custom cron job or del
123123
usb [on|off] turns usb ports on or off
124124
redirect [add|list|remove|start] redirects internet hostnames to rpi
125125
remote <check|status|upgrade|services> helps with treehouses remote android app
126-
<version|commands|allservices>
127-
<statuspage|ssh2fa|help|key>
126+
<version|commands|reverse>
127+
<allservices|statuspage|ssh2fa>
128+
<help|key>
128129
log <0|1|2|3|4|show|max> gets/sets log level and shows log
129130
blocker <0|1|2|3|4||max> website blocking levels using /etc/hosts
130131
sdbench displays read and write speed of micro SD card

modules/remote.sh

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,14 @@ function remote {
6969
log_and_exit1 "Usage: $BASENAME remote commands [json]"
7070
fi
7171
;;
72+
"reverse")
73+
checkargn $# 2
74+
reverse=$(internet reverse | sed -e 's#",\ "#"\n"#g' | cut -d'"' -f4)
75+
while IFS= read -r line; do
76+
cmd_str+="\"$line\","
77+
done <<< "$reverse"
78+
printf "[%s]\n" "${cmd_str::-1}"
79+
;;
7280
"allservices")
7381
checkargn $# 1
7482
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 {
168176
;;
169177
*)
170178
echo "Unknown command option"
171-
echo "Usage: $BASENAME remote <check | status | upgrade | services | version | commands | allservices | statuspage | ssh2fa | help | key>"
179+
echo "Usage: $BASENAME remote <check | status | upgrade | services | version | commands | reverse | allservices | statuspage | ssh2fa | help | key>"
172180
;;
173181
esac
174182
}
@@ -194,7 +202,7 @@ function autorun_helper {
194202

195203
function remote_help {
196204
echo
197-
echo "Usage: $BASENAME remote <check | status | upgrade | services | version | commands | allservices | statuspage | ssh2fa | help | key>"
205+
echo "Usage: $BASENAME remote <check | status | upgrade | services | version | commands | reverse | allservices | statuspage | ssh2fa | help | key>"
198206
echo
199207
echo "Returns a string representation of the current status of the Raspberry Pi"
200208
echo "Used for Treehouses Remote"
@@ -230,6 +238,9 @@ function remote_help {
230238
echo "$BASENAME remote commands [json]"
231239
echo "returns a list of all commands for tab completion"
232240
echo
241+
echo "$BASENAME remote reverse"
242+
echo "returns the device's internet location information"
243+
echo
233244
echo "$BASENAME remote allservices"
234245
echo "returns json string of services"
235246
echo

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@treehouses/cli",
3-
"version": "1.25.13",
3+
"version": "1.25.14",
44
"remote": "4000",
55
"description": "Thin command-line interface for Raspberry Pi low level configuration.",
66
"main": "cli.sh",

0 commit comments

Comments
 (0)