-
-
Save thynctank/3f6fe990f56f0072be22f6aa4ba67da8 to your computer and use it in GitHub Desktop.
Yip Docker Machine configs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
#AWS stuff expected from your env... | |
#export AWS_ACCESS_KEY="AWS_ACCESS_KEY" | |
#export AWS_SECRET_KEY="AWS_SECRET_KEY" | |
#path all directories should be copied to | |
copy_path=$HOME/.docker/machine/machines | |
#copy from override location? Override next line | |
usb_key_docker_path=/Volumes/Samsung\ USB/.docker | |
#usb_key_docker_path="/Users/nickcarter/Desktop/juan-key-docker" | |
source_docker_machines_path="$usb_key_docker_path/machine/machines" | |
if [ -d "$source_docker_machines_path" ] && [ -d "$copy_path" ]; then | |
for machine_directory in $source_docker_machines_path/*; do | |
echo "Copying Directory -> $machine_directory" | |
cp -r -f $machine_directory $copy_path && echo "Done Copying Directory -> $machine_directory" | |
done | |
for machine_directory in $copy_path/*; do | |
#location of newly-copied directory's config.json | |
config_path="$machine_directory/config.json" | |
#update config.json for each dir | |
#TODO copy AccessKey and SecretKey (grab from AWS CLI) | |
#replace Juan with Me, and swap AccessKey and SecretKey values | |
sed -i -e -E "s,jt044c,$(whoami),g" $config_path && echo "Replaced Juan with Myself for $machine_directory" | |
sed -i -e -E "s,(AccessKey\": \").+\",\1$AWS_ACCESS_KEY\",g" $config_path && echo "Replaced AccessKey for $machine_directory" | |
sed -i -e -E "s,(SecretKey\": \").+\",\1$AWS_SECRET_KEY\",g" $config_path && echo "Replaced SecretKey for $machine_directory" | |
chmod 400 "$machine_directory/id_rsa" && echo "Set permissions to 400 for $machine_directory/id_rsa" | |
done | |
echo "Yipped!" | |
else | |
echo "Hooyip, we have a problem. $source_docker_machines_path or $copy_path is bogus!" | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment