The main sweep — ~260 call sites across ~100 files move from string
concatenation on a single root to appDir/storageAppDirs/storageAppConfigs.
On a single-root install the resolved paths are identical, so this is a
no-op until a location is registered.
Enumerators were the interesting half. `for d in "$containers_dir"/*/`
appears in the menus, the registry/artifact scanners and the DNS setup —
and a shell glob cannot list a rootless 751 tree at all, which is the
same bug config_find_file.sh already documents in a comment. Routing them
through storageAppDirs (which enumerates as the owning user) fixes that
alongside the multi-root work.
Three places needed judgement rather than substitution:
db_app_scan.sh deletes database rows and port allocations for apps whose
folder is missing, and reaps "empty" app dirs. With a storage location
unmounted, every app on it looks exactly like that. Each of those
branches now gates on appStorageAvailable first — an app on an unplugged
drive is skipped with a notice, never deleted.
instance_create.sh rewrites cloned hooks so an instance touches its own
directory instead of the base app's. Its sed matched ${containers_dir}<type>,
which this sweep just replaced with $(appDir <type>) — so it would have
silently stopped redirecting, and an instance would have written to the
original's files (the adguard auth adapter case its own comment warns
about). Now matches both appDir forms, verified against bare, quoted,
unrelated-app, legacy and prose cases.
peer_shell/peer_pull streamed and extracted relative to the primary root.
Both now use the app's own root, and peer_shell keeps a single-root
fallback since it runs as a restricted SSH shell with no LibrePortal env.
Also fixes a pre-existing bug found on the way: webui_app_config.sh
tested "$containers_dir/frontend/data/last_update", one level short of the
real tree under the libreportal app dir, so the WebUI refresh trigger
after a config update has never once fired.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
64 lines
2.1 KiB
Bash
Executable File
64 lines
2.1 KiB
Bash
Executable File
#!/bin/bash
|
|
|
|
dockerComposeSetupFile()
|
|
{
|
|
local app_name="$1"
|
|
local custom_file="$2"
|
|
local custom_path="$3"
|
|
|
|
# Source Filenames
|
|
if [[ $custom_file == "" ]]; then
|
|
local source_compose_file="docker-compose.yml";
|
|
elif [[ $custom_file != "" ]]; then
|
|
local source_compose_file="$custom_file";
|
|
fi
|
|
|
|
if [[ $custom_path == "" ]]; then
|
|
local source_path="$install_containers_dir$app_name"
|
|
elif [[ $custom_path != "" ]]; then
|
|
local source_path="$install_containers_dir$app_name/$custom_path/"
|
|
fi
|
|
|
|
local source_file="$source_path/$source_compose_file"
|
|
|
|
# Target Filenames
|
|
if [[ $compose_setup == "default" ]]; then
|
|
local target_compose_file="docker-compose.yml";
|
|
elif [[ $compose_setup == "app" ]]; then
|
|
local target_compose_file="docker-compose.$app_name.yml";
|
|
fi
|
|
|
|
local target_path="$(appDir "$app_name")"
|
|
local target_file="$target_path/$target_compose_file"
|
|
|
|
|
|
if [ "$app_name" == "" ]; then
|
|
isError "The app_name is empty."
|
|
fi
|
|
|
|
if [ ! -f "$source_file" ]; then
|
|
isError "The source file '$source_file' does not exist."
|
|
fi
|
|
|
|
copyFile "loud" "$source_file" "$target_file" $docker_install_user | runInstallWrite -a "$logs_dir/$docker_log_file" 2>&1
|
|
|
|
if [ $? -ne 0 ]; then
|
|
isError "Failed to copy the source file to '$target_path'. Check '$docker_log_file' for more details."
|
|
fi
|
|
|
|
# Compose files often carry RANDOMIZED* placeholders for service env
|
|
# vars (DB passwords, Laravel APP_KEY, etc). The scanner is a no-op
|
|
# on files without placeholders so it's safe to call unconditionally.
|
|
if declare -F scanFileForRandomPasswordKeysUsers >/dev/null; then
|
|
scanFileForRandomPasswordKeysUsers "$target_file"
|
|
fi
|
|
|
|
# If the app's install template carries a Dockerfile, the compose
|
|
# almost certainly has `build: .` and needs the source tree alongside
|
|
# the deployed compose. dockerCopyBuildContext is itself a no-op for
|
|
# apps with no Dockerfile, so calling here is safe for every app.
|
|
if declare -F dockerCopyBuildContext >/dev/null; then
|
|
dockerCopyBuildContext "$app_name"
|
|
fi
|
|
}
|