Compare commits

...

2 Commits

Author SHA1 Message Date
librelad
fa6483cf94 Merge claude/1 2026-05-23 12:40:32 +01:00
librelad
315c528306 refactor(webui): silence per-file touch/chown noise in data generators
The WebUI data snapshots (locations.json, dashboard.json, snapshots_*.json,
etc.) are regenerated on every wizard/config change. Each file emitted two
extra success lines via createTouch — "Touching <file>" and "Updating
<file> with <user> ownership" — which spammed the output around the genuinely
useful "... JSON regenerated" line.

Add an optional "silent" flag to createTouch (third arg; default keeps the
existing loud behaviour for interactive install flows) and pass it from every
WebUI data generator/task. Touch + chown still run; only the logging is
suppressed for these background regenerations.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Signed-off-by: librelad <librelad@digitalangels.vip>
2026-05-23 12:40:32 +01:00
21 changed files with 36 additions and 30 deletions

View File

@ -1,16 +1,22 @@
#!/bin/bash #!/bin/bash
createTouch() createTouch()
{ {
local file="$1" local file="$1"
local user_name="$2" local user_name="$2"
local silent_flag="$3"
local file_name=$(basename "$file") local file_name=$(basename "$file")
local file_dir=$(dirname "$file") local file_dir=$(dirname "$file")
local clean_dir=$(echo "$file" | sed 's#//*#/#g') local clean_dir=$(echo "$file" | sed 's#//*#/#g')
local result=$(sudo touch "$clean_dir") if [ "$silent_flag" == "silent" ]; then
checkSuccess "Touching $file_name" sudo touch "$clean_dir"
sudo chown $user_name:$user_name "$file"
else
local result=$(sudo touch "$clean_dir")
checkSuccess "Touching $file_name"
local result=$(sudo chown $user_name:$user_name "$file") local result=$(sudo chown $user_name:$user_name "$file")
checkSuccess "Updating $file_name with $user_name ownership" checkSuccess "Updating $file_name with $user_name ownership"
fi
} }

View File

@ -227,7 +227,7 @@ EOF
# Already root via start.sh — drop redundant sudo. # Already root via start.sh — drop redundant sudo.
if [ $? -eq 0 ]; then if [ $? -eq 0 ]; then
mv "$temp_file" "$output_file" mv "$temp_file" "$output_file"
createTouch "$output_file" "$docker_install_user" createTouch "$output_file" "$docker_install_user" "silent"
else else
rm -f "$temp_file" 2>/dev/null rm -f "$temp_file" 2>/dev/null
fi fi

View File

