diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index 6133a24..0000000 --- a/.travis.yml +++ /dev/null @@ -1,7 +0,0 @@ -language: python - -before_install: - - git clone https://github.com/YunoHost/package_linter /tmp/package_linter - -script: -- /tmp/package_linter/package_linter.py ./ \ No newline at end of file diff --git a/check_process b/check_process index e23c831..57664ca 100644 --- a/check_process +++ b/check_process @@ -1,7 +1,7 @@ ;; Test complet ; Manifest - domain="domain.tld" (DOMAIN) - path="/Microsoft-Server-ActiveSync" (PATH) + domain="domain.tld" + path="/Microsoft-Server-ActiveSync" ; Checks pkg_linter=1 setup_sub_dir=1 diff --git a/conf/config.php b/conf/config.php index b7b456d..14cabe9 100644 --- a/conf/config.php +++ b/conf/config.php @@ -65,7 +65,7 @@ * State migration script is available, more informations: https://wiki.z-hub.io/x/xIAa */ define('STATE_MACHINE', 'FILE'); - define('STATE_DIR', '__STATEDIR__/'); + define('STATE_DIR', '__DATADIR__/'); /********************************************************************************** * IPC - InterProcessCommunication diff --git a/conf/nginx.conf b/conf/nginx.conf index 41cf3a2..764a13a 100644 --- a/conf/nginx.conf +++ b/conf/nginx.conf @@ -4,11 +4,6 @@ location /Microsoft-Server-ActiveSync/ { # Path to source alias __FINALPATH__/ ; - # 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 diff --git a/doc/.gitkeep b/doc/.gitkeep new file mode 100644 index 0000000..e69de29 diff --git a/doc/DESCRIPTION.md b/doc/DESCRIPTION.md new file mode 100644 index 0000000..0947fa2 --- /dev/null +++ b/doc/DESCRIPTION.md @@ -0,0 +1 @@ +Z-Push is an Exchange ActiveSync fronted written in PHP which lets you synchronize emails (IMAP/SMTP backend) and calendar/contacts (cardDAV and caldDAV backend) diff --git a/doc/DISCLAIMER.md b/doc/DISCLAIMER.md new file mode 100644 index 0000000..e69de29 diff --git a/doc/screenshots/.gitkeep b/doc/screenshots/.gitkeep new file mode 100644 index 0000000..e69de29 diff --git a/manifest.json b/manifest.json index cf7a981..6e81540 100644 --- a/manifest.json +++ b/manifest.json @@ -8,6 +8,12 @@ }, "version": "2.6.1~ynh3", "url": "https://z-push.org", + "upstream": { + "license": "AGPL-3.0-or-later", + "website": "http://z-push.org", + "admindoc": "https://wiki.z-hub.io/display/ZP/Documentation", + "code": "https://github.com/Z-Hub/Z-Push" + }, "license": "AGPL-3.0-or-later", "maintainer": { "name": "yalh76" @@ -21,7 +27,7 @@ } ], "requirements": { - "yunohost": ">= 4.1.3" + "yunohost": ">= 4.3.0" }, "multi_instance": true, "services": [ @@ -29,11 +35,10 @@ "php7.3-fpm" ], "arguments": { - "install" : [ + "install": [ { "name": "domain", - "type": "domain", - "example": "example.com" + "type": "domain" } ] } diff --git a/scripts/backup b/scripts/backup index 8112f3a..bfb8587 100755 --- a/scripts/backup +++ b/scripts/backup @@ -29,9 +29,9 @@ app=$YNH_APP_INSTANCE_NAME final_path=$(ynh_app_setting_get --app=$app --key=final_path) domain=$(ynh_app_setting_get --app=$app --key=domain) -statedir=$(ynh_app_setting_get --app=$app --key=statedir) -final_logpath=$(ynh_app_setting_get --app=$app --key=final_logpath) phpversion=$(ynh_app_setting_get --app=$app --key=phpversion) +datadir=$(ynh_app_setting_get --app=$app --key=datadir) +final_logpath=$(ynh_app_setting_get --app=$app --key=final_logpath) #================================================= # DECLARE DATA AND CONF FILES TO BACKUP @@ -44,11 +44,11 @@ ynh_print_info --message="Declaring files to be backed up..." ynh_backup --src_path="$final_path" -# Backup statedir -ynh_backup --src_path="$statedir" --is_big +#================================================= +# BACKUP THE DATA DIR +#================================================= -# Backup logs -ynh_backup --src_path="$final_logpath" --is_big +ynh_backup --src_path="$datadir" --is_big #================================================= # BACKUP THE NGINX CONFIGURATION diff --git a/scripts/install b/scripts/install index 9fbdaae..7447786 100755 --- a/scripts/install +++ b/scripts/install @@ -36,11 +36,6 @@ ynh_script_progression --message="Validating installation parameters..." final_path=/var/www/$app test ! -e "$final_path" || ynh_die --message="This path already contains a folder" -statedir="/home/yunohost.app/$app" -test ! -e "$statedir" || ynh_die --message="This path already contains a folder" - -final_logpath="/var/log/$app" - # Register (book) web path ynh_webpath_register --app=$app --domain=$domain --path_url=$path_url @@ -51,8 +46,6 @@ ynh_script_progression --message="Storing installation settings..." ynh_app_setting_set --app=$app --key=domain --value=$domain ynh_app_setting_set --app=$app --key=path --value=$path_url -ynh_app_setting_set --app=$app --key=statedir --value=$statedir -ynh_app_setting_set --app=$app --key=final_logpath --value=$final_logpath #================================================= # STANDARD MODIFICATIONS @@ -69,7 +62,7 @@ ynh_install_app_dependencies $pkg_dependencies ynh_script_progression --message="Configuring system user..." # Create a system user -ynh_system_user_create --username=$app --home_dir="$final_path" +ynh_system_user_create --username=$app --home_dir=$final_path #================================================= # DOWNLOAD, CHECK AND UNPACK SOURCE @@ -107,16 +100,29 @@ phpversion=$(ynh_app_setting_get --app=$app --key=phpversion) #================================================= # SPECIFIC SETUP #================================================= -# CREATE STATEDIR AND FINAL_LOGPATH +# CREATE DATA DIRECTORY #================================================= -ynh_script_progression --message="Creating statedir and final_logpath..." +ynh_script_progression --message="Creating a data directory..." -mkdir -p $statedir -chmod 750 "$statedir" -chmod -R o-rwx "$statedir" -chown -R $app:www-data "$statedir" +datadir=/home/yunohost.app/$app +ynh_app_setting_set --app=$app --key=datadir --value=$datadir + +mkdir -p $datadir + +chmod 750 "$datadir" +chmod -R o-rwx "$datadir" +chown -R $app:www-data "$datadir" + +#================================================= +# CREATE FINAL LOG PATH +#================================================= +ynh_script_progression --message="Creating a final log path..." + +final_logpath="/var/log/$app" +ynh_app_setting_set --app=$app --key=final_logpath --value=$final_logpath mkdir -p $final_logpath + chmod 750 "$final_logpath" chmod -R o-rwx "$final_logpath" chown -R $app:www-data "$final_logpath" @@ -134,7 +140,7 @@ ynh_replace_string --match_string="__FINAL_LOGPATH__" --replace_string=$final_lo # Storage of state_dir in /home/yunohost.app # This contains the sync status in between device and z-push -ynh_replace_string --match_string="__STATEDIR__" --replace_string=$statedir --target_file="../conf/config.php" +ynh_replace_string --match_string="__DATADIR__" --replace_string=$datadir --target_file="../conf/config.php" # Enable caldav carddav support if yunohost app list | grep -q 'id: baikal' ; then diff --git a/scripts/remove b/scripts/remove index 9fd996e..e8dcf2a 100755 --- a/scripts/remove +++ b/scripts/remove @@ -18,18 +18,18 @@ app=$YNH_APP_INSTANCE_NAME domain=$(ynh_app_setting_get --app=$app --key=domain) final_path=$(ynh_app_setting_get --app=$app --key=final_path) -statedir=$(ynh_app_setting_get --app=$app --key=statedir) +datadir=$(ynh_app_setting_get --app=$app --key=datadir) final_logpath=$(ynh_app_setting_get --app=$app --key=final_logpath) #================================================= # STANDARD REMOVE #================================================= -# REMOVE DEPENDENCIES +# REMOVE LOGROTATE CONFIGURATION #================================================= -ynh_script_progression --message="Removing dependencies..." +ynh_script_progression --message="Removing logrotate configuration..." -# Remove metapackage and its dependencies -ynh_remove_app_dependencies +# Remove the app-specific logrotate config +ynh_remove_logrotate #================================================= # REMOVE APP MAIN DIR @@ -39,6 +39,17 @@ ynh_script_progression --message="Removing app main directory..." # Remove the app directory securely ynh_secure_remove --file="$final_path" +#================================================= +# REMOVE DATA DIR +#================================================= + +# Remove the data directory if --purge option is used +if [ "${YNH_APP_PURGE:-0}" -eq 1 ] +then + ynh_script_progression --message="Removing app data directory..." + ynh_secure_remove --file="$datadir" +fi + #================================================= # REMOVE NGINX CONFIGURATION #================================================= @@ -56,21 +67,20 @@ ynh_script_progression --message="Removing PHP-FPM configuration..." ynh_remove_fpm_config #================================================= -# REMOVE LOGROTATE CONFIGURATION +# REMOVE DEPENDENCIES #================================================= -ynh_script_progression --message="Removing logrotate configuration..." +ynh_script_progression --message="Removing dependencies..." -# Remove the app-specific logrotate config -ynh_remove_logrotate +# Remove metapackage and its dependencies +ynh_remove_app_dependencies #================================================= # SPECIFIC REMOVE #================================================= -# REMOVE STATEDIR AND FINAL_LOGPATH +# REMOVE VARIOUS FILES #================================================= -ynh_script_progression --message="Removing statedir and final_logpath..." +ynh_script_progression --message="Removing various files..." -ynh_secure_remove --file="$statedir" ynh_secure_remove --file="$final_logpath" #================================================= diff --git a/scripts/restore b/scripts/restore index b23b13e..e7f0c49 100755 --- a/scripts/restore +++ b/scripts/restore @@ -30,17 +30,15 @@ app=$YNH_APP_INSTANCE_NAME domain=$(ynh_app_setting_get --app=$app --key=domain) path_url=$(ynh_app_setting_get --app=$app --key=path) final_path=$(ynh_app_setting_get --app=$app --key=final_path) -statedir=$(ynh_app_setting_get --app=$app --key=statedir) -final_logpath=$(ynh_app_setting_get --app=$app --key=final_logpath) phpversion=$(ynh_app_setting_get --app=$app --key=phpversion) +datadir=$(ynh_app_setting_get --app=$app --key=datadir) +final_logpath=$(ynh_app_setting_get --app=$app --key=final_logpath) #================================================= # CHECK IF THE APP CAN BE RESTORED #================================================= ynh_script_progression --message="Validating restoration parameters..." -ynh_webpath_available --domain=$domain --path_url=$path_url \ - || ynh_die --message="Path not available: ${domain}${path_url}" test ! -d $final_path \ || ynh_die --message="There is already a directory: $final_path " @@ -59,7 +57,7 @@ ynh_restore_file --origin_path="/etc/nginx/conf.d/$domain.d/$app.conf" 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" +ynh_system_user_create --username=$app --home_dir=$final_path #================================================= # RESTORE THE APP MAIN DIR @@ -68,24 +66,27 @@ ynh_script_progression --message="Restoring the app main directory..." ynh_restore_file --origin_path="$final_path" -# Restore 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" +chmod 750 "$final_path" +chmod -R o-rwx "$final_path" +chown -R $app:www-data "$final_path" -# Restore logs, data & permissions -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 DATA DIRECTORY +#================================================= +ynh_script_progression --message="Restoring the data directory..." + +ynh_restore_file --origin_path="$datadir" --not_mandatory + +mkdir -p $datadir + +chmod 750 "$datadir" +chmod -R o-rwx "$datadir" +chown -R $app:www-data "$datadir" #================================================= # RESTORE THE PHP-FPM CONFIGURATION #================================================= -ynh_script_progression --message="Restoring PHP-FPM configuration..." +ynh_script_progression --message="Restoring the PHP-FPM configuration..." ynh_restore_file --origin_path="/etc/php/$phpversion/fpm/pool.d/$app.conf" diff --git a/scripts/upgrade b/scripts/upgrade index 947a190..42ff8da 100755 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -19,7 +19,7 @@ app=$YNH_APP_INSTANCE_NAME domain=$(ynh_app_setting_get --app=$app --key=domain) path_url=$(ynh_app_setting_get --app=$app --key=path) final_path=$(ynh_app_setting_get --app=$app --key=final_path) -statedir=$(ynh_app_setting_get --app=$app --key=statedir) +datadir=$(ynh_app_setting_get --app=$app --key=datadir) final_logpath=$(ynh_app_setting_get --app=$app --key=final_logpath) #================================================= @@ -29,32 +29,6 @@ ynh_script_progression --message="Checking version..." upgrade_type=$(ynh_check_app_version_changed) -#================================================= -# ENSURE DOWNWARD COMPATIBILITY -#================================================= -ynh_script_progression --message="Ensuring downward compatibility..." - -if [ -z "$statedir" ]; -then - statedir="/home/yunohost.app/$app" - ynh_app_setting_set --app=$app --key=statedir --value=$statedir - mkdir -p $statedir -fi - -if [ -z "$final_logpath" ]; -then - final_logpath="/var/log/$app" - ynh_app_setting_set --app=$app --key=final_logpath --value=$final_logpath - mkdir -p $final_logpath -fi - -# Cleaning legacy permissions -if ynh_legacy_permissions_exists; then - ynh_legacy_permissions_delete_all - - ynh_app_setting_delete --app=$app --key=is_public -fi - #================================================= # BACKUP BEFORE UPGRADE THEN ACTIVE TRAP #================================================= @@ -71,13 +45,40 @@ ynh_abort_if_errors #================================================= # STANDARD UPGRADE STEPS +#================================================= +# ENSURE DOWNWARD COMPATIBILITY +#================================================= +ynh_script_progression --message="Ensuring downward compatibility..." + +if [ -z "$datadir" ]; +then + datadir="/home/yunohost.app/$app" + ynh_app_setting_set --app=$app --key=datadir --value=$datadir + ynh_app_setting_delete --app=$app --key=statedir + mkdir -p $datadir +fi + +if [ -z "$final_logpath" ]; +then + final_logpath="/var/log/$app" + ynh_app_setting_set --app=$app --key=final_logpath --value=$final_logpath + mkdir -p $final_logpath +fi + +# Cleaning legacy permissions +if ynh_legacy_permissions_exists; then + ynh_legacy_permissions_delete_all + + ynh_app_setting_delete --app=$app --key=is_public +fi + #================================================= # 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" +ynh_system_user_create --username=$app --home_dir=$final_path #================================================= # DOWNLOAD, CHECK AND UNPACK SOURCE @@ -137,7 +138,7 @@ ynh_replace_string --match_string="__FINAL_LOGPATH__" --replace_string="$final_l # Storage of state_dir in /home/yunohost.app # This contains the sync status in between device and z-push -ynh_replace_string __STATEDIR__ $statedir ../conf/config.php +ynh_replace_string __DATADIR__ $datadir ../conf/config.php # Enable caldav carddav support if yunohost app list | grep -q 'id: baikal' ; then