wip
This commit is contained in:
parent
9f18869ebe
commit
37e3e896c6
1 changed files with 91 additions and 0 deletions
91
blackarch.sh
Normal file
91
blackarch.sh
Normal file
|
@ -0,0 +1,91 @@
|
||||||
|
{
|
||||||
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
|
# ─< Check if the given command exists silently >─────────────────────────────────────────
|
||||||
|
command_exists() {
|
||||||
|
command -v "$@" >/dev/null 2>&1
|
||||||
|
}
|
||||||
|
|
||||||
|
getImports() {
|
||||||
|
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
|
||||||
|
|
||||||
|
source "$import"
|
||||||
|
|
||||||
|
echo "${BLUE}Sourcing external script:${NC} $url"
|
||||||
|
sleep 0.1
|
||||||
|
rm -f "$import"
|
||||||
|
}
|
||||||
|
|
||||||
|
setup-env() {
|
||||||
|
# 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..
|
||||||
|
#
|
||||||
|
# local beddu=https://git.k4li.de/scripts/beddu/raw/branch/main/dist/beddu.sh
|
||||||
|
# local pika=https://git.k4li.de/scripts/imports/raw/branch/main/distros.sh
|
||||||
|
# dream ~= combined beddu and pika
|
||||||
|
local dream=https://git.k4li.de/scripts/imports/raw/branch/main/dream.sh
|
||||||
|
|
||||||
|
if ! command_exists pkg-install && ! command_exists check-and-install && ! command_exists pen; then
|
||||||
|
getImports $dream
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
setup-blackarch() {
|
||||||
|
local tmpfile
|
||||||
|
local baURL=https://blackarch.org/strap.sh
|
||||||
|
tmpfile="$(mktemp)"
|
||||||
|
|
||||||
|
curl -fsSL $baURL -o $tmpfile
|
||||||
|
|
||||||
|
if [ -n "$tmpfile" ]; then
|
||||||
|
$_sudo chmod +x $tmpfile
|
||||||
|
$_sudo $tmpfile
|
||||||
|
else
|
||||||
|
pen bold red "$tmpfile was empty.."
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
post-setup() {
|
||||||
|
$_sudo pacman -Syyu
|
||||||
|
}
|
||||||
|
|
||||||
|
main() {
|
||||||
|
if ! command_exists curl; then
|
||||||
|
pkg-install curl
|
||||||
|
fi
|
||||||
|
|
||||||
|
setup-blackarch && post-setup
|
||||||
|
}
|
||||||
|
|
||||||
|
if setup-env; then
|
||||||
|
# ─< package variable >───────────────────────────────────────────────────────────────────
|
||||||
|
unset PACKAGE
|
||||||
|
|
||||||
|
if $arch; then
|
||||||
|
main
|
||||||
|
else
|
||||||
|
throw bold red "Your distro $distro is not made for blackarch.."
|
||||||
|
exit 69
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
}
|
Loading…
Add table
Add a link
Reference in a new issue