Switch branches/tags
Nothing to show
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
executable file 68 lines (60 sloc) 2.4 KB
# Capture Azure SPN password in variable as part of Dockerfile
echo "Enter the password for SPN '$spn' and press [ENTER]: "
read -s password
# Login into azure using SPN
if az account show &>/dev/null; then
echo "You are already logged in to Azure..."
echo "Logging into Azure using supplied SPN '$spn' and provided password..."
az login \
--service-principal \
-u $spn \
-p $password \
--tenant $tenant &>/dev/null
echo "Successfully logged into Azure..."
# Code to capture ACS master info
master_fqdn=$(az acs show -n $Servicename -g $Resource | jq -r '.masterProfile | .fqdn')
echo "Successfully captured your Master FQDN: $master_fqdn"
# Code to capture ACS agents info
agents_fqdn=$(az acs show -n $Servicename -g $Resource | jq -r '.agentPoolProfiles[0].fqdn')
echo "Successfully captured your Agents FQDN: $agents_fqdn"
# Create SSH Tunnel and check to ensure tunnel is successfully created, if errors, try again up to 5 times
echo "Opening SSH tunnel to ACS..."
until [ $n -ge 5 ]
ssh -fNL $local_port:localhost:$remote_port -p 2200 azureuser@$master_fqdn -o StrictHostKeyChecking=no -o ServerAliveInterval=240 &>/dev/null && echo "ACS SSH Tunnel successfully opened..." && break
n=$((n+1)) &>/dev/null && echo "SSH tunnel is not ready. Retrying in 5 seconds..."
sleep 5
# Check for ACS Cluster Node availability, if errors, try again up to 5 times - only necessary if ACS Cluster was recently deployed
until [ $n -ge 5 ]
docker info | grep 'Nodes: [1-9]' &>/dev/null && echo "Swarm cluster is ready..." && break
n=$((n+1)) &>/dev/null && echo "Swarm cluster is not ready. Retrying in 45 seconds..."
sleep 45
# Docker check if first arg is `-f` or `--some-option`
if [ "${1:0:1}" = '-' ]; then
set -- docker "$@"
# If our command is a valid Docker subcommand, invoke it through Docker instead - (this allows for "docker run docker ps", etc)
if docker help "$1" &>/dev/null; then
set -- docker "$@"
# Out to end user and execute docker command
echo "Reminder: Your web applications can be viewed here: $agents_fqdn"
sleep 5
echo "Executing supplied Swarm command: '$@'"
# Retry logic for executing command
until [ $n -ge 5 ]
eval "$@" && echo "'$@' completed" && break
n=$((n+1)) &>/dev/null && echo "Retrying '$@'in 5 seconds..."
sleep 5
exit $?