1
0
Fork 0
mirror of https://github.com/YunoHost-Apps/z-push_ynh.git synced 2024-09-03 18:05:58 +02:00

Merge pull request #70 from YunoHost-Apps/example

Apply last example_ynh
This commit is contained in:
yalh76 2021-04-21 21:54:40 +02:00 committed by GitHub
commit 2b31f87889
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
9 changed files with 128 additions and 150 deletions

View file

@ -11,25 +11,14 @@ Z-Push is an Exchange ActiveSync fronted written in PHP which lets you synchroni
**Shipped version:** 2.6.1
## Current status
- [x] Z-Push for YunoHost supports IMAP sync and CardDAV/CalDAV sync if Baïkal or Nextcloud is installed
- [x] Ability to send calendar invitations
- [x] Use of push for emails, contacts and calendar
- [x] Sync States are now stored in `/home/yunohost.app/$app`
- [x] Logrotate has been activated as Z-Push can become noisy at times
- [x] Z-Push is now configured to use SMTP to send emails instead of `php_mail()` function. This let us have emails signed by dkim for example.
- [x] The current IMAP backend configuration seems able to handle email addresses different from login (for example login: john and email john.doe@domain.tld instead of john@domain.tld) - Further testing required!
- [x] The sources are based on http://download.z-push.org/final/
- [x] Autodiscover implemented
## Documentation
* Official documentation: https://wiki.z-hub.io/display/ZP/Documentation
#### 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

View file

@ -1,5 +1,4 @@
;; Test complet
auto_remove=1
; Manifest
domain="domain.tld" (DOMAIN)
path="/Microsoft-Server-ActiveSync" (PATH)
@ -17,6 +16,8 @@
upgrade=1 from_commit=a857788c1fb369baa5f0608da12013b003cceed3
# 2.6.1~ynh1
upgrade=1 from_commit=a05896f0e4f2b015dcf643c644ac6c98c2f6695b
# 2.6.1~ynh2
upgrade=1 from_commit=8e99ec37fb90d1ac4f8eb2c838e6d2e1f5b0c905
backup_restore=1
multi_instance=1
port_already_use=0
@ -31,3 +32,5 @@ Notification=all
name=2.5.2~ynh1
; commit=a05896f0e4f2b015dcf643c644ac6c98c2f6695b
name=2.6.1~ynh1
; commit=8e99ec37fb90d1ac4f8eb2c838e6d2e1f5b0c905
name=2.6.1~ynh2

View file

@ -6,7 +6,7 @@
"en": "ActiveSync frontend that helps you synchronize emails, calendar and contacts",
"fr": "Frontend ActiveSync qui permet de synchroniser emails, calendrier et contacts"
},
"version": "2.6.1~ynh2",
"version": "2.6.1~ynh3",
"url": "https://z-push.org",
"license": "AGPL-3.0-or-later",
"maintainer": {
@ -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"
}
]

View file

@ -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

View file

@ -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 --home_dir="$final_path"
#=================================================
# DOWNLOAD, CHECK AND UNPACK SOURCE
#=================================================
@ -70,34 +78,29 @@ ynh_script_progression --message="Setting up source files..."
ynh_app_setting_set --app=$app --key=final_path --value=$final_path
# Download, check integrity, uncompress and patch the source from app.src
mkdir "$final_path"
mkdir "$final_path/tmp"
mkdir -p "$final_path/tmp"
ynh_setup_source --dest_dir="$final_path/tmp"
cp -a "$final_path/tmp/src/." "$final_path/."
cp -af "$final_path/tmp/src/." "$final_path/."
ynh_secure_remove "$final_path/tmp"
chmod 750 "$final_path"
chmod -R o-rwx "$final_path"
chown -R $app:www-data "$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 +112,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 $app:www-data "$statedir"
mkdir -p $final_logpath
chown -R $app: $final_logpath
chmod 750 "$final_logpath"
chmod -R o-rwx "$final_logpath"
chown -R $app:www-data "$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"
@ -153,10 +160,10 @@ if yunohost app list | grep -q 'id: baikal' ; then
ynh_replace_string --match_string="__FLAGTOCHANGE__" --replace_string="true" --target_file="../conf/backend/config-imap.php"
# Copy config
cp ../conf/backend/config-caldav.php $final_path/backend/caldav/config.php
cp ../conf/backend/config-carddav.php $final_path/backend/carddav/config.php
cp ../conf/backend/config-imap.php $final_path/backend/imap/config.php
cp ../conf/backend/config-combined.php $final_path/backend/combined/config.php
cp -af ../conf/backend/config-caldav.php $final_path/backend/caldav/config.php
cp -af ../conf/backend/config-carddav.php $final_path/backend/carddav/config.php
cp -af ../conf/backend/config-imap.php $final_path/backend/imap/config.php
cp -af ../conf/backend/config-combined.php $final_path/backend/combined/config.php
elif yunohost app list | grep -q 'id: nextcloud' ; then
echo "Detected NextCloud"
@ -181,10 +188,10 @@ elif yunohost app list | grep -q 'id: nextcloud' ; then
ynh_replace_string --match_string="__FLAGTOCHANGE__" --replace_string="true" --target_file="../conf/backend/config-imap.php"
# Copy config
cp ../conf/backend/config-caldav.php $final_path/backend/caldav/config.php
cp ../conf/backend/config-carddav.php $final_path/backend/carddav/config.php
cp ../conf/backend/config-imap.php $final_path/backend/imap/config.php
cp ../conf/backend/config-combined.php $final_path/backend/combined/config.php
cp -af ../conf/backend/config-caldav.php $final_path/backend/caldav/config.php
cp -af ../conf/backend/config-carddav.php $final_path/backend/carddav/config.php
cp -af ../conf/backend/config-imap.php $final_path/backend/imap/config.php
cp -af ../conf/backend/config-combined.php $final_path/backend/combined/config.php
else
# Configuration of backend
ynh_replace_string --match_string="__BACKEND__" --replace_string="BackendIMAP" --target_file="../conf/config.php"
@ -195,27 +202,19 @@ else
ynh_replace_string --match_string="__FLAGTOCHANGE__" --replace_string="false" --target_file="../conf/backend/config-imap.php"
# Copy config
cp ../conf/backend/config-imap.php $final_path/backend/imap/config.php
cp -af ../conf/backend/config-imap.php $final_path/backend/imap/config.php
fi
# Copy config
cp ../conf/config.php $final_path/config.php
cp ../conf/backend/config-autodiscover.php $final_path/autodiscover/config.php
cp ../conf/backend/config-searchldap.php $final_path/backend/searchldap/config.php
cp -af ../conf/config.php $final_path/config.php
cp -af ../conf/backend/config-autodiscover.php $final_path/autodiscover/config.php
cp -af ../conf/backend/config-searchldap.php $final_path/backend/searchldap/config.php
#Copy XMLElement.php
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
#=================================================
@ -233,7 +232,7 @@ ynh_script_progression --message="Configuring permissions..."
ynh_permission_update --permission="main" --add="visitors"
domain_regex=$(echo "$domain" | sed 's@-@.@g')
ynh_permission_create --permission="autodiscover" --url "re:$domain_regex/[Aa]uto[Dd]iscover/.*" --allowed="visitors" --show_tile="false" --protected="true"
ynh_permission_create --permission="autodiscover" --url="re:$domain_regex/[Aa]uto[Dd]iscover/.*" --allowed="visitors" --show_tile="false" --protected="true"
#=================================================
# RELOAD NGINX

View file

@ -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
#=================================================

View file

@ -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
@ -23,7 +23,7 @@ ynh_abort_if_errors
#=================================================
# LOAD SETTINGS
#=================================================
ynh_script_progression --message="Loading settings..."
ynh_script_progression --message="Loading installation settings..."
app=$YNH_APP_INSTANCE_NAME
@ -49,10 +49,18 @@ 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"
#=================================================
# RECREATE THE DEDICATED USER
#=================================================
ynh_script_progression --message="Recreating the dedicated system user..."
# Create the dedicated user (if not existing)
ynh_system_user_create --username=$app --home_dir="$final_path"
#=================================================
# RESTORE THE APP MAIN DIR
#=================================================
@ -61,28 +69,18 @@ ynh_script_progression --message="Restoring the app main directory..."
ynh_restore_file --origin_path="$final_path"
# Restore statedir
ynh_restore_file --origin_path="$statedir"
ynh_restore_file --origin_path="$statedir" --not_mandatory
mkdir -p $statedir
chmod 750 "$statedir"
chmod -R o-rwx "$statedir"
chown -R $app:www-data "$statedir"
# Restore logs, data & permissions
ynh_restore_file --origin_path="$final_logpath"
#=================================================
# RECREATE THE DEDICATED USER
#=================================================
ynh_script_progression --message="Recreating the dedicated system user..."
# Create the dedicated user (if not existing)
ynh_system_user_create --username=$app
#=================================================
# RESTORE USER RIGHTS
#=================================================
ynh_script_progression --message="Restoring user rights..."
# 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_logpath" --not_mandatory
mkdir -p $final_logpath
chmod 750 "$final_logpath"
chmod -R o-rwx "$final_logpath"
chown -R $app:www-data "$final_logpath"
#=================================================
# RESTORE THE PHP-FPM CONFIGURATION

