comparison docker/libervia_cont.sh @ 89:09099ce530da

docker (libervia_cont): domain can now be specified with "SAT_CONT_DOMAIN" env variable in addition to command line argument + use https for help site (wiki)
author Goffi <goffi@goffi.org>
date Fri, 19 Feb 2016 14:14:16 +0100
parents f7d275afc4f2
children 64623a78af2f
comparison
equal deleted inserted replaced
88:f7d275afc4f2 89:09099ce530da
19 VERSION="0.3.0" 19 VERSION="0.3.0"
20 ACCOUNT="salutatoi" 20 ACCOUNT="salutatoi"
21 21
22 # environment variables that can be used for configuration: 22 # environment variables that can be used for configuration:
23 # SAT_CONT_TLS_DIR for TLS certificates directory 23 # SAT_CONT_TLS_DIR for TLS certificates directory
24 # SAT_CONT_DOMAIN for the host name
24 25
25 CONTAINERS="prosody sat_pubsub salut sat libervia" 26 CONTAINERS="prosody sat_pubsub salut sat libervia"
26 27
27 DK_DETACH="-d" 28 DK_DETACH="-d"
28 DK_TERM="-ti" 29 DK_TERM="-ti"
48 49
49 DOCKER_EXE="docker" 50 DOCKER_EXE="docker"
50 51
51 USAGE="Usage: $0 [start|stop|restart|update|backup|restore|ports|config] [ARGS...]" 52 USAGE="Usage: $0 [start|stop|restart|update|backup|restore|ports|config] [ARGS...]"
52 53
53 HELP_SITE="http://wiki.goffi.org/wiki/Docker/en" 54 HELP_SITE="https://wiki.goffi.org/wiki/Docker/en"
54 HELP_MUC="sat@chat.jabberfr.org" 55 HELP_MUC="sat@chat.jabberfr.org"
55 56
56 CONT_CERT_DIR="/usr/share/sat/certificates" 57 CONT_CERT_DIR="/usr/share/sat/certificates"
57 DEFAULT_TMP_DIR="/tmp/tmp_sat_docker" 58 DEFAULT_TMP_DIR="/tmp/tmp_sat_docker"
58 59
161 shift 162 shift
162 if [ $# -eq 0 ]; then 163 if [ $# -eq 0 ]; then
163 printf "no domain given, --domain must be followed by a domain\n" 164 printf "no domain given, --domain must be followed by a domain\n"
164 exit 1 165 exit 1
165 fi 166 fi
166 DOMAIN=$1 167 SAT_CONT_DOMAIN="$1"
167 shift 168 shift
168 ;; 169 ;;
169 170
170 -p|--public) 171 -p|--public)
171 shift 172 shift
205 START) 206 START)
206 parse_run_args "$@" 207 parse_run_args "$@"
207 download_missing || exit 1 208 download_missing || exit 1
208 209
209 printf "Running data container... " 210 printf "Running data container... "
210 docker_id=$(docker run -d -ti --name $VOLUME_ALIAS $VOLUME_CONT 2>&1) 211 # we use -d even if data container doesn't stay in background to get id of the container
212 docker_id=$(docker run -d --name $VOLUME_ALIAS $VOLUME_CONT 2>&1)
211 if [ $? -eq 0 ]; then 213 if [ $? -eq 0 ]; then
212 printf "OK ($docker_id)\n" 214 printf "OK ($docker_id)\n"
213 else 215 else
214 echo $docker_id | grep Conflict > /dev/null 2>&1 216 echo $docker_id | grep Conflict > /dev/null 2>&1
215 if [ $? -eq 0 ]; then 217 if [ $? -eq 0 ]; then
226 DK_TLS="--volume=$SAT_CONT_TLS_DIR:$CONT_CERT_DIR" 228 DK_TLS="--volume=$SAT_CONT_TLS_DIR:$CONT_CERT_DIR"
227 fi 229 fi
228 for CONT in $CONTAINERS; do 230 for CONT in $CONTAINERS; do
229 case $CONT in 231 case $CONT in
230 prosody) OPTS="$DK_DETACH $DK_TERM $DK_VOLUME $DK_TLS $(public_ports_arg $CONT) --name prosody" 232 prosody) OPTS="$DK_DETACH $DK_TERM $DK_VOLUME $DK_TLS $(public_ports_arg $CONT) --name prosody"
231 if [ -n "$DOMAIN" ]; then 233 if [ -n "$SAT_CONT_DOMAIN" ]; then
232 OPTS="-e DOMAIN=$DOMAIN $OPTS" 234 OPTS="-e DOMAIN=$SAT_CONT_DOMAIN $OPTS"
233 fi 235 fi
234 ;; 236 ;;
235 sat_pubsub) OPTS="$DK_DETACH $DK_TERM $DK_VOLUME --name sat_pubsub --link=prosody:prosody";; 237 sat_pubsub) OPTS="$DK_DETACH $DK_TERM $DK_VOLUME --name sat_pubsub --link=prosody:prosody";;
236 salut) OPTS="$DK_DETACH $DK_TERM $DK_VOLUME --name salut --link=prosody:prosody";; 238 salut) OPTS="$DK_DETACH $DK_TERM $DK_VOLUME --name salut --link=prosody:prosody";;
237 sat) OPTS="$DK_DETACH $DK_TERM $DK_VOLUME -P $(public_ports_arg $CONT) --name sat --link=prosody:prosody";; 239 sat) OPTS="$DK_DETACH $DK_TERM $DK_VOLUME -P $(public_ports_arg $CONT) --name sat --link=prosody:prosody";;