#!/usr/bin/env bash # ─< Check if the given command exists silently >───────────────────────────────────────── command_exists() { command -v "$@" >/dev/null 2>&1 } source-script() { local url="$1" local import="$(mktemp)" if command_exists curl; then curl -fsSL $url -o $import elif command_exists wget; then wget -o $import $url else echo "curl/wget is required, but missing.." exit 69 fi . "$import" sleep 0.1 rm -f "$import" } spin-get-dependencies() { line spin grey "Getting dependencies.." # INFO: # ╭─────────────────────────────────────────────────────────────────────────╮ # │ You can define dependencies for various linux distros here. It will │ # │ automagically be pulled via the $pkgArray[$distro] variable │ # ╰─────────────────────────────────────────────────────────────────────────╯ depsDebian=(bash zsh curl git neofetch waybar wlogout) depsFedora=(bash zsh curl git neofetch waybar wlogout) depsOpensuse=(bash zsh curl git neofetch waybar wlogout) depsArch=(bash zsh curl git neofetch waybar wlogout firefox-esr) depsAlpine=(bash zsh curl git neofetch waybar wlogout) # declare -A deplist declare -n deplist=() declare -A deps=( [debian]="depsDebian" [ubuntu]="depsDebian" [fedora]="depsFedora" [arch]="depsArch" [alpine]="depsAlpine" [opensuse]="depsOpensuse" ) # INFO: # ╭────────────────────────────────────────────────────────────────╮ # │ This variable stores the packages you provided for each distro │ # ╰────────────────────────────────────────────────────────────────╯ declare -n pkgArray="${deps[$distro]}" case "$distro" in debian | ubuntu | arch | fedora | alpine | opensuse) for pkg in "${pkgArray[@]}"; do if ! command_exists $pkg; then deplist="$deplist $pkg" fi done declare -n pkglist="${deplist[@]}" check "pkglist: ${pkglist[*]}" line ;; *) echo_error "There are no dependencies to install for $distro" return 69 ;; esac } spin-installation() { local pkglists="$@" local pkg err out pen bold green "Starting installation now.." line for pkg in "${pkglists[@]}"; do spin grey "Installing $pkg" if run --err err --out out pkg-install $pkg; then check green "$pkg installed!" line else throw "$pkg was not installed!" echo_error "${err:-}" echo_note "${out:-}" line fi done } # echo default main() { local err if ! spin-get-dependencies; then throw "Dependencies could not get generated!" else check "Dependency list generated!" spin-installation "${pkglist[@]}" # spin bold yellow "Installing $pkg" # if run --err err pkg-install "$pkg"; then # check "Installed $pkg!" # line # else # throw "$(pen bold blue ${pkglist[*]}) could not get installed!" # echo_error "${err:-}" # line # fi # done fi # case "$distro" in # arch) # pen bold blue "This is Arch!" # ;; # debian) # pen bold red "This is Debian!" # ;; # ubuntu) # pen bold orange "This is Ubuntu!" # ;; # fedora) # pen blue "This is Fedora!" # ;; # alpine) # pen italic blue "This is Alpine!" # ;; # opensuse) # pen green bold "This is OpenSuse!" # ;; # *) # echo "$distro is not supported by this script!" # exit 1 # ;; # esac # source_script "https://git.k4li.de/scripts/beddu/raw/branch/main/dist/beddu.sh" } beddu=https://git.k4li.de/scripts/beddu/raw/branch/main/dist/beddu.sh pika=https://git.k4li.de/scripts/imports/raw/branch/main/distros.sh if source-script $pika && source-script $beddu; then # ─< package variable >─────────────────────────────────────────────────────────────────── unset PACKAGE # ─< argument list variables >──────────────────────────────────────────────────────────── silent=false sleep 0.1 # ─< parse arguments and get variable contents >────────────────────────────────────────── for arg in "$@"; do case "$arg" in --silent | -s) export silent=true ;; esac done main fi