Compare commits

..

No commits in common. "bd4887f8899890f9f052da5b12b39b2996e74834" and "a7d819799f09e5c2958869c6531c6d0a8856df56" have entirely different histories.

9 changed files with 34 additions and 33 deletions

View File

@ -9,21 +9,6 @@ createFolders()
local folder_name=$(basename "$dir_path")
local clean_dir=$(echo "$dir_path" | sed 's#//*#/#g')
# Under /docker/containers/<app>/ the owner is the docker install user
# (the rootless container + host generators run as it), so create the dir
# AS that user via runFileOp — creating it as the right owner avoids a
# chown-to-another-user the unprivileged runtime can't do. Mirrors
# createTouch; the $user_name hint is advisory for these paths.
if [[ "$clean_dir" == "$containers_dir"* || "$clean_dir" == /docker/containers/* ]]; then
if [ ! -d "$dir_path" ]; then
local result=$(runFileOp mkdir -p "$dir_path")
[ "$silent_flag" == "loud" ] && checkSuccess "Creating $folder_name directory"
elif [ "$silent_flag" == "loud" ]; then
isNotice "$folder_name directory already exists"
fi
continue
fi
if [ ! -d "$dir_path" ]; then
local result=$(sudo mkdir -p "$dir_path")
if [ "$silent_flag" == "loud" ]; then

View File

@ -4,7 +4,7 @@ webuiGenerateBackupAppStatus()
{
local app_name="$1"
local output_dir="$containers_dir/libreportal/frontend/data/backup/generated/apps"
runFileOp mkdir -p "$output_dir"
mkdir -p "$output_dir"
if [[ -z "$app_name" ]]; then
if [[ -f "$docker_dir/$db_file" ]]; then
@ -51,5 +51,7 @@ webuiGenerateBackupAppStatus()
done < <(resticEnabledLocations)
content+="]}"
echo "$content" | runFileWrite "$output_file"
echo "$content" | sudo tee "$temp_file" >/dev/null
sudo mv "$temp_file" "$output_file"
createTouch "$output_file" "$docker_install_user" "silent"
}

View File

@ -6,7 +6,7 @@ webuiGenerateBackupDashboard()
local output_file="$output_dir/dashboard.json"
local temp_file="${output_file}.tmp.$$"
runFileOp mkdir -p "$output_dir"
mkdir -p "$output_dir"
local generated_at
generated_at=$(date -Iseconds)
@ -79,6 +79,8 @@ webuiGenerateBackupDashboard()
content+="\"apps\":$apps_json"
content+="}"
echo "$content" | runFileWrite "$output_file"
echo "$content" | sudo tee "$temp_file" >/dev/null
sudo mv "$temp_file" "$output_file"
createTouch "$output_file" "$docker_install_user" "silent"
isSuccessful "Backup dashboard JSON regenerated"
}

View File

@ -8,7 +8,7 @@ webuiGenerateBackupEngines()
{
local src_dir="$install_scripts_dir/backup/engines"
local out_dir="$containers_dir/libreportal/frontend/data/backup/generated/engines"
runFileOp mkdir -p "$out_dir"
sudo mkdir -p "$out_dir"
if [[ ! -d "$src_dir" ]]; then
isNotice "No engines directory at $src_dir — skipping engines regen"
@ -22,7 +22,8 @@ webuiGenerateBackupEngines()
[[ -f "$f" ]] || continue
local base
base=$(basename "$f")
runFileOp cp "$f" "$out_dir/$base"
sudo cp "$f" "$out_dir/$base"
createTouch "$out_dir/$base" "$docker_install_user" "silent"
local id="${base%.json}"
$first || index+=","
first=false
@ -31,7 +32,8 @@ webuiGenerateBackupEngines()
index+="]"
local idx_file="$out_dir/index.json"
echo "{\"engines\":$index,\"generated_at\":\"$(date -Iseconds)\"}" | runFileWrite "$idx_file"
echo "{\"engines\":$index,\"generated_at\":\"$(date -Iseconds)\"}" | sudo tee "$idx_file" >/dev/null
createTouch "$idx_file" "$docker_install_user" "silent"
isSuccessful "Engines JSON regenerated"
}

View File

@ -5,7 +5,7 @@ webuiGenerateBackupLocations()
local output_dir="$containers_dir/libreportal/frontend/data/backup/generated"
local output_file="$output_dir/locations.json"
local temp_file="${output_file}.tmp.$$"
runFileOp mkdir -p "$output_dir"
mkdir -p "$output_dir"
if declare -f backupLocationsMigrate >/dev/null 2>&1; then
backupLocationsMigrate >/dev/null 2>&1 || true
@ -99,6 +99,8 @@ webuiGenerateBackupLocations()
done < <(resticAllLocationIndices)
content+="]}"
echo "$content" | runFileWrite "$output_file"
echo "$content" | sudo tee "$temp_file" >/dev/null
sudo mv "$temp_file" "$output_file"
createTouch "$output_file" "$docker_install_user" "silent"
isSuccessful "Locations JSON regenerated"
}

View File

@ -6,7 +6,7 @@ webuiGenerateBackupPasswords()
local output_file="$output_dir/passwords.txt"
local temp_file="${output_file}.tmp.$$"
runFileOp mkdir -p "$output_dir"
mkdir -p "$output_dir"
local generated_at
generated_at=$(date -Iseconds)
@ -33,6 +33,10 @@ webuiGenerateBackupPasswords()
echo "CFG_BACKUP_LOC_${idx}_PASSWORD=${pass}"
echo ""
done < <(resticAllLocationIndices)
} | runFileWrite "$output_file"
runFileOp chmod 0600 "$output_file"
} > "$temp_file"
chmod 0600 "$temp_file"
mv "$temp_file" "$output_file"
createTouch "$output_file" "${docker_install_user:-${sudo_user_name:-libreportal}}" "silent"
chmod 0600 "$output_file"
}

View File

@ -12,7 +12,7 @@ webuiGenerateBackupSchema()
{
local out_dir="$containers_dir/libreportal/frontend/data/backup/generated"
local out_file="$out_dir/schema.json"
runFileOp mkdir -p "$out_dir"
sudo mkdir -p "$out_dir"
# "<type>|FIELD,FIELD,..." — order here is the form's render order.
local rows=(
@ -45,6 +45,7 @@ webuiGenerateBackupSchema()
done
json+="}}"
echo "$json" | runFileWrite "$out_file"
echo "$json" | sudo tee "$out_file" >/dev/null
createTouch "$out_file" "$docker_install_user" "silent"
isSuccessful "Backup location schema regenerated"
}

View File

@ -4,7 +4,7 @@ webuiGenerateBackupSnapshots()
{
local scope="${1:-all}"
local output_dir="$containers_dir/libreportal/frontend/data/backup/generated"
runFileOp mkdir -p "$output_dir"
mkdir -p "$output_dir"
local indices=()
if [[ "$scope" == "all" ]]; then
@ -32,7 +32,9 @@ webuiGenerateBackupSnapshots()
content+="\"snapshots\":$raw"
content+="}"
echo "$content" | runFileWrite "$output_file"
echo "$content" | sudo tee "$temp_file" >/dev/null
sudo mv "$temp_file" "$output_file"
createTouch "$output_file" "$docker_install_user" "silent"
done
isSuccessful "Snapshots JSON regenerated (${#indices[@]} location(s))"

View File

@ -8,7 +8,7 @@ webuiGenerateSshAccess()
{
local out_dir="$containers_dir/libreportal/frontend/data/ssh"
local out_file="$out_dir/access.json"
runFileOp mkdir -p "$out_dir"
sudo mkdir -p "$out_dir"
local jsonEscape
jsonEscape() {
@ -45,6 +45,7 @@ webuiGenerateSshAccess()
printf '{"generated_at":"%s","user":"%s","password_auth":%s,"keys":%s}\n' \
"$(date -Iseconds)" "$(jsonEscape "$user")" "$pw_auth" "$keys_json" \
| runFileWrite "$out_file"
| sudo tee "$out_file" >/dev/null
createTouch "$out_file" "$docker_install_user" "silent"
isSuccessful "SSH access snapshot regenerated"
}