Testing new logic..
This commit is contained in:
parent
c75b6b41b2
commit
0ad00ad5d1
1 changed files with 89 additions and 63 deletions
136
zen-browser.sh
136
zen-browser.sh
|
@ -6,21 +6,17 @@
|
|||
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..
|
||||
getImports() {
|
||||
local url="https://git.k4li.de/scripts/imports/raw/branch/main/distros.sh"
|
||||
source-script() {
|
||||
local url="$1"
|
||||
local import="$(mktemp)"
|
||||
|
||||
# ─< if $1 is a local file, source this one instead >─────────────────────────────────────
|
||||
if [ -f "$url" ]; then
|
||||
source "$url"
|
||||
sleep 0.1
|
||||
return 0
|
||||
else
|
||||
# ─< if $1 is a url, grab it and source it, also deletes afterwards >─────────────────────
|
||||
if command_exists curl; then
|
||||
curl -fsSL $url -o $import
|
||||
elif command_exists wget; then
|
||||
|
@ -31,12 +27,16 @@
|
|||
fi
|
||||
|
||||
source "$import"
|
||||
sleep 0.2
|
||||
rm "$import"
|
||||
|
||||
echo "${BLUE}Sourcing external script:${NC} $url"
|
||||
line
|
||||
sleep 0.1
|
||||
rm -f "$import"
|
||||
fi
|
||||
}
|
||||
|
||||
getDependencies() {
|
||||
echo_info "Checking build dependencies.."
|
||||
pen bold blue "Checking build dependencies.."
|
||||
|
||||
# INFO:
|
||||
# ╭─────────────────────────────────────────────────────────────────────────╮
|
||||
|
@ -65,10 +65,10 @@
|
|||
declare -n pkgArray="${deps[$distro]}"
|
||||
|
||||
case "$distro" in
|
||||
debian | ubuntu | fedora | opensuse) checkAndInstall "${pkgArray[@]}" ;;
|
||||
debian | ubuntu | fedora | opensuse) check-and-install ${pkgArray[@]} ;;
|
||||
*)
|
||||
echo_warning "No dependencies for $distro.."
|
||||
echo_warning "Could be good, could be bad :):"
|
||||
pen bold yellow "No dependencies for $distro.."
|
||||
pen bold yellow "Could be good, could be bad :):"
|
||||
return 0
|
||||
;;
|
||||
esac
|
||||
|
@ -76,16 +76,16 @@
|
|||
|
||||
main() {
|
||||
if $silent; then
|
||||
echo_warning "Executing script silently!"
|
||||
pen bold yellow "Executing script silently!"
|
||||
fi
|
||||
|
||||
# if ! getDependencies; then
|
||||
# echo_error "Error when installing dependencies.."
|
||||
# echo-error "Error when installing dependencies.."
|
||||
# fi
|
||||
|
||||
case "$distro" in
|
||||
arch)
|
||||
_install zen-browser-bin
|
||||
pkg-install zen-browser-bin
|
||||
;;
|
||||
*)
|
||||
getDependencies
|
||||
|
@ -100,13 +100,14 @@
|
|||
ARCH="aarch64"
|
||||
;;
|
||||
*)
|
||||
echo_error "❌ Unsupported architecture: $ARCH" >&2
|
||||
echo-error "❌ Unsupported architecture: $ARCH" >&2
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
|
||||
cloneUrl="https://github.com/zen-browser/desktop/releases/latest/download/zen.linux-${ARCH}.tar.xz"
|
||||
local tempDir="$(mktemp -d)"
|
||||
|
||||
if [ -d "$HOME/.local/bin/" ]; then
|
||||
local zenDir="$HOME/.local/bin"
|
||||
else
|
||||
|
@ -117,47 +118,72 @@
|
|||
fi
|
||||
# cd "$zenDir" || mkdir -p "$zenDir" && cd "$zenDir"
|
||||
cd "$tempDir" || mkdir -p "$tempDir" && cd "$tempDir"
|
||||
echo_info "Downloading .tar.xz from $cloneUrl"
|
||||
spin bold blue "Downloading .tar.xz from $cloneUrl"
|
||||
|
||||
local err out
|
||||
|
||||
if command_exists wget; then
|
||||
wget "$cloneUrl"
|
||||
elif command_exists curl; then
|
||||
curl -fsSL "$cloneUrl" -o "zen.linux-${ARCH}.tar.xz"
|
||||
if run --err err --out out wget "$cloneUrl"; then
|
||||
check
|
||||
else
|
||||
throw-err
|
||||
# pen bold yellow "OUT: ${out:-}"
|
||||
# echo-error "${err:-}"
|
||||
fi
|
||||
elif command_exists curl; then
|
||||
|
||||
if run --err err --out out curl -fsSL "$cloneUrl" -o "zen.linux-${ARCH}.tar.xz"; then
|
||||
check
|
||||
else
|
||||
throw-err
|
||||
# pen bold yellow "OUT: ${out:-}"
|
||||
# echo-error "${err:-}"
|
||||
fi
|
||||
# curl -fsSL "$cloneUrl" -o "zen.linux-${ARCH}.tar.xz"
|
||||
else
|
||||
echo-error "curl/wget is required but missing.."
|
||||
exit 69
|
||||
echo_error "curl/wget is required but missing.."
|
||||
fi
|
||||
|
||||
echo_info "Extracting archive.."
|
||||
run tar -xf "./zen.linux-${ARCH}.tar.xz" -C "$zenDir"
|
||||
spin bold blue "Extracting archive.."
|
||||
if run tar -xf "./zen.linux-${ARCH}.tar.xz" -C "$zenDir"; then
|
||||
check "Extracted archive.."
|
||||
else
|
||||
throw-err
|
||||
# pen bold yellow "OUT: ${out:-}"
|
||||
# echo-error "${err:-}"
|
||||
fi
|
||||
|
||||
echo_info "Installing to /bin/zen-browser"
|
||||
pen bold blue "Installing to /bin/zen-browser"
|
||||
$_sudo ln -fsr "$zenDir/zen/zen-bin" /bin/zen-browser
|
||||
;;
|
||||
esac
|
||||
}
|
||||
|
||||
# setup() {
|
||||
# if getImports; then
|
||||
# case "$@" in
|
||||
# --silent | -s)
|
||||
# silent=true
|
||||
# echo_warning "Running script silently!"
|
||||
# ;;
|
||||
# *)
|
||||
# silent=false
|
||||
# ;;
|
||||
# esac
|
||||
# fi
|
||||
#
|
||||
# if ! command_exists zen-browser; then
|
||||
# return 0
|
||||
# else
|
||||
# echo_error "zen-browser does already exist on this machine!"
|
||||
# return 69
|
||||
# fi
|
||||
# }
|
||||
# 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 pkg-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..
|
||||
setup-env() {
|
||||
# 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
|
||||
local dream=https://git.k4li.de/scripts/imports/raw/branch/main/dream.sh
|
||||
|
||||
if getImports; then
|
||||
if ! command_exists pkg-install && ! command_exists check-and-install && ! command_exists spin; then
|
||||
source-script $dream
|
||||
line
|
||||
fi
|
||||
}
|
||||
|
||||
if setup-env; then
|
||||
# ─< package variable >───────────────────────────────────────────────────────────────────
|
||||
unset PACKAGE
|
||||
|
||||
|
@ -168,8 +194,8 @@
|
|||
|
||||
PACKAGE=zen-browser
|
||||
if command_exists "$PACKAGE"; then
|
||||
echo_warning "$PACKAGE is already installed!"
|
||||
echo_warning "Exiting now!"
|
||||
pen bold yellow "$PACKAGE is already installed!"
|
||||
pen bold yellow "Exiting now!"
|
||||
exit 69
|
||||
fi
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue