3 Commits

6 changed files with 516 additions and 231 deletions

View File

@ -4,6 +4,33 @@
All notable changes to this project will be documented in this file. All notable changes to this project will be documented in this file.
## [3.2.1] - Bug Fix Release - 2025-07-20
### Fixed (3.2.1)
- 🐛 **CRITICAL: Configuration Loading Regression**: Fixed TOML key mismatch where `allowedextensions` in config didn't map to `allowed_extensions` struct tag, causing server to use hardcoded default extensions instead of config file settings
- 🐛 **XMPP File Upload Failure**: Resolved 400 "File extension .mp4 not allowed" errors for XMPP clients (Conversations, Gajim) - MP4 uploads now work correctly
- 🐛 **Network Resilience Configuration**: Fixed configuration loading issues introduced with network resilience features that prevented proper extension validation
- 🐛 **Mobile Network Switching**: Ensured seamless WLAN ↔ IPv6 5G switching functionality works correctly with proper configuration loading
### Added (3.2.1)
- ✨ **Comprehensive Test Suite**: Consolidated all scattered test scripts into single `/tests/comprehensive_test_suite.sh` with 8 comprehensive test scenarios
- ✨ **Auto-Detection Testing**: Test suite automatically detects local vs remote server endpoints
- ✨ **Enhanced Container Builder**: Extended `builddocker.sh` with universal Docker & Podman support, auto-detection, and dedicated Podman compose file
- ✨ **Project Structure Cleanup**: Removed 10+ redundant files, organized all tests in `/tests/` directory
- ✨ **Universal Installation Documentation**: Enhanced README.md with complete installation framework and testing information
### Changed (3.2.1)
- 🔄 **Root Directory Organization**: Cleaned up project root by consolidating documentation and removing backup files
- 🔄 **Test Accessibility**: Added convenient `./test` and `./quick-test` symlinks for easy testing
- 🔄 **Documentation Consolidation**: Merged installation framework and release notes into main README.md
### Validated (3.2.1)
- ✅ **XMPP Integration**: MP4 uploads working for Conversations and Gajim clients
- ✅ **Network Resilience**: 1-second mobile network detection functional
- ✅ **Large File Support**: 1MB+ file uploads working with proper extensions
- ✅ **Security Testing**: Invalid HMAC and unsupported extensions correctly rejected
- ✅ **Multi-Architecture**: SystemD, Docker, and Podman deployments verified
## [3.2] - Stable Release - 2025-06-13 ## [3.2] - Stable Release - 2025-06-13
### Added (3.2) ### Added (3.2)

View File

@ -1,221 +0,0 @@
# HMAC File Server Universal Installation Framework
## Overview
This document describes the comprehensive installation management system we've created to ensure consistent, user-friendly deployment across all supported scenarios for HMAC File Server 3.2 "Tremora del Terra".
## Deployment Methods Supported
### ✅ 1. SystemD (Native Installation)
- **Status**: Fully functional and validated
- **Script**: `installer.sh`
- **Validation**: Service file, binary, configuration, and service status checks
- **Features**: Network resilience configuration included
- **Configuration**: `/opt/hmac-file-server/config.toml`
### ✅ 2. Docker (Containerized)
- **Status**: Fully functional and validated
- **Script**: `builddocker.sh`
- **Validation**: Docker image build test, configuration validation
- **Features**: Auto-creates missing configurations
- **Configuration**: `dockerenv/config/config.toml`
### ✅ 3. Podman (Rootless Container)
- **Status**: Fully functional and validated
- **Scripts**: `deploy-podman.sh` (full), `deploy-podman-simple.sh` (testing)
- **Validation**: Configuration auto-creation, container management
- **Features**: Rootless deployment support, test mode for validation
- **Configuration**: `/opt/podman/hmac-file-server/config/config.toml`
### ✅ 4. Debian Package
- **Status**: Functional with dependency awareness
- **Script**: `builddebian.sh`
- **Validation**: Package installation status
- **Features**: Handles Go dependency gracefully
- **Configuration**: `/etc/hmac-file-server/config.toml`
### ✅ 5. Multi-Architecture Build
- **Status**: Fully functional
- **Script**: `build-multi-arch.sh`
- **Validation**: Binary generation and verification
- **Features**: Supports AMD64, ARM64, ARM32, Windows, macOS
- **Output**: `./temp/` directory with platform-specific binaries
## Universal Tools Created
### 📋 1. Universal Installation Manager (`install-manager.sh`)
A comprehensive script that provides:
- **Interactive Menu**: User-friendly selection of deployment methods
- **System Detection**: Automatically detects available tools (Docker, Podman, Go, SystemD)
- **Validation Framework**: Tests each installation method thoroughly
- **Automated Testing**: `--test` flag validates all methods
- **Error Handling**: Graceful failure handling and informative messages
**Usage:**
```bash
./install-manager.sh # Interactive menu
./install-manager.sh --test # Test all methods
./install-manager.sh systemd # Direct method selection
```
### 🔧 2. Configuration Consistency Checker (`check-configs.sh`)
Advanced configuration validation tool:
- **Multi-Location Checking**: Validates configs across all deployment methods
- **Auto-Fix Capability**: Corrects common TOML field naming issues
- **Template Generation**: Creates standardized configurations
- **Network Resilience Validation**: Ensures network features are properly configured
**Usage:**
```bash
./check-configs.sh # Check all configurations
./check-configs.sh --fix # Auto-fix common issues
./check-configs.sh --generate # Generate standard templates
```
### 🛠️ 3. Auto-Fix Script (`fix-config.sh`)
Specialized script for common configuration mistakes:
- Fixes field naming issues (storagepath → storage_path)
- Ensures network resilience configuration consistency
- Creates backups before making changes
- Validates fixes after application
## Configuration Templates
### Standard Configuration Structure
All deployment methods now use consistent configuration structure:
```toml
[server]
listen_address = "8080"
storage_path = "/opt/hmac-file-server/data/uploads"
metrics_enabled = true
[security]
secret = "CHANGE-THIS-SECRET-KEY-MINIMUM-32-CHARACTERS"
[uploads]
networkevents = true
chunkeduploadsenabled = true
[network_resilience]
enabled = true
quality_monitoring = true
upload_resilience = true
# Mobile optimizations available but conservative defaults for servers
```
### Template Locations
- **SystemD**: `./templates/config-systemd.toml`
- **Docker**: `./templates/config-docker.toml`
- **Podman**: `./templates/config-podman.toml`
- **Debian**: `./templates/config-debian.toml`
## Network Resilience Integration
### Enhanced Mobile Support
- **Fast Detection**: 1-second network change detection for mobile scenarios
- **Quality Monitoring**: RTT and packet loss tracking per interface
- **Predictive Switching**: Switch before complete network failure
- **Upload Resilience**: Resume uploads across network changes
### Configuration Options
- Conservative server defaults (5-second detection)
- Mobile-optimized thresholds available
- Configurable per deployment scenario
## User Experience Improvements
### 1. Consistent Error Messages
- Helpful validation messages with suggestions
- Common mistake detection and auto-correction
- Clear troubleshooting guidance
### 2. Installation Validation
- Pre-installation system checks
- Post-installation validation
- Service status verification
- Configuration syntax validation
### 3. Comprehensive Documentation
- **README.md**: Enhanced with troubleshooting section
- **WIKI.MD**: Detailed configuration guides
- **NETWORK_RESILIENCE_GUIDE.md**: Mobile optimization details
- **BUILD_GUIDE.md**: Multi-architecture build instructions
## Testing Results
### Latest Test Results (Comprehensive)
```
✅ SystemD: Fully functional and validated
✅ Docker: Image builds successfully, configs auto-created
✅ Podman: Fully functional with both full and simple deployment
✅ Debian: Handles Go dependency gracefully
✅ Multi-Arch: Builds successfully for current platform
```
### Test Coverage
- System capability detection
- Installation script execution
- Configuration validation
- Service status verification
- Binary functionality testing
## Troubleshooting Guide
### Common Issues and Solutions
1. **Configuration Field Names**
- **Problem**: Using old field names (storagepath, listenport)
- **Solution**: Run `./check-configs.sh --fix`
2. **Network Resilience Not Working**
- **Problem**: networkevents=false or missing [network_resilience] section
- **Solution**: Enable networkevents and add network_resilience section
3. **Service Won't Start**
- **Problem**: Configuration validation errors
- **Solution**: Check logs and run configuration validation
4. **Docker Build Issues**
- **Problem**: Missing configuration files
- **Solution**: Auto-creation handled by validation framework
### Support Commands
```bash
# Comprehensive system check
./install-manager.sh --test
# Fix configuration issues
./check-configs.sh --fix
# Generate fresh configurations
./check-configs.sh --generate
# Validate specific deployment
systemctl status hmac-file-server # SystemD
docker ps | grep hmac-file-server # Docker
podman ps | grep hmac-file-server # Podman
```
## Next Steps
### Immediate Actions Needed
1.**Fix Podman Script Path**: ~~Verify location of `deploy-podman.sh`~~ **COMPLETED**
2. **Complete Testing**: Run full validation on clean system
3. **Documentation Update**: Ensure all guides reflect new tools
### Future Enhancements
1. **Web-based Installer**: GUI for non-technical users
2. **Remote Deployment**: Install on remote systems
3. **Configuration Migration**: Upgrade existing installations
4. **Health Monitoring**: Continuous validation of deployments
## Conclusion
We've successfully created a comprehensive, user-friendly installation framework that:
- ✅ Supports all major deployment scenarios
- ✅ Provides consistent configuration across methods
- ✅ Includes robust validation and auto-fixing
- ✅ Offers excellent user experience with clear guidance
- ✅ Integrates network resilience features seamlessly
The framework ensures that users can reliably install HMAC File Server across different environments with confidence, knowing that configuration issues will be detected and corrected automatically.

View File

@ -1,6 +1,6 @@
# HMAC File Server 3.2 - Tremora del Terra # HMAC File Server 3.2 - Tremora del Terra
[![Version](https://img.shields.io/badge/version-3.2-blue.svg)](https://github.com/PlusOne/hmac-file-server) [![Version](https://img.shields.io/badge/version-3.2.1-blue.svg)](https://github.com/PlusOne/hmac-file-server)
[![License](https://img.shields.io/badge/license-MIT-green.svg)](LICENSE) [![License](https://img.shields.io/badge/license-MIT-green.svg)](LICENSE)
[![Go Version](https://img.shields.io/badge/go-1.21+-00ADD8.svg)](https://golang.org/) [![Go Version](https://img.shields.io/badge/go-1.21+-00ADD8.svg)](https://golang.org/)
[![Architecture](https://img.shields.io/badge/arch-AMD64%20%7C%20ARM64%20%7C%20ARM32v7-brightgreen.svg)](https://github.com/PlusOne/hmac-file-server) [![Architecture](https://img.shields.io/badge/arch-AMD64%20%7C%20ARM64%20%7C%20ARM32v7-brightgreen.svg)](https://github.com/PlusOne/hmac-file-server)
@ -104,6 +104,30 @@ HMAC File Server 3.2 includes a comprehensive installation framework that suppor
./test clean # Clean up test files ./test clean # Clean up test files
``` ```
### 🐳 **Enhanced Container Build Script**
```bash
# Universal container builder - auto-detects Docker & Podman
./builddocker.sh
# Use specific container engine
./builddocker.sh docker # Force Docker usage
./builddocker.sh podman # Force Podman usage
# Build only (no services start)
./builddocker.sh docker --build-only
./builddocker.sh podman --build-only
# Show usage help
./builddocker.sh --help
```
**Features:**
-**Auto-Detection**: Automatically finds available container engines (Docker/Podman)
-**Engine Selection**: Interactive menu for multiple engines or force specific engine
-**Compose Support**: Uses appropriate compose files (docker-compose.yml / podman-compose.yml)
-**Podman Optimized**: SELinux labels, rootless support, security optimizations
-**Build & Deploy**: Combined build and optional service startup in one command
**Test Coverage:** **Test Coverage:**
- ✅ HMAC Authentication & File Upload Validation - ✅ HMAC Authentication & File Upload Validation
- ✅ XMPP Integration (MP4 uploads for Conversations/Gajim) - ✅ XMPP Integration (MP4 uploads for Conversations/Gajim)
@ -132,10 +156,10 @@ HMAC File Server 3.2 includes a comprehensive installation framework that suppor
## Release Information ## Release Information
### HMAC File Server 3.2 - Tremora del Terra ### HMAC File Server 3.2.1 - Tremora del Terra
**Release Date**: July 18, 2025 **Release Date**: July 20, 2025
**Codename**: Tremora del Terra (powerful, balanced, ready to shake the ground) **Codename**: Tremora del Terra (powerful, balanced, and ready to shake the ground)
#### Key Improvements #### Key Improvements
- **Configuration Simplification**: 93% reduction in required configuration - **Configuration Simplification**: 93% reduction in required configuration
@ -144,6 +168,12 @@ HMAC File Server 3.2 includes a comprehensive installation framework that suppor
- **Multi-Architecture Support**: Native builds for AMD64, ARM64, ARM32v7 - **Multi-Architecture Support**: Native builds for AMD64, ARM64, ARM32v7
- **Developer Experience**: Minimal config-first approach with comprehensive defaults - **Developer Experience**: Minimal config-first approach with comprehensive defaults
#### Critical Fixes (3.2.1)
- **🔧 XMPP Integration**: Fixed MP4 upload failures for Conversations/Gajim clients
- **🔧 Configuration Loading**: Resolved TOML key mismatch causing extension validation errors
- **🔧 Network Resilience**: Restored seamless WLAN ↔ IPv6 5G mobile switching
- **🔧 Testing Framework**: Comprehensive test suite with 100% pass rate validation
#### Migration Notes #### Migration Notes
- **Backward Compatible**: All existing 3.1.x configs work unchanged - **Backward Compatible**: All existing 3.1.x configs work unchanged
- **Performance Boost**: Automatic optimizations with existing configurations - **Performance Boost**: Automatic optimizations with existing configurations

207
RELEASE_NOTES_3.2.1.md Normal file
View File

@ -0,0 +1,207 @@
# HMAC File Server 3.2.1 Critical Fixes Release 🔧
**Release Date**: July 20, 2025
**Type**: Critical Bug Fix Release
**Focus**: Network Resilience Configuration & XMPP Integration Fixes
---
## 🚨 Critical Fixes
### **Configuration Loading Regression (CRITICAL)**
- **Issue**: Server used hardcoded default extensions instead of config file settings
- **Root Cause**: TOML key mismatch (`allowedextensions` vs `allowed_extensions`)
- **Impact**: XMPP file uploads failing with "File extension not allowed" errors
- **Status**: ✅ **RESOLVED** - Configuration loading now works correctly
### **XMPP File Upload Failure**
- **Issue**: MP4 uploads from Conversations/Gajim clients returning HTTP 400 errors
- **Root Cause**: Network resilience changes broke configuration field mapping
- **Impact**: Mobile XMPP file sharing completely broken
- **Status**: ✅ **RESOLVED** - MP4 uploads now work perfectly (HTTP 201)
### **Mobile Network Switching**
- **Issue**: WLAN ↔ IPv6 5G switching configuration not loading properly
- **Root Cause**: Extension validation using wrong configuration source
- **Impact**: Network resilience features not fully functional
- **Status**: ✅ **RESOLVED** - Seamless network switching operational
---
## 🎯 What Was Fixed
### **Technical Resolution**
```bash
# Before (BROKEN)
Server Log: "🔥 DEBUG: Extension .mp4 not found in allowed list"
HTTP Response: 400 "File extension .mp4 not allowed"
# After (FIXED)
Server Log: "✅ File extension .mp4 is allowed"
HTTP Response: 201 "Upload successful"
```
### **Configuration Fix Applied**
```toml
# BEFORE: Not working (wrong key name)
[uploads]
allowedextensions = [".mp4", ".mkv", ".avi"] # ❌ Wrong key
# AFTER: Working (correct key name)
[uploads]
allowed_extensions = [".mp4", ".mkv", ".avi"] # ✅ Correct key
```
---
## 🧪 Comprehensive Testing Suite
### **New Testing Infrastructure**
- **✅ Consolidated Testing**: All scattered test scripts merged into single comprehensive suite
- **✅ 8 Test Scenarios**: Complete coverage of core functionality
- **✅ Auto-Detection**: Automatically finds local vs remote servers
- **✅ 100% Pass Rate**: All tests passing after fixes
### **Test Coverage**
```bash
./test # Run all comprehensive tests
Test Results:
✅ Server Health Check (200)
✅ Basic HMAC Validation (201)
✅ MP4 Upload for XMPP (201) ← CRITICAL FIX VALIDATED
✅ Image Upload (201)
✅ Large File Upload (201)
✅ Invalid HMAC Rejection (401)
✅ Unsupported Extension Block (400)
✅ Network Resilience Metrics (200)
```
---
## 📁 Project Structure Cleanup
### **Root Directory Organization**
- **❌ Removed**: 10+ redundant backup files, duplicate configs, empty documentation
- **✅ Consolidated**: All test files moved to `/tests/` directory
- **✅ Enhanced**: README.md with complete installation and testing documentation
- **✅ Simplified**: Easy access via `./test` and `./quick-test` symlinks
### **Before/After Comparison**
```bash
# BEFORE: Cluttered root directory
comprehensive_upload_test.sh, debug-uploads.sh, test-*.sh
config-*.toml.backup.*, BUILD_GUIDE.md (empty)
LICENSE_NEW, xep0363_analysis.ipynb (empty)
# AFTER: Clean, organized structure
README.md, WIKI.MD, CHANGELOG.MD, LICENSE
tests/ (all test files consolidated)
./test → tests/comprehensive_test_suite.sh
./quick-test → tests/test-hmac-fixed.sh
```
---
## 🚀 Immediate Benefits
### **For XMPP Users**
- **✅ Conversations**: MP4 uploads working again
- **✅ Gajim**: Video file sharing restored
- **✅ Mobile Users**: Seamless network switching between WiFi and 5G
- **✅ Large Files**: Multi-MB uploads functional
### **For Developers**
- **✅ Testing**: Single comprehensive test suite
- **✅ Debugging**: Clear, organized project structure
- **✅ Documentation**: All info consolidated in README.md
- **✅ Configuration**: Proper validation and error reporting
### **For System Administrators**
- **✅ Deployment**: All methods (SystemD, Docker, Podman) verified
- **✅ Monitoring**: Network resilience features operational
- **✅ Troubleshooting**: Comprehensive test suite for validation
- **✅ Maintenance**: Clean project structure for easier management
---
## ⚡ Upgrade Instructions
### **Critical Update (Recommended for All Users)**
```bash
# 1. Backup current setup
cp config.toml config-backup.toml
# 2. Update configuration key names
sed -i 's/allowedextensions/allowed_extensions/g' config.toml
# 3. Replace binary with 3.2.1 version
# Download new binary and restart service
# 4. Validate fix
./test # Should show 100% pass rate
```
### **Validation Commands**
```bash
# Quick test - should return HTTP 201
./quick-test
# Full validation - all 8 tests should pass
./test
# Check XMPP specifically
curl -X PUT -H "Content-Type: video/mp4" \
--data-binary "@test.mp4" \
"https://your-server/path/test.mp4?v=hmac_value"
# Should return HTTP 201 instead of 400
```
---
## 🔧 Technical Details
### **Root Cause Analysis**
1. **Network Resilience Implementation**: Enhanced mobile switching features in 3.2
2. **Configuration Structure Changes**: Modified field mapping for new features
3. **TOML Key Mismatch**: `allowedextensions` config vs `allowed_extensions` struct tag
4. **Fallback Behavior**: Server fell back to hardcoded defaults when config loading failed
### **Resolution Strategy**
1. **Configuration Fix**: Corrected TOML key naming to match struct expectations
2. **Validation Enhancement**: Added comprehensive configuration validation
3. **Testing Framework**: Created unified test suite to prevent regressions
4. **Documentation Update**: Consolidated all information for better maintenance
---
## 📊 Impact Assessment
### **Before 3.2.1 (BROKEN)**
- ❌ XMPP file uploads failing
- ❌ Mobile network switching unreliable
- ❌ Configuration validation inconsistent
- ❌ Scattered test files, difficult debugging
### **After 3.2.1 (FIXED)**
- ✅ XMPP integration fully functional
- ✅ Network resilience features operational
- ✅ Configuration loading reliable
- ✅ Comprehensive testing infrastructure
---
## 🎉 Success Metrics
- **✅ 100% Test Pass Rate**: All functionality validated
- **✅ XMPP Compatibility**: Conversations & Gajim working perfectly
- **✅ Network Resilience**: 1-second mobile detection operational
- **✅ Project Quality**: Clean, organized, maintainable structure
---
> **3.2.1 restores full functionality while establishing a comprehensive testing framework to prevent future regressions. This critical fix ensures XMPP integration and mobile network resilience work as designed.**
---
*HMAC File Server 3.2.1 Reliability Restored* 🛠️

View File

@ -2,14 +2,234 @@
set -e set -e
# Enhanced Container Build Script - Supports Docker & Podman
# HMAC File Server 3.2.1 - Universal Container Support
IMAGE_NAME="hmac-file-server" IMAGE_NAME="hmac-file-server"
DOCKERFILE_PATH="dockerenv/dockerbuild/Dockerfile" DOCKERFILE_PATH="dockerenv/dockerbuild/Dockerfile"
COMPOSE_FILE="dockerenv/docker-compose.yml"
echo "Building Docker image: $IMAGE_NAME" # Select appropriate compose file based on engine
get_compose_file() {
local engine="$1"
if [ "$engine" = "podman" ] && [ -f "dockerenv/podman-compose.yml" ]; then
echo "dockerenv/podman-compose.yml"
else
echo "dockerenv/docker-compose.yml"
fi
}
# Colors for output
RED='\033[0;31m'
GREEN='\033[0;32m'
YELLOW='\033[1;33m'
BLUE='\033[0;34m'
NC='\033[0m' # No Color
# Function to detect available container engines
detect_container_engines() {
local engines=()
if command -v docker &> /dev/null; then
engines+=("docker")
fi
if command -v podman &> /dev/null; then
engines+=("podman")
fi
echo "${engines[@]}"
}
# Function to select container engine
select_container_engine() {
local available_engines=($(detect_container_engines))
if [ ${#available_engines[@]} -eq 0 ]; then
echo -e "${RED}❌ Error: Neither Docker nor Podman is installed${NC}"
echo "Please install Docker or Podman to continue"
exit 1
fi
# Check for user preference via argument
if [ "$1" = "docker" ] || [ "$1" = "podman" ]; then
local requested_engine="$1"
for engine in "${available_engines[@]}"; do
if [ "$engine" = "$requested_engine" ]; then
echo "$requested_engine"
return 0
fi
done
echo -e "${RED}❌ Error: $requested_engine is not available${NC}"
exit 1
fi
# If only one engine available, use it
if [ ${#available_engines[@]} -eq 1 ]; then
echo "${available_engines[0]}"
return 0
fi
# Multiple engines available, let user choose
echo -e "${BLUE}🐳 Multiple container engines detected:${NC}"
for i in "${!available_engines[@]}"; do
echo " $((i+1))) ${available_engines[i]}"
done
while true; do
read -p "Select container engine (1-${#available_engines[@]}): " choice
if [[ "$choice" =~ ^[0-9]+$ ]] && [ "$choice" -ge 1 ] && [ "$choice" -le ${#available_engines[@]} ]; then
echo "${available_engines[$((choice-1))]}"
return 0
fi
echo "Invalid choice. Please enter a number between 1 and ${#available_engines[@]}"
done
}
# Function to get compose command based on engine
get_compose_command() {
local engine="$1"
case "$engine" in
"docker")
if command -v docker-compose &> /dev/null; then
echo "docker-compose"
elif docker compose version &> /dev/null; then
echo "docker compose"
else
echo ""
fi
;;
"podman")
if command -v podman-compose &> /dev/null; then
echo "podman-compose"
else
echo ""
fi
;;
*)
echo ""
;;
esac
}
# Function to build container image
build_image() {
local engine="$1"
echo -e "${BLUE}🔨 Building container image with $engine...${NC}"
echo "Image: $IMAGE_NAME"
echo "Dockerfile: $DOCKERFILE_PATH"
if [ "$engine" = "podman" ]; then
# Podman specific build
podman build -t "$IMAGE_NAME" -f "$DOCKERFILE_PATH" .
else
# Docker build
docker build -t "$IMAGE_NAME" -f "$DOCKERFILE_PATH" . docker build -t "$IMAGE_NAME" -f "$DOCKERFILE_PATH" .
fi
#echo "Starting services using $COMPOSE_FILE" if [ $? -eq 0 ]; then
#docker-compose -f "$COMPOSE_FILE" up -d echo -e "${GREEN}✅ Image built successfully with $engine${NC}"
else
echo -e "${RED}❌ Failed to build image with $engine${NC}"
exit 1
fi
}
echo "Build and deployment complete." # Function to start services (optional)
start_services() {
local engine="$1"
local compose_file=$(get_compose_file "$engine")
local compose_cmd=$(get_compose_command "$engine")
if [ -z "$compose_cmd" ]; then
echo -e "${YELLOW}⚠️ No compose command available for $engine${NC}"
echo "You can start the container manually:"
if [ "$engine" = "podman" ]; then
echo " podman run -d --name hmac-file-server -p 8081:8080 -v ./dockerenv/config:/etc/hmac-file-server:Z -v ./dockerenv/data/uploads:/opt/hmac-file-server/data/uploads:Z $IMAGE_NAME"
else
echo " docker run -d --name hmac-file-server -p 8081:8080 -v ./dockerenv/config:/etc/hmac-file-server -v ./dockerenv/data/uploads:/opt/hmac-file-server/data/uploads $IMAGE_NAME"
fi
return 0
fi
echo -e "${BLUE}🚀 Starting services with $compose_cmd...${NC}"
echo "Using compose file: $compose_file"
if [ "$compose_cmd" = "docker compose" ]; then
docker compose -f "$compose_file" up -d
else
$compose_cmd -f "$compose_file" up -d
fi
if [ $? -eq 0 ]; then
echo -e "${GREEN}✅ Services started successfully${NC}"
echo "Server accessible at: http://localhost:8081"
else
echo -e "${RED}❌ Failed to start services${NC}"
exit 1
fi
}
# Main execution
main() {
echo -e "${BLUE}🐳 HMAC File Server - Universal Container Builder${NC}"
echo "Version: 3.2.1 - Docker & Podman Support"
echo
# Select container engine
CONTAINER_ENGINE=$(select_container_engine "$1")
echo -e "${GREEN}📦 Using container engine: $CONTAINER_ENGINE${NC}"
echo
# Build image
build_image "$CONTAINER_ENGINE"
echo
# Ask about starting services
if [ "$2" != "--build-only" ]; then
read -p "Start services now? (y/n): " start_choice
if [[ "$start_choice" =~ ^[Yy] ]]; then
start_services "$CONTAINER_ENGINE"
else
echo -e "${YELLOW} Build complete. Services not started.${NC}"
echo "To start manually, use:"
local compose_file=$(get_compose_file "$CONTAINER_ENGINE")
local compose_cmd=$(get_compose_command "$CONTAINER_ENGINE")
if [ -n "$compose_cmd" ]; then
if [ "$compose_cmd" = "docker compose" ]; then
echo " docker compose -f $compose_file up -d"
else
echo " $compose_cmd -f $compose_file up -d"
fi
fi
fi
fi
echo
echo -e "${GREEN}🎉 Container build process completed successfully!${NC}"
}
# Show usage if help requested
if [ "$1" = "--help" ] || [ "$1" = "-h" ]; then
echo "HMAC File Server - Universal Container Builder"
echo "Usage: $0 [engine] [options]"
echo
echo "Engines:"
echo " docker - Use Docker engine"
echo " podman - Use Podman engine"
echo " (auto) - Auto-detect and select available engine"
echo
echo "Options:"
echo " --build-only - Build image only, don't start services"
echo " --help, -h - Show this help message"
echo
echo "Examples:"
echo " $0 # Auto-detect engine and interactive mode"
echo " $0 docker # Use Docker specifically"
echo " $0 podman --build-only # Use Podman, build only"
exit 0
fi
# Run main function
main "$@"

View File

@ -0,0 +1,22 @@
# Podman Compose Configuration for HMAC File Server
# Version: 3.2.1 - Podman optimized
services:
hmac-file-server:
container_name: hmac-file-server
image: hmac-file-server:latest
ports:
- "8081:8080"
volumes:
- ./config:/etc/hmac-file-server:Z
- ./data/uploads:/opt/hmac-file-server/data/uploads:Z
- ./data/duplicates:/opt/hmac-file-server/data/duplicates:Z
- ./data/temp:/opt/hmac-file-server/data/temp:Z
- ./data/logs:/opt/hmac-file-server/data/logs:Z
environment:
- CONFIG_PATH=/etc/hmac-file-server/config.toml
restart: unless-stopped
security_opt:
- label=disable
# Podman specific optimizations
userns_mode: "keep-id"