Skip to content

UserNotes:joebwan

Joseph F. Berghof III edited this page May 3, 2017 · 63 revisions

A simple vpn/firewall troubleshooting case: send a ping from an external network to my device:

$ cat onepingonly 
#!cmd alpine bash
#!/bin/bash
ping -c 1 $REDOCTOBER

$ cat onepingonly | ssh [email protected] :create hunt:onepingonly
Creating command... done

$ ssh [email protected] :env hunt:onepingonly set REDOCTOBER=www.google.com
Setting REDOCTOBER on hunt:onepingonly... done

$ ssh [email protected] hunt:onepingonly 
PING www.google.com (172.217.3.36): 56 data bytes
64 bytes from 172.217.3.36: seq=0 ttl=47 time=1.648 ms

--- www.google.com ping statistics ---
1 packets transmitted, 1 packets received, 0% packet loss
round-trip min/avg/max = 1.648/1.648/1.648 ms

Try connecting on a specific port:

$ cat connectonport 
#!cmd alpine bash
#!/bin/bash
telnet $REDOCTOBER $PORT <<HEREDOC
quit
HEREDOC
echo "no errors for connectonport" && exit 0

$ cat connectonport | ssh [email protected] :create connectonport
Creating command... done

$ ssh [email protected] :env connectonport set REDOCTOBER=www.google.com
Setting REDOCTOBER on connectonport... done

$ ssh [email protected] :env connectonport set PORT=80
Setting PORT on connectonport... done

$ ssh [email protected] :env connectonport
PORT:         80
REDOCTOBER:   www.google.com

$ ssh [email protected] connectonport 
no errors for connectonport

How long can my script live?

$ cat sandsofthehourglass 
#!cmd alpine bash
#!/bin/bash
count="0"
while [ "1" -gt 0 ] 
do
 sleep 1;
 count=$[$count+1]
 echo -n "$count "
done

$ cat sandsofthehourglass | ssh [email protected] :create sandsofthehourglass 
Creating command... done

$ ssh [email protected] sandsofthehourglass 
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27
 28 29 maximum runtime exceded

How can I set a description for my Command on :create requests? After a quick review of the source it seems to be a minor patch:

$ git diff
diff --git a/app/builtin/create.go b/app/builtin/create.go
index 52f5780..7b3bbe2 100644
--- a/app/builtin/create.go
+++ b/app/builtin/create.go
@@ -48,6 +48,7 @@ var createCmd = func(sess cli.Session) *cobra.Command {
                                Name:   args[0],
                                User:   sess.User(),
                                Source: string(source),
+                               Description: args[1],
                        }
 
                        if err := cmd.Build(); err != nil {

How can I test this? I'm new to 'go' but they're all the same right?

# I'm using a mac - linux/winders will require different install/setup
$ brew install golang
$ brew install glide
$ PROPER=~/go/src/github.com/gliderlabs; \
mkdir -p $PROPER && mv ~/my_git_projects_dir/cmd $PROPER/
$ glide install
$ make clean && make build

NOTE: Until I moved the cmd.git directory under the expected ~/go/src/github.com/gliderlabs location I was plagued by missing packages.

Clone this wiki locally