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