63 lines
1.8 KiB
Bash
63 lines
1.8 KiB
Bash
#!/usr/bin/env sh
|
|
|
|
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', 'fedora'..>
|
|
# 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
|
|
|
|
_dependencies() {
|
|
_deps="go git mpv yt-dlp"
|
|
|
|
for dependency in $_deps; do
|
|
if ! command_exists "$dependency"; then
|
|
echo_info "Installing $dependency"
|
|
_install "$dependency" || echo_error "$dependency could not be installed!"
|
|
else
|
|
echo_note "$dependency - was already installed."
|
|
fi
|
|
done
|
|
}
|
|
|
|
_clone() {
|
|
tmpdir="$(mktemp --dir)"
|
|
repo="https://git.k4li.de/pika/ytgo.git"
|
|
|
|
cd "$tmpdir" || echo_error "$tmpdir is not a valid directory!"
|
|
git clone --depth=1 "$repo"
|
|
cd ytgo || echo_error "$tmpdir/ytgo is not a valid directory!"
|
|
}
|
|
|
|
_build() {
|
|
$_sudo make install
|
|
}
|
|
|
|
# ───────────────────────────────< main function to execute >───────────────────────────────
|
|
main() {
|
|
if check_root; then
|
|
_dependencies || echo_error "dependency function failed hard!"
|
|
_clone || echo_error "clone function failed hard!"
|
|
_build || echo_error "build function failed hard!"
|
|
else
|
|
echo_error "Something went terribly wrong!"
|
|
fi
|
|
}
|
|
|
|
main
|