Created
February 28, 2018 09:57
-
-
Save lahma/f9e9ae8df5ebeabc2600fe068c1a1a5b to your computer and use it in GitHub Desktop.
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 | |
# based on https://raw.githubusercontent.com/kvaes/docker-rancher-scripts/master/agent-with-local-ip/rancher.sh | |
# Variable Check | |
echo "# Checking Variables" | |
if [ -z "$1" ]; | |
then | |
echo "!!! no hosturl was supplied" | |
exit 2 | |
else | |
echo "### Host Url detected" | |
fi | |
AGENT_VERSION="" | |
if [ -z "$2" ]; | |
AGENT_VERSION="v1.2.9" | |
then | |
else | |
AGENT_VERSION=$2 | |
echo "### Custom agent version detected" | |
fi | |
# Variable Setup | |
echo "# Setting Variables" | |
HOST_URL=$1 | |
LOCAL_IP=`ifconfig eth0 | awk '/inet addr/{print substr($2,6)}'` | |
STATUS=255 | |
SLEEP=5 | |
echo "### Server = $HOST_URL" | |
echo "### Version = $AGENT_VERSION" | |
echo "### Agent IP = $LOCAL_IP" | |
# Rancher Agent Installation | |
echo "# Debug" | |
ps -ef | |
echo "# Installing Rancher Agent" | |
while [ $STATUS -gt 0 ] | |
do | |
sleep $SLEEP | |
OUTPUT=`sudo docker run -e "CATTLE_AGENT_IP=$LOCAL_IP" -d --privileged -v /var/run/docker.sock:/var/run/docker.sock -v /var/lib/rancher:/var/lib/rancher rancher/agent:$AGENT_VERSION $HOST_URL 2>&1` | |
STATUS=$? | |
echo $OUTPUT | |
done | |
exit $STATUS |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment