This repository has been archived on 2026-10-07. You can view files and clone it. You cannot open issues or pull requests or push a commit.
Files
omarchy-pkgs/bin/sync-repo
T
2025-09-12 21:52:49 -04:00

74 lines
2.0 KiB
Bash
Executable File

#!/bin/bash
# Source common functions
BUILD_ROOT=$(realpath "${BASH_SOURCE[0]%/*}/..")
source "$BUILD_ROOT/lib/message-helpers.sh"
# Default remote (production)
DEFAULT_REMOTE="pkgs.omarchy.org:omarchy-pkgs"
REMOTE="$DEFAULT_REMOTE"
SKIP_PROD_CHECK=false
# Parse arguments
if [ $# -eq 0 ]; then
echo "Usage: $0 <directory> [options]"
echo ""
echo "Options:"
echo " --remote <remote> Specify rclone remote (default: $DEFAULT_REMOTE)"
echo " --skip-prod-check Skip production sync confirmation"
echo ""
echo "Examples:"
echo " $0 x86_64 # Sync to production (with confirmation)"
echo " $0 x86_64 --remote test:bucket # Sync to test remote"
echo " $0 x86_64 --skip-prod-check # Sync to production without confirmation"
exit 1
fi
DIRECTORY="$1"
shift
# Parse optional arguments
while [[ $# -gt 0 ]]; do
case $1 in
--remote)
REMOTE="$2"
shift 2
;;
--skip-prod-check)
SKIP_PROD_CHECK=true
shift
;;
*)
print_error "Unknown option: $1"
exit 1
;;
esac
done
# Check if syncing to production and warn user
if [[ "$REMOTE" == "$DEFAULT_REMOTE" ]] && [[ "$SKIP_PROD_CHECK" != true ]]; then
print_warning "You are about to sync to PRODUCTION ($REMOTE)"
echo ""
gum confirm "Are you sure you want to sync to production?" || {
print_info "Sync cancelled"
exit 0
}
fi
print_info "Syncing to: $REMOTE"
# First sync packages (excluding database files to ensure packages are uploaded first)
print_info "Syncing packages..."
rclone sync "$DIRECTORY" "$REMOTE/$(basename $DIRECTORY)" \
--exclude "omarchy.db*" \
--exclude "omarchy.files*" \
--checksum --progress --copy-links --delete-after -v
# Then sync database files last to ensure repository integrity
print_info "Updating repository database..."
rclone copy "$DIRECTORY" "$REMOTE/$(basename $DIRECTORY)/" \
--include "omarchy.*" \
--checksum --progress --copy-links -v
print_success "Sync complete!"