This directory contains utility scripts for managing and testing the Sorting Office application.
A comprehensive curl-based utility for testing and interacting with the Sorting Office API.
Features:
- Authentication: Login, logout, and session management
- Backup Operations: Create, list, download, and delete database backups
- Resource Management: List aliases, domains, users
- System Operations: Health checks, statistics, configuration access
- Session Persistence: Maintains login sessions across commands
Usage Examples:
# Login with default credentials
./scripts/curl-helpers.sh login
# Login with custom credentials
./scripts/curl-helpers.sh login admin mypassword
# List database backups
./scripts/curl-helpers.sh backup-list
# Create a backup
./scripts/curl-helpers.sh backup-create primary
# Download a backup file
./scripts/curl-helpers.sh backup-download primary_sortingoffice_20250726_182756.sql
# List aliases
./scripts/curl-helpers.sh aliases-list
# Check application health
./scripts/curl-helpers.sh healthEnvironment Variables:
SORTINGOFFICE_HOST- Default host (default: localhost:3000)SORTINGOFFICE_USER- Default username (default: admin)SORTINGOFFICE_PASSWORD- Default password (default: admin123)
Generate bcrypt password hashes for admin user configuration.
Usage:
./scripts/generate_password_hash.sh "your_password"Features:
- Supports Python 3 and Node.js
- Generates bcrypt hashes with cost factor 12
- Provides fallback instructions if dependencies missing
List all configured databases from the config.toml file.
Usage:
./scripts/list-databases.shOutput:
ID Label URL
primary Main Server mysql://sortingoffice:***@localhost:3306/sortingoffice
backup1 Backup Server mysql://backupuser:***@backuphost:3306/backupdb
Set up environment variables for development and testing.
Usage:
source ./scripts/set-env.shFeatures:
- Configures database connections
- Sets up test environment variables
- Manages Docker Compose configurations
A simple wrapper for common refactoring tasks in the Rust codebase.
Usage:
# Move functions between modules
./scripts/refactor.sh move utils database_helpers get_current_db_pool
# Rename a function
./scripts/refactor.sh rename function old_name new_name
# Fix compilation errors
./scripts/refactor.sh fix
# Clean up unused imports
./scripts/refactor.sh cleanup
# Get help
./scripts/refactor.sh helpFeatures:
- Move functions between modules
- Rename functions and modules
- Fix common compilation errors
- Clean up unused imports
- Safe function reference handling
The underlying engine that handles all refactoring operations.
Operations:
move-functions- Move functions between modulesmove-module- Move entire modulesrename-function- Rename functionsrename-module- Rename modulesupdate-imports- Update import pathsfix-compilation- Fix common compilation errorscleanup-imports- Remove unused imports
Usage:
./scripts/refactor_generic.sh move-functions utils database_helpers get_current_db_pool
./scripts/refactor_generic.sh rename-function old_name new_name
./scripts/refactor_generic.sh fix-compilationA detailed health check script with verbose output and configuration options.
Usage:
# Basic health check
./scripts/health-check.sh
# Verbose output with timing
./scripts/health-check.sh -v
# Custom host and timeout
./scripts/health-check.sh -h 192.168.1.100:3000 -t 5Features:
- Colored output with status indicators
- Configurable timeout and host
- Verbose mode for debugging
- Environment variable support
- Detailed timing information
A minimal one-liner health check for quick status checks.
Usage:
# Check localhost:3000
./scripts/health-check-simple.sh
# Check remote host
./scripts/health-check-simple.sh 192.168.1.100:3000Features:
- Minimal output with emoji indicators
- Fast execution (5s timeout)
- Simple command line interface
- Exit codes for automation
Consolidate multiple database migrations into a single migration file.
Usage:
./scripts/consolidate-migrations.shFeatures:
- Combines multiple migration files
- Maintains migration order
- Creates backup of original migrations
Find translation keys that are defined but not used in the codebase.
Usage:
./scripts/find_orphaned_ftl_keys.shFeatures:
- Scans all .ftl files for defined keys
- Searches codebase for key usage
- Reports orphaned/unused keys
Remove orphaned translation keys from .ftl files.
Usage:
./scripts/bulk_remove_ftl_keys.shFeatures:
- Removes unused translation keys
- Creates backup before removal
- Supports multiple language files
Remove duplicate translation keys from all language files.
Usage:
./scripts/remove_duplicate_ftl_keys.shFeatures:
- Removes duplicate keys while preserving first occurrence
- Maintains original key order
- Creates backup before removal
- Supports all language files (en-US, de-DE, fr-FR, es-ES, nb-NO)
# Start with login
./scripts/curl-helpers.sh login
# Test various endpoints
./scripts/curl-helpers.sh backup-list
./scripts/curl-helpers.sh aliases-list
./scripts/curl-helpers.sh domains-list
# Create and manage backups
./scripts/curl-helpers.sh backup-create primary
./scripts/curl-helpers.sh backup-download filename.sql
./scripts/curl-helpers.sh backup-delete filename.sql
# Check system status
./scripts/curl-helpers.sh health
./scripts/curl-helpers.sh stats# Set up environment
source ./scripts/set-env.sh
# List configured databases
./scripts/list-databases.sh
# Generate password hash for new admin
./scripts/generate_password_hash.sh "new_password"
# Test API functionality
./scripts/curl-helpers.sh login
./scripts/curl-helpers.sh backup-list# Find unused translation keys
./scripts/find_orphaned_ftl_keys.sh
# Clean up translation files
./scripts/bulk_remove_ftl_keys.sh
# Consolidate migrations
./scripts/consolidate-migrations.sh- Bash: All scripts require bash shell
- curl: For API testing (curl-helpers.sh)
- jq: For JSON parsing (optional, for pretty output)
- Python 3 or Node.js: For password hash generation
- Docker Compose: For environment setup (set-env.sh)
- Cookie files are stored in
/tmp/and should be cleaned up automatically - Password hashes should be generated on secure systems
- Environment variables may contain sensitive information
- Scripts should be run with appropriate permissions
- Permission Denied: Make scripts executable with
chmod +x scripts/*.sh - Login Fails: Check application is running and credentials are correct
- JSON Parsing Errors: Install
jqfor better output formatting - Missing Dependencies: Install required tools (Python, Node.js, etc.)
Enable debug output by setting environment variables:
export RUST_LOG=debug
export SORTINGOFFICE_DEBUG=1When adding new scripts:
- Follow the existing naming convention
- Include proper error handling
- Add usage examples
- Update this README
- Make scripts executable
- Test with different environments