2 files changed, 40 insertions(+), 0 deletions(-)

A => .hgignore
A => scfs.sh
A => .hgignore +1 -0
@@ 0,0 1,1 @@ 
+stunnel.conf

          
A => scfs.sh +39 -0
@@ 0,0 1,39 @@ 
+#!/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