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

Apply Lest example_ynh

This commit is contained in:
yalh76 2022-01-18 22:08:28 +01:00
parent f101d8cb57
commit 464937d8fc
14 changed files with 111 additions and 99 deletions

View file

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

View file

@ -1,7 +1,7 @@
;; Test complet ;; Test complet
; Manifest ; Manifest
domain="domain.tld" (DOMAIN) domain="domain.tld"
path="/Microsoft-Server-ActiveSync" (PATH) path="/Microsoft-Server-ActiveSync"
; Checks ; Checks
pkg_linter=1 pkg_linter=1
setup_sub_dir=1 setup_sub_dir=1

View file

@ -65,7 +65,7 @@
* State migration script is available, more informations: https://wiki.z-hub.io/x/xIAa * State migration script is available, more informations: https://wiki.z-hub.io/x/xIAa
*/ */
define('STATE_MACHINE', 'FILE'); define('STATE_MACHINE', 'FILE');
define('STATE_DIR', '__STATEDIR__/'); define('STATE_DIR', '__DATADIR__/');
/********************************************************************************** /**********************************************************************************
* IPC - InterProcessCommunication * IPC - InterProcessCommunication

View file

@ -4,11 +4,6 @@ location /Microsoft-Server-ActiveSync/ {
# Path to source # Path to source
alias __FINALPATH__/ ; alias __FINALPATH__/ ;
# Force usage of https
if ($scheme = http) {
rewrite ^ https://$server_name$request_uri? permanent;
}
index index.php; index index.php;
# Common parameter to increase upload size limit in conjunction with dedicated php-fpm file # Common parameter to increase upload size limit in conjunction with dedicated php-fpm file

0
doc/.gitkeep Normal file
View file

1
doc/DESCRIPTION.md Normal file
View file

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

0
doc/DISCLAIMER.md Normal file
View file

0
doc/screenshots/.gitkeep Normal file
View file

View file

@ -8,6 +8,12 @@
}, },
"version": "2.6.1~ynh3", "version": "2.6.1~ynh3",
"url": "https://z-push.org", "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", "license": "AGPL-3.0-or-later",
"maintainer": { "maintainer": {
"name": "yalh76" "name": "yalh76"
@ -21,7 +27,7 @@
} }
], ],
"requirements": { "requirements": {
"yunohost": ">= 4.1.3" "yunohost": ">= 4.3.0"
}, },
"multi_instance": true, "multi_instance": true,
"services": [ "services": [
@ -29,11 +35,10 @@
"php7.3-fpm" "php7.3-fpm"
], ],
"arguments": { "arguments": {
"install" : [ "install": [
{ {
"name": "domain", "name": "domain",
"type": "domain", "type": "domain"
"example": "example.com"
} }
] ]
} }

View file

@ -29,9 +29,9 @@ app=$YNH_APP_INSTANCE_NAME
final_path=$(ynh_app_setting_get --app=$app --key=final_path) final_path=$(ynh_app_setting_get --app=$app --key=final_path)
domain=$(ynh_app_setting_get --app=$app --key=domain) 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) 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 # 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" 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="$datadir" --is_big
ynh_backup --src_path="$final_logpath" --is_big
#================================================= #=================================================
# BACKUP THE NGINX CONFIGURATION # BACKUP THE NGINX CONFIGURATION

View file

@ -36,11 +36,6 @@ ynh_script_progression --message="Validating installation parameters..."
final_path=/var/www/$app final_path=/var/www/$app
test ! -e "$final_path" || ynh_die --message="This path already contains a folder" 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 # Register (book) web path
ynh_webpath_register --app=$app --domain=$domain --path_url=$path_url 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=domain --value=$domain
ynh_app_setting_set --app=$app --key=path --value=$path_url 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 # STANDARD MODIFICATIONS
@ -69,7 +62,7 @@ ynh_install_app_dependencies $pkg_dependencies
ynh_script_progression --message="Configuring system user..." ynh_script_progression --message="Configuring system user..."
# Create a 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 # DOWNLOAD, CHECK AND UNPACK SOURCE
@ -107,16 +100,29 @@ phpversion=$(ynh_app_setting_get --app=$app --key=phpversion)
#================================================= #=================================================
# SPECIFIC SETUP # 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 datadir=/home/yunohost.app/$app
chmod 750 "$statedir" ynh_app_setting_set --app=$app --key=datadir --value=$datadir
chmod -R o-rwx "$statedir"
chown -R $app:www-data "$statedir" 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 mkdir -p $final_logpath
chmod 750 "$final_logpath" chmod 750 "$final_logpath"
chmod -R o-rwx "$final_logpath" chmod -R o-rwx "$final_logpath"
chown -R $app:www-data "$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 # Storage of state_dir in /home/yunohost.app
# This contains the sync status in between device and z-push # 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 # Enable caldav carddav support
if yunohost app list | grep -q 'id: baikal' ; then if yunohost app list | grep -q 'id: baikal' ; then

View file

@ -18,18 +18,18 @@ app=$YNH_APP_INSTANCE_NAME
domain=$(ynh_app_setting_get --app=$app --key=domain) domain=$(ynh_app_setting_get --app=$app --key=domain)
final_path=$(ynh_app_setting_get --app=$app --key=final_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) final_logpath=$(ynh_app_setting_get --app=$app --key=final_logpath)
#================================================= #=================================================
# STANDARD REMOVE # 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 # Remove the app-specific logrotate config
ynh_remove_app_dependencies ynh_remove_logrotate
#================================================= #=================================================
# REMOVE APP MAIN DIR # REMOVE APP MAIN DIR
@ -39,6 +39,17 @@ ynh_script_progression --message="Removing app main directory..."
# Remove the app directory securely # Remove the app directory securely
ynh_secure_remove --file="$final_path" 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 # REMOVE NGINX CONFIGURATION
#================================================= #=================================================
@ -56,21 +67,20 @@ ynh_script_progression --message="Removing PHP-FPM configuration..."
ynh_remove_fpm_config 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 # Remove metapackage and its dependencies
ynh_remove_logrotate ynh_remove_app_dependencies
#================================================= #=================================================
# SPECIFIC REMOVE # 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" ynh_secure_remove --file="$final_logpath"
#================================================= #=================================================

View file

@ -30,17 +30,15 @@ app=$YNH_APP_INSTANCE_NAME
domain=$(ynh_app_setting_get --app=$app --key=domain) domain=$(ynh_app_setting_get --app=$app --key=domain)
path_url=$(ynh_app_setting_get --app=$app --key=path) path_url=$(ynh_app_setting_get --app=$app --key=path)
final_path=$(ynh_app_setting_get --app=$app --key=final_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) 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 # CHECK IF THE APP CAN BE RESTORED
#================================================= #=================================================
ynh_script_progression --message="Validating restoration parameters..." 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 \ test ! -d $final_path \
|| ynh_die --message="There is already a directory: $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..." ynh_script_progression --message="Recreating the dedicated system user..."
# Create the dedicated user (if not existing) # 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 # 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" ynh_restore_file --origin_path="$final_path"
# Restore statedir chmod 750 "$final_path"
ynh_restore_file --origin_path="$statedir" --not_mandatory chmod -R o-rwx "$final_path"
mkdir -p $statedir chown -R $app:www-data "$final_path"
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" --not_mandatory # RESTORE THE DATA DIRECTORY
mkdir -p $final_logpath #=================================================
chmod 750 "$final_logpath" ynh_script_progression --message="Restoring the data directory..."
chmod -R o-rwx "$final_logpath"
chown -R $app:www-data "$final_logpath" 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 # 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" ynh_restore_file --origin_path="/etc/php/$phpversion/fpm/pool.d/$app.conf"

View file

@ -19,7 +19,7 @@ app=$YNH_APP_INSTANCE_NAME
domain=$(ynh_app_setting_get --app=$app --key=domain) domain=$(ynh_app_setting_get --app=$app --key=domain)
path_url=$(ynh_app_setting_get --app=$app --key=path) path_url=$(ynh_app_setting_get --app=$app --key=path)
final_path=$(ynh_app_setting_get --app=$app --key=final_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) 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) 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 # BACKUP BEFORE UPGRADE THEN ACTIVE TRAP
#================================================= #=================================================
@ -71,13 +45,40 @@ ynh_abort_if_errors
#================================================= #=================================================
# STANDARD UPGRADE STEPS # 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 # CREATE DEDICATED USER
#================================================= #=================================================
ynh_script_progression --message="Making sure dedicated system user exists..." ynh_script_progression --message="Making sure dedicated system user exists..."
# Create a dedicated user (if not existing) # 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 # 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 # Storage of state_dir in /home/yunohost.app
# This contains the sync status in between device and z-push # 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 # Enable caldav carddav support
if yunohost app list | grep -q 'id: baikal' ; then if yunohost app list | grep -q 'id: baikal' ; then