wip
This commit is contained in:
parent
71fcad4b1c
commit
e7368003c4
2 changed files with 100 additions and 0 deletions
BIN
pkgsearchtui
BIN
pkgsearchtui
Binary file not shown.
100
pkgui.sh
Normal file
100
pkgui.sh
Normal file
|
@ -0,0 +1,100 @@
|
|||
{
|
||||
#!/usr/bin/env bash
|
||||
|
||||
# ─< Check if the given command exists silently >─────────────────────────────────────────
|
||||
command_exists() {
|
||||
command -v "$@" >/dev/null 2>&1
|
||||
}
|
||||
|
||||
# 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'>
|
||||
# arch = bool
|
||||
# fedora = bool
|
||||
# opensuse = bool....
|
||||
# You can then use it for, `if $arch; then`
|
||||
# Also this gives you the _install command, which installs a package pased on the packagemanager/distro used.
|
||||
# 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..
|
||||
if command_exists curl; then
|
||||
eval "$(curl -fsSL https://git.k4li.de/scripts/imports/raw/branch/main/distros.sh)"
|
||||
else
|
||||
echo "curl is required, but missing.."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
checkDeps() {
|
||||
if ! command_exists pkgui; then
|
||||
return 0
|
||||
else
|
||||
echo_warning "pkgui is already installed.."
|
||||
return 69
|
||||
fi
|
||||
|
||||
for pkg in go curl pkgui; do
|
||||
case $pkg in
|
||||
pkgui)
|
||||
if command_exists $pkg; then
|
||||
return 0
|
||||
else
|
||||
echo_warning "$pkg is already installed.."
|
||||
return 69
|
||||
fi
|
||||
;;
|
||||
*)
|
||||
if command_exists $pkg; then
|
||||
return 0
|
||||
else
|
||||
echo_warning "$pkg is required, but missing.."
|
||||
return 69
|
||||
fi
|
||||
;;
|
||||
esac
|
||||
done
|
||||
}
|
||||
|
||||
instDeps() {
|
||||
case "$distro" in
|
||||
arch | opensuse | fedora)
|
||||
_install go
|
||||
;;
|
||||
debian | ubuntu)
|
||||
_install golang
|
||||
;;
|
||||
*)
|
||||
echo_error "$distro is not supported by this script"
|
||||
;;
|
||||
esac
|
||||
}
|
||||
|
||||
getPkgUI() {
|
||||
local tempDir="$(mktemp -d)"
|
||||
local url="https://git.k4li.de/scripts/installs/raw/branch/main/.src/pkgui"
|
||||
cd $tempDir || mkdir $tempDir && cd $tempDir
|
||||
|
||||
curl -fsSL $url -o pkgui || echo_warning "Could not curl $url"
|
||||
}
|
||||
|
||||
instPkgUI() {
|
||||
if [ -d "$HOME/.local/bin" ]; then
|
||||
ln -sfr "$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"
|
||||
fi
|
||||
}
|
||||
|
||||
main() {
|
||||
if checkDeps; then
|
||||
if instDeps; then
|
||||
if getPkgUI; then
|
||||
instPkgUI
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
}
|
||||
|
||||
main
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue