Skip to content

Instantly share code, notes, and snippets.

@metcalfc
Last active July 21, 2018 15:23
Show Gist options
  • Save metcalfc/50060709ee9d22ec620e to your computer and use it in GitHub Desktop.
Save metcalfc/50060709ee9d22ec620e to your computer and use it in GitHub Desktop.
#!/bin/bash
while [[ $# -gt 1 ]]
do
case "$1" in
-f | --file)
file="$2"
shift 2
;;
-h | --hostname)
hostname="$2"
shift 2
;;
-*)
echo "Error: Unknown option: $1" >&2
exit 1
;;
*) # No more options
break
;;
esac
done
if ! [ -n "${file:+1}" ]; then
echo "Must set -f or --file with path to CA cert"
exit 1
fi
if ! [ -n "${hostname:+1}" ]; then
echo "Must set -h or --host with docker-machine hostname"
exit 1
fi
docker-machine scp ${file} ${hostname}:dtr-ca.pem
docker-machine ssh ${hostname} sudo mv dtr-ca.pem /var/lib/boot2docker/dtr-ca.pem
docker-machine ssh ${hostname} 'echo "#!/bin/sh" | sudo tee /var/lib/boot2docker/bootlocal.sh'
docker-machine ssh ${hostname} 'echo "cat /var/lib/boot2docker/dtr-ca.pem >> /etc/ssl/certs/ca-certificates.crt" | sudo tee -a /var/lib/boot2docker/bootlocal.sh'
docker-machine ssh ${hostname} sudo chmod +x /var/lib/boot2docker/bootlocal.sh
docker-machine restart ${hostname}
@zonArt
Copy link

zonArt commented Jun 14, 2017

Thanks a lot for this little script, very useful. Could I suggest to enclose the commands (sudo chmod +x /var/lib/boot2docker/bootlocal.sh and sudo mv dtr-ca.pem /var/lib/boot2docker/dtr-ca.pem) with brackets ? It's not working for me without brackets with docker-toolbox

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment