From: Sam Date: Mon, 8 Sep 2014 02:52:04 +0000 (+1000) Subject: FEATURE: host_run support, to simplify provisioning X-Git-Url: https://vcs.fsf.org/?a=commitdiff_plain;h=60f9f04cf8d78e7c38b4e020abdf262ee8a1dbe3;p=discourse_docker.git FEATURE: host_run support, to simplify provisioning --- diff --git a/launcher b/launcher index bc7f204..cd33f0b 100755 --- a/launcher +++ b/launcher @@ -152,6 +152,37 @@ install_docker() { exit 1 } +host_run() { + read -r -d '' env_ruby << 'RUBY' + require 'yaml' + + input = STDIN.readlines.join + yaml = YAML.load(input) + + if host_run = yaml['host_run'] + params = yaml['params'] || {} + host_run.each do |run| + params.each do |k,v| + run = run.gsub("$#{k}", v) + end + STDOUT.write "#{run}--SEP--" + end + end +RUBY + + host_run=`cat $config_file | $docker_path run --rm -i -a stdout -a stdin $image ruby -e "$env_ruby"` + + while [ "$host_run" ] ; do + iter=${host_run%%--SEP--*} + echo + echo "Host run: $iter" + $iter || exit 1 + echo + host_run="${host_run#*--SEP--}" + done +} + + set_volumes() { volumes=`cat $config_file | $docker_path run --rm -i -a stdout -a stdin $image ruby -e \ "require 'yaml'; puts YAML.load(STDIN.readlines.join)['volumes'].map{|v| '-v ' << v['volume']['host'] << ':' << v['volume']['guest'] << ' '}.join"` @@ -269,6 +300,8 @@ run_stop(){ run_start(){ + host_run + if [ ! -e $cidfile ] then echo "No cid found, creating a new container" @@ -316,6 +349,9 @@ run_start(){ } run_bootstrap(){ + + host_run + get_ssh_pub_key # Is the image available?