comparison 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
comparison
equal deleted inserted replaced
87:53a579906c32 88:f7d275afc4f2
16 # You should have received a copy of the GNU Affero General Public License 16 # You should have received a copy of the GNU Affero General Public License
17 # along with this program. If not, see <http://www.gnu.org/licenses/>. 17 # along with this program. If not, see <http://www.gnu.org/licenses/>.
18 18
19 VERSION="0.3.0" 19 VERSION="0.3.0"
20 ACCOUNT="salutatoi" 20 ACCOUNT="salutatoi"
21
22 # environment variables that can be used for configuration:
23 # SAT_CONT_TLS_DIR for TLS certificates directory
21 24
22 CONTAINERS="prosody sat_pubsub salut sat libervia" 25 CONTAINERS="prosody sat_pubsub salut sat libervia"
23 26
24 DK_DETACH="-d" 27 DK_DETACH="-d"
25 DK_TERM="-ti" 28 DK_TERM="-ti"
48 USAGE="Usage: $0 [start|stop|restart|update|backup|restore|ports|config] [ARGS...]" 51 USAGE="Usage: $0 [start|stop|restart|update|backup|restore|ports|config] [ARGS...]"
49 52
50 HELP_SITE="http://wiki.goffi.org/wiki/Docker/en" 53 HELP_SITE="http://wiki.goffi.org/wiki/Docker/en"
51 HELP_MUC="sat@chat.jabberfr.org" 54 HELP_MUC="sat@chat.jabberfr.org"
52 55
56 CONT_CERT_DIR="/usr/share/sat/certificates"
53 DEFAULT_TMP_DIR="/tmp/tmp_sat_docker" 57 DEFAULT_TMP_DIR="/tmp/tmp_sat_docker"
54 58
55 get_dyn_var() { 59 get_dyn_var() {
56 # get dynamicly variable based on given name 60 # get dynamicly variable based on given name
57 61
214 printf "Error, please check data volume\nerror message: $docker_id\n" 218 printf "Error, please check data volume\nerror message: $docker_id\n"
215 exit 1 219 exit 1
216 fi 220 fi
217 fi 221 fi
218 printf "\nRunning Libervia\n\n" 222 printf "\nRunning Libervia\n\n"
223 # we first check if we need to mount TLS directory
224 if [ -n "$SAT_CONT_TLS_DIR" ]; then
225 printf "$SAT_CONT_TLS_DIR will be used for TLS certificate\n"
226 DK_TLS="--volume=$SAT_CONT_TLS_DIR:$CONT_CERT_DIR"
227 fi
219 for CONT in $CONTAINERS; do 228 for CONT in $CONTAINERS; do
220 case $CONT in 229 case $CONT in
221 prosody) OPTS="$DK_DETACH $DK_TERM $DK_VOLUME $(public_ports_arg $CONT) --name prosody" 230 prosody) OPTS="$DK_DETACH $DK_TERM $DK_VOLUME $DK_TLS $(public_ports_arg $CONT) --name prosody"
222 if [ -n "$DOMAIN" ]; then 231 if [ -n "$DOMAIN" ]; then
223 OPTS="-e DOMAIN=$DOMAIN $OPTS" 232 OPTS="-e DOMAIN=$DOMAIN $OPTS"
224 fi 233 fi
225 ;; 234 ;;
226 sat_pubsub) OPTS="$DK_DETACH $DK_TERM $DK_VOLUME --name sat_pubsub --link=prosody:prosody";; 235 sat_pubsub) OPTS="$DK_DETACH $DK_TERM $DK_VOLUME --name sat_pubsub --link=prosody:prosody";;
227 salut) OPTS="$DK_DETACH $DK_TERM $DK_VOLUME --name salut --link=prosody:prosody";; 236 salut) OPTS="$DK_DETACH $DK_TERM $DK_VOLUME --name salut --link=prosody:prosody";;
228 sat) OPTS="$DK_DETACH $DK_TERM $DK_VOLUME -P $(public_ports_arg $CONT) --name sat --link=prosody:prosody";; 237 sat) OPTS="$DK_DETACH $DK_TERM $DK_VOLUME -P $(public_ports_arg $CONT) --name sat --link=prosody:prosody";;
229 libervia) OPTS="$DK_DETACH $DK_TERM $DK_VOLUME --volumes-from sat -P $(public_ports_arg $CONT) --name libervia --link=sat:sat";; 238 libervia) OPTS="$DK_DETACH $DK_TERM $DK_VOLUME --volumes-from sat $DK_TLS -P $(public_ports_arg $CONT) --name libervia --link=sat:sat";;
230 *) printf "Unkown container $CONT\n"; exit 1 239 *) printf "Unkown container $CONT\n"; exit 1
231 esac 240 esac
232 printf "Launching $CONT... " 241 printf "Launching $CONT... "
233 docker_id=$(docker run $OPTS $ACCOUNT/$CONT 2>&1) 242 docker_id=$(docker run $OPTS $ACCOUNT/$CONT 2>&1)
234 if [ $? -eq 0 ]; then 243 if [ $? -eq 0 ]; then
306 fi 315 fi
307 316
308 printf "restoring $1 to $VOLUME_ALIAS container\n\n" 317 printf "restoring $1 to $VOLUME_ALIAS container\n\n"
309 HOST_BACKUP_DIR="$(dirname "$1")" 318 HOST_BACKUP_DIR="$(dirname "$1")"
310 if [ $HOST_BACKUP_DIR = "." ]; then 319 if [ $HOST_BACKUP_DIR = "." ]; then
311 # workaround for a Docker bug (container crash if "." is used) 320 # workaround for a Docker bug (container crash if "." is used)
312 HOST_BACKUP_DIR=$(pwd) 321 HOST_BACKUP_DIR=$(pwd)
313 fi 322 fi
314 docker run --rm $DK_VOLUME -v "$HOST_BACKUP_DIR:/backup" debian:jessie tar zxvf "/backup/$1" -C / -h volumes 323 docker run --rm $DK_VOLUME -v "$HOST_BACKUP_DIR:/backup" debian:jessie tar zxvf "/backup/$1" -C / -h volumes
315 if [ $? -eq 0 ]; then 324 if [ $? -eq 0 ]; then
316 printf "\nRestore finished\n" 325 printf "\nRestore finished\n"