fix: cascade failures

This commit is contained in:
xeruf 2022-07-05 12:41:16 +02:00
parent a15949d9dc
commit 0f01612145
3 changed files with 20 additions and 10 deletions

View file

@ -1,10 +1,10 @@
#!/bin/sh #!/bin/sh -e
arg=$1 arg=$1
name=$2 name=$2
location="/usr/local/bin/${name:-$(basename "$arg")}" location="/usr/local/bin/${name:-$(basename "$arg")}"
case "$arg" in case "$arg" in
(*://*) curl "$arg" | sudo tee "$location" > /dev/null;; (*://*) curl "$arg" | sudo tee "$location" > /dev/null;;
(*) cp "$arg" "$location";; (*) sudo cp "$arg" "$location";;
esac esac
sudo chmod +x "$location" sudo chmod +x "$location"
test "$INSTALEE_VERBOSE" -lt 3 || echo "Installed $name to $location" test "$INSTALEE_VERBOSE" -lt 3 || echo "Installed $name to $location"

View file

@ -8,7 +8,12 @@ highlight() { echo "$1"; }
destress() { echo "$1"; } destress() { echo "$1"; }
# Get the content of a file or the output of its execution # Get the content of a file or the output of its execution
getcontent() { test -x "$1" && "$1" || cat "$1"; } getcontent() {
if test -x "$1"
then "$1"
else cat "$1"
fi
}
# Get available package entries for given package # Get available package entries for given package
getentries() { getentries() {
@ -35,6 +40,7 @@ installpkg() {
fi fi
for pkg in $pkgs for pkg in $pkgs
do highlight "$pkg" do highlight "$pkg"
set -e
local name="$(basename $pkg)" local name="$(basename $pkg)"
local base="${name%_*}" local base="${name%_*}"
@ -42,10 +48,13 @@ installpkg() {
local handler="$home/handlers/$base" local handler="$home/handlers/$base"
if test -d "$handler" if test -d "$handler"
then then
local args="$(getcontent "$pkg" | grep . || echo "$1")" # This declaration needs to be ahead, otherwise it overrides failing exit codes
local install="$(find "$handler" -name "install$ext" | head -1)" && local args install
destress " $install $args" && args="$(getcontent "$pkg")"
$install $args args="${args:-$1}"
install="$(find "$handler" -name "install$ext" | head -1)"
destress " $install $args"
$install $args
else else
destress " running unhandled $pkg" destress " running unhandled $pkg"
$pkg $pkg

7
packages/logcli/script Normal file → Executable file
View file

@ -1,5 +1,6 @@
#!/bin/sh -e
cd /tmp cd /tmp
git clone https://github.com/grafana/loki.git git clone https://github.com/grafana/loki.git || true
cd loki cd loki
make logcli make logcli >&2
cmd/logcli/logcli echo "$PWD/cmd/logcli/logcli"