Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 20 additions & 6 deletions install_on_linux.sh
Original file line number Diff line number Diff line change
Expand Up @@ -15,20 +15,34 @@ if [ $? -ne 0 ]; then
exit 1
fi

curl -fL $COMPOSE_SWITCH_URL -o /usr/local/bin/compose-switch
chmod +x /usr/local/bin/compose-switch
sh_c='sh -c'
sudo_sh_c='sh -c'
if [ "$user" != 'root' ]; then
if [ "$(command -v sudo)" ]; then
sudo_sh_c='sudo -E sh -c'
elif [ "$(command -v su)" ]; then
sudo_sh_c='su -c'
else
echo "Error: This installer needs the ability to run commands as root."
exit 1
fi
fi

$sudo_sh_c "curl -fL $COMPOSE_SWITCH_URL -o /usr/local/bin/compose-switch"
$sudo_sh_c "chmod +x /usr/local/bin/compose-switch"

COMPOSE=$(command -v docker-compose)
if [ "$COMPOSE" = /usr/local/bin/docker-compose ]; then
# This is a manual installation of docker-compose
# so, safe for us to rename binary
mv /usr/local/bin/docker-compose /usr/local/bin/docker-compose-v1
$sudo_sh_c "mv /usr/local/bin/docker-compose /usr/local/bin/docker-compose-v1"
COMPOSE=/usr/local/bin/docker-compose-v1
fi

ALTERNATIVES="update-alternatives"

ALTERNATIVES="$sudo_sh_c update-alternatives"
if ! command -v $ALTERNATIVES; then
ALTERNATIVES=alternatives
ALTERNATIVES="$sudo_sh_c alternatives"
fi

echo "Configuring `docker-compose` alternatives"
Expand All @@ -38,4 +52,4 @@ fi
$ALTERNATIVES --install /usr/local/bin/docker-compose docker-compose /usr/local/bin/compose-switch 99

echo "'docker-compose' is now set to run Compose V2"
echo "use '$ALTERNATIVES --config docker-compose' if you want to switch back to Compose V1"
echo "use '$ALTERNATIVES --config docker-compose' if you want to switch back to Compose V1"