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"
|
API_ENDPOINT="https://git.ccc-rheintal.ch/api/v1/repos/spacefreak/pbc"
|
||||||
|
|
||||||
TMPDIR=''
|
WORK_DIR=''
|
||||||
function cleanup_tmpdir() {
|
function cleanup_work_dir() {
|
||||||
[ -n "$TMPDIR" -a -d "$TMPDIR" ] && rm -r "$TMPDIR"
|
[ -n "$WORK_DIR" ] && [ -d "$WORK_DIR" ] && rm -r "$WORK_DIR"
|
||||||
trap - EXIT
|
trap - EXIT
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -18,7 +18,7 @@ function download_files() {
|
|||||||
while (( $# > 0 )); do
|
while (( $# > 0 )); do
|
||||||
path=$1
|
path=$1
|
||||||
shift
|
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=$?
|
rc=$?
|
||||||
if (( $rc != 0 )); then
|
if (( $rc != 0 )); then
|
||||||
return $rc
|
return $rc
|
||||||
@@ -33,20 +33,20 @@ else
|
|||||||
echo "Warning: no Git tag found, installing from repository default branch" >&2
|
echo "Warning: no Git tag found, installing from repository default branch" >&2
|
||||||
fi
|
fi
|
||||||
|
|
||||||
TMPDIR=$(mktemp -d)
|
WORK_DIR=$(mktemp -d)
|
||||||
trap cleanup_tmpdir EXIT
|
trap cleanup_work_dir EXIT
|
||||||
|
|
||||||
! download_files config.example pbc && echo "Error downloading files!" >&2 && exit 10
|
! download_files config.example pbc && echo "Error downloading files!" >&2 && exit 10
|
||||||
chmod +x "$TMPDIR/pbc"
|
chmod +x "$WORK_DIR/pbc"
|
||||||
chmod o= "$TMPDIR/config.example"
|
chmod o= "$WORK_DIR/config.example"
|
||||||
|
|
||||||
"$TMPDIR/pbc" install
|
"$WORK_DIR/pbc" install
|
||||||
rc=$?
|
rc=$?
|
||||||
if (( $rc != 0 )); then
|
if (( $rc != 0 )); then
|
||||||
echo "Error installing pbc requirements!" >&2
|
echo "Error installing pbc requirements!" >&2
|
||||||
exit $rc
|
exit $rc
|
||||||
fi
|
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!"
|
echo "Success!"
|
||||||
|
|||||||
@@ -102,9 +102,9 @@ function apt_get_install() {
|
|||||||
return $rc
|
return $rc
|
||||||
}
|
}
|
||||||
|
|
||||||
TMPDIR=''
|
WORK_DIR=''
|
||||||
function cleanup_tmpdir() {
|
function cleanup_work_dir() {
|
||||||
[ -n "$TMPDIR" -a -d "$TMPDIR" ] && rm -r "$TMPDIR"
|
[ -n "$WORK_DIR" ] && [ -d "$WORK_DIR" ] && rm -r "$WORK_DIR"
|
||||||
trap - EXIT
|
trap - EXIT
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -140,23 +140,23 @@ function install_proxmox_backup_client() {
|
|||||||
local pkgfile=$(curl -fsSL "$PBC_DOWNLOAD_URL/" | grep proxmox-backup-client-static_ | sed 's#.*href="##g;s#".*##g;' | sort --version-sort | tail -n 1)
|
local pkgfile=$(curl -fsSL "$PBC_DOWNLOAD_URL/" | grep proxmox-backup-client-static_ | sed 's#.*href="##g;s#".*##g;' | sort --version-sort | tail -n 1)
|
||||||
[ -z "$pkgfile" ] && echo "Unable to determine current package file!" >&2 && return 30
|
[ -z "$pkgfile" ] && echo "Unable to determine current package file!" >&2 && return 30
|
||||||
|
|
||||||
TMPDIR=$(mktemp -d)
|
WORK_DIR=$(mktemp -d)
|
||||||
trap cleanup_tmpdir EXIT
|
trap cleanup_work_dir EXIT
|
||||||
|
|
||||||
echo "Info: downloading $PBC_DOWNLOAD_URL/$pkgfile ..."
|
echo "Info: downloading $PBC_DOWNLOAD_URL/$pkgfile ..."
|
||||||
! curl -fsSL -o "$TMPDIR/$pkgfile" "$PBC_DOWNLOAD_URL/$pkgfile" && echo "Error downloading file!" >&2 && return 40
|
! curl -fsSL -o "$WORK_DIR/$pkgfile" "$PBC_DOWNLOAD_URL/$pkgfile" && echo "Error downloading file!" >&2 && return 40
|
||||||
|
|
||||||
echo "Info: extracting $pkgfile ..."
|
echo "Info: extracting $pkgfile ..."
|
||||||
! dpkg-deb -x "$TMPDIR/$pkgfile" "$TMPDIR/" && echo "Error extracting file!" >&2 && return 50
|
! dpkg-deb -x "$WORK_DIR/$pkgfile" "$WORK_DIR/" && echo "Error extracting file!" >&2 && return 50
|
||||||
|
|
||||||
echo "Info: installing proxmox-backup-client static binary to $PBC ..."
|
echo "Info: installing proxmox-backup-client static binary to $PBC ..."
|
||||||
! install -m 0755 -D "$TMPDIR/usr/bin/proxmox-backup-client" "$PBC" && echo "Error installing binary!" >&2 && return 60
|
! install -m 0755 -D "$WORK_DIR/usr/bin/proxmox-backup-client" "$PBC" && echo "Error installing binary!" >&2 && return 60
|
||||||
|
|
||||||
version=$(pbc-version) || return $?
|
version=$(pbc-version) || return $?
|
||||||
$update && action='updated' || action='installed'
|
$update && action='updated' || action='installed'
|
||||||
echo "Info: successfully $action proxmox-backup-$version"
|
echo "Info: successfully $action proxmox-backup-$version"
|
||||||
|
|
||||||
cleanup_tmpdir
|
cleanup_work_dir
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user