changed docker stuff

This commit is contained in:
pika 2025-05-11 15:16:07 +02:00
parent 3713396153
commit b00ff7426b

View file

@ -39,7 +39,7 @@ getImports() {
} }
init_docker() { init_docker() {
if command -v docker >/dev/null 2>&1; then if command_exists docker; then
echo_info "Docker was installed correctly. Do you want to add $(whoami) to the docker group? (y/n)" echo_info "Docker was installed correctly. Do you want to add $(whoami) to the docker group? (y/n)"
read -r dgroup </dev/tty read -r dgroup </dev/tty
case "$dgroup" in case "$dgroup" in
@ -48,7 +48,7 @@ init_docker() {
;; ;;
esac esac
sleep 1 sleep 1
$_sudo systemctl enable --now docker run $_sudo 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." 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 else
echo_error "Something went wrong!" echo_error "Something went wrong!"
@ -57,19 +57,19 @@ init_docker() {
_arch() { _arch() {
echo_info "executing arch" echo_info "executing arch"
sleep 2 sleep 1.3
_install docker docker-compose --noconfirm run _install docker docker-compose --noconfirm
} }
_debian() { _debian() {
if ! $trixie; then if ! $trixie; then
echo_info "executing debian" echo_info "executing debian"
sleep 2 sleep 1.3
$_sudo apt-get update && run $_sudo apt-get update &&
$_sudo apt-get install -y ca-certificates curl && run $_sudo apt-get install -y ca-certificates curl &&
$_sudo install -m 0755 -d /etc/apt/keyrings && run $_sudo install -m 0755 -d /etc/apt/keyrings &&
$_sudo curl -fsSL https://download.docker.com/linux/debian/gpg -o /etc/apt/keyrings/docker.asc && run $_sudo curl -fsSL https://download.docker.com/linux/debian/gpg -o /etc/apt/keyrings/docker.asc &&
$_sudo chmod a+r /etc/apt/keyrings/docker.asc && run $_sudo chmod a+r /etc/apt/keyrings/docker.asc &&
sleep 0.5 sleep 0.5
if [ "$VERSION_CODENAME" == "trixie" ]; then if [ "$VERSION_CODENAME" == "trixie" ]; then
VERSION_CODENAME="bookworm" VERSION_CODENAME="bookworm"
@ -79,37 +79,37 @@ _debian() {
echo_info "Addet repository. Updating and installing now.." echo_info "Addet repository. Updating and installing now.."
sleep 1 sleep 1
$_sudo apt-get update run $_sudo apt-get update
checkAndInstall "docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin" run checkAndInstall "docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin"
else else
echo_info "executing trixie.." echo_info "executing trixie.."
_install docker.io docker-compose run _install docker.io docker-compose
fi fi
} }
_ubuntu() { _ubuntu() {
echo_info "executing ubuntu" echo_info "executing ubuntu"
sleep 2 sleep 2
$_sudo apt-get update && run $_sudo apt-get update &&
$_sudo apt-get install -y ca-certificates curl && run $_sudo apt-get install -y ca-certificates curl &&
$_sudo install -m 0755 -d /etc/apt/keyrings && run $_sudo install -m 0755 -d /etc/apt/keyrings &&
$_sudo curl -fsSL https://download.docker.com/linux/ubuntu/gpg -o /etc/apt/keyrings/docker.asc && run $_sudo curl -fsSL https://download.docker.com/linux/ubuntu/gpg -o /etc/apt/keyrings/docker.asc &&
$_sudo chmod a+r /etc/apt/keyrings/docker.asc run $_sudo 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 \ 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" | $_sudo tee /etc/apt/sources.list.d/docker.list >/dev/null $(. /etc/os-release && echo "$VERSION_CODENAME") stable" | $_sudo tee /etc/apt/sources.list.d/docker.list >/dev/null
echo_info "Addet repository. Updating and installing now.." echo_info "Addet repository. Updating and installing now.."
sleep 0.5 sleep 0.5
$_sudo apt-get update run $_sudo apt-get update
checkAndInstall "docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin" run checkAndInstall "docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin"
} }
_fedora() { _fedora() {
echo_info "executing fedora" echo_info "executing fedora"
sleep 2 sleep 2
_install dnf-plugins-core run _install dnf-plugins-core
$_sudo dnf config-manager --add-repo https://download.docker.com/linux/fedora/docker-ce.repo run $_sudo dnf config-manager --add-repo https://download.docker.com/linux/fedora/docker-ce.repo
checkAndInstall "docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin" run checkAndInstall "docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin"
} }
main() { main() {
@ -125,25 +125,15 @@ main() {
if getImports; then if getImports; then
case "$1" in case "$1" in
--silent | -s) --silent | -s)
echo_warning "Executing silently!" silent=true
echo_info "Executing $distro" echo_warning "Running the script silently.."
case "$distro" in
arch) silentexec _arch ;;
debian) silentexec _debian ;;
ubuntu) silentexec _ubuntu ;;
fedora) silentexec _fedora ;;
*)
echo "$distro is not supported by this script"
exit 1
;;
esac
init_docker
;; ;;
*) *)
if main; then silent=false
init_docker
fi
;; ;;
esac esac
if main; then
init_docker
fi
fi fi