@ -71,7 +71,7 @@ webuiGenerateGluetunProviders() {
if [ -s "$tmp" ]; then if [ -s "$tmp" ]; then
mv "$tmp" "$output_file" mv "$tmp" "$output_file"
createTouch "$output_file" "$docker_install_user" createTouch "$output_file" "$docker_install_user" "silent"
[[ -n "$new_etag" ]] && echo "$new_etag" | tee "$etag_file" >/dev/null [[ -n "$new_etag" ]] && echo "$new_etag" | tee "$etag_file" >/dev/null
isSuccessful "Refreshed gluetun provider snapshot ($(jq '.providers | length' "$output_file") providers)." isSuccessful "Refreshed gluetun provider snapshot ($(jq '.providers | length' "$output_file") providers)."
else else

View File

@ -28,7 +28,7 @@ EOF
echo " ]" >> "$temp_file" echo " ]" >> "$temp_file"
echo "}" >> "$temp_file" echo "}" >> "$temp_file"
mv "$temp_file" "$output_file" mv "$temp_file" "$output_file"
createTouch "$output_file" "$docker_install_user" createTouch "$output_file" "$docker_install_user" "silent"
fi fi
# Get all installed apps # Get all installed apps
@ -40,7 +40,7 @@ EOF
echo " ]" >> "$temp_file" echo " ]" >> "$temp_file"
echo "}" >> "$temp_file" echo "}" >> "$temp_file"
mv "$temp_file" "$output_file" mv "$temp_file" "$output_file"
createTouch "$output_file" "$docker_install_user" createTouch "$output_file" "$docker_install_user" "silent"
fi fi
# Process each app # Process each app
@ -293,7 +293,7 @@ EOF
echo " ]" >> "$temp_file" echo " ]" >> "$temp_file"
echo "}" >> "$temp_file" echo "}" >> "$temp_file"
mv "$temp_file" "$output_file" mv "$temp_file" "$output_file"
createTouch "$output_file" "$docker_install_user" createTouch "$output_file" "$docker_install_user" "silent"
echo "No services found to generate" echo "No services found to generate"
fi fi
@ -304,7 +304,7 @@ EOF
if [ $? -eq 0 ]; then if [ $? -eq 0 ]; then
mv "$temp_file" "$output_file" mv "$temp_file" "$output_file"
# Set proper ownership for web UI access # Set proper ownership for web UI access
createTouch "$output_file" "$docker_install_user" createTouch "$output_file" "$docker_install_user" "silent"
else else
rm -f "$temp_file" 2>/dev/null rm -f "$temp_file" 2>/dev/null
fi fi

View File

@ -423,6 +423,6 @@ JSON
fi fi
mv "$tmp" "$output_file" mv "$tmp" "$output_file"
createTouch "$output_file" "$docker_install_user" createTouch "$output_file" "$docker_install_user" "silent"
isSuccessful "Generated apps-tools.json ($(jq '[.apps[].tools | length] | add' "$output_file" 2>/dev/null || echo "?") tool(s) across $(jq '.apps | length' "$output_file" 2>/dev/null || echo "?") app(s))." isSuccessful "Generated apps-tools.json ($(jq '[.apps[].tools | length] | add' "$output_file" 2>/dev/null || echo "?") tool(s) across $(jq '.apps | length' "$output_file" 2>/dev/null || echo "?") app(s))."
} }

View File

@ -53,5 +53,5 @@ webuiGenerateBackupAppStatus()
echo "$content" | sudo tee "$temp_file" >/dev/null echo "$content" | sudo tee "$temp_file" >/dev/null
sudo mv "$temp_file" "$output_file" sudo mv "$temp_file" "$output_file"
createTouch "$output_file" "$docker_install_user" createTouch "$output_file" "$docker_install_user" "silent"
} }

View File

@ -81,6 +81,6 @@ webuiGenerateBackupDashboard()
echo "$content" | sudo tee "$temp_file" >/dev/null echo "$content" | sudo tee "$temp_file" >/dev/null
sudo mv "$temp_file" "$output_file" sudo mv "$temp_file" "$output_file"
createTouch "$output_file" "$docker_install_user" createTouch "$output_file" "$docker_install_user" "silent"
isSuccessful "Backup dashboard JSON regenerated" isSuccessful "Backup dashboard JSON regenerated"
} }

View File

@ -23,7 +23,7 @@ webuiGenerateBackupEngines()
local base local base
base=$(basename "$f") base=$(basename "$f")
sudo cp "$f" "$out_dir/$base" sudo cp "$f" "$out_dir/$base"
createTouch "$out_dir/$base" "$docker_install_user" createTouch "$out_dir/$base" "$docker_install_user" "silent"
local id="${base%.json}" local id="${base%.json}"
$first || index+="," $first || index+=","
first=false first=false
@ -33,7 +33,7 @@ webuiGenerateBackupEngines()
local idx_file="$out_dir/index.json" local idx_file="$out_dir/index.json"
echo "{\"engines\":$index,\"generated_at\":\"$(date -Iseconds)\"}" | sudo tee "$idx_file" >/dev/null echo "{\"engines\":$index,\"generated_at\":\"$(date -Iseconds)\"}" | sudo tee "$idx_file" >/dev/null
createTouch "$idx_file" "$docker_install_user" createTouch "$idx_file" "$docker_install_user" "silent"
isSuccessful "Engines JSON regenerated" isSuccessful "Engines JSON regenerated"
} }

View File

