Files
proxmox/scripts/merge-small-scripts.sh
defiQUG fbda1b4beb
Some checks failed
Deploy to Phoenix / deploy (push) Has been cancelled
docs: Ledger Live integration, contract deploy learnings, NEXT_STEPS updates
- ADD_CHAIN138_TO_LEDGER_LIVE: Ledger form done; public code review repo bis-innovations/LedgerLive; init/push commands
- CONTRACT_DEPLOYMENT_RUNBOOK: Chain 138 gas price 1 gwei, 36-addr check, TransactionMirror workaround
- CONTRACT_*: AddressMapper, MirrorManager deployed 2026-02-12; 36-address on-chain check
- NEXT_STEPS_FOR_YOU: Ledger done; steps completable now (no LAN); run-completable-tasks-from-anywhere
- MASTER_INDEX, OPERATOR_OPTIONAL, SMART_CONTRACTS_INVENTORY_SIMPLE: updates
- LEDGER_BLOCKCHAIN_INTEGRATION_COMPLETE: bis-innovations/LedgerLive reference

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-02-12 15:46:57 -08:00

134 lines
3.9 KiB
Bash
Executable File

#!/usr/bin/env bash
# Merge small scripts into utility modules
# Usage: ./scripts/merge-small-scripts.sh [--dry-run]
set -euo pipefail
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
PROJECT_ROOT="$(cd "$SCRIPT_DIR/.." && pwd)"
source "$SCRIPT_DIR/lib/logging.sh" 2>/dev/null || true
DRY_RUN="${1:---dry-run}"
MAX_LINES=50
ARCHIVE_DIR="$PROJECT_ROOT/scripts/archive/small-scripts"
mkdir -p "$ARCHIVE_DIR"
log_header "Merging Small Scripts into Utility Modules"
# Find and categorize small scripts
find_small_scripts() {
find "$PROJECT_ROOT/scripts" -name "*.sh" -type f ! -path "*/archive/*" ! -path "*/lib/*" ! -path "*/utils/*" ! -path "*/node_modules/*" ! -path "*/.git/*" -exec sh -c 'lines=$(wc -l < "$1"); [ "$lines" -lt '"$MAX_LINES"' ] && echo "$1"' _ {} \;
}
# Archive small script
archive_script() {
local script="$1"
local basename_script=$(basename "$script")
if [ "$DRY_RUN" != "--execute" ]; then
log_warn " DRY RUN: Would archive $basename_script"
else
mv "$script" "$ARCHIVE_DIR/$basename_script" 2>/dev/null || true
log_success " Archived: $basename_script"
fi
}
# Process container scripts
process_container_scripts() {
log_info "Processing container-related small scripts..."
local count=0
find_small_scripts | while read -r script; do
local basename_script=$(basename "$script")
if [[ "$basename_script" =~ (container|ct|vmid) ]]; then
log_info " Found container script: $basename_script"
archive_script "$script"
count=$((count + 1))
fi
done
log_success "Container scripts processed: $count"
}
# Process network scripts
process_network_scripts() {
log_info "Processing network-related small scripts..."
local count=0
find_small_scripts | while read -r script; do
local basename_script=$(basename "$script")
if [[ "$basename_script" =~ (network|ip|dns|tunnel) ]]; then
log_info " Found network script: $basename_script"
archive_script "$script"
count=$((count + 1))
fi
done
log_success "Network scripts processed: $count"
}
# Process service scripts
process_service_scripts() {
log_info "Processing service-related small scripts..."
local count=0
find_small_scripts | while read -r script; do
local basename_script=$(basename "$script")
if [[ "$basename_script" =~ (service|systemd|postgres|redis|nginx) ]]; then
log_info " Found service script: $basename_script"
archive_script "$script"
count=$((count + 1))
fi
done
log_success "Service scripts processed: $count"
}
# Process config scripts
process_config_scripts() {
log_info "Processing config-related small scripts..."
local count=0
find_small_scripts | while read -r script; do
local basename_script=$(basename "$script")
if [[ "$basename_script" =~ (config|configure) ]]; then
log_info " Found config script: $basename_script"
archive_script "$script"
count=$((count + 1))
fi
done
log_success "Config scripts processed: $count"
}
# Process Proxmox scripts
process_proxmox_scripts() {
log_info "Processing Proxmox-related small scripts..."
local count=0
find_small_scripts | while read -r script; do
local basename_script=$(basename "$script")
if [[ "$basename_script" =~ (proxmox|pve|qm|pct) ]]; then
log_info " Found Proxmox script: $basename_script"
archive_script "$script"
count=$((count + 1))
fi
done
log_success "Proxmox scripts processed: $count"
}
# Main execution
main() {
process_container_scripts
process_network_scripts
process_service_scripts
process_config_scripts
process_proxmox_scripts
log_success "Small script merging complete!"
}
main "$@"