Added WO_ prefix to env vars

pull/332/head
Piero Toffanin 2017-11-17 14:43:06 -05:00
rodzic 523f476540
commit 6353b5cc39
9 zmienionych plików z 56 dodań i 56 usunięć

14
.env
Wyświetl plik

@ -1,7 +1,7 @@
HOST=localhost
PORT=8000
MEDIA_DIR=appmedia
SSL=NO
SSL_KEY=
SSL_CERT=
SSL_INSECURE_PORT_REDIRECT=80
WO_HOST=localhost
WO_PORT=8000
WO_MEDIA_DIR=appmedia
WO_SSL=NO
WO_SSL_KEY=
WO_SSL_CERT=
WO_SSL_INSECURE_PORT_REDIRECT=80

Wyświetl plik

@ -3,5 +3,5 @@ version: '2'
services:
webapp:
volumes:
- ${SSL_KEY}:/webodm/nginx/ssl/key.pem
- ${SSL_CERT}:/webodm/nginx/ssl/cert.pem
- ${WO_SSL_KEY}:/webodm/nginx/ssl/key.pem
- ${WO_SSL_CERT}:/webodm/nginx/ssl/cert.pem

Wyświetl plik

@ -6,9 +6,9 @@ volumes:
services:
webapp:
ports:
- "${SSL_INSECURE_PORT_REDIRECT}:8080"
- "${WO_SSL_INSECURE_PORT_REDIRECT}:8080"
volumes:
- letsencrypt:/webodm/nginx/letsencrypt
environment:
- SSL
- SSL_KEY
- WO_SSL
- WO_SSL_KEY

Wyświetl plik

@ -19,9 +19,9 @@ services:
container_name: webapp
entrypoint: /bin/bash -c "chmod +x /webodm/*.sh && /bin/bash -c \"/webodm/wait-for-it.sh db:5432 -- /webodm/start.sh\""
volumes:
- ${MEDIA_DIR}:/webodm/app/media
- ${WO_MEDIA_DIR}:/webodm/app/media
ports:
- "${PORT}:8000"
- "${WO_PORT}:8000"
depends_on:
- db
environment:

Wyświetl plik

@ -9,12 +9,12 @@ if [ $not_found ]; then
exit 1
fi
if [ "$SSL" = "NO" ] || [ ! -z "$SSL_KEY" ]; then
if [ "$WO_SSL" = "NO" ] || [ ! -z "$WO_SSL_KEY" ]; then
echo "SSL not enabled, or manual SSL key specified, exiting."
exit 1
fi
DOMAIN="${HOST:=$1}"
DOMAIN="${WO_HOST:=$1}"
if [ -z $DOMAIN ]; then
echo "Usage: $0 <my.domain.com>"
exit 1

Wyświetl plik

