diff --git a/README.md b/README.md index 8968cc0..39b38ec 100644 --- a/README.md +++ b/README.md @@ -28,16 +28,16 @@ Z-Push is an Exchange ActiveSync fronted written in php which lets you synchroni #### Supported architectures -* x86-64b - [![Build Status](https://ci-apps.yunohost.org/ci/logs/z-push%20%28Community%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%28Community%29.svg)](https://ci-apps-arm.yunohost.org/ci/apps/z-push/) -* Jessie x86-64b - [![Build Status](https://ci-stretch.nohost.me/ci/logs/z-push%20%28Community%29.svg)](https://ci-stretch.nohost.me/ci/apps/z-push/) +* x86-64b - [![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/) +* Jessie x86-64b - [![Build Status](https://ci-stretch.nohost.me/ci/logs/z-push%20%28Apps%29.svg)](https://ci-stretch.nohost.me/ci/apps/z-push/) ## Links * Report a bug: https://github.com/YunoHost-Apps/z-push_ynh/issues * App website: http://z-push.org/ - * App github website: https://github.com/Z-Hub/Z-Push + * Upstream app repository: https://github.com/Z-Hub/Z-Push * YunoHost website: https://yunohost.org/ --- diff --git a/manifest.json b/manifest.json index 4eca72f..91d6f61 100644 --- a/manifest.json +++ b/manifest.json @@ -21,7 +21,7 @@ } ], "requirements": { - "yunohost": ">= 3.4" + "yunohost": ">= 3.5" }, "services": [ "nginx", diff --git a/scripts/backup b/scripts/backup index c6f0692..1707cc1 100755 --- a/scripts/backup +++ b/scripts/backup @@ -20,53 +20,53 @@ ynh_abort_if_errors #================================================= # LOAD SETTINGS #================================================= -ynh_print_info "Loading installation settings..." +ynh_print_info --message="Loading installation settings..." app=$YNH_APP_INSTANCE_NAME -final_path=$(ynh_app_setting_get $app final_path) -domain=$(ynh_app_setting_get $app domain) -statedir=$(ynh_app_setting_get $app statedir) -final_logpath=$(ynh_app_setting_get $app final_logpath) +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) #================================================= # STANDARD BACKUP STEPS #================================================= # BACKUP THE APP MAIN DIR #================================================= -ynh_print_info "Backing up the main app directory..." +ynh_print_info --message="Backing up the main app directory..." -ynh_backup "$final_path" +ynh_backup --src_path="$final_path" # Backup statedir -ynh_backup "$statedir" +ynh_backup --src_path="$statedir" # Backup logs -ynh_backup "$final_logpath" +ynh_backup --src_path="$final_logpath" #================================================= # BACKUP THE NGINX CONFIGURATION #================================================= -ynh_print_info "Backing up nginx web server configuration..." +ynh_print_info --message="Backing up nginx web server configuration..." -ynh_backup "/etc/nginx/conf.d/$domain.d/$app.conf" +ynh_backup --src_path="/etc/nginx/conf.d/$domain.d/$app.conf" #================================================= # BACKUP THE PHP-FPM CONFIGURATION #================================================= -ynh_print_info "Backing up php-fpm configuration..." +ynh_print_info --message="Backing up php-fpm configuration..." -ynh_backup "/etc/php/7.0/fpm/pool.d/$app.conf" +ynh_backup --src_path="/etc/php/7.0/fpm/pool.d/$app.conf" #================================================= # BACKUP LOGROTATE #================================================= -ynh_print_info "Backing up logrotate configuration..." +ynh_print_info --message="Backing up logrotate configuration..." -ynh_backup "/etc/logrotate.d/$app" +ynh_backup --src_path="/etc/logrotate.d/$app" #================================================= # END OF SCRIPT #================================================= -ynh_print_info "Backup script completed for $app. (YunoHost will then actually copy those files to the archive)." +ynh_print_info --message="Backup script completed for $app. (YunoHost will then actually copy those files to the archive)." diff --git a/scripts/install b/scripts/install index 4586dd0..31b2d4b 100755 --- a/scripts/install +++ b/scripts/install @@ -28,54 +28,56 @@ app=$YNH_APP_INSTANCE_NAME #================================================= # CHECK IF THE APP CAN BE INSTALLED WITH THESE ARGS #================================================= -ynh_print_info "Validating installation parameters..." +ynh_print_info --message="Validating installation parameters..." final_path=/var/www/$app -test ! -e "$final_path" || ynh_die "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 "This path already contains a folder" +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 $domain $path_url +ynh_webpath_register --app=$app --domain=$domain --path_url=$path_url #================================================= # STORE SETTINGS FROM MANIFEST #================================================= -ynh_print_info "Storing installation settings..." +ynh_print_info --message="Storing installation settings..." -ynh_app_setting_set $app domain $domain -ynh_app_setting_set $app path $path_url +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 statedir "$statedir" -ynh_app_setting_set $app final_logpath "$final_logpath" +ynh_app_setting_set --app=$app --key=statedir --value="$statedir" +ynh_app_setting_set --app=$app --key=final_logpath --value="$final_logpath" +#================================================= +# STANDARD MODIFICATIONS #================================================= # INSTALL DEPENDENCIES #================================================= -ynh_print_info "Installing dependencies..." +ynh_print_info --message="Installing dependencies..." ynh_install_app_dependencies $pkg_dependencies #================================================= # DOWNLOAD, CHECK AND UNPACK SOURCE #================================================= -ynh_print_info "Setting up source files..." +ynh_print_info --message="Setting up source files..." -ynh_app_setting_set $app final_path $final_path +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" -ynh_setup_source "$final_path/tmp" +ynh_setup_source --dest_dir="$final_path/tmp" cp -a "$final_path/tmp/src/." "$final_path/." ynh_secure_remove "$final_path/tmp" #================================================= # NGINX CONFIGURATION #================================================= -ynh_print_info "Configuring nginx web server..." +ynh_print_info --message="Configuring nginx web server..." ### `ynh_add_nginx_config` will use the file conf/nginx.conf @@ -85,15 +87,15 @@ ynh_add_nginx_config #================================================= # CREATE DEDICATED USER #================================================= -ynh_print_info "Configuring system user..." +ynh_print_info --message="Configuring system user..." # Create a system user -ynh_system_user_create $app +ynh_system_user_create --username=$app #================================================= # PHP-FPM CONFIGURATION #================================================= -ynh_print_info "Configuring php-fpm..." +ynh_print_info --message="Configuring php-fpm..." # Create a dedicated php-fpm config ynh_add_fpm_config @@ -103,7 +105,7 @@ ynh_add_fpm_config #================================================= # CREATE STATEDIR AND FINAL_LOGPATH #================================================= -ynh_print_info "Creating statedir and final_logpath..." +ynh_print_info --message="Creating statedir and final_logpath..." mkdir -p $statedir chown -R $app: $statedir @@ -116,37 +118,37 @@ chown -R $app: $final_logpath #================================================= # Configuration -ynh_replace_string __TIMEZONE__ $(cat /etc/timezone) ../conf/config.php -ynh_replace_string __TIMEZONE__ $(cat /etc/timezone) ../conf/backend/config-autodiscover.php -ynh_replace_string __FINAL_LOGPATH__ $final_logpath ../conf/config.php -ynh_replace_string __FINAL_LOGPATH__ $final_logpath ../conf/backend/config-autodiscover.php +ynh_replace_string --match_string="__TIMEZONE__" --replace_string=$(cat /etc/timezone) --target_file="../conf/config.php" +ynh_replace_string --match_string="__TIMEZONE__" --replace_string=$(cat /etc/timezone) --target_file="../conf/backend/config-autodiscover.php" +ynh_replace_string --match_string="__FINAL_LOGPATH__" --replace_string=$final_logpath --target_file="../conf/config.php" +ynh_replace_string --match_string="__FINAL_LOGPATH__" --replace_string=$final_logpath --target_file="../conf/backend/config-autodiscover.php" # 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 --match_string="__STATEDIR__" --replace_string=$statedir --target_file="../conf/config.php" # Enable caldav carddav support if yunohost app list --installed -f baikal | grep -q id ; then echo "Detected Baikal" - bailkaldomain=$(ynh_app_setting_get baikal domain) - bailkalpath=$(ynh_app_setting_get baikal path) + bailkaldomain=$(ynh_app_setting_get --app="baikal" --key=domain) + bailkalpath=$(ynh_app_setting_get --app="baikal" --key=path) bailkalpath=${bailkalpath%/} # Configuration of backend - ynh_replace_string __BACKEND__ BackendCombined ../conf/config.php - ynh_replace_string __BACKEND__ BackendCombined ../conf/backend/config-autodiscover.php + ynh_replace_string --match_string="__BACKEND__" --replace_string="BackendCombined" --target_file="../conf/config.php" + ynh_replace_string --match_string="__BACKEND__" --replace_string="BackendCombined" --target_file="../conf/backend/config-autodiscover.php" # Configuration baikal - ynh_replace_string __CALDAV_SERVER__ "${bailkaldomain}" ../conf/backend/config-caldav.php - ynh_replace_string __CALDAV_PATH__ "${bailkalpath}/cal.php/calendars/%u/" ../conf/backend/config-caldav.php - ynh_replace_string __CALDAV_PERSONAL__ "default" ../conf/backend/config-caldav.php + ynh_replace_string --match_string="__CALDAV_SERVER__" --replace_string="${bailkaldomain}" --target_file="../conf/backend/config-caldav.php" + ynh_replace_string --match_string="__CALDAV_PATH__" --replace_string="${bailkalpath}/cal.php/calendars/%u/" --target_file="../conf/backend/config-caldav.php" + ynh_replace_string --match_string="__CALDAV_PERSONAL__" --replace_string="default" --target_file="../conf/backend/config-caldav.php" - ynh_replace_string __CARDDAV_SERVER__ "${bailkaldomain}" ../conf/backend/config-carddav.php - ynh_replace_string __CARDDAV_PATH__ "${bailkalpath}/card.php/addressbooks/%u/" ../conf/backend/config-carddav.php - ynh_replace_string __CARDDAV_DEFAULT_PATH__ "${bailkalpath}/card.php/addressbooks/%u/default" ../conf/backend/config-carddav.php + ynh_replace_string --match_string="__CARDDAV_SERVER__" --replace_string="${bailkaldomain}" --target_file="../conf/backend/config-carddav.php" + ynh_replace_string --match_string="__CARDDAV_PATH__" --replace_string="${bailkalpath}/card.php/addressbooks/%u/" --target_file="../conf/backend/config-carddav.php" + ynh_replace_string --match_string="__CARDDAV_DEFAULT_PATH__" --replace_string="${bailkalpath}/card.php/addressbooks/%u/default" --target_file="../conf/backend/config-carddav.php" - ynh_replace_string __IMAP_SERVER__ "${domain}" ../conf/backend/config-imap.php - ynh_replace_string __FLAGTOCHANGE__ true ../conf/backend/config-imap.php + ynh_replace_string --match_string="__IMAP_SERVER__" --replace_string="${domain}" --target_file="../conf/backend/config-imap.php" + 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 @@ -156,25 +158,25 @@ if yunohost app list --installed -f baikal | grep -q id ; then elif yunohost app list --installed -f nextcloud | grep -q id ; then echo "Detected NextCloud" - nextclouddomain=$(ynh_app_setting_get nextcloud domain) - nextcloudpath=$(ynh_app_setting_get nextcloud path) + nextclouddomain=$(ynh_app_setting_get --app="nextcloud" --key=domain) + nextcloudpath=$(ynh_app_setting_get --app="nextcloud" --key=path) nextcloudpath=${nextcloudpath%/} # Configuration of backend - ynh_replace_string __BACKEND__ BackendCombined ../conf/config.php - ynh_replace_string __BACKEND__ BackendCombined ../conf/backend/config-autodiscover.php + ynh_replace_string --match_string="__BACKEND__" --replace_string="BackendCombined" --target_file="../conf/config.php" + ynh_replace_string --match_string="__BACKEND__" --replace_string="BackendCombined" --target_file="../conf/backend/config-autodiscover.php" # Configuration nextcloud - ynh_replace_string __CALDAV_SERVER__ "${nextclouddomain}" ../conf/backend/config-caldav.php - ynh_replace_string __CALDAV_PATH__ "${nextcloudpath}/remote.php/dav/calendars/%u/" ../conf/backend/config-caldav.php - ynh_replace_string __CALDAV_PERSONAL__ "personal" ../conf/backend/config-caldav.php + ynh_replace_string --match_string="__CALDAV_SERVER__" --replace_string="${nextclouddomain}" --target_file="../conf/backend/config-caldav.php" + ynh_replace_string --match_string="__CALDAV_PATH__" --replace_string="${nextcloudpath}/remote.php/dav/calendars/%u/" --target_file="../conf/backend/config-caldav.php" + ynh_replace_string --match_string="__CALDAV_PERSONAL__" --replace_string="personal" --target_file="../conf/backend/config-caldav.php" - ynh_replace_string __CARDDAV_SERVER__ "${nextclouddomain}" ../conf/backend/config-carddav.php - ynh_replace_string __CARDDAV_PATH__ "${nextcloudpath}/remote.php/dav/addressbooks/users/%u/contacts/" ../conf/backend/config-carddav.php - ynh_replace_string __CARDDAV_DEFAULT_PATH__ "${nextcloudpath}/remote.php/dav/addressbooks/users/%u/contacts/" ../conf/backend/config-carddav.php + ynh_replace_string --match_string="__CARDDAV_SERVER__" --replace_string="${nextclouddomain}" --target_file="../conf/backend/config-carddav.php" + ynh_replace_string --match_string="__CARDDAV_PATH__" --replace_string="${nextcloudpath}/remote.php/dav/addressbooks/users/%u/contacts/" --target_file="../conf/backend/config-carddav.php" + ynh_replace_string --match_string="__CARDDAV_DEFAULT_PATH__" --replace_string="${nextcloudpath}/remote.php/dav/addressbooks/users/%u/contacts/" --target_file="../conf/backend/config-carddav.php" - ynh_replace_string __IMAP_SERVER__ "${domain}" ../conf/backend/config-imap.php - ynh_replace_string __FLAGTOCHANGE__ true ../conf/backend/config-imap.php + ynh_replace_string --match_string="__IMAP_SERVER__" --replace_string="${domain}" --target_file="../conf/backend/config-imap.php" + 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 @@ -183,12 +185,12 @@ elif yunohost app list --installed -f nextcloud | grep -q id ; then cp ../conf/backend/config-combined.php $final_path/backend/combined/config.php else # Configuration of backend - ynh_replace_string __BACKEND__ BackendIMAP ../conf/config.php - ynh_replace_string __BACKEND__ BackendIMAP ../conf/backend/config-autodiscover.php + ynh_replace_string --match_string="__BACKEND__" --replace_string="BackendIMAP" --target_file="../conf/config.php" + ynh_replace_string --match_string="__BACKEND__" --replace_string="BackendIMAP" --target_file="../conf/backend/config-autodiscover.php" # Configuration imap - ynh_replace_string __IMAP_SERVER__ "${domain}" ../conf/backend/config-imap.php - ynh_replace_string __FLAGTOCHANGE__ false ../conf/backend/config-imap.php + ynh_replace_string --match_string="__IMAP_SERVER__" --replace_string="${domain}" --target_file="../conf/backend/config-imap.php" + 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 @@ -214,7 +216,7 @@ chown -R $app: $final_path #================================================= # SETUP LOGROTATE #================================================= -ynh_print_info "Configuring log rotation..." +ynh_print_info --message="Configuring log rotation..." # Use logrotate to manage application logfile(s) ynh_use_logrotate @@ -222,22 +224,22 @@ ynh_use_logrotate #================================================= # SETUP SSOWAT #================================================= -ynh_print_info "Configuring SSOwat..." +ynh_print_info --message="Configuring SSOwat..." # Make app public -ynh_app_setting_set $app unprotected_uris "/" +ynh_app_setting_set --app=$app --key=unprotected_uris --value="/" domain_regex=$(echo "$domain" | sed 's@-@.@g') -ynh_app_setting_set $app skipped_regex "$domain_regex/[Aa]uto[Dd]iscover/.*" +ynh_app_setting_set --app=$app --key=skipped_regex --value="$domain_regex/[Aa]uto[Dd]iscover/.*" #================================================= # RELOAD NGINX #================================================= -ynh_print_info "Reloading nginx web server..." +ynh_print_info --message="Reloading nginx web server..." -systemctl reload nginx +ynh_systemd_action --service_name=nginx --action=reload #================================================= # END OF SCRIPT #================================================= -ynh_print_info "Installation of $app completed" +ynh_print_info --message="Installation of $app completed" diff --git a/scripts/remove b/scripts/remove index 8af8d4e..0975c57 100755 --- a/scripts/remove +++ b/scripts/remove @@ -12,20 +12,22 @@ source /usr/share/yunohost/helpers #================================================= # LOAD SETTINGS #================================================= -ynh_print_info "Loading installation settings..." +ynh_print_info --message="Loading installation settings..." app=$YNH_APP_INSTANCE_NAME -domain=$(ynh_app_setting_get $app domain) +domain=$(ynh_app_setting_get --app=$app --key=domain) -final_path=$(ynh_app_setting_get $app final_path) -statedir=$(ynh_app_setting_get $app statedir) -final_logpath=$(ynh_app_setting_get $app final_logpath) +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) +#================================================= +# STANDARD REMOVE #================================================= # REMOVE DEPENDENCIES #================================================= -ynh_print_info "Removing dependencies" +ynh_print_info --message="Removing dependencies..." # Remove metapackage and its dependencies ynh_remove_app_dependencies @@ -33,15 +35,15 @@ ynh_remove_app_dependencies #================================================= # REMOVE APP MAIN DIR #================================================= -ynh_print_info "Removing app main directory" +ynh_print_info --message="Removing app main directory..." # Remove the app directory securely -ynh_secure_remove "$final_path" +ynh_secure_remove --file="$final_path" #================================================= # REMOVE NGINX CONFIGURATION #================================================= -ynh_print_info "Removing nginx web server configuration" +ynh_print_info --message="Removing nginx web server configuration..." # Remove the dedicated nginx config ynh_remove_nginx_config @@ -49,7 +51,7 @@ ynh_remove_nginx_config #================================================= # REMOVE PHP-FPM CONFIGURATION #================================================= -ynh_print_info "Removing php-fpm configuration" +ynh_print_info --message="Removing php-fpm configuration..." # Remove the dedicated php-fpm config ynh_remove_fpm_config @@ -57,7 +59,7 @@ ynh_remove_fpm_config #================================================= # REMOVE LOGROTATE CONFIGURATION #================================================= -ynh_print_info "Removing logrotate configuration" +ynh_print_info --message="Removing logrotate configuration..." # Remove the app-specific logrotate config ynh_remove_logrotate @@ -68,11 +70,11 @@ ynh_remove_logrotate # REMOVE STATEDIR AND FINAL_LOGPATH #================================================= -ynh_secure_remove "$statedir" -ynh_secure_remove "$final_logpath" +ynh_secure_remove --file="$statedir" +ynh_secure_remove --file="$final_logpath" #================================================= # END OF SCRIPT #================================================= -ynh_print_info "Removal of $app completed" +ynh_print_info --message="Removal of $app completed" diff --git a/scripts/restore b/scripts/restore index 69de332..7d11623 100755 --- a/scripts/restore +++ b/scripts/restore @@ -20,25 +20,25 @@ ynh_abort_if_errors #================================================= # LOAD SETTINGS #================================================= -ynh_print_info "Loading settings..." +ynh_print_info --message="Loading settings..." app=$YNH_APP_INSTANCE_NAME -domain=$(ynh_app_setting_get $app domain) -path_url=$(ynh_app_setting_get $app path) -final_path=$(ynh_app_setting_get $app final_path) -statedir=$(ynh_app_setting_get $app statedir) -final_logpath=$(ynh_app_setting_get $app final_logpath) +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) #================================================= # CHECK IF THE APP CAN BE RESTORED #================================================= -ynh_print_info "Validating restoration parameters..." +ynh_print_info --message="Validating restoration parameters..." -ynh_webpath_available $domain $path_url \ - || ynh_die "Path not available: ${domain}${path_url}" +ynh_webpath_available --domain=$domain --path_url=$path_url \ + || ynh_die --message="Path not available: ${domain}${path_url}" test ! -d $final_path \ - || ynh_die "There is already a directory: $final_path " + || ynh_die --message="There is already a directory: $final_path " #================================================= # STANDARD RESTORATION STEPS @@ -46,28 +46,28 @@ test ! -d $final_path \ # RESTORE THE NGINX CONFIGURATION #================================================= -ynh_restore_file "/etc/nginx/conf.d/$domain.d/$app.conf" +ynh_restore_file --origin_path="/etc/nginx/conf.d/$domain.d/$app.conf" #================================================= # RESTORE THE APP MAIN DIR #================================================= -ynh_print_info "Restoring the app main directory..." +ynh_print_info --message="Restoring the app main directory..." -ynh_restore_file "$final_path" +ynh_restore_file --origin_path="$final_path" # Restore statedir -ynh_restore_file "$statedir" +ynh_restore_file --origin_path="$statedir" # Restore logs, data & permissions -ynh_restore_file "$final_logpath" +ynh_restore_file --origin_path="$final_logpath" #================================================= # RECREATE THE DEDICATED USER #================================================= -ynh_print_info "Recreating the dedicated system user..." +ynh_print_info --message="Recreating the dedicated system user..." # Create the dedicated user (if not existing) -ynh_system_user_create $app +ynh_system_user_create --username=$app #================================================= # RESTORE USER RIGHTS @@ -82,14 +82,14 @@ chown -R $app: $final_logpath # RESTORE THE PHP-FPM CONFIGURATION #================================================= -ynh_restore_file "/etc/php/7.0/fpm/pool.d/$app.conf" +ynh_restore_file --origin_path="/etc/php/7.0/fpm/pool.d/$app.conf" #================================================= # SPECIFIC RESTORATION #================================================= # REINSTALL DEPENDENCIES #================================================= -ynh_print_info "Reinstalling dependencies..." +ynh_print_info --message="Reinstalling dependencies..." # Define and install dependencies ynh_install_app_dependencies $pkg_dependencies @@ -98,20 +98,20 @@ ynh_install_app_dependencies $pkg_dependencies # RESTORE THE LOGROTATE CONFIGURATION #================================================= -ynh_restore_file "/etc/logrotate.d/$app" +ynh_restore_file --origin_path="/etc/logrotate.d/$app" #================================================= # GENERIC FINALIZATION #================================================= # RELOAD NGINX AND PHP-FPM #================================================= -ynh_print_info "Reloading nginx web server and php-fpm..." +ynh_print_info --message="Reloading nginx web server and php-fpm..." -systemctl reload php7.0-fpm -systemctl reload nginx +ynh_systemd_action --service_name=php7.0-fpm --action=reload +ynh_systemd_action --service_name=nginx --action=reload #================================================= # END OF SCRIPT #================================================= -ynh_print_info "Restoration completed for $app" +ynh_print_info --message="Restoration completed for $app" diff --git a/scripts/upgrade b/scripts/upgrade index 35b4eb5..56717a7 100755 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -12,58 +12,60 @@ source /usr/share/yunohost/helpers #================================================= # LOAD SETTINGS #================================================= -ynh_print_info "Loading installation settings..." +ynh_print_info --message="Loading installation settings..." app=$YNH_APP_INSTANCE_NAME -domain=$(ynh_app_setting_get $app domain) -path_url=$(ynh_app_setting_get $app path) -final_path=$(ynh_app_setting_get $app final_path) -statedir=$(ynh_app_setting_get $app statedir) -final_logpath=$(ynh_app_setting_get $app final_logpath) +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) + +#================================================= +# CHECK VERSION +#================================================= + +upgrade_type=$(ynh_check_app_version_changed) #================================================= # ENSURE DOWNWARD COMPATIBILITY #================================================= -ynh_print_info "Ensuring downward compatibility..." +ynh_print_info --message="Ensuring downward compatibility..." # Fix is_public as a boolean value if [ "$is_public" = "Yes" ]; then - ynh_app_setting_set $app is_public 1 + ynh_app_setting_set --app=$app --key=is_public --value=1 is_public=1 elif [ "$is_public" = "No" ]; then - ynh_app_setting_set $app is_public 0 + ynh_app_setting_set --app=$app --key=is_public --value=0 is_public=0 fi # If final_path doesn't exist, create it -if [ -z $final_path ]; then +if [ -z "$final_path" ]; then final_path=/var/www/$app - ynh_app_setting_set $app final_path $final_path + ynh_app_setting_set --app=$app --key=final_path --value=$final_path fi if [ -z "$statedir" ]; then statedir="/home/yunohost.app/$app" - ynh_app_setting_set "$app" statedir "$statedir" + ynh_app_setting_set --app=$app --key=statedir --value=$statedir mkdir -p $statedir -else - ynh_print_info "${statedir} exists, we don't create it." fi if [ -z "$final_logpath" ]; then final_logpath="/var/log/$app" - ynh_app_setting_set "$app" final_logpath "$final_logpath" + ynh_app_setting_set --app=$app --key=final_logpath --value=$final_logpath mkdir -p $final_logpath -else - ynh_print_info "${final_logpath} exists, we don't create it." fi #================================================= # BACKUP BEFORE UPGRADE THEN ACTIVE TRAP #================================================= -ynh_print_info "Backing up the app before upgrading (may take a while)..." +ynh_print_info --message="Backing up the app before upgrading (may take a while)..." # Backup the current version of the app ynh_backup_before_upgrade @@ -74,23 +76,33 @@ ynh_clean_setup () { # Exit if an error occurs during the execution of the script ynh_abort_if_errors +#================================================= +# CHECK THE PATH +#================================================= + +path_url=$(ynh_normalize_url_path --path_url=$path_url) + #================================================= # STANDARD UPGRADE STEPS #================================================= # DOWNLOAD, CHECK AND UNPACK SOURCE #================================================= -ynh_print_info "Upgrading source files..." -# Download, check integrity, uncompress and patch the source from app.src -mkdir "$final_path/tmp" -ynh_setup_source "$final_path/tmp" -cp -a "$final_path/tmp/src/." "$final_path/." -ynh_secure_remove "$final_path/tmp" +if [ "$upgrade_type" == "UPGRADE_APP" ] +then + ynh_script_progression --message="Upgrading source files..." --time --weight=1 + + # 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/." + ynh_secure_remove --file="$final_path/tmp" +fi #================================================= # NGINX CONFIGURATION #================================================= -ynh_print_info "Upgrading nginx web server configuration..." +ynh_print_info --message="Upgrading nginx web server configuration..." # Create a dedicated nginx config ynh_add_nginx_config @@ -98,22 +110,22 @@ ynh_add_nginx_config #================================================= # UPGRADE DEPENDENCIES #================================================= -ynh_print_info "Upgrading dependencies..." +ynh_print_info --message="Upgrading dependencies..." ynh_install_app_dependencies $pkg_dependencies #================================================= # CREATE DEDICATED USER #================================================= -ynh_print_info "Making sure dedicated system user exists..." +ynh_print_info --message="Making sure dedicated system user exists..." # Create a dedicated user (if not existing) -ynh_system_user_create $app +ynh_system_user_create --username=$app #================================================= # PHP-FPM CONFIGURATION #================================================= -ynh_print_info "Upgrading php-fpm configuration..." +ynh_print_info --message="Upgrading php-fpm configuration..." # Create a dedicated php-fpm config ynh_add_fpm_config @@ -125,10 +137,10 @@ ynh_add_fpm_config #================================================= # Configuration -ynh_replace_string __TIMEZONE__ $(cat /etc/timezone) ../conf/config.php -ynh_replace_string __TIMEZONE__ $(cat /etc/timezone) ../conf/backend/config-autodiscover.php -ynh_replace_string __FINAL_LOGPATH__ $final_logpath ../conf/config.php -ynh_replace_string __FINAL_LOGPATH__ $final_logpath ../conf/backend/config-autodiscover.php +ynh_replace_string --match_string="__TIMEZONE__" --replace_string="$(cat /etc/timezone)" --target_file="../conf/config.php" +ynh_replace_string --match_string="__TIMEZONE__" --replace_string="$(cat /etc/timezone)" --target_file="../conf/backend/config-autodiscover.php" +ynh_replace_string --match_string="__FINAL_LOGPATH__" --replace_string="$final_logpath" --target_file="../conf/config.php" +ynh_replace_string --match_string="__FINAL_LOGPATH__" --replace_string="$final_logpath" --target_file="../conf/backend/config-autodiscover.php" # Storage of state_dir in /home/yunohost.app # This contains the sync status in between device and z-push @@ -137,25 +149,25 @@ ynh_replace_string __STATEDIR__ $statedir ../conf/config.php # Enable caldav carddav support if yunohost app list --installed -f baikal | grep -q id ; then echo "Detected Baikal" - bailkaldomain=$(ynh_app_setting_get baikal domain) - bailkalpath=$(ynh_app_setting_get baikal path) + bailkaldomain=$(ynh_app_setting_get --app=baikal --key=domain) + bailkalpath=$(ynh_app_setting_get --app=baikal --key=path) bailkalpath=${bailkalpath%/} # Configuration of backend - ynh_replace_string __BACKEND__ BackendCombined ../conf/config.php - ynh_replace_string __BACKEND__ BackendCombined ../conf/backend/config-autodiscover.php + ynh_replace_string --match_string="__BACKEND__" --replace_string="BackendCombined" --target_file="../conf/config.php" + ynh_replace_string --match_string="__BACKEND__" --replace_string="BackendCombined" --target_file="../conf/backend/config-autodiscover.php" # Configuration baikal - ynh_replace_string __CALDAV_SERVER__ "${bailkaldomain}" ../conf/backend/config-caldav.php - ynh_replace_string __CALDAV_PATH__ "${bailkalpath}/cal.php/calendars/%u/" ../conf/backend/config-caldav.php - ynh_replace_string __CALDAV_PERSONAL__ "default" ../conf/backend/config-caldav.php + ynh_replace_string --match_string="__CALDAV_SERVER__" --replace_string="${bailkaldomain}" --target_file="../conf/backend/config-caldav.php" + ynh_replace_string --match_string="__CALDAV_PATH__" --replace_string="${bailkalpath}/cal.php/calendars/%u/" --target_file="../conf/backend/config-caldav.php" + ynh_replace_string --match_string="__CALDAV_PERSONAL__" --replace_string="default" --target_file="../conf/backend/config-caldav.php" - ynh_replace_string __CARDDAV_SERVER__ "${bailkaldomain}" ../conf/backend/config-carddav.php - ynh_replace_string __CARDDAV_PATH__ "${bailkalpath}/card.php/addressbooks/%u/" ../conf/backend/config-carddav.php - ynh_replace_string __CARDDAV_DEFAULT_PATH__ "${bailkalpath}/card.php/addressbooks/%u/default" ../conf/backend/config-carddav.php + ynh_replace_string --match_string="__CARDDAV_SERVER__" --replace_string="${bailkaldomain}" --target_file="../conf/backend/config-carddav.php" + ynh_replace_string --match_string="__CARDDAV_PATH__" --replace_string="${bailkalpath}/card.php/addressbooks/%u/" --target_file="../conf/backend/config-carddav.php" + ynh_replace_string --match_string="__CARDDAV_DEFAULT_PATH__" --replace_string="${bailkalpath}/card.php/addressbooks/%u/default" --target_file="../conf/backend/config-carddav.php" - ynh_replace_string __IMAP_SERVER__ "${domain}" ../conf/backend/config-imap.php - ynh_replace_string __FLAGTOCHANGE__ true ../conf/backend/config-imap.php + ynh_replace_string --match_string="__IMAP_SERVER__" --replace_string="${domain}" --target_file="../conf/backend/config-imap.php" + 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 @@ -165,25 +177,25 @@ if yunohost app list --installed -f baikal | grep -q id ; then elif yunohost app list --installed -f nextcloud | grep -q id ; then echo "Detected NextCloud" - nextclouddomain=$(ynh_app_setting_get nextcloud domain) - nextcloudpath=$(ynh_app_setting_get nextcloud path) + nextclouddomain=$(ynh_app_setting_get --app=nextcloud --key=domain) + nextcloudpath=$(ynh_app_setting_get --app=nextcloud --key=path) nextcloudpath=${nextcloudpath%/} # Configuration of backend - ynh_replace_string __BACKEND__ BackendCombined ../conf/config.php - ynh_replace_string __BACKEND__ BackendCombined ../conf/backend/config-autodiscover.php + ynh_replace_string --match_string="__BACKEND__" --replace_string="BackendCombined" --target_file="../conf/config.php" + ynh_replace_string --match_string="__BACKEND__" --replace_string="BackendCombined" --target_file="../conf/backend/config-autodiscover.php" # Configuration nextcloud - ynh_replace_string __CALDAV_SERVER__ "${nextclouddomain}" ../conf/backend/config-caldav.php - ynh_replace_string __CALDAV_PATH__ "${nextcloudpath}/remote.php/dav/calendars/%u/" ../conf/backend/config-caldav.php - ynh_replace_string __CALDAV_PERSONAL__ "personal" ../conf/backend/config-caldav.php + ynh_replace_string --match_string="__CALDAV_SERVER__" --replace_string="${nextclouddomain}" --target_file="../conf/backend/config-caldav.php" + ynh_replace_string --match_string="__CALDAV_PATH__" --replace_string="${nextcloudpath}/remote.php/dav/calendars/%u/" --target_file="../conf/backend/config-caldav.php" + ynh_replace_string --match_string="__CALDAV_PERSONAL__" --replace_string="personal" --target_file="../conf/backend/config-caldav.php" - ynh_replace_string __CARDDAV_SERVER__ "${nextclouddomain}" ../conf/backend/config-carddav.php - ynh_replace_string __CARDDAV_PATH__ "${nextcloudpath}/remote.php/dav/addressbooks/users/%u/contacts/" ../conf/backend/config-carddav.php - ynh_replace_string __CARDDAV_DEFAULT_PATH__ "${nextcloudpath}/remote.php/dav/addressbooks/users/%u/contacts/" ../conf/backend/config-carddav.php + ynh_replace_string --match_string="__CARDDAV_SERVER__" --replace_string="${nextclouddomain}" --target_file="../conf/backend/config-carddav.php" + ynh_replace_string --match_string="__CARDDAV_PATH__" --replace_string="${nextcloudpath}/remote.php/dav/addressbooks/users/%u/contacts/" --target_file="../conf/backend/config-carddav.php" + ynh_replace_string --match_string="__CARDDAV_DEFAULT_PATH__" --replace_string="${nextcloudpath}/remote.php/dav/addressbooks/users/%u/contacts/" --target_file="../conf/backend/config-carddav.php" - ynh_replace_string __IMAP_SERVER__ "${domain}" ../conf/backend/config-imap.php - ynh_replace_string __FLAGTOCHANGE__ true ../conf/backend/config-imap.php + ynh_replace_string --match_string="__IMAP_SERVER__" --replace_string="${domain}" --target_file="../conf/backend/config-imap.php" + 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 @@ -192,12 +204,12 @@ elif yunohost app list --installed -f nextcloud | grep -q id ; then cp ../conf/backend/config-combined.php $final_path/backend/combined/config.php else # Configuration of backend - ynh_replace_string __BACKEND__ BackendIMAP ../conf/config.php - ynh_replace_string __BACKEND__ BackendIMAP ../conf/backend/config-autodiscover.php + ynh_replace_string --match_string="__BACKEND__" --replace_string="BackendIMAP" --target_file="../conf/config.php" + ynh_replace_string --match_string="__BACKEND__" --replace_string="BackendIMAP" --target_file="../conf/backend/config-autodiscover.php" # Configuration imap - ynh_replace_string __IMAP_SERVER__ "${domain}" ../conf/backend/config-imap.php - ynh_replace_string __FLAGTOCHANGE__ false ../conf/backend/config-imap.php + ynh_replace_string --match_string="__IMAP_SERVER__" --replace_string="${domain}" --target_file="../conf/backend/config-imap.php" + 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 @@ -214,7 +226,7 @@ $final_path/z-push-admin.php -a fixstates #================================================= # SETUP LOGROTATE #================================================= -ynh_print_info "Upgrading logrotate configuration..." +ynh_print_info --message="Upgrading logrotate configuration..." # Use logrotate to manage app-specific logfile(s) ynh_use_logrotate --non-append @@ -234,22 +246,22 @@ chown -R $app: $final_logpath #================================================= # SETUP SSOWAT #================================================= -ynh_print_info "Upgrading SSOwat configuration..." +ynh_print_info --message="Upgrading SSOwat configuration..." # Make app public -ynh_app_setting_set $app unprotected_uris "/" +ynh_app_setting_set --app=$app --key=unprotected_uris --value="/" domain_regex=$(echo "$domain" | sed 's@-@.@g') -ynh_app_setting_set $app skipped_regex "$domain_regex/[Aa]uto[Dd]iscover/.*" +ynh_app_setting_set --app=$app --key=skipped_regex --value="$domain_regex/[Aa]uto[Dd]iscover/.*" #================================================= # RELOAD NGINX #================================================= -ynh_print_info "Reloading nginx web server..." +ynh_print_info --message="Reloading nginx web server..." -systemctl reload nginx +ynh_systemd_action --service_name=nginx --action=reload #================================================= # END OF SCRIPT #================================================= -ynh_print_info "Upgrade of $app completed" +ynh_print_info --message="Upgrade of $app completed"