command=$1
config=$2
-config_file="$config".yml
+config_file=containers/"$config".yml
cidfile=cids/"$config".cid
cidbootstrap=cids/"$config"_boostrap.cid
local_discourse=local_discourse
image=samsaffron/discourse
docker_path=`which docker`
+docker_ip=`/sbin/ifconfig | \
+ grep -B1 "inet addr" | \
+ awk '{ if ( $1 == "inet" ) { print $2 } else if ( $2 == "Link" ) { printf "%s:" ,$1 } }' | \
+ grep docker0 | \
+ awk -F: '{ print $3 }';`
+
+
usage () {
echo "Usage: launcher COMMAND CONFIG"
echo "Commands:"
echo " destroy: Stop and remove a container"
echo " ssh: Start a bash shell in a running container"
echo " logs: Docker logs for container"
- echo " bootstrap: Bootstrap a container for the config base on an image"
+ echo " bootstrap: Bootstrap a container for the config based on a template"
exit 1
}
"require 'yaml'; puts YAML.load(STDIN.readlines.join)['templates']"`
arrTemplates=(${templates// / })
- input=$(cat $config_file)
-
+ config_data=$(cat $config_file)
+ input="hack: true"
for template in "${arrTemplates[@]}"
do
}
done
+ # we always want our config file last so it takes priority
+ input="$input _FILE_SEPERATOR_ $config_data"
+
set_volumes
rm -f $cidbootstrap
- (exec echo "$input" | docker run -cidfile $cidbootstrap -i -a stdin -a stdout -a stderr $volumes $image \
+ (exec echo "$input" | docker run -e DOCKER_HOST_IP=$docker_ip -cidfile $cidbootstrap -i -a stdin -a stdout -a stderr $volumes $image \
/bin/bash -c 'cd /pups && git pull && /pups/bin/pups --stdin') \
|| (docker rm `cat $cidbootstrap` && rm $cidbootstrap)
set_volumes
- docker run -name $config -cidfile $cidfile $ports -d $volumes $local_discourse/$config /usr/bin/runsvdir -P /etc/service
+ docker run -e DOCKER_HOST_IP=$docker_ip -name $config -cidfile $cidfile $ports \
+ -d $volumes $local_discourse/$config /usr/bin/runsvdir -P /etc/service
+
exit 0
else
echo "cid found, ensuring container is started"