diff --git a/containers/nextcloud/scripts/nextcloud_install_hooks.sh b/containers/nextcloud/scripts/nextcloud_install_hooks.sh new file mode 100644 index 0000000..fca3a8f --- /dev/null +++ b/containers/nextcloud/scripts/nextcloud_install_hooks.sh @@ -0,0 +1,33 @@ +#!/bin/bash + +# Nextcloud install hooks. +# +# The compose bind-mounts ./resources/nginx.conf into the web container, but +# nothing ever copied that file into the container tree — so on a fresh install +# Docker did what Docker does with a missing bind source and created a DIRECTORY +# in its place. nginx then refused to start with: +# +# error mounting ".../resources/nginx.conf" to rootfs at "/etc/nginx/nginx.conf": +# not a directory: Are you trying to mount a directory onto a file? +# +# The app still "installed" — three of four containers came up and the app was +# recorded as installed — so it failed quietly, with only the web front end +# missing. Apps that need a resource file declare the copy in a hook (authelia +# does exactly this); Nextcloud never had one. +# +# post_compose is the right point: the compose file is written, permissions and +# `up` have not run yet, so the mount source exists before anything reads it. + +nextcloud_install_post_compose() +{ + local app_name="$1" + + # Clear a stub directory left behind by any previous attempt, otherwise the + # copy lands INSIDE it (resources/nginx.conf/nginx.conf) and the mount fails + # exactly as before. Shared helper — same repair the WebUI's own config uses. + repairStubDirForFile "$containers_dir$app_name/resources/nginx.conf" "loud" + + local result + result=$(copyResource "$app_name" "nginx.conf" "resources" | runInstallWrite -a "$logs_dir/$docker_log_file" 2>&1) + checkSuccess "Copying nginx.conf to $containers_dir$app_name/resources" +} diff --git a/scripts/source/files/arrays/function_manifest.sh b/scripts/source/files/arrays/function_manifest.sh index 1af4d5d..1e59121 100644 --- a/scripts/source/files/arrays/function_manifest.sh +++ b/scripts/source/files/arrays/function_manifest.sh @@ -700,6 +700,7 @@ declare -gA LP_FN_MAP=( [networkMtuCacheFile]="network/network_mtu.sh" [networkRedetectMtu]="network/network_mtu.sh" [networkScanConflicts]="docker/network/network_conflicts.sh" + [nextcloud_install_post_compose]="nextcloud/scripts/nextcloud_install_hooks.sh" [_nextcloudOcc]="nextcloud/scripts/nextcloud_auth.sh" [_nextcloudOccWithPass]="nextcloud/scripts/nextcloud_auth.sh" [nextcloud_upgrade_verify]="nextcloud/scripts/nextcloud_upgrade_hooks.sh" @@ -1745,6 +1746,7 @@ declare -gA LP_FN_ROOT=( [networkMtuCacheFile]="scripts" [networkRedetectMtu]="scripts" [networkScanConflicts]="scripts" + [nextcloud_install_post_compose]="containers" [_nextcloudOcc]="containers" [_nextcloudOccWithPass]="containers" [nextcloud_upgrade_verify]="containers" @@ -2824,6 +2826,7 @@ networkHealConflicts() { unset -f networkHealConflicts; __lpAutoload "${install_ networkMtuCacheFile() { unset -f networkMtuCacheFile; __lpAutoload "${install_scripts_dir}network/network_mtu.sh"; networkMtuCacheFile "$@"; } networkRedetectMtu() { unset -f networkRedetectMtu; __lpAutoload "${install_scripts_dir}network/network_mtu.sh"; networkRedetectMtu "$@"; } networkScanConflicts() { unset -f networkScanConflicts; __lpAutoload "${install_scripts_dir}docker/network/network_conflicts.sh"; networkScanConflicts "$@"; } +nextcloud_install_post_compose() { unset -f nextcloud_install_post_compose; __lpAutoload "${install_containers_dir}nextcloud/scripts/nextcloud_install_hooks.sh"; nextcloud_install_post_compose "$@"; } _nextcloudOcc() { unset -f _nextcloudOcc; __lpAutoload "${install_containers_dir}nextcloud/scripts/nextcloud_auth.sh"; _nextcloudOcc "$@"; } _nextcloudOccWithPass() { unset -f _nextcloudOccWithPass; __lpAutoload "${install_containers_dir}nextcloud/scripts/nextcloud_auth.sh"; _nextcloudOccWithPass "$@"; } nextcloud_upgrade_verify() { unset -f nextcloud_upgrade_verify; __lpAutoload "${install_containers_dir}nextcloud/scripts/nextcloud_upgrade_hooks.sh"; nextcloud_upgrade_verify "$@"; }