SHA256
rename TMPDIR to WORK_DIR
This commit is contained in:
+10
-10
@@ -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!"
|
||||
|
||||
Reference in New Issue
Block a user