View file

@ -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 --home_dir="$final_path"
#=================================================
# DOWNLOAD, CHECK AND UNPACK SOURCE
#=================================================
@ -82,16 +90,20 @@ then
# Download, check integrity, uncompress and patch the source from app.src
mkdir "$final_path/tmp"
ynh_setup_source --dest_dir="$final_path/tmp"
cp -a "$final_path/tmp/src/." "$final_path/."
cp -af "$final_path/tmp/src/." "$final_path/."
ynh_secure_remove --file="$final_path/tmp"
fi
chmod 750 "$final_path"
chmod -R o-rwx "$final_path"
chown -R $app:www-data "$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"
@ -159,10 +163,10 @@ if yunohost app list | grep -q 'id: baikal' ; then
ynh_replace_string --match_string="__FLAGTOCHANGE__" --replace_string="true" --target_file="../conf/backend/config-imap.php"
# Copy config
cp ../conf/backend/config-caldav.php $final_path/backend/caldav/config.php
cp ../conf/backend/config-carddav.php $final_path/backend/carddav/config.php
cp ../conf/backend/config-imap.php $final_path/backend/imap/config.php
cp ../conf/backend/config-combined.php $final_path/backend/combined/config.php
cp -af ../conf/backend/config-caldav.php $final_path/backend/caldav/config.php
cp -af ../conf/backend/config-carddav.php $final_path/backend/carddav/config.php
cp -af ../conf/backend/config-imap.php $final_path/backend/imap/config.php
cp -af ../conf/backend/config-combined.php $final_path/backend/combined/config.php
elif yunohost app list | grep -q 'id: nextcloud' ; then
echo "Detected NextCloud"
@ -187,10 +191,10 @@ elif yunohost app list | grep -q 'id: nextcloud' ; then
ynh_replace_string --match_string="__FLAGTOCHANGE__" --replace_string="true" --target_file="../conf/backend/config-imap.php"
# Copy config
cp ../conf/backend/config-caldav.php $final_path/backend/caldav/config.php
cp ../conf/backend/config-carddav.php $final_path/backend/carddav/config.php
cp ../conf/backend/config-imap.php $final_path/backend/imap/config.php
cp ../conf/backend/config-combined.php $final_path/backend/combined/config.php
cp -af ../conf/backend/config-caldav.php $final_path/backend/caldav/config.php
cp -af ../conf/backend/config-carddav.php $final_path/backend/carddav/config.php
cp -af ../conf/backend/config-imap.php $final_path/backend/imap/config.php
cp -af ../conf/backend/config-combined.php $final_path/backend/combined/config.php
else
# Configuration of backend
ynh_replace_string --match_string="__BACKEND__" --replace_string="BackendIMAP" --target_file="../conf/config.php"
@ -201,30 +205,19 @@ else
ynh_replace_string --match_string="__FLAGTOCHANGE__" --replace_string="false" --target_file="../conf/backend/config-imap.php"
# Copy config
cp ../conf/backend/config-imap.php $final_path/backend/imap/config.php
cp -af ../conf/backend/config-imap.php $final_path/backend/imap/config.php
fi
# Copy config
cp ../conf/config.php $final_path/config.php
cp ../conf/backend/config-autodiscover.php $final_path/autodiscover/config.php
cp ../conf/backend/config-searchldap.php $final_path/backend/searchldap/config.php
cp -af ../conf/config.php $final_path/config.php
cp -af ../conf/backend/config-autodiscover.php $final_path/autodiscover/config.php
cp -af ../conf/backend/config-searchldap.php $final_path/backend/searchldap/config.php
# Fixstates to avoid full resync of devices after version upgrades
$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
#=================================================