Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Debian 12 docker-compose installation #112

Open
wants to merge 10 commits into
base: trunk
Choose a base branch
from
66 changes: 41 additions & 25 deletions getdess.sh
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,6 @@ arch_support='x86_64 amd64 aarch64 arm64 armv7l'
# Required base packages
packages="curl openssl qrencode"

# Docker compose link
compose_url="https://github.com/docker/compose/releases/download/1.29.2"

# Atsign user info
user_info="atsign, secondaries account, atsign.com"

Expand Down Expand Up @@ -127,32 +124,51 @@ install_docker () {
dnf -y install docker-ce docker-ce-cli containerd.io;
systemctl enable --now docker.service;
;;
*) curl -fsSL https://get.docker.com | sh;;
*)
# Add Docker's official GPG key:
sudo apt-get update
sudo apt-get install ca-certificates curl gnupg
sudo install -m 0755 -d /etc/apt/keyrings
curl -fsSL https://download.docker.com/linux/debian/gpg | sudo gpg --dearmor -o /etc/apt/keyrings/docker.gpg
sudo chmod a+r /etc/apt/keyrings/docker.gpg

# Add the repository to Apt sources:
# Need to add conditional for derivative distros
echo \
"deb [arch=\"$(dpkg --print-architecture)\" signed-by=/etc/apt/keyrings/docker.gpg] https://download.docker.com/linux/debian \
$\"(. /etc/os-release && echo \"$\"VERSION_CODENAME\"\")"\" stable\" | \
sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
sudo apt-get update
sudo apt-get install docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin
;;
esac
fi

# docker-compose
if ! command_exists docker-compose; then
case $(uname -m) in
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If it helps, this case is for different architectures, we try to use a generic solution when available, but for when the generic solution isn't working we add a case statement.

x86_64|amd64) curl -fsSL "$compose_url/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose;;
*)
case "$os_release" in
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The os_release variable contains the distro information, which was extracted from /etc/os-release. This is where you will find what ever Debian's defaults to, it should be consistent across all versions of debian

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here is the information from my bookworm machine:

PRETTY_NAME="Debian GNU/Linux 12 (bookworm)"
NAME="Debian GNU/Linux"
VERSION_ID="12"
VERSION="12 (bookworm)"
VERSION_CODENAME=bookworm
ID=debian
HOME_URL="https://www.debian.org/"
SUPPORT_URL="https://www.debian.org/support"
BUG_REPORT_URL="https://bugs.debian.org/"

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

since we use id, then you can use "debian" as the case key

amzn) $pkg_man install -y libffi libffi-devel openssl-devel python3 python3-pip python3-devel gcc;;
*) $pkg_man install -y python3 python3-pip;;
esac;
pip3 install docker-compose;
;;
esac
COMPOSE_RESULT=$?
echo "$COMPOSE_RESULT"
if [[ $COMPOSE_RESULT -gt 0 ]]; then
error_exit 51
fi
chown root:docker /usr/local/bin/docker-compose
chmod +x /usr/local/bin/docker-compose
# Install docker-compose v2
echo "Installing Docker Compose v2..."
curl -SL https://github.com/docker/compose/releases/download/v2.27.0/docker-compose-linux-x86_64 -o /usr/local/bin/docker-compose
# Apply executable permissions to the binary
echo "Applying executable permissions to Docker Compose binary..."
chmod +x "${/usr/local/bin/docker-compose}"

# Test the installation
echo "Testing Docker Compose installation..."
if "${/usr/local/bin/docker-compose}" --version; then
echo "Docker Compose installed successfully."
else
echo "Docker Compose installation failed."
exit 1
fi
ln -s /usr/local/bin/docker-compose /usr/bin/docker-compose
systemctl enable --now docker.service

# Check if /usr/local/bin is in the PATH
if ! echo "$PATH" | grep -q "/usr/local/bin"; then
echo "/usr/local/bin is not in the PATH. Creating a symbolic link to /usr/bin..."
sudo ln -s "${/usr/local/bin/docker-compose}" /usr/bin/docker-compose
else
echo "/usr/local/bin is in the PATH. No need to create a symbolic link."
fi

echo "Installation completed."
}

mkdir_atsign () {
Expand Down