use sauceproxy_ctl separatly
3 files changed, 39 insertions(+), 39 deletions(-)

M README.md
A => generate_config.sh
R scfs.sh => 
M README.md +4 -0
@@ 1,6 1,10 @@ 
 Dependencies
 ============
 
+go build github.com/saucelabs/sauceproxy-rest/cmd/sauceproxy_ctl
+go build github.com/elazarl/goproxy/examples/goproxy-basic
+go build bitbucket.org/henry/kgp/cmd/kgpdemux
+
     - stunnel
     - HTTP forwarding proxy
 

          
A => generate_config.sh +35 -0
@@ 0,0 1,35 @@ 
+#!/bin/sh
+#
+# assumes sauceproxy_ctl is installed
+#
+#   go get github.com/saucelabs/sauceproxy-rest
+#   go build github.com/saucelabs/sauceproxy-rest/cmd/sauceproxy_ctl
+#
+
+SSLSOCK='localhost:4443'
+
+tunnelid="$@"
+
+# Get the tunnel's address
+kgp_host=$(./sauceproxy_ctl kgp_host $tunnelid)
+printf 'Tunnel Address: %s\n' "$kgp_host"
+
+# Create metadata file for kgpdemux
+cat > ./meta.json <<EOF
+{"username": "$SAUCE_USERNAME", "access_key": "$SAUCE_ACCESS_KEY"}
+EOF
+
+# Create configuration file for stunnel
+cat > ./stunnel.conf <<EOF
+foreground = yes
+pid =
+[kgp]
+client = yes
+connect = $kgp_host:443
+accept = $SSLSOCK
+sni = $kgp_host
+EOF
+
+# Ask the user to run the other programs
+printf 'run stunnel ./stunnel.conf\n'
+printf 'then ./kgpdemux tcp://%s <proxy address> < ./meta.json\n' "$SSLSOCK"

          
R scfs.sh =>  +0 -39
@@ 1,39 0,0 @@ 
-#!/bin/sh
-#
-# assumes sauceproxy_ctl is installed
-#
-#   go get github.com/saucelabs/sauceproxy-rest
-#   go build github.com/saucelabs/sauceproxy-rest/cmd/sauceproxy_ctl
-#
-
-readonly ctl='./sauceproxy_ctl -v'
-readonly sslsock=/tmp/scfs_stunnel.sock
-
-echo 'Creating tunnel'
-readonly tunnelid=$($ctl create)
-trap "$ctl shutdown $tunnelid" INT
-readonly kgp_host=$($ctl kgp_host $tunnelid)
-printf 'Tunnel ID: %s, Tunnel Address: %s\n' "$tunnelid" "$kgp_host"
-
-cat > ./meta.json <<EOF
-{"username": "$SAUCE_USERNAME", "access_key": "$SAUCE_ACCESS_KEY"}
-EOF
-
-cat > ./stunnel.conf <<EOF
-foreground = yes
-pid =
-[kgp]
-client = yes
-connect = $kgp_host:443
-accept = $sslsock
-sni = $kgp_host
-EOF
-
-printf 'run stunnel ./stunnel.conf\n'
-printf 'then ./kgp_client unix://%s <proxy address> < ./meta.json\n' "$sslsock"
-# Ping the tunnel in the background
-while true
-do
-    $ctl ping -c $tunnelid || { echo "keepalive error"; break; }
-    sleep 240
-done