# /etc/sysconfig/cisco_docker
#
# Other arguments to pass to the docker daemon process
# These will be parsed by the initscript and appended
# to the arguments list passed to docker daemon

if [ -f /etc/rc.d/init.d/calvados_bootstrap.cfg ]; then
    source /etc/rc.d/init.d/calvados_bootstrap.cfg
fi

if [ -f /etc/init.d/app-hosting-functions ]; then
    source /etc/init.d/app-hosting-functions
fi

export DOCKER_TLS="no"

DOCKER_STORAGE_VOLUME="/var/lib/docker"
DOCKER_STORAGE_MOUNT="${TP_STORAGE_MOUNT}/docker"
DOCKER_CGROUP_ROOT="/machine/tp_app.partition/docker"
DOCKER_STORAGE_BACKEND="devicemapper"
DOCKER_BRIDGE="none"
DOCKER_DAEMON_SOCKET="unix:///misc/app_host/docker.sock"
DOCKER_DAEMON_PID_FILE="/misc/app_host/docker.pid"

# We need at least 1.5 GB (1536 MB) for docker volume, but will permit more if available.
DOCKER_VOLUME_SIZE=1536

function get_docker_volume_size() {
  if [ -n "$1" ]; then
    local MAX=$1
    local MIN=$((MAX/2))
    DOCKER_VOLUME_SIZE=$((MIN > DOCKER_VOLUME_SIZE ? MIN : DOCKER_VOLUME_SIZE))
    DOCKER_VOLUME_SIZE=$((MAX < DOCKER_VOLUME_SIZE ? MAX : DOCKER_VOLUME_SIZE))
  fi
}

get_docker_volume_size "$DISK_TP_VOL_PART_SIZE"

CISCO_DOCKER_OPTS="\
    -D \
    -s ${DOCKER_STORAGE_BACKEND} \
    --cgroup-parent=${DOCKER_CGROUP_ROOT} \
    --storage-opt dm.basesize=${DOCKER_VOLUME_SIZE}M \
    --bridge=${DOCKER_BRIDGE} \
    -H=${DOCKER_DAEMON_SOCKET} \
    --pidfile=${DOCKER_DAEMON_PID_FILE} \
    --iptables=false \
"

