#!/bin/bash ACTION="$1" PKG="$2" case $ACTION in addRepoKeys) echo "[EPI]:Adding repository key..." apt-get install --yes apt-transport-https ca-certificates curl gnupg-agent software-properties-common curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key --keyring /tmp/epi_keyring add - ;; preInstall) echo "[EPI]:Preparing installation..." if dpkg-query -l $PKG>/dev/null 2>&1;then echo "Nothing to do" else OLD_PACKAGES="docker docker-engine docker.io containerd runc" for ix in $OLD_PACKAGES do if dpkg-query -l $ix>/dev/null 2>&1;then apt-get remove --yes $ix fi done fi ;; postInstall) if [ -f "/usr/bin/docker-compose" ]; then echo "Skipping docker-compose installation..." else echo "[EPI]:Installing docker-compose from github..." TAG="$(curl -sSL "https://github.com/docker/compose/releases/latest" | sed -nr 's@.*compose/releases/tag/v([1-9]+(\.[0-9]+)*)".*@\1@p' | tr ' ' '\n'|sort -n|uniq|tail -1)" nTAG="$(echo ${TAG}|wc -w)" if [ -z "${nTAG}" -o "x${nTAG}" != "x1" ];then echo "[EPI]:fail installing docker-compose! from tag" exit 1 fi if [ -n "${TAG}" ]; then echo "[EPI]:Downloading docker-compose version ${TAG}" curl -sSL "https://github.com/docker/compose/releases/download/v${TAG}/docker-compose-$(uname -s)-$(uname -m)" -o /tmp/docker-compose fi if [ -f "/tmp/docker-compose" -a -n "$(file /tmp/docker-compose|grep -o 'ELF 64-bit')" ]; then mv /tmp/docker-compose /usr/bin/docker-compose chmod +x /usr/bin/docker-compose echo "[EPI]:docker-compose installed!" else echo "[EPI]:fail installing docker-compose!" exit 1 fi fi ;; esac exit 0