1
0
Fork 0
mirror of https://github.com/YunoHost-Apps/nextcloud_ynh.git synced 2024-09-03 19:55:57 +02:00

Merge pull request #712 from YunoHost-Apps/fix-dav-detection

wait until nginx has actually remove the nextcloud conf during upgrad…
This commit is contained in:
Kayou 2024-08-01 14:09:18 +02:00 committed by GitHub
commit 79c87b1b2b
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 28 additions and 10 deletions

View file

@ -8,6 +8,19 @@
# EXPERIMENTAL HELPERS # EXPERIMENTAL HELPERS
#================================================= #=================================================
wait_nginx_reload() {
# Nginx may take some time to support the new configuration,
# wait for the nextcloud configuration file to disappear from nginx before checking the CalDAV/CardDAV URL.
timeout=30
for i in $(seq 1 $timeout); do
if ! ynh_exec_warn_less nginx -T | grep --quiet "# configuration file /etc/nginx/conf.d/$domain.d/$app.conf:"; then
break
fi
sleep 1
done
}
# Check if an URL is already handled # Check if an URL is already handled
# usage: is_url_handled --domain=DOMAIN --path=PATH_URI # usage: is_url_handled --domain=DOMAIN --path=PATH_URI
is_url_handled() { is_url_handled() {

View file

@ -14,6 +14,19 @@ source /usr/share/yunohost/helpers
#================================================= #=================================================
ynh_script_progression --message="Updating NGINX web server configuration..." --weight=2 ynh_script_progression --message="Updating NGINX web server configuration..." --weight=2
if [ $change_domain -eq 1 ]
then
# Check if .well-known is available for this domain
if is_url_handled --domain="$new_domain" --path="/.well-known/caldav" || is_url_handled --domain="$new_domain" --path="/.well-known/carddav"
then
ynh_print_warn --message="Another app already uses the domain $new_domain to serve a CalDAV/CardDAV feature. You may encounter issues when dealing with your calendar or address book."
# Remove lines about .well-known/carddav and caldav with sed.
sed --in-place --regexp-extended '/location = \/\.well\-known\/(caldav|carddav)/d' "/etc/nginx/conf.d/$domain.d/$app.conf"
ynh_store_file_checksum --file="/etc/nginx/conf.d/$domain.d/$app.conf"
fi
fi
ynh_change_url_nginx_config ynh_change_url_nginx_config
#================================================= #=================================================
@ -37,16 +50,6 @@ then
# Reload php fpm, necessary for force nextcloud to re-read config.php, cf opcache.revalidate_freq # Reload php fpm, necessary for force nextcloud to re-read config.php, cf opcache.revalidate_freq
ynh_systemd_action --service_name=php${phpversion}-fpm --action=reload ynh_systemd_action --service_name=php${phpversion}-fpm --action=reload
# Check if .well-known is available for this domain
if is_url_handled --domain="$new_domain" --path="/.well-known/caldav" || is_url_handled --domain="$new_domain" --path="/.well-known/carddav"
then
ynh_print_warn --message="Another app already uses the domain $new_domain to serve a CalDAV/CardDAV feature. You may encounter issues when dealing with your calendar or address book."
# Remove lines about .well-known/carddav and caldav with sed.
sed --in-place --regexp-extended '/location = \/\.well\-known\/(caldav|carddav)/d' "/etc/nginx/conf.d/$new_domain.d/$app.conf"
ynh_store_file_checksum --file="/etc/nginx/conf.d/$new_domain.d/$app.conf"
fi
fi fi
#================================================= #=================================================

View file

@ -357,6 +357,8 @@ ynh_app_setting_delete --app=$app --key="checksum__etc_nginx_conf.d_$domain.d_$a
# Wait untils NGINX has fully reloaded # Wait untils NGINX has fully reloaded
ynh_systemd_action --service_name=nginx --action=reload --line_match="Reloaded" --log_path="systemd" ynh_systemd_action --service_name=nginx --action=reload --line_match="Reloaded" --log_path="systemd"
wait_nginx_reload
# Check if .well-known is available for this domain # Check if .well-known is available for this domain
if is_url_handled --domain="$domain" --path="/.well-known/caldav" || is_url_handled --domain="$domain" --path="/.well-known/carddav" if is_url_handled --domain="$domain" --path="/.well-known/caldav" || is_url_handled --domain="$domain" --path="/.well-known/carddav"
then then