# AutoNAS - Change Log

## [v3.0.1] - 2026-03-02

### 🔧 CLI Simplification

#### Removed Redundant Disk Commands
- **Removed** `autonas mount` and `autonas unmount/umount` from user-facing CLI
- **Standardized disk operations** on `autonas attach` and `autonas detach`
- **Updated help output and documentation** to reflect the simplified command set

#### Why This Change
- Reduced command redundancy and ambiguity between attach/detach vs mount/unmount
- Clearer operational model for both manual and automated workflows

## [v3.0.0] - 2025-08-15 🚀

### 🎉 **CLEAN USER INTERFACE & SCRIPT ORGANIZATION**

#### 🔧 Complete Script Architecture Refactoring
- **Single User Command**: Only `autonas` visible in shell autocomplete
- **Internal Script Organization**: All utility scripts moved to `/usr/local/lib/autonas/`
- **47% Code Reduction**: ~2,300 lines eliminated through deduplication
- **Single Source of Truth**: All shared functions in `autonas-core.sh` library

#### 📁 New Script Architecture
```
/usr/local/bin/
├── autonas -> autonas.sh          # Only user-visible command
├── autonas.sh                     # Main CLI interface (1,208 lines)  
└── autonas-core.sh                # Core business logic library (1,044 lines)

/usr/local/lib/autonas/            # Internal scripts (hidden from autocomplete)
├── autonas-boot-scan.sh           # Boot scanner
├── autonas-disk-handler.sh        # Disk event handler
├── autonas-media-importer.sh      # Media importer
├── autonas-network-handler.sh     # Network handler
├── autonas-udev-wrapper.sh        # Udev wrapper
└── autonas-uninstall.sh           # System uninstaller
```

#### 🎯 Clean User Experience
- **Professional Interface**: Only `autonas` command appears in tab completion
- **Unified Functionality**: All operations through single command interface
- **Organized Backend**: All system utilities properly categorized and hidden
- **Zero Code Duplication**: Complete elimination of duplicate functions

#### 🔄 Revolutionary Background Import Architecture (Preserved)
- **Service-Based Import System**: Complete separation of mount/import through systemd services
- **Unlimited Import Duration**: No more systemd timeout constraints (tested with 300+ files)
- **Production Scalability**: Architecture tested and validated in production environment

#### �️ **Complete System Integration Updates**
- **All Service Files**: Updated systemd services with new script paths
- **All udev Rules**: Updated with `/usr/local/lib/autonas/` paths  
- **All Configuration References**: Updated throughout entire system
- **Deploy Script**: Enhanced with directory creation and proper installation
- **Install/Uninstall**: Complete support for new architecture

#### 🔧 **Technical Architecture Improvements**
- **Core Library Pattern**: `autonas-core.sh` with all shared business logic
- **Clean Separation**: User interface vs. system utilities properly organized
- **Professional Deployment**: Only essential commands visible to users
- **Backward Compatibility**: Seamless upgrade path from previous versions

#### 📊 **Production Test Results** (Background Import)
- **✅ 302 files imported** successfully in single session (36 minutes)
- **✅ 100% success rate** with zero errors
- **✅ Perfect UTC conversion** for all QuickTime/EXIF timestamps
- **✅ Complete workflow** mount → background import → auto unmount
- **✅ Robust error handling** and disconnect detection

#### 🚨 **Architecture Changes** 
- **Script Locations**: Internal scripts moved from `/usr/local/bin/` to `/usr/local/lib/autonas/`
- **User Interface**: Single `autonas` command replaces multiple visible scripts
- **Configuration Updates**: All references updated throughout system
- **Clean Autocomplete**: Professional user experience with hidden utilities

---

## [v2.5.0] - 2024-08-12

### 🚀 Dual Configuration System

#### Enhanced Mounting Options
- **Dual Configuration Support**: Complete system supporting both NFS shares and simple local mounts
  - **NFS share complet**: Cu IP și export pentru acces de rețea
  - **Montare locală simplă**: Doar mount point, fără IP și NFS (NOUĂ!)
- **LOCAL Configuration Format**: New `UUID:NAME:LOCAL:LOCAL:MOUNT_POINT:LOCAL` format
- **Interactive Configuration Selection**: Enhanced `autonas-config.sh add` with mount type selection
- **Mixed Environment Support**: Both NFS and LOCAL configurations can coexist seamlessly

#### Core System Improvements
- **Extended UUID Support**: Support for both standard UUIDs and FAT32 short UUIDs (e.g., `8765-4321`)
- **Enhanced Manager Integration**: Complete autonas-manager.sh support for LOCAL configurations
- **Clean Logging**: LOCAL configurations show "Skipping X for local mount configuration" instead of errors
- **Synchronized Disk Display**: Fixed desynchronization between disk display and mapping logic

#### Bug Fixes Resolved
- **Disk Selection Mapping Bug**: Fixed issue where selecting disk 6 would map to wrong UUID
- **LOG Spam Resolution**: Eliminated infinite "Waiting for interface LOCAL" loops
- **UUID Regex Enhancement**: Updated regex pattern to handle FAT32 short UUIDs properly
- **Manager Function Updates**: All network-related functions now properly detect and skip LOCAL configurations

#### Technical Implementation
```bash
# NFS Configuration (existing)
UUID:NAME:IP:INTERFACE:MOUNT_POINT:NFS_OPTIONS

# LOCAL Configuration (new)
UUID:NAME:LOCAL:LOCAL:MOUNT_POINT:LOCAL
```

#### Manager Function Enhancements
- **`activate_ip()`**: Skips IP activation for LOCAL configurations
- **`deactivate_ip()`**: Skips IP deactivation for LOCAL configurations  
- **`add_nfs_export()`**: Skips NFS export for LOCAL configurations
- **`remove_nfs_export()`**: Skips NFS export removal for LOCAL configurations

#### Use Cases for LOCAL Configurations
- **Simple local storage**: Diskuri pentru backup-uri locale fără acces de rețea
- **Scratch space**: Space temporar pentru procesare locală de date  
- **Development storage**: Storage local pentru cache-uri și fișiere temporare
- **Archive storage**: Archive locale care nu necesită export NFS
- **Mixed environments**: Combinație de storage local și shares de rețea

#### Configuration Examples
```properties
# NFS Shares (network access)
920fe1b7-4091-4d6a-bab8-2f48d8d704bc:shared-docs:192.168.1.100:eth0:/mnt/autonas/shared-docs:*(rw,all_squash,insecure,async,no_subtree_check,anonuid=0,anongid=0)

# LOCAL Mounts (local only)  
8765-4321:local-backup:LOCAL:LOCAL:/mnt/autonas/local-backup:LOCAL
abcd-1234:scratch-space:LOCAL:LOCAL:/mnt/autonas/scratch-space:LOCAL
```

#### Backward Compatibility
- **Full compatibility**: Existing NFS configurations continue to work unchanged
- **No migration required**: Current setups work without any changes
- **Enhanced functionality**: New LOCAL options available alongside existing NFS features

## [v2.4.0] - 2025-08-11

### 🌐 Interface Stability Management System

#### Problema Rezolvată
- **USB/Thunderbolt interfaces instabile**: Interfețele USB și Thunderbolt dispar și revin periodic
- **IP-uri pierdute**: IP-urile configurate pentru diskuri nu se readaugă automat când interfața revine
- **NFS exports indisponibile**: Export-urile devin temporar inaccesibile din cauza IP-urilor lipsă

#### Interface Management Tools
- **autonas-interface-handler.sh**: Handler principal pentru evenimente udev de interfețe
- **Event-driven only**: Arhitectură complet bazată pe evenimente (fără daemon/servicii permanente)
- **Emergency diagnostics**: Tool-uri de diagnostic pentru depanare în cazuri extreme

#### Interface Handler System  
- **autonas-interface-handler.sh**: Handler principal pentru evenimente udev de interfețe
- **Event-driven architecture**: Răspuns instant la schimbările interfețelor (nu polling)
- **Multiple event types**: Detectează add/remove/change/carrier/operstate events
- **Focus USB/Thunderbolt**: Tratament special pentru interfețele instabile
- **Smart restoration**: Verifică starea interfețelor înainte de configurare IP
- **Background processing**: Execuție asincronă pentru a evita timeout-urile udev
- **Retry mechanism**: Logică de retry pentru configurarea IP-urilor pe interfețe instabile

#### Advanced IP Management
- **Interface existence checking**: Verificare inteligentă dacă interfața există înainte de configurare
- **IP conflict resolution**: Detectează și evită conflictele de IP-uri
- **Retry mechanism**: Logic de retry pentru configurarea IP-urilor pe interfețe instabile
- **Shared IP management**: Gestionarea corectă a IP-urilor folosite de multiple diskuri
- **Wait for interface**: Așteaptă ca interfețele USB/Thunderbolt să apară (până la 30 secunde)

#### Comprehensive Debug Tools
- **autonas-interface-debug.sh**: Tool complet de diagnostic pentru probleme interfețe
- **Status analysis**: Analiză detaliată a statusului interfețelor și IP-urilor configurate
- **Real-time monitoring**: Monitorizare în timp real a schimbărilor de interfețe
- **Configuration validation**: Verificare configurații AutoNAS vs. starea actuală
- **Troubleshooting guide**: Sugestii automate pentru rezolvarea problemelor
- **Color-coded output**: Interface prietenoasă cu coding color pentru status

#### Enhanced udev Rules
- **98-autonas-interfaces.rules**: Reguli udev comprehensive pentru interfețe de rețea
- **Event-driven primary mechanism**: Detectare principală prin evenimente, nu polling
- **Multiple trigger types**: add/remove/change/operstate/carrier events
- **USB/Thunderbolt specific**: Tratament special pentru interfețele instabile
- **State change monitoring**: Monitorizează schimbările de stare operațională și carrier
- **Instant response**: Răspuns în 2-3 secunde la schimbările interfețelor

#### Management Commands
```bash
# Debug interfețe și IP-uri
autonas-interface-debug.sh check

# Monitorizare timp real schimbări
autonas-interface-debug.sh realtime

# Test stabilitate interfețe USB/Thunderbolt
autonas-test-interface-stability.sh
```

#### Installation & Service Integration
- **Automatic installation**: Toate componentele sunt instalate automat de `install.sh`
- **Service auto-start**: Serviciul de monitorizare pornește automat la instalare
- **Initial restore**: Restaurare automată a IP-urilor la finalul instalării
- **Proper dependencies**: Dependențe corecte cu serviciile de rețea și NFS

### 🔧 Îmbunătățiri Core Manager

#### Smart IP Configuration
- **Interface existence validation**: Verifică dacă interfața există înainte de configurare
- **Wait for interface**: Logică de așteptare pentru interfețele care apar cu întârziere
- **Retry mechanism**: Până la 3 încercări pentru configurarea IP-urilor
- **Conflict detection**: Evită adăugarea IP-urilor deja configurate

#### Enhanced Error Handling
- **Detailed error reporting**: Mesaje de eroare mai descriptive
- **Recovery suggestions**: Sugestii pentru rezolvarea problemelor
- **Graceful degradation**: Continuă operațiunea chiar dacă unele componente eșuează

### 📚 Documentație Extinsă

#### New Troubleshooting Section
- **USB/Thunderbolt specific issues**: Secțiune dedicată pentru problemele interfețelor instabile
- **Debug commands**: Liste complete de comenzi pentru diagnosticare
- **Step-by-step solutions**: Soluții pas cu pas pentru probleme comune
- **Power management tips**: Sugestii pentru managementul power al USB

#### Updated Architecture Documentation
- **Interface monitoring flow**: Documentare completă a fluxului de monitorizare
- **Service interactions**: Interacțiunile între servicii și dependențele lor
- **Debug methodology**: Metodologie pentru diagnosticarea problemelor

### 🎯 Use Cases Noi

#### Unstable Interface Environments
- **USB docking stations**: Stații de andocare USB care se deconectează periodic
- **Thunderbolt hubs**: Hub-uri Thunderbolt cu conectivitate intermitentă  
- **USB-C multiport adapters**: Adaptoare multiport cu stabilitate variabilă
- **Laptop docking scenarios**: Scenarii de laptop care se conectează/deconectează des

#### Enterprise Environment
- **Multiple identical setups**: Deploy pe multiple servere cu aceleași probleme interfețe
- **Centralized monitoring**: Monitorizare centralizată a stabilității interfețelor
- **Automated recovery**: Recuperare automată fără intervenție manuală

