docker.sh

This commit is contained in:
pika 2025-05-24 18:12:46 +02:00
parent 6629c72bfa
commit 73bf2fa236

View file

@ -48,13 +48,21 @@
# fi
# }
getImports() {
source-script() {
local url="$1"
local import="$(mktemp)"
# ─< if $1 is a local file, source this one instead >─────────────────────────────────────
if [ -f "$url" ]; then
source "$url"
sleep 0.1
return 0
else
# ─< if $1 is a url, grab it and source it, also deletes afterwards >─────────────────────
if command_exists curl; then
curl -fsSL $url -o $import
elif command_exists wget; then
wget -O $import $url
wget -o $import $url
else
echo "curl/wget is required, but missing.."
exit 69
@ -63,8 +71,10 @@
source "$import"
echo "${BLUE}Sourcing external script:${NC} $url"
line
sleep 0.1
rm -f "$import"
fi
}
setup-env() {
@ -88,7 +98,7 @@
local dream=https://git.k4li.de/scripts/imports/raw/branch/main/dream.sh
if ! command_exists pkg-install && ! command_exists check-and-install && ! command_exists pen; then
getImports $dream
source-script $dream
fi
}
@ -148,13 +158,15 @@
# spin and run
spin bold grey "Enabling docker service.."
if run --err err $_sudo systemctl enable --now docker; then
upclear
check "Docker service is enabled!"
else
upclear
throw "Could not setup the service.."
echo-error "${err:-}"
fi
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."
pen bold gred "$USER 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
@ -181,14 +193,20 @@
;;
ubuntu)
spin bold grey "Setting up $(pen bold blue 'docker-repo')"
if $plucky; then
UBUNTU_CODENAME=jammy
fi
if run $_sudo install -m 0755 -d /etc/apt/keyrings; then
run $_sudo curl -fsSL https://download.docker.com/linux/ubuntu/gpg -o /etc/apt/keyrings/docker.asc
run $_sudo chmod a+r /etc/apt/keyrings/docker.asc
run $_sudo curl -fsSL https://download.docker.com/linux/ubuntu/gpg -o /etc/apt/keyrings/docker.asc || throw-err
run $_sudo chmod a+r /etc/apt/keyrings/docker.asc || throw-err
echo "deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.asc] https://download.docker.com/linux/ubuntu \
$(. /etc/os-release && echo "${UBUNTU_CODENAME:-$VERSION_CODENAME}") stable" | $_sudo tee /etc/apt/sources.list.d/docker.list >/dev/null
pen bold green "Addet repository"
sleep 4
# check "Setup done, going forward.."
check bold green "Addet repository"
sleep 2
upclear
spin "Installing docker now.."
if run --err err $_sudo apt-get update; then
@ -196,7 +214,7 @@
check "Updated repositories.."
pen bold blue "Installind docker now.."
pen bold blue "Installing docker now.."
check-and-install "docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin"
else
@ -262,8 +280,8 @@
PACKAGE=packagename
if command_exists "$PACKAGE"; then
echo_warning "$PACKAGE is already installed!"
echo_warning "Exiting now!"
pen bold yellow "$PACKAGE is already installed!"
pen bold yellow "Exiting now!"
exit 69
fi