addet silent exec

This commit is contained in:
pika 2025-05-11 13:40:31 +02:00
parent f8288b8893
commit ad24809234

133
docker.sh
View file

@ -5,12 +5,34 @@ 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
# WHY:
# This import will give you the following variables:
# _sudo="sudo -E" <- only if non root user
# distro = <distro name, like 'arch', 'debian', 'fedora'..>
# arch = bool
# fedora = bool
# opensuse = bool....
# You can then use it for, `if $arch; then`
# Also this gives you the _install command, which installs a package pased on the packagemanager/distro used.
# CAUTION:
# This only wokrs for generic package names, like neovim, or vim, or tmux etc..
# not every package packagemanager has the same packagenames for their packages..
getImports() {
i="https://git.k4li.de/scripts/imports/raw/branch/main/distros.sh"
import="$(mktemp)"
if command_exists curl; then
curl -fsSL $i -o $import
elif command_exists wget; then
wget $i -o $import
else
echo "curl/wget is required, but missing.."
exit 1
fi
source "$import"
sleep 0.3
rm "$import"
}
init_docker() {
if command -v docker >/dev/null 2>&1; then
@ -29,15 +51,15 @@ init_docker() {
fi
}
main() {
case "$distro" in
arch)
clear
echo_info "executing arch"
sleep 2
$_sudo pacman -S docker docker-compose --noconfirm
;;
debian)
_arch() {
clear
echo_info "executing arch"
sleep 2
_install docker docker-compose --noconfirm
}
_debian() {
if ! $trixie; then
clear
echo_info "executing debian"
sleep 2
@ -56,37 +78,64 @@ main() {
echo_info "Addet repository. Updating and installing now.."
sleep 1
$_sudo apt-get update
$_sudo apt-get install docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin
;;
ubuntu)
checkAndInstall "docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin"
else
clear
echo_info "executing ubuntu"
sleep 2
$_sudo apt-get update &&
$_sudo apt-get install -y ca-certificates curl &&
$_sudo install -m 0755 -d /etc/apt/keyrings &&
$_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
echo "deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.asc] https://download.docker.com/linux/ubuntu \
echo_info "executing trixie.."
_install docker.io docker-compose
fi
}
_ubuntu() {
clear
echo_info "executing ubuntu"
sleep 2
$_sudo apt-get update &&
$_sudo apt-get install -y ca-certificates curl &&
$_sudo install -m 0755 -d /etc/apt/keyrings &&
$_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
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
clear &&
echo_info "Addet repository. Updating and installing now.."
sleep 0.5
$_sudo apt-get update
$_sudo apt-get install docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin
;;
fedora)
clear
echo_info "executing fedora"
sleep 2
$_sudo dnf -y install dnf-plugins-core
$_sudo dnf config-manager --add-repo https://download.docker.com/linux/fedora/docker-ce.repo
$_sudo dnf install -y docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin
;;
clear &&
echo_info "Addet repository. Updating and installing now.."
sleep 0.5
$_sudo apt-get update
checkAndInstall "docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin"
}
_fedora() {
clear
echo_info "executing fedora"
sleep 2
_install dnf-plugins-core
$_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"
}
main() {
case "$distro" in
arch) _arch ;;
debian) _debian ;;
ubuntu) _ubuntu ;;
fedora) _fedora ;;
*) echo "$distro is not supported by this script" ;;
esac
}
if main; then
init_docker
if getImports; then
case "$1" in
--silent | -s)
clear
echo_info "Executin $distro"
if silentexec main; then
init_docker
fi
;;
*)
if main; then
init_docker
fi
;;
esac
fi