comparison docker/libervia_cont.sh @ 112:a573bddf8039

docker (libervia_cont): put container used for maintenance in a variable
author Goffi <goffi@goffi.org>
date Mon, 29 Feb 2016 22:01:02 +0100
parents a3f9cfa2721e
children 885818d29012
comparison
equal deleted inserted replaced
111:a3f9cfa2721e 112:a573bddf8039
27 # SAT_CONT_DK_EXTRA is used for extra options (used with all containers but sat_data) 27 # SAT_CONT_DK_EXTRA is used for extra options (used with all containers but sat_data)
28 # SAT_CONT_PORT_<port> is used to specify port when -p is used, <port> must be an exposed port 28 # SAT_CONT_PORT_<port> is used to specify port when -p is used, <port> must be an exposed port
29 29
30 CONTAINERS="prosody sat_pubsub salut sat libervia" 30 CONTAINERS="prosody sat_pubsub salut sat libervia"
31 TEST_CONT="libervia" # container used to test status 31 TEST_CONT="libervia" # container used to test status
32 MAINT_CONT="debian:jessie" # container used for maintenance
32 33
33 DK_DETACH="-d" 34 DK_DETACH="-d"
34 DK_TERM="-ti" 35 DK_TERM="-ti"
35 36
36 VOLUME_NAME="data" 37 VOLUME_NAME="data"
363 ;; 364 ;;
364 esac 365 esac
365 SAT_CONT_BACKUP_DIR=$(echo $SAT_CONT_BACKUP_DIR | sed 's%^\/*\|\/*$%\/%g') # we want to be sure that path starts and finishes with "/" 366 SAT_CONT_BACKUP_DIR=$(echo $SAT_CONT_BACKUP_DIR | sed 's%^\/*\|\/*$%\/%g') # we want to be sure that path starts and finishes with "/"
366 filename="sat_data_backup_$(date '+%Y-%m-%d_%H:%M:%S').tar.gz" 367 filename="sat_data_backup_$(date '+%Y-%m-%d_%H:%M:%S').tar.gz"
367 printf "backing up data container to ${SAT_CONT_BACKUP_DIR}${filename}\n\n" 368 printf "backing up data container to ${SAT_CONT_BACKUP_DIR}${filename}\n\n"
368 docker run --rm $DK_VOLUME -v "$SAT_CONT_BACKUP_DIR:/backup" debian:jessie tar zcvf "/backup/$filename" -C / -h volumes 369 docker run --rm $DK_VOLUME -v "$SAT_CONT_BACKUP_DIR:/backup" $MAINT_CONT tar zcvf "/backup/$filename" -C / -h volumes
369 if [ $? -eq 0 ]; then 370 if [ $? -eq 0 ]; then
370 printf "\nBackup finished and available at ${SAT_CONT_BACKUP_DIR}${filename}\n" 371 printf "\nBackup finished and available at ${SAT_CONT_BACKUP_DIR}${filename}\n"
371 else 372 else
372 printf "\nBackup Error !\n" 373 printf "\nBackup Error !\n"
373 exit 1 374 exit 1
391 HOST_BACKUP_NAME=$(basename "$1") 392 HOST_BACKUP_NAME=$(basename "$1")
392 if [ $HOST_BACKUP_DIR = "." ]; then 393 if [ $HOST_BACKUP_DIR = "." ]; then
393 # workaround for a Docker bug (container crash if "." is used) 394 # workaround for a Docker bug (container crash if "." is used)
394 HOST_BACKUP_DIR=$(pwd) 395 HOST_BACKUP_DIR=$(pwd)
395 fi 396 fi
396 docker run --rm $DK_VOLUME -v "$HOST_BACKUP_DIR:/backup" debian:jessie tar zxvf "/backup/$HOST_BACKUP_NAME" -C / -h volumes 397 docker run --rm $DK_VOLUME -v "$HOST_BACKUP_DIR:/backup" $MAINT_CONT tar zxvf "/backup/$HOST_BACKUP_NAME" -C / -h volumes
397 if [ $? -eq 0 ]; then 398 if [ $? -eq 0 ]; then
398 printf "\nRestore finished\n" 399 printf "\nRestore finished\n"
399 else 400 else
400 printf "\nRestore Error !\n" 401 printf "\nRestore Error !\n"
401 exit 1 402 exit 1
441 check_docker_version 1 8 0 442 check_docker_version 1 8 0
442 if [ $? -eq 0 ]; then 443 if [ $? -eq 0 ]; then
443 docker cp "$TMP_DIR/$HOST_CONF_FILE" "$VOLUME_ALIAS:$CONT_CONF_FILE" 444 docker cp "$TMP_DIR/$HOST_CONF_FILE" "$VOLUME_ALIAS:$CONT_CONF_FILE"
444 else 445 else
445 eprintf "Old Docker version detected, using workaround, please update!\n" 446 eprintf "Old Docker version detected, using workaround, please update!\n"
446 docker run --rm $DK_VOLUME -v "$TMP_DIR:/tmp_config" debian:jessie /bin/cp -f "/tmp_config/$HOST_CONF_FILE" "$CONT_CONF_FILE" 447 docker run --rm $DK_VOLUME -v "$TMP_DIR:/tmp_config" $MAINT_CONT /bin/cp -f "/tmp_config/$HOST_CONF_FILE" "$CONT_CONF_FILE"
447 fi 448 fi
448 fi 449 fi
449 rm -rf "$TMP_DIR" 450 rm -rf "$TMP_DIR"
450 ;; 451 ;;
451 STATS) 452 STATS)