69 lines
1.8 KiB
Bash
Executable File
69 lines
1.8 KiB
Bash
Executable File
#!/usr/bin/env bash
|
|
set -euo pipefail
|
|
|
|
script_dir="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
|
repo_root="$(cd "${script_dir}/.." && pwd)"
|
|
|
|
custom_apps_root="${NEXTCLOUD_CUSTOM_APPS_PATH:-${repo_root}/nextcloud/custom_apps}"
|
|
if [[ "${custom_apps_root}" != /* ]]; then
|
|
custom_apps_root="${repo_root}/${custom_apps_root}"
|
|
fi
|
|
|
|
required_app="qortal_integration"
|
|
optional_apps=(
|
|
"custom_pwa"
|
|
"chd_admin"
|
|
"qortal_files_bridge"
|
|
"qortal_talk_bridge"
|
|
"nuqloud_scrum"
|
|
)
|
|
apps_to_sync=("${required_app}" "${optional_apps[@]}")
|
|
|
|
mkdir -p "${custom_apps_root}"
|
|
|
|
sync_one_app() {
|
|
local app_name="$1"
|
|
local source_dir="${repo_root}/nextcloud/custom_apps/${app_name}"
|
|
local target_dir="${custom_apps_root}/${app_name}"
|
|
|
|
if [[ ! -d "${source_dir}" || ! -f "${source_dir}/appinfo/info.xml" ]]; then
|
|
if [[ "${app_name}" == "${required_app}" ]]; then
|
|
echo "Missing source ${required_app} app at ${source_dir}"
|
|
return 1
|
|
fi
|
|
echo "Skipping optional app ${app_name}; source not found at ${source_dir}"
|
|
return 0
|
|
fi
|
|
|
|
local source_real
|
|
source_real="$(cd "${source_dir}" && pwd -P)"
|
|
local target_real=""
|
|
if [[ -d "${target_dir}" ]]; then
|
|
target_real="$(cd "${target_dir}" && pwd -P)"
|
|
fi
|
|
|
|
if [[ -n "${target_real}" && "${source_real}" == "${target_real}" ]]; then
|
|
echo "${app_name} app already mounted from source path: ${source_dir}"
|
|
return 0
|
|
fi
|
|
|
|
if command -v rsync >/dev/null 2>&1; then
|
|
rsync -a --delete "${source_dir}/" "${target_dir}/"
|
|
else
|
|
rm -rf "${target_dir}"
|
|
mkdir -p "${target_dir}"
|
|
cp -R "${source_dir}/." "${target_dir}/"
|
|
fi
|
|
|
|
if [[ ! -f "${target_dir}/appinfo/info.xml" ]]; then
|
|
echo "Failed to prepare ${app_name} app at ${target_dir}"
|
|
return 1
|
|
fi
|
|
|
|
echo "${app_name} app prepared at ${target_dir}"
|
|
}
|
|
|
|
for app_name in "${apps_to_sync[@]}"; do
|
|
sync_one_app "${app_name}"
|
|
done
|