fixed pkgui
This commit is contained in:
parent
b1012d36a5
commit
53761dca87
1 changed files with 39 additions and 18 deletions
45
pkgui.sh
45
pkgui.sh
|
@ -9,7 +9,7 @@
|
|||
# WHY:
|
||||
# This import will give you the following variables:
|
||||
# _sudo="sudo -E" <- only if non root user
|
||||
# distro = <distro name, like 'arch', 'debian', 'ubuntu', 'fedora', 'opensuse' or 'alpine'>
|
||||
# distro = <distro name, like 'arch', 'debian', 'fedora'..>
|
||||
# arch = bool
|
||||
# fedora = bool
|
||||
# opensuse = bool....
|
||||
|
@ -18,14 +18,24 @@
|
|||
# CAUTION:
|
||||
# This only wokrs for generic package names, like neovim, or vim, or tmux etc..
|
||||
# not every package packagemanager has the same packagenames for their packages..
|
||||
getImports() {
|
||||
i="https://git.k4li.de/scripts/imports/raw/branch/main/distros.sh"
|
||||
import="$(mktemp)"
|
||||
if command_exists curl; then
|
||||
eval "$(curl -fsSL https://git.k4li.de/scripts/imports/raw/branch/main/distros.sh)"
|
||||
curl -fsSL $i -o $import
|
||||
else
|
||||
echo "curl is required, but missing.."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
source "$import"
|
||||
sleep 0.3
|
||||
rm "$import"
|
||||
echo_warning "cleaned $import"
|
||||
}
|
||||
|
||||
checkDeps() {
|
||||
echo_info "Checking dependencies.."
|
||||
if ! command_exists pkgui; then
|
||||
return 0
|
||||
else
|
||||
|
@ -56,12 +66,13 @@
|
|||
}
|
||||
|
||||
instDeps() {
|
||||
echo_info "Installing missing dependencies.."
|
||||
case "$distro" in
|
||||
arch | opensuse | fedora)
|
||||
_install go
|
||||
run _install go
|
||||
;;
|
||||
debian | ubuntu)
|
||||
_install golang
|
||||
run _install golang
|
||||
;;
|
||||
*)
|
||||
echo_error "$distro is not supported by this script"
|
||||
|
@ -72,6 +83,7 @@
|
|||
getPkgUI() {
|
||||
local tempDir="$(mktemp -d)"
|
||||
local url="https://git.k4li.de/scripts/installs/raw/branch/main/.src/pkgui"
|
||||
echo_info "Getting the pkgui binary from $url"
|
||||
cd $tempDir || mkdir $tempDir && cd $tempDir
|
||||
|
||||
echo_info "Curling the binary directly via $url.."
|
||||
|
@ -84,23 +96,32 @@
|
|||
}
|
||||
|
||||
instPkgUI() {
|
||||
echo_info "Installing the binary"
|
||||
if [ -d "$HOME/.local/bin" ]; then
|
||||
ln -srf ./pkgui "$HOME/.local/bin/pkgui" && echo_note "Linked to $HOME/.local/bin/pkgui"
|
||||
run ln -srf ./pkgui "$HOME/.local/bin/pkgui" && echo_note "Linked to $HOME/.local/bin/pkgui"
|
||||
else
|
||||
echo_note "Couldn't find $HOME/.local/bin directory, linking systemwide.."
|
||||
$_sudo ln -sfr ./pkgui /bin/pkgui && echo_note "Linked to /bin/pkgui"
|
||||
run $_sudo ln -sfr ./pkgui /bin/pkgui && echo_note "Linked to /bin/pkgui"
|
||||
fi
|
||||
}
|
||||
|
||||
main() {
|
||||
if checkDeps; then
|
||||
if instDeps; then
|
||||
if getPkgUI; then
|
||||
checkDeps
|
||||
instDeps
|
||||
getPkgUI
|
||||
instPkgUI
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
}
|
||||
|
||||
if getImports; then
|
||||
case "$1" in
|
||||
--silent | -s)
|
||||
silent=true
|
||||
;;
|
||||
*)
|
||||
silent=false
|
||||
;;
|
||||
esac
|
||||
fi
|
||||
|
||||
main
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue