188 lines
5.3 KiB
Bash
Executable file
188 lines
5.3 KiB
Bash
Executable file
#!/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
|
|
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+=("$pkg")
|
|
fi
|
|
done
|
|
|
|
check "pkglist: ${pkglist[*]}"
|
|
|
|
line
|
|
|
|
# pen red "$deplist"
|
|
# pkglist=${deplist[@]}
|
|
|
|
# for dep in "${deplist[@]}"; do
|
|
# pen bold grey "Dep: $dep"
|
|
# done
|
|
|
|
spin-installation "${deplist[@]}"
|
|
|
|
# for pk in "${pkglist[@]}"; do
|
|
# pen bold red "Pkg: $pk"
|
|
# done
|
|
|
|
# line
|
|
|
|
# exit 1
|
|
;;
|
|
*)
|
|
echo_error "There are no dependencies to install for $distro"
|
|
return 69
|
|
;;
|
|
esac
|
|
}
|
|
|
|
spin-installation() {
|
|
local err out
|
|
local pkgs="$@"
|
|
|
|
for pkg in "${pkgs[@]}"; do
|
|
spin bold yellow "Installing $pkg"
|
|
if run --err err --out out pkg-install "$pkg"; then
|
|
check "Installed $pkg"
|
|
line
|
|
else
|
|
throw "$pkg could not get installed.."
|
|
echo_error "${err:-}"
|
|
echo_note "${out:-}"
|
|
line
|
|
fi
|
|
done
|
|
}
|
|
|
|
main() {
|
|
local err out
|
|
|
|
if ! spin-get-dependencies; then
|
|
throw "Dependencies could not get generated!"
|
|
else
|
|
check "Dependency list generated!"
|
|
pen red bold "There are ${#deplist[@]} items to install.."
|
|
# local pkgs="$@"
|
|
|
|
for pkg in "${deplist[@]}"; do
|
|
spin bold yellow "Installing $pkg"
|
|
if run --err err --out out pkg-install "$pkg"; then
|
|
check "Installed $pkg"
|
|
line
|
|
else
|
|
check "$pkg could not get installed.."
|
|
echo_error "${err:-}"
|
|
echo_note "${out:-}"
|
|
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"
|
|
|
|
check "Complete!"
|
|
}
|
|
|
|
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
|