-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathstart-server.sh
executable file
·47 lines (39 loc) · 1.23 KB
/
start-server.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
#!/bin/bash -eu
set -o pipefail
SCRIPT_DIR=$(cd $(dirname "$0"); pwd)
. "$SCRIPT_DIR"/scripts/lib-logging.sh
trap "handle_error" 0
function handle_error () {
error "$STAGE failed"
warnings
}
STAGE="Initialising"
if [ -z "$(ls "$SCRIPT_DIR"/webDiplomacy)" ] ; then
warn "Missing source directory for webDiplomacy; running git submodule commands"
git submodule init
git submodule update --remote
fi
INSTALLED_CONFIG="$SCRIPT_DIR"/webDiplomacy/config.php
CONFIG="$SCRIPT_DIR"/config.php
if [ -f "$INSTALLED_CONFIG" ] ; then
if [ "`cat "$CONFIG" | diff - $INSTALLED_CONFIG | cat`" != "" ] ; then
warn "Config file '$INSTALLED_CONFIG' has changed from the development version"
warn_info "If this is not expected, you may need to run the following command:"
warn_info " cp $CONFIG $INSTALLED_CONFIG"
fi
else
log "Installing config.php"
cp $CONFIG $INSTALLED_CONFIG
fi
STAGE="Build"
log "Building image"
docker build -t webdiplomacydev $SCRIPT_DIR
log "Starting server"
if [ -z ${WEBDIP_PORT+x} ] ; then
WEBDIP_PORT=80
fi
trap "log 'Server stopped' ;warnings" 0
docker run -p $WEBDIP_PORT:80 --rm -t -i \
-v "$SCRIPT_DIR"/webDiplomacy:/var/www/example.com/public_html \
-e WEBDIP_PORT=$WEBDIP_PORT \
webdiplomacydev