mirror of
https://github.com/CyberMind-FR/secubox-deb.git
synced 2026-07-28 21:17:36 +00:00
Task 14: Arch Profiles - Add profiles/arch/arm64.yaml and profiles/arch/amd64.yaml - Add ResolveWithArch() to merger for base → arch → tier chain - Add tests for arch profile resolution Task 15: Package secubox.yaml for All Packages - Add scripts/generate-secubox-yaml.py generator script - Generate 131 debian/secubox.yaml files with: - Category detection (security, network, system, etc.) - Tier assignment (all, lite, standard, pro) - API socket and UI path detection Task 16: APT Repository Setup - Add apt/conf/ reprepro configuration (multi-arch arm64/amd64) - Add apt/hooks/lintian-check pre-publish validation - Add scripts/apt-publish.sh and scripts/apt-sync.sh - Add apt/README.md documentation Task 17: CI Integration - Add .github/workflows/build-secubox-cli.yml - Build for linux-amd64 and linux-arm64 - Version injection via ldflags - GitHub releases on tag push Code Quality Fixes (Tasks 10-13): - Add atomic writes for OTA boot control files (0600 perms) - Fix NVME device extraction (nvme0n1p2 → nvme0n1) - Add scanner.Err() checks in hardware detection - Fix URL injection validation in fetch command - Add proper cleanup on checksum failures Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
154 lines
3.3 KiB
Bash
Executable File
154 lines
3.3 KiB
Bash
Executable File
#!/bin/bash
|
|
# scripts/apt-sync.sh
|
|
# Sync local APT repository to apt.secubox.in
|
|
# SecuBox-DEB - CyberMind
|
|
|
|
set -euo pipefail
|
|
|
|
readonly SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
|
readonly REPO_ROOT="$(dirname "$SCRIPT_DIR")"
|
|
readonly APT_LOCAL="/srv/apt"
|
|
readonly APT_REMOTE="apt.secubox.in:/srv/apt"
|
|
readonly LOG_FILE="/var/log/secubox/apt-sync.log"
|
|
|
|
# Colors for output
|
|
RED='\033[0;31m'
|
|
GREEN='\033[0;32m'
|
|
YELLOW='\033[1;33m'
|
|
NC='\033[0m' # No Color
|
|
|
|
log() {
|
|
local level="$1"
|
|
shift
|
|
local msg="$*"
|
|
local timestamp=$(date '+%Y-%m-%d %H:%M:%S')
|
|
echo -e "${timestamp} [${level}] ${msg}" | tee -a "$LOG_FILE"
|
|
}
|
|
|
|
usage() {
|
|
cat << EOF
|
|
Usage: $(basename "$0") [OPTIONS]
|
|
|
|
Sync local APT repository to apt.secubox.in
|
|
|
|
Options:
|
|
-n, --dry-run Show what would be synced without doing it
|
|
-f, --force Force sync even if no changes detected
|
|
-v, --verbose Verbose output
|
|
-h, --help Show this help message
|
|
|
|
Examples:
|
|
$(basename "$0") # Normal sync
|
|
$(basename "$0") --dry-run # Preview changes
|
|
$(basename "$0") --force # Force full sync
|
|
EOF
|
|
}
|
|
|
|
check_deps() {
|
|
local missing=()
|
|
for cmd in rsync reprepro ssh; do
|
|
if ! command -v "$cmd" &> /dev/null; then
|
|
missing+=("$cmd")
|
|
fi
|
|
done
|
|
|
|
if [ ${#missing[@]} -gt 0 ]; then
|
|
log "ERROR" "Missing dependencies: ${missing[*]}"
|
|
exit 1
|
|
fi
|
|
}
|
|
|
|
check_repo() {
|
|
if [ ! -d "$APT_LOCAL" ]; then
|
|
log "ERROR" "Local repository not found: $APT_LOCAL"
|
|
exit 1
|
|
fi
|
|
|
|
if [ ! -f "$APT_LOCAL/conf/distributions" ]; then
|
|
log "ERROR" "Repository not initialized. Run 'reprepro export' first."
|
|
exit 1
|
|
fi
|
|
}
|
|
|
|
sync_repo() {
|
|
local dry_run="${1:-false}"
|
|
local verbose="${2:-false}"
|
|
|
|
local rsync_opts="-avz --delete"
|
|
if [ "$dry_run" = "true" ]; then
|
|
rsync_opts="$rsync_opts --dry-run"
|
|
fi
|
|
if [ "$verbose" = "true" ]; then
|
|
rsync_opts="$rsync_opts --progress"
|
|
fi
|
|
|
|
log "INFO" "Syncing $APT_LOCAL to $APT_REMOTE..."
|
|
|
|
# Sync dists/ and pool/
|
|
rsync $rsync_opts \
|
|
--include='dists/***' \
|
|
--include='pool/***' \
|
|
--exclude='conf/' \
|
|
--exclude='db/' \
|
|
--exclude='incoming/' \
|
|
--exclude='tmp/' \
|
|
"$APT_LOCAL/" \
|
|
"$APT_REMOTE/"
|
|
|
|
local rc=$?
|
|
if [ $rc -eq 0 ]; then
|
|
log "INFO" "${GREEN}Sync completed successfully${NC}"
|
|
else
|
|
log "ERROR" "${RED}Sync failed with exit code $rc${NC}"
|
|
exit $rc
|
|
fi
|
|
}
|
|
|
|
# Parse arguments
|
|
DRY_RUN=false
|
|
FORCE=false
|
|
VERBOSE=false
|
|
|
|
while [[ $# -gt 0 ]]; do
|
|
case $1 in
|
|
-n|--dry-run)
|
|
DRY_RUN=true
|
|
shift
|
|
;;
|
|
-f|--force)
|
|
FORCE=true
|
|
shift
|
|
;;
|
|
-v|--verbose)
|
|
VERBOSE=true
|
|
shift
|
|
;;
|
|
-h|--help)
|
|
usage
|
|
exit 0
|
|
;;
|
|
*)
|
|
echo "Unknown option: $1"
|
|
usage
|
|
exit 1
|
|
;;
|
|
esac
|
|
done
|
|
|
|
# Main
|
|
check_deps
|
|
check_repo
|
|
|
|
# Create log directory if needed
|
|
mkdir -p "$(dirname "$LOG_FILE")"
|
|
|
|
log "INFO" "Starting APT repository sync..."
|
|
|
|
if [ "$DRY_RUN" = "true" ]; then
|
|
log "INFO" "${YELLOW}DRY RUN - no changes will be made${NC}"
|
|
fi
|
|
|
|
sync_repo "$DRY_RUN" "$VERBOSE"
|
|
|
|
log "INFO" "Done."
|