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!"
|
||||
|
||||
@@ -102,9 +102,9 @@ function apt_get_install() {
|
||||
return $rc
|
||||
}
|
||||
|
||||
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
|
||||
}
|
||||
|
||||
@@ -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)
|
||||
[ -z "$pkgfile" ] && echo "Unable to determine current package file!" >&2 && return 30
|
||||
|
||||
TMPDIR=$(mktemp -d)
|
||||
trap cleanup_tmpdir EXIT
|
||||
WORK_DIR=$(mktemp -d)
|
||||
trap cleanup_work_dir EXIT
|
||||
|
||||
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 ..."
|
||||
! 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 ..."
|
||||
! 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 $?
|
||||
$update && action='updated' || action='installed'
|
||||
echo "Info: successfully $action proxmox-backup-$version"
|
||||
|
||||
cleanup_tmpdir
|
||||
cleanup_work_dir
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user