X-Git-Url: https://vcs.fsf.org/?a=blobdiff_plain;f=launcher;h=27b6a8d6e1e6ece0863a74f4a89b75375b4ee180;hb=955d360c6d016a601134f0fbe992a9dda19c854d;hp=02687299951a029d2ebff763b22ca258e24e3698;hpb=cec2be292738f7d5bfbf61834897250f9717f6d8;p=discourse_docker.git diff --git a/launcher b/launcher index 0268729..27b6a8d 100755 --- a/launcher +++ b/launcher @@ -25,9 +25,11 @@ user_args="" while [ ${#} -gt 0 ]; do case "${1}" in - + --debug) + DEBUG="1" + ;; --skip-prereqs) - SKIP_PREREQ="1" + SKIP_PREREQS="1" ;; --docker-args) user_args="$2" @@ -50,15 +52,15 @@ fi cd "$(dirname "$0")" -docker_min_version='1.6.0' -docker_rec_version='1.6.0' +docker_min_version='1.8.0' +docker_rec_version='1.8.0' git_min_version='1.8.0' git_rec_version='1.8.0' config_file=containers/"$config".yml cidbootstrap=cids/"$config"_bootstrap.cid local_discourse=local_discourse -image=discourse/discourse:1.0.17 +image=discourse/discourse:1.3.2 docker_path=`which docker.io || which docker` git_path=`which git` @@ -108,10 +110,7 @@ compare_version() { install_docker() { echo "Docker is not installed, you will need to install Docker in order to run Launcher" - echo "Please visit https://docs.docker.com/installation/ for instructions on how to do this for your system" - echo - echo "If you are running a recent Ubuntu Server, try the following:" - echo "sudo apt-get install docker-engine" + echo "See https://docs.docker.com/installation/" exit 1 } @@ -449,9 +448,12 @@ run_start() { # docker added more hostname rules hostname=${hostname//_/-} + mac_address="--mac-address $($docker_path run $user_args -i --rm -a stdout -a stderr $image /bin/sh -c "echo $hostname | md5sum | sed 's/^\(..\)\(..\)\(..\)\(..\)\(..\).*$/02:\1:\2:\3:\4:\5/'")" + set -x $docker_path run $user_args $links $attach_on_run $restart_policy "${env[@]}" -h "$hostname" \ - -e DOCKER_HOST_IP=$docker_ip --name $config -t $ports $volumes $docker_args $run_image $boot_command + -e DOCKER_HOST_IP=$docker_ip --name $config -t $ports $volumes $mac_address $docker_args \ + $run_image $boot_command ) exit 0 @@ -493,11 +495,21 @@ run_bootstrap() { echo $run_command + unset FAILED (exec echo "$input" | $docker_path run $user_args $links "${env[@]}" -e DOCKER_HOST_IP=$docker_ip --cidfile $cidbootstrap -i -a stdin -a stdout -a stderr $volumes $image \ - /bin/bash -c "$run_command") \ - || ($docker_path rm `cat $cidbootstrap` && rm $cidbootstrap) + /bin/bash -c "$run_command") || FAILED="TRUE" - [ ! -e $cidbootstrap ] && echo "** FAILED TO BOOTSTRAP ** please scroll up and look for earlier error messages, there may be more than one" && exit 1 + if [[ $FAILED = "TRUE" ]]; then + if [[ ! -z "$DEBUG" ]]; then + $docker_path commit `cat $cidbootstrap` $local_discourse/$config-debug || echo 'FAILED TO COMMIT' + echo "** DEBUG ** Maintaining image for diagnostics $local_discourse/$config-debug" + fi + + $docker_path rm `cat $cidbootstrap` + rm $cidbootstrap + echo "** FAILED TO BOOTSTRAP ** please scroll up and look for earlier error messages, there may be more than one" + exit 1 + fi sleep 5