| #!/bin/bash |
| # ================================================= |
| # This file is managed by SaltStack aptly formula. |
| # Manual changes may be overwritten. |
| # ================================================= |
| # |
| # Run aptly-publisher in a container |
| # |
| # This script will attempt to mirror the host paths by using volumes for the |
| # following paths: |
| # * /etc/aptly-publisher.yaml |
| # * /etc/aptly |
| # * $(pwd) |
| # * $HOME if it's set |
| # |
| # You can add additional volumes (or any docker run options) using |
| # the $APTLY_PUBLISHER_OPTIONS environment variable. |
| # |
| |
| |
| set -e |
| |
| IMAGE=${IMAGE:-"{{ image }}"} |
| |
| # Setup options for connecting to docker host |
| if [ -z "$DOCKER_HOST" ]; then |
| DOCKER_HOST="/var/run/docker.sock" |
| fi |
| if [ -S "$DOCKER_HOST" ]; then |
| DOCKER_ADDR="-v $DOCKER_HOST:$DOCKER_HOST -e DOCKER_HOST" |
| else |
| DOCKER_ADDR="-e DOCKER_HOST -e DOCKER_TLS_VERIFY -e DOCKER_CERT_PATH" |
| fi |
| |
| |
| # Setup volume mounts for compose config and context |
| if [ "$(pwd)" != '/' ]; then |
| VOLUMES="-v $(pwd):$(pwd):ro" |
| fi |
| |
| if [ -e /etc/aptly-publisher.yaml ]; then |
| VOLUMES="-v /etc/aptly-publisher.yaml:/etc/aptly-publisher.yaml:ro" |
| fi |
| |
| if [ -d /etc/aptly ]; then |
| VOLUMES="-v /etc/aptly:/etc/aptly:ro" |
| fi |
| |
| if [ -n "$HOME" ]; then |
| VOLUMES="$VOLUMES -v $HOME:$HOME:ro" |
| fi |
| |
| # Only allocate tty if we detect one |
| if [ -t 1 ]; then |
| DOCKER_RUN_OPTIONS="-t" |
| fi |
| if [ -t 0 ]; then |
| DOCKER_RUN_OPTIONS="$DOCKER_RUN_OPTIONS -i" |
| fi |
| |
| exec docker run --rm $DOCKER_RUN_OPTIONS $DOCKER_ADDR $APTLY_PUBLISHER_OPTIONS $VOLUMES -w "$(pwd)" $IMAGE "$@" |