From a734ac22aa5b4faa86507e8078ceeed28c7196f5 Mon Sep 17 00:00:00 2001 From: yalh76 Date: Fri, 9 Apr 2021 20:48:50 +0200 Subject: [PATCH] Apply last example_ynh --- README.md | 4 ++-- check_process | 55 ++++++++++++++++++++++++------------------------- conf/nginx.conf | 2 +- manifest.json | 4 ---- scripts/backup | 6 +++--- scripts/install | 44 +++++++++++++++++++-------------------- scripts/remove | 4 ++-- scripts/restore | 40 +++++++++++++++++------------------ scripts/upgrade | 41 +++++++++++++++--------------------- 9 files changed, 94 insertions(+), 106 deletions(-) diff --git a/README.md b/README.md index 45ab151..b9da417 100644 --- a/README.md +++ b/README.md @@ -28,8 +28,8 @@ Z-Push is an Exchange ActiveSync fronted written in PHP which lets you synchroni #### Supported architectures -* x86-64 - [![Build Status](https://ci-apps.yunohost.org/ci/logs/z-push%20%28Apps%29.svg)](https://ci-apps.yunohost.org/ci/apps/z-push/) -* ARMv8-A - [![Build Status](https://ci-apps-arm.yunohost.org/ci/logs/z-push%20%28Apps%29.svg)](https://ci-apps-arm.yunohost.org/ci/apps/z-push/) +* x86-64 - [![Build Status](https://ci-apps.yunohost.org/ci/logs/z-push.svg)](https://ci-apps.yunohost.org/ci/apps/z-push/) +* ARMv8-A - [![Build Status](https://ci-apps-arm.yunohost.org/ci/logs/z-push.svg)](https://ci-apps-arm.yunohost.org/ci/apps/z-push/) ## Links diff --git a/check_process b/check_process index ee41019..8983981 100644 --- a/check_process +++ b/check_process @@ -1,33 +1,32 @@ ;; Test complet - auto_remove=1 - ; Manifest - domain="domain.tld" (DOMAIN) - path="/Microsoft-Server-ActiveSync" (PATH) - ; Checks - pkg_linter=1 - setup_sub_dir=1 - setup_root=0 - setup_nourl=0 - setup_private=0 - setup_public=1 - upgrade=1 - # 2.5.1~ynh3 - upgrade=1 from_commit=9e8a72669814237122dfc6f901c9377895c193db - # 2.5.2~ynh1 - upgrade=1 from_commit=a857788c1fb369baa5f0608da12013b003cceed3 - # 2.6.1~ynh1 - upgrade=1 from_commit=a05896f0e4f2b015dcf643c644ac6c98c2f6695b - backup_restore=1 - multi_instance=1 - port_already_use=0 - change_url=0 + ; Manifest + domain="domain.tld" (DOMAIN) + path="/Microsoft-Server-ActiveSync" (PATH) + ; Checks + pkg_linter=1 + setup_sub_dir=1 + setup_root=0 + setup_nourl=0 + setup_private=0 + setup_public=1 + upgrade=1 + # 2.5.1~ynh3 + upgrade=1 from_commit=9e8a72669814237122dfc6f901c9377895c193db + # 2.5.2~ynh1 + upgrade=1 from_commit=a857788c1fb369baa5f0608da12013b003cceed3 + # 2.6.1~ynh1 + upgrade=1 from_commit=a05896f0e4f2b015dcf643c644ac6c98c2f6695b + backup_restore=1 + multi_instance=1 + port_already_use=0 + change_url=0 ;;; Options Email=yalh@yahoo.com Notification=all ;;; Upgrade options - ; commit=9e8a72669814237122dfc6f901c9377895c193db - name=2.5.1~ynh3 - ; commit=a857788c1fb369baa5f0608da12013b003cceed3 - name=2.5.2~ynh1 - ; commit=a05896f0e4f2b015dcf643c644ac6c98c2f6695b - name=2.6.1~ynh1 + ; commit=9e8a72669814237122dfc6f901c9377895c193db + name=2.5.1~ynh3 + ; commit=a857788c1fb369baa5f0608da12013b003cceed3 + name=2.5.2~ynh1 + ; commit=a05896f0e4f2b015dcf643c644ac6c98c2f6695b + name=2.6.1~ynh1 diff --git a/conf/nginx.conf b/conf/nginx.conf index 70e4d41..41cf3a2 100644 --- a/conf/nginx.conf +++ b/conf/nginx.conf @@ -13,7 +13,7 @@ location /Microsoft-Server-ActiveSync/ { # 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(/|$) { diff --git a/manifest.json b/manifest.json index 44f0e06..ecf5315 100644 --- a/manifest.json +++ b/manifest.json @@ -33,10 +33,6 @@ { "name": "domain", "type": "domain", - "ask": { - "en": "Choose a domain for Z-Push", - "fr": "Choisissez un domaine pour Z-Push" - }, "example": "example.com" } ] diff --git a/scripts/backup b/scripts/backup index 89a96c0..8112f3a 100755 --- a/scripts/backup +++ b/scripts/backup @@ -6,7 +6,7 @@ # IMPORT GENERIC HELPERS #================================================= -#Keep this path for calling _common.sh inside the execution's context of backup and restore scripts +# Keep this path for calling _common.sh inside the execution's context of backup and restore scripts source ../settings/scripts/_common.sh source /usr/share/yunohost/helpers @@ -45,10 +45,10 @@ ynh_print_info --message="Declaring files to be backed up..." ynh_backup --src_path="$final_path" # Backup statedir -ynh_backup --src_path="$statedir" +ynh_backup --src_path="$statedir" --is_big # Backup logs -ynh_backup --src_path="$final_logpath" +ynh_backup --src_path="$final_logpath" --is_big #================================================= # BACKUP THE NGINX CONFIGURATION diff --git a/scripts/install b/scripts/install index df6f985..068d833 100755 --- a/scripts/install +++ b/scripts/install @@ -63,6 +63,14 @@ ynh_script_progression --message="Installing dependencies..." ynh_install_app_dependencies $pkg_dependencies +#================================================= +# CREATE DEDICATED USER +#================================================= +ynh_script_progression --message="Configuring system user..." + +# Create a system user +ynh_system_user_create --username=$app + #================================================= # DOWNLOAD, CHECK AND UNPACK SOURCE #================================================= @@ -76,28 +84,24 @@ ynh_setup_source --dest_dir="$final_path/tmp" cp -a "$final_path/tmp/src/." "$final_path/." ynh_secure_remove "$final_path/tmp" +chmod 750 "$final_path" +chmod -R o-rwx "$final_path" +chown -R root:$app "$final_path" + #================================================= # NGINX CONFIGURATION #================================================= ynh_script_progression --message="Configuring NGINX web server..." -# Create a dedicated nginx config +# Create a dedicated NGINX config ynh_add_nginx_config -#================================================= -# CREATE DEDICATED USER -#================================================= -ynh_script_progression --message="Configuring system user..." - -# Create a system user -ynh_system_user_create --username=$app - #================================================= # PHP-FPM CONFIGURATION #================================================= ynh_script_progression --message="Configuring PHP-FPM..." -# Create a dedicated php-fpm config +# Create a dedicated PHP-FPM config ynh_add_fpm_config --usage=low --footprint=low --package="$extra_php_dependencies" phpversion=$(ynh_app_setting_get --app=$app --key=phpversion) @@ -109,15 +113,19 @@ phpversion=$(ynh_app_setting_get --app=$app --key=phpversion) ynh_script_progression --message="Creating statedir and final_logpath..." mkdir -p $statedir -chown -R $app: $statedir +chmod 750 "$statedir" +chmod -R o-rwx "$statedir" +chown -R root:$app "$statedir" mkdir -p $final_logpath -chown -R $app: $final_logpath +chmod 750 "$final_logpath" +chmod -R o-rwx "$final_logpath" +chown -R root:$app "$final_logpath" #================================================= -# MODIFY A CONFIG FILE +# ADD A CONFIGURATION #================================================= -ynh_script_progression --message="Modifying a config file..." +ynh_script_progression --message="Adding a config file..." # Configuration ynh_replace_string --match_string="__TIMEZONE__" --replace_string=$(cat /etc/timezone) --target_file="../conf/config.php" @@ -208,14 +216,6 @@ ln -s /usr/share/awl/inc/XML* /var/www/$app/include/ #================================================= # GENERIC FINALIZATION -#================================================= -# SECURE FILES AND DIRECTORIES -#================================================= -ynh_script_progression --message="Securing files and directories..." - -# Set permissions to app files -chown -R $app: $final_path - #================================================= # SETUP LOGROTATE #================================================= diff --git a/scripts/remove b/scripts/remove index 710d389..9fd996e 100755 --- a/scripts/remove +++ b/scripts/remove @@ -44,7 +44,7 @@ ynh_secure_remove --file="$final_path" #================================================= ynh_script_progression --message="Removing NGINX web server configuration..." -# Remove the dedicated nginx config +# Remove the dedicated NGINX config ynh_remove_nginx_config #================================================= @@ -52,7 +52,7 @@ ynh_remove_nginx_config #================================================= ynh_script_progression --message="Removing PHP-FPM configuration..." -# Remove the dedicated php-fpm config +# Remove the dedicated PHP-FPM config ynh_remove_fpm_config #================================================= diff --git a/scripts/restore b/scripts/restore index 1690a70..172258b 100755 --- a/scripts/restore +++ b/scripts/restore @@ -49,23 +49,10 @@ test ! -d $final_path \ #================================================= # RESTORE THE NGINX CONFIGURATION #================================================= -ynh_script_progression --message="Restoring the NGINX configuration..." +ynh_script_progression --message="Restoring the NGINX web server configuration..." ynh_restore_file --origin_path="/etc/nginx/conf.d/$domain.d/$app.conf" -#================================================= -# RESTORE THE APP MAIN DIR -#================================================= -ynh_script_progression --message="Restoring the app main directory..." - -ynh_restore_file --origin_path="$final_path" - -# Restore statedir -ynh_restore_file --origin_path="$statedir" - -# Restore logs, data & permissions -ynh_restore_file --origin_path="$final_logpath" - #================================================= # RECREATE THE DEDICATED USER #================================================= @@ -75,14 +62,27 @@ ynh_script_progression --message="Recreating the dedicated system user..." ynh_system_user_create --username=$app #================================================= -# RESTORE USER RIGHTS +# RESTORE THE APP MAIN DIR #================================================= -ynh_script_progression --message="Restoring user rights..." +ynh_script_progression --message="Restoring the app main directory..." -# Restore permissions on app files -chown -R $app: $final_path -chown -R $app: $statedir -chown -R $app: $final_logpath +ynh_restore_file --origin_path="$final_path" + +# Restore statedir +ynh_restore_file --origin_path="$statedir" --not_mandatory + +# Restore logs, data & permissions +ynh_restore_file --origin_path="$final_logpath" --not_mandatory + +mkdir -p $statedir +chmod 750 "$statedir" +chmod -R o-rwx "$statedir" +chown -R root:$app "$statedir" + +mkdir -p $final_logpath +chmod 750 "$final_logpath" +chmod -R o-rwx "$final_logpath" +chown -R root:$app "$final_logpath" #================================================= # RESTORE THE PHP-FPM CONFIGURATION diff --git a/scripts/upgrade b/scripts/upgrade index 0fa9dd8..cd409be 100755 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -63,7 +63,7 @@ ynh_script_progression --message="Backing up the app before upgrading (may take # Backup the current version of the app ynh_backup_before_upgrade ynh_clean_setup () { - # restore it if the upgrade fails + # Restore it if the upgrade fails ynh_restore_upgradebackup } # Exit if an error occurs during the execution of the script @@ -71,6 +71,14 @@ ynh_abort_if_errors #================================================= # STANDARD UPGRADE STEPS +#================================================= +# CREATE DEDICATED USER +#================================================= +ynh_script_progression --message="Making sure dedicated system user exists..." + +# Create a dedicated user (if not existing) +ynh_system_user_create --username=$app + #================================================= # DOWNLOAD, CHECK AND UNPACK SOURCE #================================================= @@ -86,12 +94,16 @@ then ynh_secure_remove --file="$final_path/tmp" fi +chmod 750 "$final_path" +chmod -R o-rwx "$final_path" +chown -R root:$app "$final_path" + #================================================= # NGINX CONFIGURATION #================================================= ynh_script_progression --message="Upgrading NGINX web server configuration..." -# Create a dedicated nginx config +# Create a dedicated NGINX config ynh_add_nginx_config #================================================= @@ -101,29 +113,21 @@ ynh_script_progression --message="Upgrading dependencies..." ynh_install_app_dependencies $pkg_dependencies -#================================================= -# CREATE DEDICATED USER -#================================================= -ynh_script_progression --message="Making sure dedicated system user exists..." - -# Create a dedicated user (if not existing) -ynh_system_user_create --username=$app - #================================================= # PHP-FPM CONFIGURATION #================================================= ynh_script_progression --message="Upgrading PHP-FPM configuration..." -# Create a dedicated php-fpm config +# Create a dedicated PHP-FPM config ynh_add_fpm_config --usage=low --footprint=low --package="$extra_php_dependencies" phpversion=$(ynh_app_setting_get --app=$app --key=phpversion) #================================================= # SPECIFIC UPGRADE #================================================= -# MODIFY A CONFIG FILE +# UPDATE A CONFIG FILE #================================================= -ynh_script_progression --message="Modifying a config file..." +ynh_script_progression --message="Updating a config file..." # Configuration ynh_replace_string --match_string="__TIMEZONE__" --replace_string="$(cat /etc/timezone)" --target_file="../conf/config.php" @@ -214,17 +218,6 @@ $final_path/z-push-admin.php -a fixstates #================================================= # GENERIC FINALIZATION -#================================================= -# SECURE FILES AND DIRECTORIES -#================================================= -ynh_script_progression --message="Securing files and directories..." - -# Set permissions on app files -chown -R $app: $final_path - -chown -R $app: $statedir -chown -R $app: $final_logpath - #================================================= # SETUP LOGROTATE #=================================================