From 289c83b5468be89b2528c8dbe29ea169a0268472 Mon Sep 17 00:00:00 2001 From: yalh76 Date: Sun, 23 Feb 2020 17:08:21 +0100 Subject: [PATCH] Apply example_ynh --- conf/nginx.conf | 54 +++++++++++++++++++++++++++---------------------- scripts/backup | 4 ++++ scripts/install | 11 +++++++--- scripts/remove | 1 + scripts/restore | 8 ++++++++ scripts/upgrade | 9 +++++++++ 6 files changed, 60 insertions(+), 27 deletions(-) diff --git a/conf/nginx.conf b/conf/nginx.conf index d7d078b..32a8839 100644 --- a/conf/nginx.conf +++ b/conf/nginx.conf @@ -1,29 +1,35 @@ location /Microsoft-Server-ActiveSync { - alias __FINALPATH__/ ; - if ($scheme = http) { - rewrite ^ https://$server_name$request_uri? permanent; - } - index index.php; - client_max_body_size 50M; - try_files $uri $uri/ index.php; - rewrite ^(.*)$ /Microsoft-Server-ActiveSync/index.php last; - location ~ [^/]\.php(/|$) { - fastcgi_split_path_info ^(.+?\.php)(/.*)$; - fastcgi_pass unix:/var/run/php/php7.0-fpm-__NAME__.sock; - - fastcgi_index index.php; - include fastcgi_params; - fastcgi_param HTTPS on; - fastcgi_read_timeout 630; - fastcgi_param SCRIPT_FILENAME $request_filename; - } + # Path to source + alias __FINALPATH__/ ; -# Include SSOWAT user panel. -include conf.d/yunohost_panel.conf.inc; + # Force usage of https + if ($scheme = http) { + rewrite ^ https://$server_name$request_uri? permanent; + } + + index index.php; + + # Common parameter to increase upload size limit in conjunction with dedicated php-fpm file + client_max_body_size 50M; + try_files $uri $uri/ index.php; + rewrite ^(.*)$ /Microsoft-Server-ActiveSync/index.php last; + location ~ [^/]\.php(/|$) { + fastcgi_split_path_info ^(.+?\.php)(/.*)$; + fastcgi_pass unix:/var/run/php/php7.0-fpm-__NAME__.sock; + + fastcgi_index index.php; + include fastcgi_params; + fastcgi_param HTTPS on; + fastcgi_read_timeout 630; + fastcgi_param SCRIPT_FILENAME $request_filename; + } + + # Include SSOWAT user panel. + include conf.d/yunohost_panel.conf.inc; } location /AutoDiscover/AutoDiscover.xml { - alias __FINALPATH__/autodiscover/autodiscover.php; + alias __FINALPATH__/autodiscover/autodiscover.php; fastcgi_pass unix:/var/run/php/php7.0-fpm-__NAME__.sock; include fastcgi_params; fastcgi_param HTTPS on; @@ -31,7 +37,7 @@ location /AutoDiscover/AutoDiscover.xml { } location /Autodiscover/Autodiscover.xml { - alias __FINALPATH__/autodiscover/autodiscover.php; + alias __FINALPATH__/autodiscover/autodiscover.php; fastcgi_pass unix:/var/run/php/php7.0-fpm-__NAME__.sock; include fastcgi_params; fastcgi_param HTTPS on; @@ -39,9 +45,9 @@ location /Autodiscover/Autodiscover.xml { } location /autodiscover/autodiscover.xml { - alias __FINALPATH__/autodiscover/autodiscover.php; + alias __FINALPATH__/autodiscover/autodiscover.php; fastcgi_pass unix:/var/run/php/php7.0-fpm-__NAME__.sock; include fastcgi_params; fastcgi_param HTTPS on; fastcgi_param SCRIPT_FILENAME $request_filename; -} \ No newline at end of file +} diff --git a/scripts/backup b/scripts/backup index 1707cc1..fd740e8 100755 --- a/scripts/backup +++ b/scripts/backup @@ -13,7 +13,11 @@ source /usr/share/yunohost/helpers #================================================= # MANAGE SCRIPT FAILURE #================================================= +ynh_print_info --message="Managing script failure..." +ynh_clean_setup () { + true +} # Exit if an error occurs during the execution of the script ynh_abort_if_errors diff --git a/scripts/install b/scripts/install index 31b2d4b..fa236d2 100755 --- a/scripts/install +++ b/scripts/install @@ -12,17 +12,22 @@ source /usr/share/yunohost/helpers #================================================= # MANAGE SCRIPT FAILURE #================================================= +ynh_print_info --message="Managing script failure..." +ynh_clean_setup () { + true +} # Exit if an error occurs during the execution of the script ynh_abort_if_errors #================================================= # RETRIEVE ARGUMENTS FROM THE MANIFEST #================================================= +ynh_print_info --message="Retrieving arguments from the manifest..." domain=$YNH_APP_ARG_DOMAIN - path_url="/Microsoft-Server-ActiveSync" + app=$YNH_APP_INSTANCE_NAME #================================================= @@ -79,8 +84,6 @@ ynh_secure_remove "$final_path/tmp" #================================================= ynh_print_info --message="Configuring nginx web server..." -### `ynh_add_nginx_config` will use the file conf/nginx.conf - # Create a dedicated nginx config ynh_add_nginx_config @@ -116,6 +119,7 @@ chown -R $app: $final_logpath #================================================= # MODIFY A CONFIG FILE #================================================= +ynh_print_info --message="Modifying a config file..." # Configuration ynh_replace_string --match_string="__TIMEZONE__" --replace_string=$(cat /etc/timezone) --target_file="../conf/config.php" @@ -209,6 +213,7 @@ ln -s /usr/share/awl/inc/XML* /var/www/$app/include/ #================================================= # SECURE FILES AND DIRECTORIES #================================================= +ynh_print_info --message="Securing files and directories..." # Set permissions to app files chown -R $app: $final_path diff --git a/scripts/remove b/scripts/remove index 0975c57..3f6bad4 100755 --- a/scripts/remove +++ b/scripts/remove @@ -69,6 +69,7 @@ ynh_remove_logrotate #================================================= # REMOVE STATEDIR AND FINAL_LOGPATH #================================================= +ynh_print_info --message="Removing statedir and final_logpath..." ynh_secure_remove --file="$statedir" ynh_secure_remove --file="$final_logpath" diff --git a/scripts/restore b/scripts/restore index 7d11623..56df3f6 100755 --- a/scripts/restore +++ b/scripts/restore @@ -13,7 +13,11 @@ source /usr/share/yunohost/helpers #================================================= # MANAGE SCRIPT FAILURE #================================================= +ynh_print_info --message="Managing script failure..." +ynh_clean_setup () { + true +} # Exit if an error occurs during the execution of the script ynh_abort_if_errors @@ -45,6 +49,7 @@ test ! -d $final_path \ #================================================= # RESTORE THE NGINX CONFIGURATION #================================================= +ynh_print_info --message="Restoring the nginx configuration..." ynh_restore_file --origin_path="/etc/nginx/conf.d/$domain.d/$app.conf" @@ -72,6 +77,7 @@ ynh_system_user_create --username=$app #================================================= # RESTORE USER RIGHTS #================================================= +ynh_print_info --message="Restoring user rights..." # Restore permissions on app files chown -R $app: $final_path @@ -81,6 +87,7 @@ chown -R $app: $final_logpath #================================================= # RESTORE THE PHP-FPM CONFIGURATION #================================================= +ynh_print_info --message="Restoring PHP-FPM configuration..." ynh_restore_file --origin_path="/etc/php/7.0/fpm/pool.d/$app.conf" @@ -97,6 +104,7 @@ ynh_install_app_dependencies $pkg_dependencies #================================================= # RESTORE THE LOGROTATE CONFIGURATION #================================================= +ynh_print_info --message="Restoring the logrotate configuration..." ynh_restore_file --origin_path="/etc/logrotate.d/$app" diff --git a/scripts/upgrade b/scripts/upgrade index 8a05631..e60c67d 100755 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -25,6 +25,7 @@ final_logpath=$(ynh_app_setting_get --app=$app --key=final_logpath) #================================================= # CHECK VERSION #================================================= +ynh_print_info --message="Checking version..." upgrade_type=$(ynh_check_app_version_changed) @@ -80,6 +81,12 @@ ynh_abort_if_errors # CHECK THE PATH #================================================= +# Normalize the URL path syntax +# N.B. : this is for app installations before YunoHost 2.7 +# where this value might be something like /foo/ or foo/ +# instead of /foo .... +# If nobody installed your app before 2.7, then you may +# safely remove this line path_url=$(ynh_normalize_url_path --path_url=$path_url) #================================================= @@ -135,6 +142,7 @@ ynh_add_fpm_config #================================================= # MODIFY A CONFIG FILE #================================================= +ynh_print_info --message="Modifying a config file..." # Configuration ynh_replace_string --match_string="__TIMEZONE__" --replace_string="$(cat /etc/timezone)" --target_file="../conf/config.php" @@ -236,6 +244,7 @@ ynh_use_logrotate --non-append #================================================= # SECURE FILES AND DIRECTORIES #================================================= +ynh_print_info --message="Securing files and directories..." # Set permissions on app files chown -R $app: $final_path