90 lines
3.2 KiB
Bash
90 lines
3.2 KiB
Bash
#!/usr/bin/env bash
|
|
|
|
# ─< Check if the given command exists silently >─────────────────────────────────────────
|
|
command_exists() {
|
|
command -v "$@" >/dev/null 2>&1
|
|
}
|
|
|
|
if command_exists curl; then
|
|
eval "$(curl -fsSL https://git.k4li.de/scripts/imports/raw/branch/main/distros.sh)"
|
|
else
|
|
echo "curl is required, but not installed"
|
|
exit 1
|
|
fi
|
|
|
|
init_docker() {
|
|
if command -v docker >/dev/null 2>&1; then
|
|
echo_info "Docker was installed correctly. Do you want to add $(whoami) to the docker group? (y/n)"
|
|
read -r dgroup </dev/tty
|
|
case "$dgroup" in
|
|
[Yy])
|
|
$su usermod -aG docker "$(whoami)"
|
|
;;
|
|
esac
|
|
sleep 1
|
|
$su systemctl enable --now docker
|
|
echo_info "$(whoami) is now part of the docker group. Restart your session to enable the changes. Also docker was addet as a service. Should autostart from now on."
|
|
else
|
|
echo_error "Something went wrong!"
|
|
fi
|
|
}
|
|
|
|
main() {
|
|
case "$distro" in
|
|
arch)
|
|
clear
|
|
echo_info "executing arch"
|
|
sleep 2
|
|
$su pacman -S docker docker-compose --noconfirm
|
|
;;
|
|
debian)
|
|
clear
|
|
echo_info "executing debian"
|
|
sleep 2
|
|
$su apt-get update &&
|
|
$su apt-get install -y ca-certificates curl &&
|
|
$su install -m 0755 -d /etc/apt/keyrings &&
|
|
$su curl -fsSL https://download.docker.com/linux/debian/gpg -o /etc/apt/keyrings/docker.asc &&
|
|
$su chmod a+r /etc/apt/keyrings/docker.asc &&
|
|
sleep 0.5
|
|
if [ "$VERSION_CODENAME" == "trixie" ]; then
|
|
VERSION_CODENAME="bookworm"
|
|
fi
|
|
echo "deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.asc] https://download.docker.com/linux/debian \
|
|
$(. /etc/os-release && echo "$VERSION_CODENAME") stable" | $su tee /etc/apt/sources.list.d/docker.list >/dev/null
|
|
clear &&
|
|
echo_info "Addet repository. Updating and installing now.."
|
|
sleep 1
|
|
$su apt-get update
|
|
$su apt-get install docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin
|
|
;;
|
|
ubuntu)
|
|
clear
|
|
echo_info "executing ubuntu"
|
|
sleep 2
|
|
$su apt-get update &&
|
|
$su apt-get install -y ca-certificates curl &&
|
|
$su install -m 0755 -d /etc/apt/keyrings &&
|
|
$su curl -fsSL https://download.docker.com/linux/ubuntu/gpg -o /etc/apt/keyrings/docker.asc &&
|
|
$su chmod a+r /etc/apt/keyrings/docker.asc
|
|
echo "deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.asc] https://download.docker.com/linux/ubuntu \
|
|
$(. /etc/os-release && echo "$VERSION_CODENAME") stable" | $su tee /etc/apt/sources.list.d/docker.list >/dev/null
|
|
clear &&
|
|
echo_info "Addet repository. Updating and installing now.."
|
|
sleep 0.5
|
|
$su apt-get update
|
|
$su apt-get install docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin
|
|
;;
|
|
fedora)
|
|
clear
|
|
echo_info "executing fedora"
|
|
sleep 2
|
|
$su dnf -y install dnf-plugins-core
|
|
$su dnf config-manager --add-repo https://download.docker.com/linux/fedora/docker-ce.repo
|
|
$su dnf install -y docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin
|
|
;;
|
|
*) echo "$distro is not supported by this script" ;;
|
|
esac
|
|
}
|
|
|
|
main </dev/tty
|