#!/usr/bin/env bash # ─< Check if the given command exists silently >───────────────────────────────────────── command_exists() { command -v "$@" >/dev/null 2>&1 } getImports() { local url="https://git.k4li.de/scripts/beddu/raw/branch/main/dist/beddu.sh" 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" } getDependencies() { echo_info "Checking build dependencies.." # INFO: # ╭─────────────────────────────────────────────────────────────────────────╮ # │ You can define dependencies for various linux distros here. It will │ # │ automagically be pulled via the $pkgArray[$distro] variable │ # ╰─────────────────────────────────────────────────────────────────────────╯ depsDebian=() depsFedora=() depsOpensuse=() depsArch=() depsAlpine=() declare -A deps=( [debian]="depsDebian" [ubuntu]="depsUbuntu" [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) checkAndInstall "${pkgArray[@]}" ;; *) echo_error "There are no dependencies to install for $distro" return 69 ;; esac } # echo default main() { if $silent; then pen bold red "Executing script silently!" fi # Kindly ask for input (empty answer is accepted) seek name "What's your name?" pen "Hello, $name!" # Firmly ask for input (empty answer NOT accepted) # request name "No really, what's your name?" # pen "There you go, $name!" # Yes/no confirmation (defaults to "yes") if confirm "Continue?"; then spin "Working on it.." sleep 2 check "Done!" pen green "Continuing..." else spin "Working on it.." sleep 2 check "Done!" pen red "waiting.." sleep 2 repen spin "Almost done.." sleep 2 repen spin "Waiting some more.." sleep 2 check "Task completed!" fi # Defaulting to "no" if confirm --default-no "Are you sure?"; then pen green "Proceeding..." else pen red "Cancelled." fi # Menu selection choose color "Select a color:" "Red" "Green" "Blue" pen "You selected: $color" # source_script "https://git.k4li.de/scripts/beddu/raw/branch/main/dist/beddu.sh" # 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 } if getImports; 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