rename TMPDIR to WORK_DIR

This commit is contained in:
2026-08-22 06:19:51 +02:00
parent 4e24ee218c
commit 22abaf6431
2 changed files with 19 additions and 19 deletions
+10 -10
View File
@@ -4,9 +4,9 @@
API_ENDPOINT="https://git.ccc-rheintal.ch/api/v1/repos/spacefreak/pbc"
TMPDIR=''
function cleanup_tmpdir() {
[ -n "$TMPDIR" -a -d "$TMPDIR" ] && rm -r "$TMPDIR"
WORK_DIR=''
function cleanup_work_dir() {
[ -n "$WORK_DIR" ] && [ -d "$WORK_DIR" ] && rm -r "$WORK_DIR"
trap - EXIT
}
@@ -18,7 +18,7 @@ function download_files() {
while (( $# > 0 )); do
path=$1
shift
curl -fsSL --output-dir "$TMPDIR/" --remote-name "$API_ENDPOINT/raw/$path$query_params"
curl -fsSL --output-dir "$WORK_DIR/" --remote-name "$API_ENDPOINT/raw/$path$query_params"
rc=$?
if (( $rc != 0 )); then
return $rc
@@ -33,20 +33,20 @@ else
echo "Warning: no Git tag found, installing from repository default branch" >&2
fi
TMPDIR=$(mktemp -d)
trap cleanup_tmpdir EXIT
WORK_DIR=$(mktemp -d)
trap cleanup_work_dir EXIT
! download_files config.example pbc && echo "Error downloading files!" >&2 && exit 10
chmod +x "$TMPDIR/pbc"
chmod o= "$TMPDIR/config.example"
chmod +x "$WORK_DIR/pbc"
chmod o= "$WORK_DIR/config.example"
"$TMPDIR/pbc" install
"$WORK_DIR/pbc" install
rc=$?
if (( $rc != 0 )); then
echo "Error installing pbc requirements!" >&2
exit $rc
fi
! mv "$TMPDIR/pbc" /usr/local/bin/pbc && echo 'Error moving file!' >&2 && exit 20
! mv "$WORK_DIR/pbc" /usr/local/bin/pbc && echo 'Error moving file!' >&2 && exit 20
echo "Success!"