Last active
April 23, 2022 03:13
-
-
Save neggles/20ef49290e71916240044b2301918774 to your computer and use it in GitHub Desktop.
get compose v2
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
set -e | |
# choose location for the incantation | |
DOCKER_CONFIG=${DOCKER_CONFIG:-/usr/local/lib/docker} | |
# determine core thaumaturgic framework | |
ARCH=$(uname -m) | |
ARCH=${ARCH/aarch64/arm64} | |
# request the most recent revision from the library | |
COMPOSE_REL=$(curl -fsSL 'https://api.github.com/repos/docker/compose/releases/latest' | grep 'tag_name' | cut -d'"' -f4) | |
CSWITCH_REL=$(curl -fsSL 'https://api.github.com/repos/docker/compose-switch/releases/latest' | grep 'tag_name' | cut -d'"' -f4) | |
# select compatible ritual materia | |
COMPOSE_URL="https://github.com/docker/compose/releases/download/${COMPOSE_REL}/docker-compose-linux-${ARCH}" | |
CSWITCH_URL="https://github.com/docker/compose-switch/releases/download/${CSWITCH_REL}/docker-compose-linux-${ARCH/x86_64/amd64}" | |
# inform the spellcaster of status | |
echo "ritual begins. acquiring materia for ${ARCH}" | |
# make dir for where put | |
mkdir -p "${DOCKER_CONFIG}/cli-plugins" | |
# receive the incantation and imbue it with power | |
curl -fsSL "${COMPOSE_URL}" -o "${DOCKER_CONFIG}/cli-plugins/docker-compose" | |
chmod +x "${DOCKER_CONFIG}/cli-plugins/docker-compose" | |
# receive the protective ward and prepare for casting | |
curl -fsSL "${CSWITCH_URL}" -o /usr/local/bin/compose-switch | |
chmod +x /usr/local/bin/compose-switch | |
# further inform the spellcaster | |
echo "the first stage is complete. reconfiguring local eigenmatrix" | |
# check for old spell in library, True Name collisions can be catastrophic | |
COMPOSE=$(command -v docker-compose) | |
if [[ "$COMPOSE" = /usr/local/bin/docker-compose ]]; then | |
mv $COMPOSE /usr/local/bin/docker-compose-v1 | |
COMPOSE=/usr/local/bin/docker-compose-v1 | |
fi | |
# some regions use a different True Name for this one, but the invocation is otherwise unchanged | |
command -v update-alternatives && ALTERNATIVES='update-alternatives' || ALTERNATIVES='alternatives' | |
# inform the eigenmatrix of our adjustments | |
[[ -z $COMPOSE ]] || $ALTERNATIVES --install /usr/local/bin/docker-compose docker-compose $COMPOSE 1 | |
$ALTERNATIVES --install /usr/local/bin/docker-compose docker-compose /usr/local/bin/compose-switch 99 | |
# final statement to whomever invoked us | |
echo "the ritual is complete, this scroll will now terminate" | |
exit 0 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment