From: Sam Saffron Date: Thu, 28 Nov 2013 00:13:23 +0000 (-0800) Subject: clean up bootstrapper, make it more robust X-Git-Url: https://vcs.fsf.org/?a=commitdiff_plain;h=2162f1d4ee2d5f72cd045daffbb4869067efae83;p=discourse_docker.git clean up bootstrapper, make it more robust init clean data dir --- diff --git a/launcher b/launcher index a8f1d36..1031f14 100755 --- a/launcher +++ b/launcher @@ -79,16 +79,20 @@ case "$command" in set_volumes - docker run -cidfile $cidbootstrap -i -a stdin -a stdout -a stderr $image /bin/bash -c 'cd /pups && git pull' - docker commit `cat $cidbootstrap` $local_discourse/up_to_date_pups - docker rm `cat $cidbootstrap` && rm $cidbootstrap + rm -f $cidbootstrap + + (exec echo "$input" | docker run -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) - (exec echo "$input" | docker run -cidfile $cidbootstrap -i -a stdin -a stdout -a stderr $volumes $local_discourse/up_to_date_pups /pups/bin/pups --stdin) \ - || exit 1 && docker rm `cat $cidbootstrap` && rm $cidbootstrap && exit 1 + [ ! -e $cidbootstrap ] && echo "FAILED TO BOOTSTRAP" && exit 1 + + sleep 5 - sleep 10 docker commit `cat $cidbootstrap` $local_discourse/$config || echo 'FAILED TO COMMIT' docker rm `cat $cidbootstrap` && rm $cidbootstrap + + echo "Successfully bootstrappd, to starup use ./launcher start $config" exit 0 ;; diff --git a/templates/postgres.template.yml b/templates/postgres.template.yml index b42145c..6e8a746 100644 --- a/templates/postgres.template.yml +++ b/templates/postgres.template.yml @@ -50,9 +50,7 @@ hooks: from: "# postgres" to: sv start postgres || exit 1 - run: - - file: path: /etc/service/postgres/run chmod: "+x" @@ -64,7 +62,7 @@ run: - exec: cmd: - chown -R root /var/lib/postgresql/9.2/main - - "[ ! -e /shared/postgres_data ] && cp -r /var/lib/postgresql/9.2/main /shared/postgres_data || exit 0" + - "[ ! -e /shared/postgres_data ] && install -d -m 0755 -o postgres -g postgres /shared/postgres_data && sudo -u postgres /usr/lib/postgresql/9.2/bin/initdb -D /shared/postgres_data || exit 0" - chown -R postgres:postgres /shared/postgres_data - replace: