This commit is contained in:
pika 2025-06-25 20:36:50 +02:00
parent 09ee5f9315
commit bfa48d5d12

56
pika.sh
View file

@ -42,11 +42,25 @@ get-packager() {
$_sudo apt install --assume-yes "$@" $_sudo apt install --assume-yes "$@"
fi fi
} }
update-func() {
if command-exists nala; then
$_sudo nala update
$_sudo nala upgrade --assume-yes --full
else
$_sudo apt-get update
$_sudo apt-get upgrade --assume-yes
fi
}
;; ;;
dnf) dnf)
pkg-install() { pkg-install() {
$_sudo dnf -y install "$@" $_sudo dnf -y install "$@"
} }
update-func() {
$_sudo dnf update -y
}
;; ;;
pacman) pacman)
pkg-install() { pkg-install() {
@ -58,16 +72,34 @@ get-packager() {
$_sudo pacman --noconfirm -S "$@" $_sudo pacman --noconfirm -S "$@"
fi fi
} }
update-func() {
if command-exists paru; then
paru -Syyu
elif command-exists yay; then
yay -Syyu
else
$_sudo pacman -Syyu
fi
}
;; ;;
zypper) zypper)
pkg-install() { pkg-install() {
$_sudo zypper install "$@" $_sudo zypper install "$@"
} }
update-func() {
$_sudo zypper ref
$_sudo zypper update
}
;; ;;
apk) apk)
pkg-install() { pkg-install() {
$_sudo apk add "$@" $_sudo apk add "$@"
} }
update-func() {
$_sudo apk update
$_sudo apk upgrade
}
;; ;;
esac esac
fi fi
@ -75,7 +107,9 @@ get-packager() {
} }
source-script() { source-script() {
i="$1" local i import
i=$1
import="$(mktemp)" import="$(mktemp)"
if command-exists curl; then if command-exists curl; then
curl -fsSL $i -o $import curl -fsSL $i -o $import
@ -84,18 +118,20 @@ source-script() {
exit 1 exit 1
fi fi
source "$import" bash "$import"
sleep 0.3 sleep 0.3
rm "$import" rm "$import"
} }
script-exists() { script-exists() {
local install_url=https://git.k4li.de/scripts/installs/raw/branch/main local install_url=https://git.k4li.de/scripts/installs/raw/branch/main
local script_url local script_url arr=()
for pkg in "$@"; do arr=("$@")
for pkg in "${arr[@]}"; do
script_url="${install_url}/${pkg}.sh" script_url="${install_url}/${pkg}.sh"
if curl -fsSL $script_url 2>/dev/null; then if curl -fsSL $script_url &>/dev/null; then
return 0 return 0
else else
return 69 return 69
@ -106,8 +142,12 @@ script-exists() {
install-func() { install-func() {
local pkg local pkg
for pkg in "$@"; do for pkg in "$@"; do
case "$pkg" in
nvim) pkg=neovim ;;
esac
if script-exists $pkg; then if script-exists $pkg; then
eval "$(curl -fsSL https://git.k4li.de/scripts/installs/raw/branch/main/${pkg}.sh)" source-script "https://git.k4li.de/scripts/installs/raw/branch/main/$pkg.sh"
else else
pkg-install "$pkg" pkg-install "$pkg"
fi fi
@ -148,6 +188,10 @@ for arg in "$@"; do
shift shift
install-func "$@" install-func "$@"
;; ;;
update | u)
shift
update-func "${@:-}"
;;
*) *)
help-func help-func
;; ;;