Compare commits

..
4 Commits
3 changed files with 18 additions and 13 deletions
+12 -1
View File
@@ -23,6 +23,17 @@ curl -fsSL https://git.ccc-rheintal.ch/spacefreak/pbc/raw/branch/master/install.
This installs the newest tagged version to `/usr/local/bin/pbc`, installs the This installs the newest tagged version to `/usr/local/bin/pbc`, installs the
dependencies, and puts an example config at `/etc/pbc/config.example`. dependencies, and puts an example config at `/etc/pbc/config.example`.
### Installing a specific version
Set `PBC_GIT_TAG` to install that tag instead of the newest one:
```bash
curl -fsSL https://git.ccc-rheintal.ch/spacefreak/pbc/raw/branch/master/install.sh | sudo PBC_GIT_TAG=v1.0.0 bash
```
`sudo` drops the environment, so set the variable on the `sudo` command itself (or use
`sudo -E`), not before `curl`. Any Git ref works, e.g. a branch name for testing.
### Updating ### Updating
Run the same command again to update `pbc` itself: Run the same command again to update `pbc` itself:
@@ -32,7 +43,7 @@ curl -fsSL https://git.ccc-rheintal.ch/spacefreak/pbc/raw/branch/master/install.
``` ```
It fetches the newest tag and overwrites `/usr/local/bin/pbc`. Your `/etc/pbc/config` is It fetches the newest tag and overwrites `/usr/local/bin/pbc`. Your `/etc/pbc/config` is
left untouched. left untouched. `PBC_GIT_TAG` works here too, to pin or roll back to a given version.
To update only the `proxmox-backup-client` binary: To update only the `proxmox-backup-client` binary:
+4 -5
View File
@@ -13,7 +13,7 @@ function cleanup_work_dir() {
function download_files() { function download_files() {
local path rc local path rc
local query_params='' local query_params=''
[ -n "$GIT_TAG" ] && query_params="?ref=$GIT_TAG" [ -n "$PBC_GIT_TAG" ] && query_params="?ref=$PBC_GIT_TAG"
while (( $# > 0 )); do while (( $# > 0 )); do
path=$1 path=$1
@@ -26,9 +26,9 @@ function download_files() {
done done
} }
GIT_TAG=$(curl -fsSL "$API_ENDPOINT/tags" | grep -o '{"name":"[^"]*"' | sed 's/^{"name":"//;s/"$//' | grep -E '^v[0-9]+' | sort --version-sort | tail -n 1) [ -z "$PBC_GIT_TAG" ] && PBC_GIT_TAG=$(curl -fsSL "$API_ENDPOINT/tags" | grep -o '{"name":"[^"]*"' | sed 's/^{"name":"//;s/"$//' | grep -E '^v[0-9]+' | sort --version-sort | tail -n 1)
if [ -n "$GIT_TAG" ]; then if [ -n "$PBC_GIT_TAG" ]; then
echo "Info: installing pbc version $GIT_TAG" echo "Info: installing pbc version $PBC_GIT_TAG"
else 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
@@ -38,7 +38,6 @@ 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 "$WORK_DIR/pbc" chmod +x "$WORK_DIR/pbc"
chmod o= "$WORK_DIR/config.example"
"$WORK_DIR/pbc" install "$WORK_DIR/pbc" install
rc=$? rc=$?
-5
View File
@@ -86,7 +86,6 @@ function apt_get_install() {
return $rc return $rc
} }
WORK_DIR=''
function cleanup_work_dir() { function cleanup_work_dir() {
[ -n "$WORK_DIR" ] && [ -d "$WORK_DIR" ] && rm -r "$WORK_DIR" [ -n "$WORK_DIR" ] && [ -d "$WORK_DIR" ] && rm -r "$WORK_DIR"
trap - EXIT trap - EXIT
@@ -143,7 +142,6 @@ function install_proxmox_backup_client() {
cleanup_work_dir cleanup_work_dir
} }
function arr_contains() { function arr_contains() {
local search=$1 local search=$1
shift shift
@@ -275,7 +273,6 @@ while (( $# > 0 )); do
fi fi
done done
if [ -f "$cfgfile" ]; then if [ -f "$cfgfile" ]; then
perms=$(stat -c '%a' "$cfgfile") perms=$(stat -c '%a' "$cfgfile")
(( 8#$perms & 0022 )) && echo "Error: $cfgfile is writable by group or others!" >&2 && exit 202 (( 8#$perms & 0022 )) && echo "Error: $cfgfile is writable by group or others!" >&2 && exit 202
@@ -405,11 +402,9 @@ case "$action" in
fi fi
if [ -f "$SCRIPT_DIR/config.example" ]; then if [ -f "$SCRIPT_DIR/config.example" ]; then
if $update_pbc || [ ! -f "$ETC_DIR/config.example" ]; then
echo "Install example config to $ETC_DIR/config.example ..." echo "Install example config to $ETC_DIR/config.example ..."
! install -m 0640 "$SCRIPT_DIR/config.example" "$ETC_DIR/config.example" && echo "Error installing file!" >&2 && exit 4 ! install -m 0640 "$SCRIPT_DIR/config.example" "$ETC_DIR/config.example" && echo "Error installing file!" >&2 && exit 4
fi fi
fi
echo "Info: successfully installed pbc dependencies" echo "Info: successfully installed pbc dependencies"
;; ;;