addet silent exec

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

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"
# 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
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)
_arch() {
clear
echo_info "executing arch"
sleep 2
$_sudo pacman -S docker docker-compose --noconfirm
;;
debian)
_install docker docker-compose --noconfirm
}
_debian() {
if ! $trixie; then
clear
echo_info "executing debian"
sleep 2
@ -56,9 +78,15 @@ 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 trixie.."
_install docker.io docker-compose
fi
}
_ubuntu() {
clear
echo_info "executing ubuntu"
sleep 2
@ -73,20 +101,41 @@ main() {
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)
checkAndInstall "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
_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
;;
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
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