2022-08-06 07:52:11 -05:00
|
|
|
#!/bin/bash
|
|
|
|
# 2022-08-05 Hyperling
|
|
|
|
# Install docker from official repository. Currently only supports apt.
|
|
|
|
# Original comands came from here: https://docs.docker.com/engine/install/debian/
|
|
|
|
# usage: install.sh
|
|
|
|
|
2022-09-27 04:48:08 -05:00
|
|
|
## Variables ##
|
|
|
|
|
|
|
|
os=`grep ^'NAME=' /etc/os-release`
|
|
|
|
pkgmgr=""
|
|
|
|
|
|
|
|
## Validations ##
|
|
|
|
|
|
|
|
if [[ "$os" == *"Debian"* ]]; then
|
|
|
|
repo="debian"
|
|
|
|
pkgmgr="apt"
|
|
|
|
elif [[ "$os" == *"Ubuntu"* ]]; then
|
|
|
|
repo="ubuntu"
|
|
|
|
pkgmgr="apt"
|
2022-09-30 04:54:53 -05:00
|
|
|
elif [[ $os == "Arch Linux" ]]; then
|
|
|
|
pkgmgr="pacman"
|
2022-09-27 04:48:08 -05:00
|
|
|
else
|
|
|
|
echo "Distribution not yet supported." &&
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
echo "os=$os"
|
|
|
|
echo "repo=$repo"
|
|
|
|
echo "pkgmgr=$pkgmgr"
|
|
|
|
|
|
|
|
## Main ##
|
|
|
|
|
|
|
|
if [[ "$pkgmgr" == "apt" ]]; then
|
2023-07-05 18:36:34 -07:00
|
|
|
apt purge docker docker-engine docker.io containerd runc podman-docker
|
2022-09-27 04:48:08 -05:00
|
|
|
|
|
|
|
apt update &&
|
|
|
|
apt install -y ca-certificates curl gnupg lsb-release &&
|
|
|
|
mkdir -p /etc/apt/keyrings &&
|
|
|
|
curl -fsSL https://download.docker.com/linux/$repo/gpg | sudo gpg --dearmor -o /etc/apt/keyrings/docker.gpg &&
|
|
|
|
echo \
|
|
|
|
"deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.gpg] https://download.docker.com/linux/$repo \
|
|
|
|
$(lsb_release -cs) stable" | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null &&
|
|
|
|
apt update &&
|
2023-07-05 18:36:34 -07:00
|
|
|
apt install -y docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin &&
|
2022-09-27 04:48:08 -05:00
|
|
|
|
2022-09-30 04:54:53 -05:00
|
|
|
echo "Success!" &&
|
|
|
|
exit 0
|
|
|
|
elif [[ $pkgmgr == "pacman" ]]; then
|
|
|
|
pacman -Rcns --noconfirm *docker*
|
2023-07-05 18:36:34 -07:00
|
|
|
|
2022-09-30 04:54:53 -05:00
|
|
|
pacman -Sy --noconfirm docker docker-compose &&
|
2022-09-27 04:48:08 -05:00
|
|
|
echo "Success!" &&
|
|
|
|
exit 0
|
|
|
|
fi
|
|
|
|
|
|
|
|
## Error ##
|
2022-08-06 07:52:11 -05:00
|
|
|
|
|
|
|
echo "ERROR: Installation failed!"
|
|
|
|
exit 1
|