@ -29,16 +29,16 @@ http {
# Redirect all non-encrypted to encrypted
server {
server_name $HOST;
server_name $WO_HOST;
listen 8080;
return 301 https://$HOST:$PORT$request_uri;
return 301 https://$WO_HOST:$WO_PORT$request_uri;
}
server {
listen 8000 deferred;
client_max_body_size 0;
server_name $HOST;
server_name $WO_HOST;
ssl on;
ssl_certificate /webodm/nginx/ssl/cert.pem

Wyświetl plik

@ -31,7 +31,7 @@ http {
listen 8000 deferred;
client_max_body_size 0;
server_name $HOST;
server_name $WO_HOST;
keepalive_timeout 5;

Wyświetl plik

@ -58,8 +58,8 @@ if [[ "$1" = "--create-default-pnode" ]]; then
echo "from nodeodm.models import ProcessingNode; ProcessingNode.objects.update_or_create(hostname='node-odm-1', defaults={'hostname': 'node-odm-1', 'port': 3000})" | python manage.py shell
fi
export HOST="${HOST:=localhost}"
export PORT="${PORT:=8000}"
export WO_HOST="${WO_HOST:=localhost}"
export WO_PORT="${WO_PORT:=8000}"
# Dump environment to .cronenv
printenv > .cronenv
@ -71,7 +71,7 @@ echo ==========================
echo -e "\033[39m"
echo "If there are no errors, WebODM should be up and running!"
echo -e "\033[93m"
echo Open a web browser and navigate to http://$HOST:$PORT
echo Open a web browser and navigate to http://$WO_HOST:$WO_PORT
echo -e "\033[39m"
echo -e "\033[91mNOTE:\033[39m Windows users using docker should replace localhost with the IP of their docker machine's IP. To find what that is, run: docker-machine ip") &
@ -85,12 +85,12 @@ else
echo "Generating nginx configurations from templates..."
for templ in nginx/*.template
do
echo "- $templ"
envsubst '\$HOST \$OTHER_VAR' < $templ > ${templ%.*}
echo "- ${templ%.*}"
envsubst '\$WO_PORT \$WO_HOST' < $templ > ${templ%.*}
done
# Check if we need to auto-generate SSL certs via letsencrypt
if [ "$SSL" = "YES" ] && [ -z "$SSL_KEY" ]; then
if [ "$WO_SSL" = "YES" ] && [ -z "$WO_SSL_KEY" ]; then
bash -c "nginx/letsencrypt-autogen.sh"
fi

Wyświetl plik

@ -20,11 +20,11 @@ fi
# Load default values
source .env
DEFAULT_PORT="$PORT"
DEFAULT_HOST="$HOST"
DEFAULT_MEDIA_DIR="$MEDIA_DIR"
DEFAULT_SSL="$SSL"
DEFAULT_SSL_INSECURE_PORT_REDIRECT="$SSL_INSECURE_PORT_REDIRECT"
DEFAULT_PORT="$WO_PORT"
DEFAULT_HOST="$WO_HOST"
DEFAULT_MEDIA_DIR="$WO_MEDIA_DIR"
DEFAULT_SSL="$WO_SSL"
DEFAULT_SSL_INSECURE_PORT_REDIRECT="$WO_SSL_INSECURE_PORT_REDIRECT"
# Parse args for overrides
POSITIONAL=()
@ -34,36 +34,36 @@ key="$1"
case $key in
--port)
export PORT="$2"
export WO_PORT="$2"
shift # past argument
shift # past value
;;
--hostname)
export HOST="$2"
export WO_HOST="$2"
shift # past argument
shift # past value
;;
--media-dir)
export MEDIA_DIR=$(realpath "$2")
export WO_MEDIA_DIR=$(realpath "$2")
shift # past argument
shift # past value
;;
--ssl)
SSL=YES
WO_SSL=YES
shift # past argument
;;
--ssl-key)
export SSL_KEY=$(realpath "$2")
export WO_SSL_KEY=$(realpath "$2")
shift # past argument
shift # past value
;;
--ssl-cert)
export SSL_CERT=$(realpath "$2")
export WO_SSL_CERT=$(realpath "$2")
shift # past argument
shift # past value
;;
--ssl-insecure-port-redirect)
export SSL_INSECURE_PORT_REDIRECT="$2"
export WO_SSL_INSECURE_PORT_REDIRECT="$2"
shift # past argument
shift # past value
;;
@ -143,20 +143,20 @@ run(){
start(){
command="docker-compose -f docker-compose.yml -f docker-compose.nodeodm.yml"
if [ "$SSL" = "YES" ]; then
if [ ! -z "$SSL_KEY" ] && [ ! -e "$SSL_KEY" ]; then
echo -e "\033[91mSSL key file does not exist: $SSL_KEY\033[39m"
if [ "$WO_SSL" = "YES" ]; then
if [ ! -z "$WO_SSL_KEY" ] && [ ! -e "$WO_SSL_KEY" ]; then
echo -e "\033[91mSSL key file does not exist: $WO_SSL_KEY\033[39m"
exit 1
fi
if [ ! -z "$SSL_CERT" ] && [ ! -e "$SSL_CERT" ]; then
echo -e "\033[91mSSL certificate file does not exist: $SSL_CERT\033[39m"
if [ ! -z "$WO_SSL_CERT" ] && [ ! -e "$WO_SSL_CERT" ]; then
echo -e "\033[91mSSL certificate file does not exist: $WO_SSL_CERT\033[39m"
exit 1
fi
command+=" -f docker-compose.ssl.yml"
method="Lets Encrypt"
if [ ! -z "$SSL_KEY" ] && [ ! -z "$SSL_CERT" ]; then
if [ ! -z "$WO_SSL_KEY" ] && [ ! -z "$WO_SSL_CERT" ]; then
method="Manual"
command+=" -f docker-compose.ssl-manual.yml"
fi
@ -165,15 +165,15 @@ start(){
# Check port settings
# as let's encrypt cannot communicate on ports
# different than 80 or 443
if [ "$PORT" != "$DEFAULT_PORT" ]; then
echo -e "\033[93mLets Encrypt cannot run on port: $PORT, switching to 443.\033[39m"
if [ "$WO_PORT" != "$DEFAULT_PORT" ]; then
echo -e "\033[93mLets Encrypt cannot run on port: $WO_PORT, switching to 443.\033[39m"
echo "If you need to use a different port, you'll need to generate the SSL certificate files separately and use the --ssl-key and --ssl-certificate options."
fi
export PORT=443
export WO_PORT=443
# Make sure we have a hostname
if [ "$HOST" = "localhost" ]; then
echo -e "\033[91mSSL is enabled, but hostname cannot be set to $HOST. Set the --hostname argument to the domain of your WebODM server (for example: www.mywebodm.org).\033[39m"
if [ "$WO_HOST" = "localhost" ]; then
echo -e "\033[91mSSL is enabled, but hostname cannot be set to $WO_HOST. Set the --hostname argument to the domain of your WebODM server (for example: www.mywebodm.org).\033[39m"
exit 1
fi
fi
@ -231,13 +231,13 @@ if [[ $1 = "start" ]]; then
echo ""
echo "Using the following environment:"
echo "================================"
echo "Host: $HOST"
echo "Port: $PORT"
echo "Media directory: $MEDIA_DIR"
echo "SSL: $SSL"
echo "SSL key: $SSL_KEY"
echo "SSL certificate: $SSL_CERT"
echo "SSL insecure port redirect: $SSL_INSECURE_PORT_REDIRECT"
echo "Host: $WO_HOST"
echo "Port: $WO_PORT"
echo "Media directory: $WO_MEDIA_DIR"
echo "SSL: $WO_SSL"
echo "SSL key: $WO_SSL_KEY"
echo "SSL certificate: $WO_SSL_CERT"
echo "SSL insecure port redirect: $WO_SSL_INSECURE_PORT_REDIRECT"
echo "================================"
echo "Make sure to issue a $0 down if you decide to change the environment."
echo ""