Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
#!/usr/bin/env sh
docker-machine rm -f rancher host1
docker-machine create rancher --driver virtualbox --virtualbox-cpu-count "-1" --virtualbox-disk-size "8000" --virtualbox-memory "512" --virtualbox-boot2docker-url=https://github.com/boot2docker/boot2docker/releases/download/v1.11.2/boot2docker.iso
docker-machine scp scripts/rancher-net.sh rancher:.
docker-machine ssh rancher sh rancher-net.sh
docker-machine regenerate-certs rancher -f
eval $(docker-machine env rancher)
docker-compose up -d
eval $(docker-machine env -u)
docker-machine create host1 --driver virtualbox --virtualbox-cpu-count "-1" --virtualbox-disk-size "54000" --virtualbox-memory "2048" --virtualbox-boot2docker-url=https://github.com/boot2docker/boot2docker/releases/download/v1.11.2/boot2docker.iso
docker-machine scp scripts/host1-net.sh host1:.
docker-machine ssh host1 sh host1-net.sh
docker-machine scp scripts/host1-add.sh host1:.
docker-machine ssh host1 sh host1-add.sh
docker-machine scp host1:api-keys .
#!/bin/sh
if [ ! -e "/usr/local/bin/jq" ]; then
sudo wget -O /usr/local/bin/jq https://github.com/stedolan/jq/releases/download/jq-1.5/jq-linux64
sudo chmod +x /usr/local/bin/jq
fi
PID=`curl -s -X GET -H "Accept: application/json" http://192.168.99.100:8080/v1/projects | jq -r '.data[0].id'`
TID=`curl -s -X POST -H "Accept: application/json" -H "Content-Type: application/json" http://192.168.99.100:8080/v1/projects/$PID/registrationTokens | jq -r '.id'`
touch token.json
while [ `jq -r .command token.json | wc -c` -lt 10 ]; do
curl -s -X GET -H "Accept: application/json" http://192.168.99.100:8080/v1/projects/$PID/registrationToken/$TID > token.json
sleep 1
done
CMD=`jq -r .command token.json`
eval $CMD
touch apiout.json
while [ `jq -r .secretValue apiout.json | wc -c` -eq 0 ]; do
curl -s -X POST -H "Accept: application/json" -H "Content-Type: application/json" -d '{"accountId":"1a1", "publicValue":"publicKey", "secretValue":"secretKey"}' http://192.168.99.100:8080/v1/projects/$PID/apikeys > apiout.json
sleep 1
done
echo export RANCHER_URL=http://192.168.99.100:8080/v1/projects/$PID > api-keys
echo export RANCHER_ACCESS_KEY=`jq -r '.publicValue' apiout.json` >> api-keys
echo export RANCHER_SECRET_KEY=`jq -r '.secretValue' apiout.json` >> api-keys
#!/bin/sh
sudo mkdir /mnt/sda1/var/lib/rancher
cp /var/lib/boot2docker/profile .
cat >> ./profile <<PROFILE
sudo cat /var/run/udhcpc.eth1.pid | xargs sudo kill
sudo ifconfig eth1 192.168.99.101 netmask 255.255.255.0 broadcast 192.168.99.255 up
sudo mkdir /var/lib/rancher
sudo mount -r /mnt/sda1/var/lib/rancher /var/lib/rancher
PROFILE
sudo mv ./profile /var/lib/boot2docker/profile
sh /var/lib/boot2docker/profile
#!/bin/sh
cp /var/lib/boot2docker/profile ./profile
cat >> ./profile <<PROFILE
sudo cat /var/run/udhcpc.eth1.pid | xargs sudo kill
sudo ifconfig eth1 192.168.99.100 netmask 255.255.255.0 broadcast 192.168.99.255 up
PROFILE
sudo mv ./profile /var/lib/boot2docker/profile
sh /var/lib/boot2docker/profile
@vikas027

This comment has been minimized.

Copy link

@vikas027 vikas027 commented Mar 13, 2017

Good job @mathuin. This works for v1.4.2 (latest stable as on date) too. Thanks.

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