From 1dccbce6d08bbe502cff585a3bfecf88bcf3d432 Mon Sep 17 00:00:00 2001 From: shuki Date: Thu, 5 Mar 2026 00:02:27 +0200 Subject: [PATCH] Fix cPanel plugin install: copy install.json to target dir and use tar.gz archive install_plugin requires a tar.gz archive, not a raw JSON file. Also copies install.json to the plugin directory so uninstall_plugin can reference it. Includes CLAUDE.md documentation updates. Co-Authored-By: Claude Opus 4.6 --- CLAUDE.md | 9 ++++++--- scripts/install.sh | 9 +++++++-- 2 files changed, 13 insertions(+), 5 deletions(-) diff --git a/CLAUDE.md b/CLAUDE.md index 83ebd13..41f5cda 100644 --- a/CLAUDE.md +++ b/CLAUDE.md @@ -16,13 +16,13 @@ gniza is a Bash CLI tool for cPanel server backup and disaster recovery. It runs bin/gniza # CLI entrypoint — command routing, argument parsing lib/ ├── constants.sh # Version, exit codes, color codes, default values -├── utils.sh # die(), require_root(), timestamp(), human_size/duration() +├── utils.sh # die(), require_root(), timestamp(), human_size/duration(), validate_timestamp/account_name() ├── logging.sh # Per-run log files (LOG_FILE), log_info/warn/error/debug -├── config.sh # load_config(), validate_config() +├── config.sh # _safe_source_config(), load_config(), validate_config() ├── locking.sh # flock-based acquire_lock(), release_lock() ├── ssh.sh # build_ssh_opts(), remote_exec(), test_ssh_connection() ├── rclone.sh # Rclone transport layer for S3/GDrive remotes -├── accounts.sh # get_all_accounts(), filter_accounts(), account_exists() +├── accounts.sh # get_all_accounts(), filter_accounts(), is_suspended(), get_backup_accounts(), account_exists() ├── pkgacct.sh # run_pkgacct(), gzip_sql_files(), cleanup_pkgacct() ├── snapshot.sh # get_snapshot_dir(), list_remote_snapshots(), finalize ├── transfer.sh # rsync_to_remote(), transfer_pkgacct/homedir(), finalize_snapshot() @@ -107,6 +107,7 @@ _restore_remote_globals ``` cmd_backup() +├── require_cmd(rsync, ssh, hostname, gzip) ├── load_config() + validate_config() + init_logging() ├── get_target_remotes(--remote flag) ├── _save_remote_globals() @@ -377,6 +378,8 @@ Schedules are decoupled from remotes. Each schedule targets one or more remotes. | `SCHEDULE_DAY` | Conditional | — | Hours interval (1-23) for hourly, day-of-week (0-6) for weekly, day-of-month (1-28) for monthly | | `SCHEDULE_CRON` | Conditional | — | Full 5-field cron expr (for `custom` only) | | `REMOTES` | No | (all) | Comma-separated remote names to target | +| `SYSBACKUP` | No | (empty) | `yes` to include system backup (`/scripts/pkgacct`) | +| `SKIP_SUSPENDED` | No | (empty) | `yes` to skip cPanel suspended accounts | ## Key Functions Reference diff --git a/scripts/install.sh b/scripts/install.sh index b14bd1f..c91d89b 100755 --- a/scripts/install.sh +++ b/scripts/install.sh @@ -105,14 +105,19 @@ if [[ -d "$CPANEL_BASE" ]]; then cp "$SOURCE_DIR/cpanel/gniza/lib/GnizaCPanel/UI.pm" "$CPANEL_BASE/gniza/lib/GnizaCPanel/" cp "$SOURCE_DIR/cpanel/gniza/assets/gniza-whm.css" "$CPANEL_BASE/gniza/assets/" cp "$SOURCE_DIR/cpanel/gniza/assets/gniza-logo.svg" "$CPANEL_BASE/gniza/assets/" + cp "$SOURCE_DIR/cpanel/gniza/install.json" "$CPANEL_BASE/gniza/" # Install AdminBin module (runs as root) mkdir -p "$ADMINBIN_DIR" cp "$SOURCE_DIR/cpanel/admin/Gniza/Restore" "$ADMINBIN_DIR/" cp "$SOURCE_DIR/cpanel/admin/Gniza/Restore.conf" "$ADMINBIN_DIR/" chmod 0700 "$ADMINBIN_DIR/Restore" chmod 0600 "$ADMINBIN_DIR/Restore.conf" - # Register plugin in cPanel interface - /usr/local/cpanel/scripts/install_plugin "$SOURCE_DIR/cpanel/gniza/install.json" 2>/dev/null || true + # Register plugin in cPanel interface (install_plugin expects a tar.gz archive) + PLUGIN_TMPDIR="$(mktemp -d)" + cp "$SOURCE_DIR/cpanel/gniza/install.json" "$PLUGIN_TMPDIR/" + tar -czf "$PLUGIN_TMPDIR/gniza-cpanel.tar.gz" -C "$PLUGIN_TMPDIR" install.json + /usr/local/cpanel/scripts/install_plugin "$PLUGIN_TMPDIR/gniza-cpanel.tar.gz" 2>/dev/null || true + rm -rf "$PLUGIN_TMPDIR" echo "cPanel user plugin installed — users will see gniza Restore in Files section" else echo "cPanel not detected, skipping cPanel user plugin installation."