-
Notifications
You must be signed in to change notification settings - Fork 35
/
Copy pathinstall_on_linux.sh
executable file
·40 lines (32 loc) · 1.38 KB
/
install_on_linux.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
#!/bin/sh
set -e
ARCHITECTURE=amd64
if [ "$(uname -m)" = "aarch64" ]; then
ARCHITECTURE=arm64
fi
COMPOSE_SWITCH_VERSION=$(curl -sI https://github.com/docker/compose-switch/releases/latest | grep '^location:' | sed 's,.*/,,' | tr -d '\r')
COMPOSE_SWITCH_URL="https://github.com/docker/compose-switch/releases/download/${COMPOSE_SWITCH_VERSION}/docker-compose-linux-${ARCHITECTURE}"
if ! docker compose version >/dev/null 2>&1; then
echo "Docker Compose V2 is not installed"
exit 1
fi
curl -fL "$COMPOSE_SWITCH_URL" -o /usr/local/bin/compose-switch
chmod +x /usr/local/bin/compose-switch
COMPOSE=$(command -v docker-compose || true)
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
COMPOSE=/usr/local/bin/docker-compose-v1
fi
ALTERNATIVES="update-alternatives"
if ! command -v $ALTERNATIVES; then
ALTERNATIVES=alternatives
fi
echo "Configuring docker-compose alternatives"
if [ -n "$COMPOSE" ]; then
$ALTERNATIVES --install /usr/local/bin/docker-compose docker-compose $COMPOSE 1
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"