diff docker/libervia_cont.sh @ 88:f7d275afc4f2

docker (libervia_cont): TLS dir (directory with certificate) can now be specified with env variable "SAT_CONT_TLS_DIR"
author Goffi <goffi@goffi.org>
date Fri, 19 Feb 2016 13:35:25 +0100
parents 53a579906c32
children 09099ce530da
line wrap: on
line diff
--- a/docker/libervia_cont.sh	Thu Feb 18 18:34:11 2016 +0100
+++ b/docker/libervia_cont.sh	Fri Feb 19 13:35:25 2016 +0100
@@ -19,6 +19,9 @@
 VERSION="0.3.0"
 ACCOUNT="salutatoi"
 
+# environment variables that can be used for configuration:
+# SAT_CONT_TLS_DIR for TLS certificates directory
+
 CONTAINERS="prosody sat_pubsub salut sat libervia"
 
 DK_DETACH="-d"
@@ -50,6 +53,7 @@
 HELP_SITE="http://wiki.goffi.org/wiki/Docker/en"
 HELP_MUC="sat@chat.jabberfr.org"
 
+CONT_CERT_DIR="/usr/share/sat/certificates"
 DEFAULT_TMP_DIR="/tmp/tmp_sat_docker"
 
 get_dyn_var() {
@@ -216,9 +220,14 @@
             fi
         fi
         printf "\nRunning Libervia\n\n"
+        # we first check if we need to mount TLS directory
+        if [ -n "$SAT_CONT_TLS_DIR" ]; then
+            printf "$SAT_CONT_TLS_DIR will be used for TLS certificate\n"
+            DK_TLS="--volume=$SAT_CONT_TLS_DIR:$CONT_CERT_DIR"
+        fi
         for CONT in $CONTAINERS; do
             case $CONT in
-                prosody) OPTS="$DK_DETACH $DK_TERM $DK_VOLUME $(public_ports_arg $CONT) --name prosody"
+                prosody) OPTS="$DK_DETACH $DK_TERM $DK_VOLUME $DK_TLS $(public_ports_arg $CONT) --name prosody"
                          if [ -n "$DOMAIN" ]; then
                              OPTS="-e DOMAIN=$DOMAIN $OPTS"
                          fi
@@ -226,7 +235,7 @@
                 sat_pubsub) OPTS="$DK_DETACH $DK_TERM $DK_VOLUME --name sat_pubsub --link=prosody:prosody";;
                 salut) OPTS="$DK_DETACH $DK_TERM $DK_VOLUME --name salut --link=prosody:prosody";;
                 sat) OPTS="$DK_DETACH $DK_TERM $DK_VOLUME -P $(public_ports_arg $CONT) --name sat --link=prosody:prosody";;
-                libervia) OPTS="$DK_DETACH $DK_TERM $DK_VOLUME --volumes-from sat -P $(public_ports_arg $CONT) --name libervia --link=sat:sat";;
+                libervia) OPTS="$DK_DETACH $DK_TERM $DK_VOLUME --volumes-from sat $DK_TLS -P $(public_ports_arg $CONT) --name libervia --link=sat:sat";;
                 *) printf "Unkown container $CONT\n"; exit 1
             esac
             printf "Launching $CONT... "
@@ -308,7 +317,7 @@
         printf "restoring $1 to $VOLUME_ALIAS container\n\n"
         HOST_BACKUP_DIR="$(dirname "$1")"
         if [ $HOST_BACKUP_DIR = "." ]; then
-			# workaround for a Docker bug (container crash if "." is used)
+            # workaround for a Docker bug (container crash if "." is used)
             HOST_BACKUP_DIR=$(pwd)
         fi
         docker run --rm $DK_VOLUME -v "$HOST_BACKUP_DIR:/backup" debian:jessie tar zxvf "/backup/$1" -C / -h volumes