Files
gniza4linux/lib/ui_verify.sh
shuki 928d5af54c Initial implementation of gniza4linux backup tool
Complete Linux backup manager with Whiptail TUI and CLI interface.
Adapted from gniza4cp (cPanel backup tool) with target/profile-based
system replacing cPanel-specific features.

- 14 core engine modules (backup, restore, targets, remotes, transfer, etc.)
- 11 Whiptail TUI screens (full CRUD for targets/remotes/schedules)
- CLI entrypoint with subcommands for scripting/cron
- Support for SSH, local, S3, and Google Drive remotes
- rsync --link-dest incremental snapshots
- Root and user mode (XDG paths)
- 70 passing tests
- Config templates, installer, uninstaller

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-05 21:15:29 +02:00

86 lines
2.0 KiB
Bash

#!/usr/bin/env bash
# gniza4linux/lib/ui_verify.sh — Backup verification TUI
[[ -n "${_GNIZA4LINUX_UI_VERIFY_LOADED:-}" ]] && return 0
_GNIZA4LINUX_UI_VERIFY_LOADED=1
ui_verify_menu() {
while true; do
local choice
choice=$(ui_menu "Verify" \
"SINGLE" "Verify single target" \
"ALL" "Verify all targets" \
"BACK" "Return to main menu") || return 0
case "$choice" in
SINGLE) _ui_verify_single ;;
ALL) _ui_verify_all ;;
BACK) return 0 ;;
esac
done
}
_ui_verify_single() {
if ! has_targets; then
ui_msgbox "No targets configured."
return 0
fi
local -a items=()
local targets
targets=$(list_targets)
while IFS= read -r t; do
items+=("$t" "Target: $t")
done <<< "$targets"
local target
target=$(ui_menu "Select Target to Verify" "${items[@]}") || return 0
local tmpfile
tmpfile=$(mktemp /tmp/gniza-verify-XXXXXX.log)
(
echo "10"
if gniza --cli verify --target="$target" > "$tmpfile" 2>&1; then
echo "100"
else
echo "100"
fi
) | ui_gauge "Verifying target: $target"
if [[ -s "$tmpfile" ]]; then
ui_textbox "$tmpfile"
else
ui_msgbox "Verification of '$target' completed successfully."
fi
rm -f "$tmpfile"
}
_ui_verify_all() {
if ! has_targets; then
ui_msgbox "No targets configured."
return 0
fi
local targets
targets=$(list_targets)
local count=0 total=0
total=$(echo "$targets" | wc -l)
local output=""
while IFS= read -r t; do
((count++))
local pct=$(( count * 100 / total ))
echo "$pct"
local result
if result=$(gniza --cli verify --target="$t" 2>&1); then
output+="$t: OK\n"
else
output+="$t: FAILED\n$result\n"
fi
done <<< "$targets" | ui_gauge "Verifying all targets..."
ui_msgbox "Verification Results:\n\n$output"
}