Compare commits

..
2 Commits
Author SHA256 Message Date
spacefreak 22965dc8ed add install.sh 2026-08-22 02:02:36 +02:00
spacefreak fbf638cbf0 change success message 2026-08-22 02:00:10 +02:00
2 changed files with 52 additions and 2 deletions
Executable
+51
View File
@@ -0,0 +1,51 @@
#!/usr/bin/env bash
[ "$(whoami)" != "root" ] && echo "Error: installation only works as root!" >&2 && exit 1
API_ENDPOINT="https://git.ccc-rheintal.ch/api/v1/repos/spacefreak/pbc"
TMPDIR=''
function cleanup_tmpdir() {
[ -n "$TMPDIR" -a -d "$TMPDIR" ] && rm -r "$TMPDIR"
trap - EXIT
}
function download_files() {
local path
local query_params=''
[ -n "$GIT_TAG" ] && query_params="?ref=$GIT_TAG"
while [ -n "$1" ]; do
path=$1
shift
curl -s --output-dir "$TMPDIR/" --remote-name "$API_ENDPOINT/raw/$path$query_params"
rc=$?
if (( $rc != 0 )); then
return $rc
fi
done
}
GIT_TAG=$(curl -s "$API_ENDPOINT/tags" | jq -r '.[] | .name' | sort --version-sort | tail -n 1)
if [ -n "$GIT_TAG" ]; then
echo "Info: installing pbc version $GIT_TAG"
else
echo "Warning: no Git tag found, installing from repository default branch" >&2
fi
TMPDIR=$(mktemp -d)
trap cleanup_tmpdir EXIT
! download_files config.example pbc && echo "Error downloading files!" >&2 && exit 10
chmod +x "$TMPDIR/pbc"
"$TMPDIR/pbc" install
rc=$?
if (( $? != 0 )); then
echo "Error installing pbc requirements!" >&2
exit $rc
fi
! mv "$TMPDIR/pbc" /usr/local/bin/pbc && echo 'Error moving pbc to /usr/local/bin/pbc !' >&2 && exit 20
echo "Success!"
+1 -2
View File
@@ -394,8 +394,7 @@ case "$action" in
fi
fi
$update && action='Update' || action='Installation'
echo "$action successful!"
echo "Success!"
;;
*)
"$PBC" "$action" "${args[@]}" || exit $?