@ -88,6 +88,6 @@ webuiGenerateBackupLocations()
echo "$content" | sudo tee "$temp_file" >/dev/null echo "$content" | sudo tee "$temp_file" >/dev/null
sudo mv "$temp_file" "$output_file" sudo mv "$temp_file" "$output_file"
createTouch "$output_file" "$docker_install_user" createTouch "$output_file" "$docker_install_user" "silent"
isSuccessful "Locations JSON regenerated" isSuccessful "Locations JSON regenerated"
} }

View File

@ -37,6 +37,6 @@ webuiGenerateBackupPasswords()
chmod 0600 "$temp_file" chmod 0600 "$temp_file"
mv "$temp_file" "$output_file" mv "$temp_file" "$output_file"
createTouch "$output_file" "${docker_install_user:-${sudo_user_name:-libreportal}}" createTouch "$output_file" "${docker_install_user:-${sudo_user_name:-libreportal}}" "silent"
chmod 0600 "$output_file" chmod 0600 "$output_file"
} }

View File

@ -34,7 +34,7 @@ webuiGenerateBackupSnapshots()
echo "$content" | sudo tee "$temp_file" >/dev/null echo "$content" | sudo tee "$temp_file" >/dev/null
sudo mv "$temp_file" "$output_file" sudo mv "$temp_file" "$output_file"
createTouch "$output_file" "$docker_install_user" createTouch "$output_file" "$docker_install_user" "silent"
done done
isSuccessful "Snapshots JSON regenerated (${#indices[@]} location(s))" isSuccessful "Snapshots JSON regenerated (${#indices[@]} location(s))"

View File

@ -97,7 +97,7 @@ EOF
if [ $? -eq 0 ]; then if [ $? -eq 0 ]; then
sudo mv "$temp_file" "$final_file" sudo mv "$temp_file" "$final_file"
# Set proper ownership for web UI access using createTouch # Set proper ownership for web UI access using createTouch
createTouch "$final_file" "$docker_install_user" createTouch "$final_file" "$docker_install_user" "silent"
else else
rm -f "$temp_file" 2>/dev/null rm -f "$temp_file" 2>/dev/null
fi fi

View File

@ -79,7 +79,7 @@ EOF
if [ $? -eq 0 ]; then if [ $? -eq 0 ]; then
sudo mv "$temp_file" "$final_file" sudo mv "$temp_file" "$final_file"
# Set proper ownership for web UI access using createTouch # Set proper ownership for web UI access using createTouch
createTouch "$final_file" "$docker_install_user" createTouch "$final_file" "$docker_install_user" "silent"
else else
rm -f "$temp_file" 2>/dev/null rm -f "$temp_file" 2>/dev/null
fi fi

View File

@ -792,7 +792,7 @@ RESTEOF
sed -i "s|__INSTALL_NAME__|${install_name_safe}|g" "$temp_file" sed -i "s|__INSTALL_NAME__|${install_name_safe}|g" "$temp_file"
mv "$temp_file" "$final_file" mv "$temp_file" "$final_file"
# Set proper ownership for web UI access using createTouch # Set proper ownership for web UI access using createTouch
createTouch "$final_file" "$docker_install_user" createTouch "$final_file" "$docker_install_user" "silent"
else else
rm -f "$temp_file" 2>/dev/null rm -f "$temp_file" 2>/dev/null
fi fi

View File

@ -294,7 +294,7 @@ EOF
# Already running as root via start.sh — sudo was redundant overhead. # Already running as root via start.sh — sudo was redundant overhead.
if [ $? -eq 0 ]; then if [ $? -eq 0 ]; then
mv "$temp_file" "$output_file" mv "$temp_file" "$output_file"
createTouch "$output_file" "$docker_install_user" createTouch "$output_file" "$docker_install_user" "silent"
else else
rm -f "$temp_file" 2>/dev/null rm -f "$temp_file" 2>/dev/null
fi fi

View File

