add manage.bash

This commit is contained in:
Fazlul Shahriar
2017-06-21 17:02:19 -04:00
parent b784059791
commit 2c1cbefc07
4 changed files with 80 additions and 19 deletions

View File

@@ -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

View File

@@ -1,3 +0,0 @@
#!/bin/bash
docker build --network=pgdp -t pgdp-web .

78
manage.bash Executable file
View File

@@ -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 '<url|kill|build|run>'
exit 2
;;
esac

View File

@@ -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