Skip to content

Examples: add rancher #16

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Apr 19, 2016
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
43 changes: 43 additions & 0 deletions examples/start-rancher.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
#!/bin/sh

# create a machine for the Rancher server
docker-machine create -d scaleway --scaleway-name=rancher-server rancher-server || exit 1

# configure shell to use rancher-server
eval $(docker-machine env rancher-server)

# create a machine for a Rancher host
docker-machine create -d scaleway --scaleway-name=rancher-host-1 rancher-host-1 || exit 1 &

# start a Rancher Server on rancher-server
docker run -d --restart=always -p 8080:8080 rancher/server || exit 1

false
while [ "$?" != "0" ]
do
# wait for Rancher Server installation
docker logs $(docker ps -q) | grep "Startup Succeeded"
done

# wait for background tasks
wait `jobs -p` || true

IP=$(docker-machine ip rancher-server)

sleep 10

# generate a token
curl 'http://'$IP':8080/v1/registrationtoken' -H 'x-api-project-id: 1a5' -H 'Accept: application/json' --data-binary '{"type":"registrationToken"}' --compressed > /dev/null
sleep 5
CMD=$(curl 'http://'$IP':8080/v1/registrationtokens?state=active&limit=-1' -H 'x-api-project-id: 1a5' -H 'Accept: application/json' --compressed | jq '.data[0].command' | sed 's/sudo//g' | tr -d '"')

# start a Rancher Agent on rancher-server
$CMD || exit 1

# configure shell to use rancher-host-1
eval $(docker-machine env rancher-host-1)

# start a Rancher Agent on rancher-host-1
$CMD || exit 1

echo "Open your browser at http://"$IP":8080"