From 2c1cbefc07d9f02a5c58bfc2be096cfc867f22fd Mon Sep 17 00:00:00 2001 From: Fazlul Shahriar Date: Wed, 21 Jun 2017 17:02:19 -0400 Subject: [PATCH] add manage.bash --- app/config/dproofreads_config.sh | 4 +- build.sh | 3 -- manage.bash | 78 ++++++++++++++++++++++++++++++++ run.bash | 14 ------ 4 files changed, 80 insertions(+), 19 deletions(-) delete mode 100755 build.sh create mode 100755 manage.bash delete mode 100755 run.bash diff --git a/app/config/dproofreads_config.sh b/app/config/dproofreads_config.sh index ce2d993..ce70983 100644 --- a/app/config/dproofreads_config.sh +++ b/app/config/dproofreads_config.sh @@ -160,11 +160,11 @@ _FORUMS_URL=$base_url/phpBB3 # Something like 'Distributed Proofreaders' would be good. It should # make sense in contexts like 'Welcome to %s', and 'the %s website'. -_SITE_NAME=PICK_A_NAME +_SITE_NAME="Distributed Proofreaders" # Something like 'DP' would be good. It will be used in the HTML title # of each page ('%s: Welcome') and in the subject line of emails. -_SITE_ABBREVIATION=PICK_AN_ABBREVIATION +_SITE_ABBREVIATION=DP # Something like 'Thank you!\nThe Management' would be good. It will be # used in the footer of emails from the site. (Does not affect phpBB diff --git a/build.sh b/build.sh deleted file mode 100755 index 0eebd0d..0000000 --- a/build.sh +++ /dev/null @@ -1,3 +0,0 @@ -#!/bin/bash - -docker build --network=pgdp -t pgdp-web . diff --git a/manage.bash b/manage.bash new file mode 100755 index 0000000..43a1c3c --- /dev/null +++ b/manage.bash @@ -0,0 +1,78 @@ +#!/bin/bash + +set -e + +NET=dproofreaders + +containerstatus(){ + docker inspect -f '{{.State.Status}}' "$1" 2>/dev/null +} + +runimg(){ + name=$1 + shift + + case "$(containerstatus ${name})" in + running) + echo $name already running + ;; + exited) + echo docker start $name '#' currently stopped + ;; + *) + docker run -d --restart=always --network=$NET \ + --name=${name} --hostname=${name} "$@" + ;; + esac +} + +if ! docker network inspect "$NET" >/dev/null 2>&1 +then + docker network create $NET +fi + +showurl(){ + IP=$(docker inspect -f '{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' pgdp-web) + echo http://${IP}/ +} + +downloadsrc(){ + PHPBB_VER=3.0.14 + DP_VER=R201701 + ( + cd app/src + if [ ! -e "phpBB-${PHPBB_VER}.tar.bz2" ] + then + curl -L -O "https://www.phpbb.com/files/release/phpBB-${PHPBB_VER}.tar.bz2" + fi + if [ ! -e "dproofreaders.${DP_VER}.tgz" ] + then + curl -L -O "https://downloads.sourceforge.net/project/dproofreaders/dproofreaders/${DP_VER}/dproofreaders.${DP_VER}.tgz" + fi + ) +} + + +case "$1" in +url) + showurl + ;; +kill) + docker stop pgdp-sql pgdp-web + docker rm pgdp-sql pgdp-web + ;; +build) + downloadsrc + docker build --network=pgdp -t pgdp-web . + ;; +run) + runimg pgdp-sql -e 'MYSQL_ROOT_PASSWORD=dp_password' mysql:5.7 + sleep 10 # wait for mysql to start up + runimg pgdp-web pgdp-web + showurl + ;; +*) + echo usage: $0 '' + exit 2 + ;; +esac diff --git a/run.bash b/run.bash deleted file mode 100755 index 86721ee..0000000 --- a/run.bash +++ /dev/null @@ -1,14 +0,0 @@ -#!/bin/bash - -set -e - -docker stop pgdp-sql -docker rm pgdp-sql -docker run --name=pgdp-sql --network=pgdp \ - -e 'MYSQL_ROOT_PASSWORD=dp_password' -d mysql:5.7 - -sleep 10 - -docker stop pgdp-web -docker rm pgdp-web -docker run --name=pgdp-web --network=pgdp -d pgdp-web