Update sudo access check to prompt for password when needed, allowing system-wide installation even with password-protected sudo
This commit is contained in:
@@ -283,17 +283,29 @@ determine_install_strategy() {
|
||||
local install_type=$(echo "$current_info" | cut -d: -f2)
|
||||
|
||||
# Strategy: Prefer system installation for all users
|
||||
if [[ $EUID -eq 0 ]] || sudo -n true 2>/dev/null; then
|
||||
print_status "Installing system-wide for all users"
|
||||
if [[ $EUID -eq 0 ]]; then
|
||||
print_status "Running as root, installing system-wide"
|
||||
INSTALL_STRATEGY="system_install"
|
||||
TARGET_DIR="$SYSTEM_INSTALL_DIR"
|
||||
|
||||
# Warn if user bin has borg
|
||||
if [[ -f "$USER_BIN_DIR/borg" ]]; then
|
||||
print_warning "Borg CLI found in user bin directory ($USER_BIN_DIR)"
|
||||
print_status "This might take precedence if $USER_BIN_DIR is in PATH before system paths"
|
||||
elif sudo -n true 2>/dev/null; then
|
||||
print_status "Passwordless sudo available, installing system-wide"
|
||||
INSTALL_STRATEGY="system_install"
|
||||
TARGET_DIR="$SYSTEM_INSTALL_DIR"
|
||||
elif command_exists sudo; then
|
||||
print_status "Testing sudo access (you may be prompted for password)..."
|
||||
if sudo -v 2>/dev/null; then
|
||||
print_success "Sudo access confirmed, installing system-wide"
|
||||
INSTALL_STRATEGY="system_install"
|
||||
TARGET_DIR="$SYSTEM_INSTALL_DIR"
|
||||
else
|
||||
print_warning "Sudo access failed, falling back to user installation"
|
||||
fi
|
||||
else
|
||||
print_warning "Sudo not available, using user installation"
|
||||
fi
|
||||
|
||||
# If not system install, check user bin
|
||||
if [[ "$INSTALL_STRATEGY" != "system_install" ]]; then
|
||||
print_status "No sudo access, checking user bin directory"
|
||||
if check_user_bin_setup; then
|
||||
print_status "User bin directory is available and in PATH"
|
||||
|
||||
Reference in New Issue
Block a user