File tree Expand file tree Collapse file tree 1 file changed +20
-2
lines changed
Expand file tree Collapse file tree 1 file changed +20
-2
lines changed Original file line number Diff line number Diff line change 143143ensure_packages () {
144144 echo
145145 echo " ==> Installing Docker & prerequisites..."
146+
147+ # Detect OS type
148+ if [[ -f /etc/os-release ]]; then
149+ . /etc/os-release
150+ OS_ID=" $ID "
151+ OS_LIKE=" ${ID_LIKE:- } "
152+ else
153+ echo " ERROR: Cannot detect OS type." >&2
154+ exit 1
155+ fi
156+
157+ # Determine Docker distribution
158+ if [[ " $OS_ID " == " debian" || " $OS_LIKE " == * " debian" * ]]; then
159+ DOCKER_DIST=" debian"
160+ else
161+ DOCKER_DIST=" ubuntu"
162+ fi
163+
146164 apt-get update -y
147165 apt-get install -y ca-certificates curl git gnupg
148166
149167 install -m 0755 -d /etc/apt/keyrings
150168 if [[ ! -f /etc/apt/keyrings/docker.gpg ]]; then
151- curl -fsSL https://download.docker.com/linux/ubuntu /gpg \
169+ curl -fsSL " https://download.docker.com/linux/${DOCKER_DIST} /gpg" \
152170 | gpg --dearmor -o /etc/apt/keyrings/docker.gpg
153171 chmod a+r /etc/apt/keyrings/docker.gpg
154172 echo \
155- " deb [arch=$( dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.gpg] https://download.docker.com/linux/ubuntu \
173+ " deb [arch=$( dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.gpg] https://download.docker.com/linux/${DOCKER_DIST} \
156174 $( . /etc/os-release && echo " ${VERSION_CODENAME} " ) stable" \
157175 > /etc/apt/sources.list.d/docker.list
158176 apt-get update -y
You can’t perform that action at this time.
0 commit comments