#!/bin/bash
set -xe

if docker -H docker-host.lagoon.svc info &> /dev/null; then
    export DOCKER_HOST=docker-host.lagoon.svc
else
    echo "could not connect to docker-host.lagoon.svc, trying fallback of docker-host.default.svc";
    if docker -H docker-host.default.svc info &> /dev/null; then
        export DOCKER_HOST=docker-host.default.svc
    else
        echo "could not connect to docker-host.default.svc";
    fi
fi

mkdir -p ~/.ssh

cp /var/run/secrets/lagoon/ssh/ssh-privatekey ~/.ssh/id_rsa
echo -e "Host * \n    StrictHostKeyChecking no" > ~/.ssh/config
chmod 400 ~/.ssh/*

eval $(ssh-agent)
ssh-add ~/.ssh/id_rsa

#!/bin/bash
set -xe

if docker -H docker-host.lagoon.svc info &> /dev/null; then
    export DOCKER_HOST=docker-host.lagoon.svc
else
    echo "could not connect to docker-host.lagoon.svc, trying fallback of docker-host.default.svc";
    if docker -H docker-host.default.svc info &> /dev/null; then
        export DOCKER_HOST=docker-host.default.svc
    else
        echo "could not connect to docker-host.default.svc";
    fi
fi

mkdir -p ~/.ssh

cp /var/run/secrets/lagoon/ssh/ssh-privatekey ~/.ssh/key

# Add a new line to the key, as some ssh key formats need a new line
echo "" >> ~/.ssh/key

echo -e "Host * \n    StrictHostKeyChecking no" > ~/.ssh/config
chmod 400 ~/.ssh/*

eval $(ssh-agent)
ssh-add ~/.ssh/key

Add a new line to the key, as some ssh key formats need a new line
Add a new line to the key, as some ssh key formats need a new line
