SHA256
use dedicated variable update_pbc for the install flag
This commit is contained in:
@@ -189,7 +189,8 @@ PBC=$(command -v proxmox-backup-client)
|
|||||||
PBC_DOWNLOAD_URL='http://download.proxmox.com/debian/pbs-client/dists/trixie/main/binary-amd64'
|
PBC_DOWNLOAD_URL='http://download.proxmox.com/debian/pbs-client/dists/trixie/main/binary-amd64'
|
||||||
ETC_DIR="/etc/$SCRIPT"
|
ETC_DIR="/etc/$SCRIPT"
|
||||||
|
|
||||||
FULL_HELP=false
|
full_help=false
|
||||||
|
update_pbc=false
|
||||||
|
|
||||||
action=''
|
action=''
|
||||||
cfgfile="$ETC_DIR/config"
|
cfgfile="$ETC_DIR/config"
|
||||||
@@ -210,7 +211,7 @@ while (( $# > 0 )); do
|
|||||||
exit 0
|
exit 0
|
||||||
;;
|
;;
|
||||||
-H|--full-help)
|
-H|--full-help)
|
||||||
FULL_HELP=true
|
full_help=true
|
||||||
;;
|
;;
|
||||||
-*)
|
-*)
|
||||||
echo "Error: invalid option: $opt" >&2
|
echo "Error: invalid option: $opt" >&2
|
||||||
@@ -225,7 +226,7 @@ while (( $# > 0 )); do
|
|||||||
elif [ "$action" == "install" ]; then
|
elif [ "$action" == "install" ]; then
|
||||||
case "$opt" in
|
case "$opt" in
|
||||||
-u|--update)
|
-u|--update)
|
||||||
args+=('true')
|
update_pbc=true
|
||||||
;;
|
;;
|
||||||
-*)
|
-*)
|
||||||
echo "Error: invalid option: $opt" >&2
|
echo "Error: invalid option: $opt" >&2
|
||||||
@@ -252,7 +253,7 @@ if [ -f "$cfgfile" ]; then
|
|||||||
(( 8#$perms & 0007 )) && echo "Warning: $cfgfile is readable by others!" >&2
|
(( 8#$perms & 0007 )) && echo "Warning: $cfgfile is readable by others!" >&2
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if $FULL_HELP; then
|
if $full_help; then
|
||||||
[ -f "$cfgfile" ] && source "$cfgfile"
|
[ -f "$cfgfile" ] && source "$cfgfile"
|
||||||
PBC=${PBC:-/usr/local/bin/proxmox-backup-client}
|
PBC=${PBC:-/usr/local/bin/proxmox-backup-client}
|
||||||
full_usage
|
full_usage
|
||||||
@@ -369,14 +370,12 @@ case "$action" in
|
|||||||
pbc-mount "$snapshot" "$archive" "$target" || exit $?
|
pbc-mount "$snapshot" "$archive" "$target" || exit $?
|
||||||
;;
|
;;
|
||||||
install)
|
install)
|
||||||
update=${args[0]:-false}
|
|
||||||
|
|
||||||
(( EUID != 0 )) && echo "Error: installation only works as root!" >&2 && exit 1
|
(( EUID != 0 )) && echo "Error: installation only works as root!" >&2 && exit 1
|
||||||
|
|
||||||
install_proxmox_backup_client "$update" || exit $?
|
install_proxmox_backup_client "$update_pbc" || exit $?
|
||||||
|
|
||||||
if dpkg -s jq &>/dev/null; then
|
if dpkg -s jq &>/dev/null; then
|
||||||
$update && echo "Info: skip update of jq, package is managed by package manager" || echo "Info: jq is already installed"
|
$update_pbc && echo "Info: skip update of jq, package is managed by package manager" || echo "Info: jq is already installed"
|
||||||
else
|
else
|
||||||
apt_get_install jq || exit $?
|
apt_get_install jq || exit $?
|
||||||
fi
|
fi
|
||||||
@@ -389,7 +388,7 @@ case "$action" in
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
if [ -f "$SCRIPT_DIR/config.example" ]; then
|
if [ -f "$SCRIPT_DIR/config.example" ]; then
|
||||||
if $update || [ ! -f "$ETC_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
|
||||||
|
|||||||
Reference in New Issue
Block a user