diff --git a/CHANGELOG.md b/CHANGELOG.md index 12f2db0..a729400 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -120,6 +120,16 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Script version bumped to 1.1.0 for multi-target support ### Added +- **System-wide installation support** + - New `--install` flag to install PBSClientTool to /usr/local/bin + - Run from anywhere with `sudo PBSClientTool` command + - No need to navigate to script directory + - Includes `--uninstall` to remove from system + - Added `--help` and `--version` flags for command-line usage + - Installation preserves original script (safe to update via git pull) + - install_script() function handles installation with overwrite confirmation + - uninstall_script() function removes command but keeps configurations + - Command-line argument parsing before main() execution - **Automatic connection testing at startup** - All configured targets are automatically tested when script starts - Quick authentication check (5 second timeout per target) diff --git a/README.md b/README.md index 95972cb..aee7979 100644 --- a/README.md +++ b/README.md @@ -4,6 +4,7 @@ Interactive bash script that automatically installs and configures Proxmox Backu ## Features +- **Multi-target backup support** - Backup to multiple PBS servers for redundancy - **Auto-detects Linux distribution** (Ubuntu 20.04/22.04/24.04, Debian 10/11/12, Arch Linux) - **Installs correct PBS client version** for your system - **Interactive configuration** via console prompts @@ -12,6 +13,57 @@ Interactive bash script that automatically installs and configures Proxmox Backu - **Configurable retention policies** (daily, weekly, monthly) - **Connection testing** before finalizing setup - **Immediate backup option** after installation +- **System-wide installation** - Run from anywhere with `PBSClientTool` command + +## Installation + +### Quick Install + +```bash +# Clone the repository +git clone https://github.com/zaphod-black/PBSClientTool.git +cd PBSClientTool + +# Install PBSClientTool to your system +sudo ./pbs-client-installer.sh --install +``` + +After installation, you can run the tool from anywhere: + +```bash +sudo PBSClientTool +``` + +### Manual Usage (Without Installing) + +You can also run the script directly without installing: + +```bash +sudo ./pbs-client-installer.sh +``` + +### Command-Line Options + +```bash +sudo PBSClientTool --help # Show help message +sudo PBSClientTool --version # Show version +sudo PBSClientTool --install # Install to /usr/local/bin +sudo PBSClientTool --uninstall # Remove from system +``` + +### Uninstallation + +To remove the PBSClientTool command from your system: + +```bash +sudo PBSClientTool --uninstall +``` + +**Note:** This only removes the command. Your backup targets and configurations are preserved. To completely remove all backups and configurations, use: + +```bash +sudo ./uninstaller.sh +``` ## Prerequisites diff --git a/pbs-client-installer.sh b/pbs-client-installer.sh index b22ef0a..c83769b 100755 --- a/pbs-client-installer.sh +++ b/pbs-client-installer.sh @@ -10,6 +10,8 @@ NC='\033[0m' # No Color # Script configuration SCRIPT_VERSION="1.1.0" +SCRIPT_NAME="PBSClientTool" +INSTALL_PATH="/usr/local/bin/$SCRIPT_NAME" CONFIG_DIR="/etc/proxmox-backup-client" TARGETS_DIR="$CONFIG_DIR/targets" LOG_FILE="/var/log/pbs-client-installer.log" @@ -1989,6 +1991,132 @@ show_summary() { log "Setup completed successfully!" } +# Install script to system PATH +install_script() { + check_root + + echo + echo "╔════════════════════════════════════════╗" + echo "║ Install PBSClientTool ║" + echo "╚════════════════════════════════════════╝" + echo + + # Get the absolute path of this script + SCRIPT_PATH="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)/$(basename "${BASH_SOURCE[0]}")" + + if [ -f "$INSTALL_PATH" ]; then + warn "PBSClientTool is already installed at $INSTALL_PATH" + OVERWRITE=$(prompt "Do you want to overwrite it? (yes/no)" "no") + if [ "$OVERWRITE" != "yes" ]; then + info "Installation cancelled" + return 0 + fi + fi + + log "Installing PBSClientTool to $INSTALL_PATH..." + + # Copy script to /usr/local/bin/ + cp "$SCRIPT_PATH" "$INSTALL_PATH" + chmod +x "$INSTALL_PATH" + + log "Installation complete!" + echo + info "You can now run the tool from anywhere using:" + echo " sudo $SCRIPT_NAME" + echo + info "Available commands:" + echo " sudo $SCRIPT_NAME - Run interactive menu" + echo " sudo $SCRIPT_NAME --help - Show help message" + echo " sudo $SCRIPT_NAME --version - Show version" + echo +} + +# Uninstall script from system PATH +uninstall_script() { + check_root + + echo + echo "╔════════════════════════════════════════╗" + echo "║ Uninstall PBSClientTool ║" + echo "╚════════════════════════════════════════╝" + echo + + if [ ! -f "$INSTALL_PATH" ]; then + error "PBSClientTool is not installed at $INSTALL_PATH" + return 1 + fi + + warn "This will remove the PBSClientTool command from your system" + warn "Your backup targets and configurations will NOT be removed" + echo + CONFIRM=$(prompt "Do you want to continue? (yes/no)" "no") + + if [ "$CONFIRM" != "yes" ]; then + info "Uninstall cancelled" + return 0 + fi + + log "Removing $INSTALL_PATH..." + rm -f "$INSTALL_PATH" + + log "Uninstall complete!" + echo + info "To completely remove all backup configurations, use the uninstaller:" + echo " sudo ./uninstaller.sh" + echo +} + +# Show help message +show_help() { + cat << EOF + +Proxmox Backup Client Tool v${SCRIPT_VERSION} + +A tool for managing Proxmox Backup Server client installations and multi-target backups. + +USAGE: + sudo $SCRIPT_NAME [OPTIONS] + +OPTIONS: + --install Install PBSClientTool to /usr/local/bin (makes it available system-wide) + --uninstall Uninstall PBSClientTool from system + --help, -h Show this help message + --version, -v Show version information + +INTERACTIVE MODE (default): + Run without arguments to launch the interactive menu for managing backup targets. + +EXAMPLES: + # Install to system PATH + sudo ./pbs-client-installer.sh --install + + # Run from anywhere after installation + sudo $SCRIPT_NAME + + # Show version + sudo $SCRIPT_NAME --version + + # Uninstall from system + sudo $SCRIPT_NAME --uninstall + +FEATURES: + - Multi-target backup support (backup to multiple PBS servers) + - File-level and block device backups + - Automated backup scheduling with systemd timers + - Connection testing and validation + - Easy target management (add, edit, delete, view) + +DOCUMENTATION: + https://github.com/zaphod-black/PBSClientTool + +EOF +} + +# Show version +show_version() { + echo "PBSClientTool version $SCRIPT_VERSION" +} + # Main script execution main() { echo @@ -2193,5 +2321,28 @@ main() { exit 1 } -# Run main function -main "$@" +# Parse command-line arguments +case "${1:-}" in + --install) + install_script + ;; + --uninstall) + uninstall_script + ;; + --help|-h) + show_help + ;; + --version|-v) + show_version + ;; + "") + # No arguments - run interactive mode + main + ;; + *) + error "Unknown option: $1" + echo + echo "Run with --help for usage information" + exit 1 + ;; +esac