## [v2.3.0] - 2025-07-22

### 🚀 Boot Recovery System

#### Boot Scan Service
- **Automatic boot detection**: New `autonas-boot-scan.service` detects and mounts configured disks at system boot
- **Pre-connected disk support**: Handles disks that were already attached before system start
- **Intelligent scanning**: Checks all configured UUIDs from `/etc/pve/autonas/disks.conf`
- **Mount status detection**: Identifies disks already mounted elsewhere and handles appropriately

#### Boot Scanner Script
- **autonas-boot-scan.sh**: Comprehensive boot-time disk scanner
- **UUID existence verification**: Checks if configured disk UUIDs are present as devices
- **Mount state analysis**: Determines if disks are unmounted, mounted elsewhere, or correctly mounted
- **Automatic attachment**: Uses `autonas-manager.sh` to properly mount and configure detected disks
- **Detailed reporting**: Statistics on total, processed, already-mounted, and newly-attached disks

#### System Integration
- **Service dependencies**: Proper ordering after filesystem, udev-settle, network, and NFS services
- **Installation automation**: Added to install/uninstall scripts with proper enable/disable
- **Documentation updates**: Complete documentation of new boot recovery architecture
- **RemainAfterExit=yes**: Service stays active to indicate successful boot scan completion

#### Main Service Integration
- **autonas.service**: New main AutoNAS service for centralized system management
- **Enhanced reload functionality**: Comprehensive reload of udev rules, NFS exports, and systemd daemon
- **Service orchestration**: Proper dependencies and integration with boot-scan service
- **Centralized control**: Single point of management for the entire AutoNAS system

#### Orphan File Prevention System
- **Pre-installation cleanup**: Automatic cleanup of previous installations before reinstalling
- **Uninstaller integration**: Install script now installs uninstaller for future clean upgrades
- **Deploy script uninstall**: New `./deploy.sh uninstall` command for remote uninstallation
- **Force mode uninstaller**: Silent cleanup mode with `--force` flag for automated use
- **Evolution protection**: Prevents orphan files during project evolution and upgrades

#### Problem Resolution
- **Solves reboot issue**: Addresses problem where pre-connected disks weren't exported after system restart
- **udev gap coverage**: Handles scenario where udev doesn't re-trigger events for existing devices
- **NFS export recovery**: Ensures all configured disks are properly exported after boot
- **Robust boot process**: System now handles both hot-plug and pre-connected disk scenarios

## [v2.2.0] - 2025-07-22

### 🚀 Remote Deployment System

#### Deploy Script Added
- **Remote deployment support**: New `deploy.sh` script for automated installation on multiple targets
- **Multi-target management**: Support for servers 192.168.2.91, 192.168.2.92, 192.168.2.93
- **SSH-based automation**: Uses SSH keys for seamless remote operations
- **Intelligent connectivity checks**: Host availability verification before operations

#### Enhanced Reliability
- **Host status verification**: Ping test before attempting SSH connections
- **Graceful failure handling**: Skip unavailable hosts with clear warnings
- **Connection testing**: SSH connectivity validation before deployment
- **Error reporting**: Clear status messages for each operation step

#### Deployment Features
- **Complete installation**: Automated install, configure, and start services
- **Service management**: Start, restart, stop remote AutoNAS services
- **Status monitoring**: Remote status checking and health validation
- **Cleanup operations**: Temporary file cleanup on target systems

#### Command Operations
- **install**: Complete AutoNAS installation and configuration
- **start/restart/stop**: Service lifecycle management
- **status**: Health check and configuration validation
- **cleanup**: Temporary file removal
- **help**: Comprehensive usage documentation

#### Documentation Consolidation
- **Merged TECHNICAL.md into README.md**: Complete technical documentation in single file
- **Enhanced architecture section**: Detailed component descriptions and workflows
- **Comprehensive troubleshooting**: Technical debugging and extensibility guides
- **Unified documentation**: Single source of truth for all AutoNAS information

## [v2.1.0] - 2024-12-02

### 🚀 udev Context Improvements

#### Simplified Execution Strategy
- **Direct systemd execution**: Removed unreliable direct execution in udev context
- **Guaranteed privilege handling**: All mount operations now run through systemd service
- **Improved reliability**: Eliminates "permission denied" issues in restricted udev context
- **Consistent behavior**: Same execution path for all environments

#### Enhanced Logging
- **Streamlined logging**: Clear indication of systemd service usage
- **Better debugging**: Simplified troubleshooting without fallback complexity

## [v2.0.0] - 2024-12-02

### 🚀 Major Features Added

#### Intelligent Device Detection
- **Multiple device type support**: USB storage, SCSI removable, USB-to-SATA bridges
- **UUID-based identification**: Precise device matching via filesystem UUID
- **Smart udev rules**: Comprehensive detection for various hardware configurations

#### Enhanced User Experience
- **Interactive configuration helper**: `autonas-config.sh` with guided setup
- **UUID parameter support**: Pre-populate UUIDs in `add` and `test` commands
- **Automatic mounting post-configuration**: Immediate disk availability after setup
- **Standardized NFS configuration**: Optimized settings applied automatically

#### Advanced System Integration
- **udev wrapper**: Prevents timeout issues with asynchronous execution
- **Intelligent IP management**: Shared IP handling across multiple disks
- **Comprehensive logging**: Structured logging with proper syslog tags
- **Error handling and recovery**: Robust failure handling with detailed reporting

### 🛡️ Data Protection & Safety

#### Installation Safety
- **Configuration preservation**: Existing `disks.conf` files are never overwritten
- **User data detection**: Automatically detects and preserves user configurations
- **Template system**: New installs get templates, upgrades preserve data

#### Uninstallation Safety
- **Data-preserving uninstall**: User configurations and mount points preserved
- **Selective cleanup**: Only removes AutoNAS components, keeps user data
- **Manual cleanup guidance**: Clear instructions for complete removal if desired

### 🔧 Configuration Management

#### Simplified Configuration Process
```bash
# Old method (manual editing)
sudo nano /etc/pve/autonas/disks.conf

# New method (guided interactive)
sudo autonas-config.sh add <UUID>
```

#### Smart Validation
- **UUID format validation**: Proper 8-4-4-4-12 hex format checking
- **Disk name validation**: Character restrictions and reserved name checking
- **Network interface validation**: Real-time interface existence checking
- **IP address validation**: Format and availability checking

#### Enhanced Commands
- **`autonas-config.sh add [UUID]`**: Interactive configuration with optional UUID
- **`autonas-config.sh test [UUID]`**: Configuration testing with optional UUID
- **`autonas-config.sh list`**: Formatted display of all configurations
- **`autonas-config.sh remove`**: Interactive configuration removal

### 🌐 Network & NFS Improvements

#### Standardized NFS Configuration
```
*(rw,all_squash,insecure,async,no_subtree_check,anonuid=0,anongid=0)
```
- **Optimized for performance**: Async writes with no_subtree_check
- **Security balanced**: all_squash with root mapping for compatibility
- **Wide compatibility**: insecure flag for broader client support

#### Intelligent IP Management
- **Shared IP support**: Multiple disks can use the same IP address
- **Smart cleanup**: IPs only removed when no longer in use
- **Automatic configuration**: IP setup integrated with disk mounting

### 🔍 Monitoring & Debugging

#### Enhanced Logging System
- **Structured logging**: Separate tags for different components
  - `autonas`: Main manager operations
  - `autonas-wrapper`: udev wrapper operations
  - `autonas-config`: Configuration helper operations
- **Informative messages**: Clear indication of actions and results
- **Debugging support**: Detailed error reporting with context

#### Monitoring Commands
```bash
# Live monitoring all AutoNAS components
journalctl -t autonas -t autonas-wrapper -t autonas-config -f

# Component-specific monitoring
journalctl -t autonas --since "10 minutes ago"

# udev debugging
udevadm monitor --subsystem-match=block
```

### 📁 Project Structure Improvements

#### Organized Component Structure
```
autoNAS/
├── README.md                   # User documentation
├── TECHNICAL.md               # Technical documentation  
├── CHANGELOG.md               # This file
├── config/
│   ├── disks.conf              # Configuration template
│   ├── 99-autonas-disk.rules   # udev detection rules
│   └── autonas-attach@.service # systemd fallback service
└── scripts/
    ├── autonas-manager.sh      # Main disk management
    ├── autonas-udev-wrapper.sh # udev timeout prevention
    ├── autonas-config.sh       # Interactive configuration
    ├── install.sh              # Safe installation
    └── uninstall.sh            # Safe uninstallation
```

#### Documentation Overhaul
- **Complete README**: Comprehensive user guide with examples
- **Technical documentation**: Developer-focused implementation details
- **Inline comments**: Extensive code documentation for maintainability

### ⚡ Performance Optimizations

#### udev Integration
- **Timeout prevention**: Asynchronous wrapper prevents udev blocking
- **Background processing**: Non-blocking device handling
- **Immediate feedback**: Quick udev response with background operations

#### File System Operations
- **UUID-based mounting**: Consistent device identification
- **Optimized mount points**: Organized `/mnt/autonas/` structure
- **Efficient configuration parsing**: Fast config file processing

### 🔒 Security Enhancements

#### File Permissions
- **Proper ownership**: All scripts owned by root:root
- **Secure permissions**: 755 for scripts, 644 for configs
- **Protected configuration**: Config files not world-writable

#### NFS Security
- **User mapping**: all_squash prevents privilege escalation
- **Anonymous mapping**: anonuid=0,anongid=0 for consistent access
- **Performance vs security**: Balanced configuration for practical use

### 🧪 Testing & Validation

#### Configuration Testing
- **Real-time validation**: Test configurations against current system state
- **Device detection**: Check if UUIDs correspond to actual devices
- **Network validation**: Verify interface existence and IP availability

#### Integration Testing
- **Manual testing support**: Commands for manual mount/unmount testing
- **Status verification**: Built-in checks for successful operations
- **Rollback capability**: Automatic cleanup on operation failures

### 🚨 Error Handling Improvements

#### Graceful Failure Handling
- **Descriptive error messages**: Clear indication of what went wrong
- **Suggested remedies**: Specific commands to fix common issues
- **Logging preservation**: All errors logged for later analysis

#### Recovery Mechanisms
- **Automatic rollback**: Failed operations clean up after themselves
- **State consistency**: System left in known good state after failures
- **Manual recovery**: Clear instructions for manual intervention when needed

### 📖 Breaking Changes

#### Configuration Format
- **No breaking changes**: Existing configurations continue to work
- **Enhanced format**: New configurations use optimized NFS settings
- **Backwards compatibility**: Old configurations preserved during upgrades

#### Command Interface
- **Extended syntax**: Commands now accept optional parameters
- **Backwards compatibility**: Old syntax continues to work
- **Enhanced features**: New parameters provide additional functionality

### 🔄 Migration Guide

#### From Manual Configuration
If you've been manually editing configuration files:
1. **Backup existing configs**: `sudo cp /etc/pve/autonas/disks.conf ~/backup.conf`
2. **Run installer**: `sudo bash scripts/install.sh` (preserves existing configs)
3. **Use new tools**: `autonas-config.sh list` to see current configurations

#### From Previous AutoNAS Version
1. **Safe upgrade**: `sudo bash scripts/install.sh` automatically preserves data
2. **New features**: Start using `autonas-config.sh add <UUID>` for new disks
3. **Enhanced monitoring**: Use new logging commands for better visibility

### 🎯 Future Roadmap

#### Planned Features
- **Web interface**: GUI for configuration management
- **Notification system**: Email/webhook notifications for disk events
- **Health monitoring**: SMART data integration and disk health reporting
- **Cloud integration**: Automatic cloud backup triggers

#### Performance Improvements
- **Parallel processing**: Concurrent handling of multiple disk operations
- **Caching**: Configuration caching for faster operations
- **Optimization**: Further NFS and mount option tuning

#### Security Enhancements
- **TLS support**: Encrypted NFS where supported
- **Access control**: Per-disk user/group restrictions
- **Audit logging**: Enhanced security logging for compliance

---

### 📝 Notes

- **Semantic versioning**: AutoNAS follows semver for version numbering
- **Stability focus**: All changes prioritize data safety and system stability
- **Community feedback**: Features developed based on user needs and feedback

For detailed technical information, see [TECHNICAL.md](TECHNICAL.md).
For user documentation, see [README.md](README.md).
