A free, open, self-hosted app platform (GNU AGPLv3): one-click app deploys, Traefik reverse proxy with automatic SSL, rootless Docker support, gluetun VPN routing, and a web dashboard to manage it all. Free & open forever to self-host; optional paid hosted services fund it. See PROMISE.md. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com> Signed-off-by: librelad <librelad@digitalangels.vip>
30 lines
731 B
Bash
Executable File
30 lines
731 B
Bash
Executable File
#!/bin/bash
|
|
|
|
# LibrePortal WebUI Atomic Write Utilities
|
|
# Provides atomic file writing functionality for web UI safety
|
|
|
|
# Atomic file write function for web UI safety
|
|
atomicWriteWebUI() {
|
|
local content="$1"
|
|
local target_file="$2"
|
|
local temp_file="${target_file}.tmp.$$"
|
|
|
|
# Ensure directory exists
|
|
mkdir -p "$(dirname "$target_file")"
|
|
|
|
# Write to temp file first
|
|
printf '%s' "$content" > "$temp_file"
|
|
|
|
# Set proper permissions
|
|
chmod 644 "$temp_file"
|
|
|
|
# Atomic rename (instantaneous - no partial reads)
|
|
mv "$temp_file" "$target_file"
|
|
|
|
if [ $? -eq 0 ]; then
|
|
echo "✓ Atomic write successful: $target_file"
|
|
else
|
|
echo "✗ Atomic write failed: $target_file"
|
|
fi
|
|
}
|