refactor(scripts): better handling for ubuntu distro
This commit is contained in:
parent
53f1e23bab
commit
01837c2a30
@ -8,14 +8,22 @@ for pkg in docker.io docker-doc docker-compose podman-docker containerd runc; do
|
||||
done
|
||||
|
||||
# Detect OS
|
||||
if [ -f /etc/debian_version ]; then
|
||||
DOCKER_OS="debian"
|
||||
elif [ -f /etc/lsb-release ]; then
|
||||
if grep -q "Ubuntu" /etc/os-release 2>/dev/null; then
|
||||
DOCKER_OS="ubuntu"
|
||||
# Source the os-release file to get variables
|
||||
. /etc/os-release
|
||||
# Use UBUNTU_CODENAME with fallback to VERSION_CODENAME
|
||||
CODENAME=${UBUNTU_CODENAME:-$VERSION_CODENAME}
|
||||
elif [ -f /etc/debian_version ]; then
|
||||
DOCKER_OS="debian"
|
||||
# Source the os-release file to get VERSION_CODENAME
|
||||
. /etc/os-release
|
||||
CODENAME=$VERSION_CODENAME
|
||||
else
|
||||
echo "Error: Unsupported OS"
|
||||
exit 1
|
||||
fi
|
||||
echo "Detected OS: ${DOCKER_OS}, Codename: ${CODENAME}"
|
||||
|
||||
echo "Updating package list and installing dependencies..."
|
||||
sudo apt-get update
|
||||
@ -30,7 +38,7 @@ sudo chmod a+r /etc/apt/keyrings/docker.asc
|
||||
# Add the repository to Apt sources
|
||||
echo \
|
||||
"deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.asc] https://download.docker.com/linux/${DOCKER_OS} \
|
||||
$(. /etc/os-release && echo "$VERSION_CODENAME") stable" | \
|
||||
${CODENAME} stable" | \
|
||||
sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
|
||||
|
||||
echo "Installing Docker..."
|
||||
|
||||
Loading…
Reference in New Issue
Block a user