Skip to content

Instantly share code, notes, and snippets.

@johanneswuerbach
Forked from santiycr/sauce_connect_setup.sh
Last active August 29, 2015 14:13
Show Gist options
  • Save johanneswuerbach/e4950820c0d685fc545e to your computer and use it in GitHub Desktop.
Save johanneswuerbach/e4950820c0d685fc545e to your computer and use it in GitHub Desktop.
Setup a Sauce Connect 3 tunnel
#!/bin/bash
if [ -z "${SAUCE_USERNAME}" ] || [ -z "${SAUCE_ACCESS_KEY}" ]; then
echo "This script can't run without your Sauce credentials"
echo "Please set SAUCE_USERNAME and SAUCE_ACCESS_KEY env variables"
echo "export SAUCE_USERNAME=ur-username"
echo "export SAUCE_ACCESS_KEY=ur-access-key"
exit 1
fi
SAUCE_TMP_DIR="$(mktemp -d -t sc.XXXX)"
echo "Using temp dir $SAUCE_TMP_DIR"
pushd $SAUCE_TMP_DIR
SC_DISTRIBUTION="Sauce-Connect-latest.zip"
SC_READYFILE=sauce-connect-ready-$RANDOM
SC_LOGFILE=$HOME/sauce-connect.log
if [ ! -z "${TRAVIS_JOB_NUMBER}" ]; then
SC_TUNNEL_ID="-i ${TRAVIS_JOB_NUMBER}"
fi
echo "Downloading Sauce Connect"
wget http://saucelabs.com/downloads/${SC_DISTRIBUTION}
echo "Extracting Sauce Connect"
unzip $SC_DISTRIBUTION
echo "Starting Sauce Connect"
java -jar Sauce-Connect.jar --readyfile $SC_READYFILE \
$SC_TUNNEL_ID \
$SAUCE_USERNAME $SAUCE_ACCESS_KEY 1> $SC_LOGFILE &
echo "Waiting for Sauce Connect readyfile"
while [ ! -f ${SC_READYFILE} ]; do
sleep .5
done
unset SAUCE_TMP_DIR SC_DISTRIBUTION SC_READYFILE SC_LOGFILE SC_TUNNEL_ID
popd
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment