53590fb8e4
- Document the removal of /tmp fallback - Explain directory structure and permissions - Provide troubleshooting guide - Include migration instructions for existing installations
4.1 KiB
4.1 KiB
Persistent Storage Configuration
Overview
This document explains the persistent storage configuration for DDNS Updater and the changes made to ensure JSON files are stored in a persistent location.
Problem
Previously, the DDNS Updater would fall back to /tmp/ddns-updater when /var/lib/ddns-updater was not accessible. This caused several issues:
- Data Loss: Files in
/tmpare typically cleared on reboot - Inconsistent Behavior: Service behavior differed between installations
- systemd PrivateTmp: With
PrivateTmp=true, the/tmpdirectory is isolated and not persistent
Solution
Changes Made
1. Systemd Service Files
- File:
systemd/ddns-updater.service - File:
systemd/ddns-updater@.service - Change: Removed
/tmp/ddns-updaterfromReadWritePaths - Result: Service can only write to
/var/lib/ddns-updater
2. Installation Script
- File:
systemd/install-systemd.sh - Change: Added creation of
/var/lib/ddns-updaterdirectory - Details:
mkdir -p /var/lib/ddns-updater chmod 755 /var/lib/ddns-updater chown root:root /var/lib/ddns-updater
3. CLI Interface
- File:
src/interface/cli_interface.rs - Change: Removed
/tmp/ddns-updaterfallback - Result: Application exits with clear error message if persistent storage unavailable
4. Error Handling
When /var/lib/ddns-updater is not accessible, the application now:
- Displays a clear error message
- Provides instructions for manual directory creation
- Exits gracefully instead of using temporary storage
Directory Structure
Production Environment
/var/lib/ddns-updater/ # Persistent storage directory
├── hostname1.json # IP data for hostname1
├── hostname2.json # IP data for hostname2
└── ... # Additional hostname files
Test Environment
./test_storage/ # Local test directory (DDNS_TEST_MODE=1)
├── hostname1.json # Test IP data
└── ... # Additional test files
Permissions
| Directory | Owner | Group | Permissions | Purpose |
|---|---|---|---|---|
/var/lib/ddns-updater |
root | root | 755 | JSON storage |
/var/log/ddns-updater |
ddns-updater | ddns-updater | 750 | Log files (Debian pkg) |
/etc/ddns-updater |
root | ddns-updater | 750 | Config files (Debian pkg) |
Installation Methods
1. Systemd Installation Script
sudo ./systemd/install-systemd.sh
This automatically creates the required directories.
2. Debian Package
sudo dpkg -i ddns-updater_*.deb
The postinst script creates all required directories.
3. Manual Installation
If installing manually:
sudo mkdir -p /var/lib/ddns-updater
sudo chmod 755 /var/lib/ddns-updater
sudo chown root:root /var/lib/ddns-updater
Benefits
- Data Persistence: IP data survives reboots and system maintenance
- Predictable Behavior: Service always uses the same storage location
- Better Error Handling: Clear error messages when storage is unavailable
- Security: No reliance on world-writable temporary directories
- Compliance: Follows Linux filesystem hierarchy standards
Troubleshooting
Error: "Cannot access /var/lib/ddns-updater"
- Check if directory exists:
ls -la /var/lib/ddns-updater - Create if missing:
sudo mkdir -p /var/lib/ddns-updater - Set permissions:
sudo chmod 755 /var/lib/ddns-updater - Set ownership:
sudo chown root:root /var/lib/ddns-updater
Service fails to start
- Check systemd logs:
journalctl -u ddns-updater.service - Verify directory permissions
- Ensure service has write access to
/var/lib/ddns-updater
Migration
For existing installations using /tmp/ddns-updater:
- Copy any important JSON files to
/var/lib/ddns-updater - Update systemd service files
- Restart the service
Version History
- v1.2.1: Removed
/tmpfallback, enforced persistent storage - v1.2.0: Enhanced logging with absolute paths
- v1.0.0: Initial release with
/tmpfallback