@ -57,7 +57,7 @@ EOF
if [ $? -eq 0 ]; then if [ $? -eq 0 ]; then
mv "$temp_file" "$final_file" mv "$temp_file" "$final_file"
# Set proper ownership for web UI access using createTouch # Set proper ownership for web UI access using createTouch
createTouch "$final_file" "$sudo_user_name" createTouch "$final_file" "$sudo_user_name" "silent"
else else
rm -f "$temp_file" 2>/dev/null rm -f "$temp_file" 2>/dev/null
fi fi

View File

@ -54,7 +54,7 @@ EOF
if [ $? -eq 0 ]; then if [ $? -eq 0 ]; then
mv "$temp_file" "$final_file" mv "$temp_file" "$final_file"
# Set proper ownership for web UI access using createTouch # Set proper ownership for web UI access using createTouch
createTouch "$final_file" "$sudo_user_name" createTouch "$final_file" "$sudo_user_name" "silent"
else else
rm -f "$temp_file" 2>/dev/null rm -f "$temp_file" 2>/dev/null
fi fi

View File

@ -51,7 +51,7 @@ EOF
if [ $? -eq 0 ]; then if [ $? -eq 0 ]; then
mv "$temp_file" "$final_file" mv "$temp_file" "$final_file"
# Set proper ownership for web UI access using createTouch # Set proper ownership for web UI access using createTouch
createTouch "$final_file" "$sudo_user_name" createTouch "$final_file" "$sudo_user_name" "silent"
else else
rm -f "$temp_file" 2>/dev/null rm -f "$temp_file" 2>/dev/null
fi fi

View File

@ -92,7 +92,7 @@ webuiSystemUpdateCheck() {
EOF EOF
if [ $? -eq 0 ]; then if [ $? -eq 0 ]; then
mv "$temp_file" "$final_file" mv "$temp_file" "$final_file"
createTouch "$final_file" "$sudo_user_name" createTouch "$final_file" "$sudo_user_name" "silent"
else else
rm -f "$temp_file" 2>/dev/null rm -f "$temp_file" 2>/dev/null
fi fi

View File

@ -15,7 +15,7 @@ webuiEnsureTaskFiles() {
# Create queue.json if it doesn't exist # Create queue.json if it doesn't exist
if [ ! -f "$task_dir/queue.json" ]; then if [ ! -f "$task_dir/queue.json" ]; then
echo " Creating queue.json" echo " Creating queue.json"
createTouch "$task_dir/queue.json" $docker_install_user createTouch "$task_dir/queue.json" $docker_install_user "silent"
local result=$(echo "[]" | sudo tee "$task_dir/queue.json" > /dev/null) local result=$(echo "[]" | sudo tee "$task_dir/queue.json" > /dev/null)
checkSuccess "Created queue.json..." checkSuccess "Created queue.json..."
else else
@ -25,7 +25,7 @@ webuiEnsureTaskFiles() {
# Create current.json if it doesn't exist # Create current.json if it doesn't exist
if [ ! -f "$task_dir/current.json" ]; then if [ ! -f "$task_dir/current.json" ]; then
echo " Creating current.json" echo " Creating current.json"
createTouch "$task_dir/current.json" $docker_install_user createTouch "$task_dir/current.json" $docker_install_user "silent"
local result=$(echo '{}' | sudo tee "$task_dir/current.json" > /dev/null) local result=$(echo '{}' | sudo tee "$task_dir/current.json" > /dev/null)
checkSuccess "Created current.json..." checkSuccess "Created current.json..."
else else

View File

@ -18,7 +18,7 @@ webuiUpdateAppLog()
if [[ "$type" == "install" ]]; then if [[ "$type" == "install" ]]; then
# Create WebUI log file if it doesn't exist # Create WebUI log file if it doesn't exist
if [ ! -f "${log_file}" ]; then if [ ! -f "${log_file}" ]; then
createTouch "$log_file" $sudo_user_name createTouch "$log_file" $sudo_user_name "silent"
echo "=== LibrePortal Installation Started at $(date) ===" | sudo tee "${log_file}" > /dev/null echo "=== LibrePortal Installation Started at $(date) ===" | sudo tee "${log_file}" > /dev/null
fi fi
elif [[ "$type" == "uninstall" ]]; then elif [[ "$type" == "uninstall" ]]; then