From 5097244db5b667b171daebf878a0d42531b7dc4c Mon Sep 17 00:00:00 2001 From: Yalh Date: Mon, 28 Jan 2019 04:07:33 +0100 Subject: [PATCH 01/13] update to 1.38 + readme additional informations --- README.md | 28 +++++++++++++++++++++++++++- check_process | 1 - conf/app.src | 4 ++-- manifest.json | 2 +- 4 files changed, 30 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index 7bebd8d..bccc505 100644 --- a/README.md +++ b/README.md @@ -1,10 +1,17 @@ Roundcube for YunoHost ---------------------- +[![Integration level](https://dash.yunohost.org/integration/roundcube.svg)](https://dash.yunohost.org/appci/app/roundcube) +[![Install roundcube with YunoHost](https://install-app.yunohost.org/install-with-yunohost.png)](https://install-app.yunohost.org/?app=roundcube) + +> *This package allow you to install roundcube quickly and simply on a YunoHost server. +If you don't have YunoHost, please see [here](https://yunohost.org/#/install) to know how to install and enjoy it.* + +## Overview [Roundcube](https://roundcube.net/) is a browser-based multilingual IMAP client with an application-like user interface. -**Shipped version:** 1.3.6 +**Shipped version:** 1.3.8 ![](https://roundcube.net/images/screens/mailview.jpg) @@ -76,7 +83,26 @@ steps as needed. You can also download the plugin and put it under the `plugins/` directory. In this case, do not forget to change ownerships of this folder to `roundcube`. +## YunoHost specific features + +#### Multi-users support + +Are LDAP and HTTP auth supported? +Can the app be used by multiple users? + +#### Supported architectures + +* x86-64b - [![Build Status](https://ci-apps.yunohost.org/ci/logs/roundcube%20%28Community%29.svg)](https://ci-apps.yunohost.org/ci/apps/roundcube/) +* ARMv8-A - [![Build Status](https://ci-apps-arm.yunohost.org/ci/logs/roundcube%20%28Community%29.svg)](https://ci-apps-arm.yunohost.org/ci/apps/roundcube/) +* Jessie x86-64b - [![Build Status](https://ci-stretch.nohost.me/ci/logs/roundcube%20%28Community%29.svg)](https://ci-stretch.nohost.me/ci/apps/roundcube/) + +## Limitations + +* No known limitations. + + ## Links + * Report a bug: https://github.com/YunoHost-Apps/roundcube_ynh/issues * Roundcube website: https://roundcube.net/ * YunoHost website: https://yunohost.org/ diff --git a/check_process b/check_process index 7992dff..bac5b8d 100644 --- a/check_process +++ b/check_process @@ -12,7 +12,6 @@ setup_private=0 setup_public=0 upgrade=1 - upgrade=1 from_commit=8d0acb6953a4c4c2206985c7d9881c5b7b637ebd backup_restore=1 multi_instance=1 incorrect_path=1 diff --git a/conf/app.src b/conf/app.src index d264dc7..02c0974 100644 --- a/conf/app.src +++ b/conf/app.src @@ -1,5 +1,5 @@ -SOURCE_URL=https://github.com/roundcube/roundcubemail/releases/download/1.3.6/roundcubemail-1.3.6.tar.gz -SOURCE_SUM=5796670080c9c3c4071eecc70ddcb6b5df98d8a241a73e8a687fd536a9410c7a +SOURCE_URL=https://github.com/roundcube/roundcubemail/releases/download/1.3.8/roundcubemail-1.3.8.tar.gz +SOURCE_SUM=93314f125033d8ce2755198367c45bdd2f4cfee5d7688f913877beeb6c532858 SOURCE_SUM_PRG=sha256sum SOURCE_FORMAT=tar.gz SOURCE_IN_SUBDIR=true diff --git a/manifest.json b/manifest.json index ea3211f..9deb5fb 100644 --- a/manifest.json +++ b/manifest.json @@ -8,7 +8,7 @@ }, "url": "https://roundcube.net/", "license": "GPL-3", - "version": "1.3.6~ynh1", + "version": "1.3.8~ynh1", "maintainer": { "name": "YunoHost Contributors", "email": "apps@yunohost.org" From e2227de021b65461df7794db3820f2501c7ba2fd Mon Sep 17 00:00:00 2001 From: Yalh Date: Mon, 28 Jan 2019 04:10:27 +0100 Subject: [PATCH 02/13] Fix Build status svg --- README.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index bccc505..33c41e9 100644 --- a/README.md +++ b/README.md @@ -92,9 +92,9 @@ Can the app be used by multiple users? #### Supported architectures -* x86-64b - [![Build Status](https://ci-apps.yunohost.org/ci/logs/roundcube%20%28Community%29.svg)](https://ci-apps.yunohost.org/ci/apps/roundcube/) -* ARMv8-A - [![Build Status](https://ci-apps-arm.yunohost.org/ci/logs/roundcube%20%28Community%29.svg)](https://ci-apps-arm.yunohost.org/ci/apps/roundcube/) -* Jessie x86-64b - [![Build Status](https://ci-stretch.nohost.me/ci/logs/roundcube%20%28Community%29.svg)](https://ci-stretch.nohost.me/ci/apps/roundcube/) +* x86-64b - [![Build Status](https://ci-apps.yunohost.org/ci/logs/roundcube%20%28Official%29.svg)](https://ci-apps.yunohost.org/ci/apps/roundcube/) +* ARMv8-A - [![Build Status](https://ci-apps-arm.yunohost.org/ci/logs/roundcube%20%28Official%29.svg)](https://ci-apps-arm.yunohost.org/ci/apps/roundcube/) +* Jessie x86-64b - [![Build Status](https://ci-stretch.nohost.me/ci/logs/roundcube%20%28Official%29.svg)](https://ci-stretch.nohost.me/ci/apps/roundcube/) ## Limitations From d55969c64e19fa588b39e18753f9caa35b4e2b8c Mon Sep 17 00:00:00 2001 From: Yalh Date: Mon, 28 Jan 2019 04:17:58 +0100 Subject: [PATCH 03/13] Upgrade cardav version --- scripts/_common.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/_common.sh b/scripts/_common.sh index 959dc15..cf6b55e 100644 --- a/scripts/_common.sh +++ b/scripts/_common.sh @@ -15,7 +15,7 @@ fi # Plugins version contextmenu_version=2.3 automatic_addressbook_version=v0.4.3 -carddav_version=2.0.4 +carddav_version=3.0.3 # ============================================================================= # COMMON ROUNDCUBE FUNCTIONS From b435b69aa351105e8ad0dfc83c118eb2c166e667 Mon Sep 17 00:00:00 2001 From: Yalh Date: Mon, 28 Jan 2019 04:54:35 +0100 Subject: [PATCH 04/13] Fix serveral errors from package_linter not [YEP-2.4] compliant --- scripts/backup | 25 ++++++++++++------------- scripts/restore | 25 ++++++++++++------------- 2 files changed, 24 insertions(+), 26 deletions(-) diff --git a/scripts/backup b/scripts/backup index 4deae33..10f2b20 100644 --- a/scripts/backup +++ b/scripts/backup @@ -2,25 +2,24 @@ #================================================= # GENERIC START -#================================================= -# MANAGE SCRIPT FAILURE -#================================================= - -# Exit on command errors and treat access to unset variables as an error -set -eu - #================================================= # IMPORT GENERIC HELPERS #================================================= -if [ ! -e _common.sh ]; then - # Get the _common.sh file if it's not in the current directory - cp ../settings/scripts/_common.sh ./_common.sh - chmod a+rx _common.sh -fi -source _common.sh +source ../settings/scripts/_common.sh source /usr/share/yunohost/helpers +#================================================= +# MANAGE SCRIPT FAILURE +#================================================= + +ynh_clean_setup () { + ### Remove this function if there's nothing to clean before calling the remove script. + true +} +# Exit if an error occurs during the execution of the script +ynh_abort_if_errors + #================================================= # LOAD SETTINGS #================================================= diff --git a/scripts/restore b/scripts/restore index db99773..cc76381 100644 --- a/scripts/restore +++ b/scripts/restore @@ -2,25 +2,24 @@ #================================================= # GENERIC START -#================================================= -# MANAGE SCRIPT FAILURE -#================================================= - -# Exit on command errors and treat access to unset variables as an error -set -eu - #================================================= # IMPORT GENERIC HELPERS #================================================= -if [ ! -e _common.sh ]; then - # Get the _common.sh file if it's not in the current directory - cp ../settings/scripts/_common.sh ./_common.sh - chmod a+rx _common.sh -fi -source _common.sh +source ../settings/scripts/_common.sh source /usr/share/yunohost/helpers +#================================================= +# MANAGE SCRIPT FAILURE +#================================================= + +ynh_clean_setup () { + #### Remove this function if there's nothing to clean before calling the remove script. + true +} +# Exit if an error occurs during the execution of the script +ynh_abort_if_errors + #================================================= # LOAD SETTINGS #================================================= From 040196ab083cc0c152574a414707ef398827f2c0 Mon Sep 17 00:00:00 2001 From: Yalh Date: Mon, 28 Jan 2019 04:58:51 +0100 Subject: [PATCH 05/13] Fix licence informations --- README.md | 6 +++++- manifest.json | 2 +- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 33c41e9..129dc25 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -Roundcube for YunoHost +# Roundcube for YunoHost ---------------------- [![Integration level](https://dash.yunohost.org/integration/roundcube.svg)](https://dash.yunohost.org/appci/app/roundcube) @@ -15,6 +15,10 @@ an application-like user interface. ![](https://roundcube.net/images/screens/mailview.jpg) +## Licence + +LICENCE: GPL-3.0-only + ## Features In addition to Roundcube core features, the following are made available with diff --git a/manifest.json b/manifest.json index 9deb5fb..d61d19a 100644 --- a/manifest.json +++ b/manifest.json @@ -7,7 +7,7 @@ "fr": "Webmail Open Source" }, "url": "https://roundcube.net/", - "license": "GPL-3", + "license": "GPL-3.0-only", "version": "1.3.8~ynh1", "maintainer": { "name": "YunoHost Contributors", From f307b4cc25ab25b8d8cadd72b96ea318ba507da2 Mon Sep 17 00:00:00 2001 From: yalh76 Date: Thu, 28 Feb 2019 00:17:18 +0100 Subject: [PATCH 06/13] roll back to test an upgrade --- check_process | 1 + 1 file changed, 1 insertion(+) diff --git a/check_process b/check_process index bac5b8d..04fdec0 100644 --- a/check_process +++ b/check_process @@ -12,6 +12,7 @@ setup_private=0 setup_public=0 upgrade=1 + upgrade=1 from_commit=8d0acb6953a4c4c2206985c7d9881c5b7b637ebd backup_restore=1 multi_instance=1 incorrect_path=1 From 1112b12b1d7ebe7702f642d86b17c403ae23117f Mon Sep 17 00:00:00 2001 From: Maniack Crudelis Date: Sun, 3 Mar 2019 18:12:41 +0100 Subject: [PATCH 07/13] Normalization from example_ynh --- README.md | 66 ++++++++++--- conf/config.inc.php | 4 +- conf/nginx.conf | 10 +- manifest.json | 8 +- scripts/_common.sh | 104 ++++++++------------ scripts/_getopts_fix.sh | 213 ++++++++++++++++++++++++++++++++++++++++ scripts/backup | 21 ++-- scripts/install | 97 ++++++++++-------- scripts/remove | 17 +--- scripts/restore | 67 ++++++------- scripts/upgrade | 173 ++++++++++++++++++-------------- 11 files changed, 519 insertions(+), 261 deletions(-) create mode 100644 scripts/_getopts_fix.sh diff --git a/README.md b/README.md index 7bebd8d..b9c199d 100644 --- a/README.md +++ b/README.md @@ -1,14 +1,36 @@ -Roundcube for YunoHost ----------------------- +# Roundcube for YunoHost + +[![Integration level](https://dash.yunohost.org/integration/roundcube.svg)](https://dash.yunohost.org/appci/app/roundcube) +[![Install Roundcube with YunoHost](https://install-app.yunohost.org/install-with-yunohost.png)](https://install-app.yunohost.org/?app=roundcube) + +> *This package allow you to install Roundcube quickly and simply on a YunoHost server. +If you don't have YunoHost, please see [here](https://yunohost.org/#/install) to know how to install and enjoy it.* + +## Overview [Roundcube](https://roundcube.net/) is a browser-based multilingual IMAP client with an application-like user interface. **Shipped version:** 1.3.6 -![](https://roundcube.net/images/screens/mailview.jpg) +## Screenshots -## Features +![](https://roundcube.net/images/screens/mailbox.png) + +## Demo + +* [YunoHost demo](https://demo.yunohost.org/webmail/) + +## Configuration + +You can extend - or even override - the Roundcube configuration which is coming with this package in the file `conf/local.inc.php`. Do not edit the file `conf/config.inc.php` as future upgrades will overwrite it. + +## Documentation + + * Official documentation: https://github.com/roundcube/roundcubemail/wiki + * YunoHost documentation: https://github.com/YunoHost/doc/blob/master/app_roundcube.md + +## YunoHost specific features In addition to Roundcube core features, the following are made available with this package: @@ -24,20 +46,24 @@ this package: you have installed ownCloud or Baïkal, it will automatically add the corresponding and existing address book. -## Extend and tweak +#### Multi-users support -### Configuration +#### Supported architectures -You can extend - or even override - the Roundcube configuration which is coming -with this package in the file `conf/local.inc.php`. Do not edit the file -`conf/config.inc.php` as future upgrades will overwrite it. +* x86-64b - [![Build Status](https://ci-apps.yunohost.org/ci/logs/roundcube%20%28Official%29.svg)](https://ci-apps.yunohost.org/ci/apps/roundcube/) +* ARMv8-A - [![Build Status](https://ci-apps-arm.yunohost.org/ci/logs/roundcube%20%28Official%29.svg)](https://ci-apps-arm.yunohost.org/ci/apps/roundcube/) +* Jessie x86-64b - [![Build Status](https://ci-stretch.nohost.me/ci/logs/roundcube%20%28Official%29.svg)](https://ci-stretch.nohost.me/ci/apps/roundcube/) -### Plugins +## Limitations + +## Additional information + +#### Plugins You can also install other plugins - which will not be removed with upgrades. To do so, you can use the official [Plugin Repository](https://plugins.roundcube.net/). -#### From the Plugin Repository +##### From the Plugin Repository Let's say for example that we want to install the [html5_notifier](https://plugins.roundcube.net/packages/kitist/html5_notifier) plugin. @@ -71,12 +97,28 @@ Let's say for example that we want to install the Note that you should also check the plugin homepage for additional installation steps as needed. -#### Manual installation +##### Manual installation You can also download the plugin and put it under the `plugins/` directory. In this case, do not forget to change ownerships of this folder to `roundcube`. ## Links + * Report a bug: https://github.com/YunoHost-Apps/roundcube_ynh/issues * Roundcube website: https://roundcube.net/ * YunoHost website: https://yunohost.org/ + +--- + +Developers info +---------------- + +**Only if you want to use a testing branch for coding, instead of merging directly into master.** +Please do your pull request to the [testing branch](https://github.com/YunoHost-Apps/roundcube_ynh/tree/testing). + +To try the testing branch, please proceed like that. +``` +sudo yunohost app install https://github.com/YunoHost-Apps/roundcube_ynh/tree/testing --debug +or +sudo yunohost app upgrade roundcube -u https://github.com/YunoHost-Apps/roundcube_ynh/tree/testing --debug +``` diff --git a/conf/config.inc.php b/conf/config.inc.php index 2ba5c5e..f1b5959 100644 --- a/conf/config.inc.php +++ b/conf/config.inc.php @@ -32,7 +32,7 @@ $config = array(); // Currently supported db_providers: mysql, pgsql, sqlite, mssql or sqlsrv // For examples see http://pear.php.net/manual/en/package.database.mdb2.intro-dsn.php // NOTE: for SQLite use absolute path: 'sqlite:////full/path/to/sqlite.db?mode=0646' -$config['db_dsnw'] = 'mysql://#DBUSER#:#DBPASS#@localhost/#DBNAME#'; +$config['db_dsnw'] = 'mysql://__DBUSER__:__DBPASS__@localhost/__DBNAME__'; // The mail host chosen to perform the log-in. // Leave blank to show a textbox at login, give a list of hosts @@ -94,7 +94,7 @@ $config['product_name'] = 'YunoHost Webmail'; // in the session record (and the client cookie if remember password is enabled). // please provide a string of exactly 24 chars. // YOUR KEY MUST BE DIFFERENT THAN THE SAMPLE VALUE FOR SECURITY REASONS -$config['des_key'] = '#DESKEY#'; +$config['des_key'] = '__DESKEY__'; // skin name: folder from skins/ $config['skin'] = 'larry'; diff --git a/conf/nginx.conf b/conf/nginx.conf index 4d3f57a..729c27d 100644 --- a/conf/nginx.conf +++ b/conf/nginx.conf @@ -1,6 +1,10 @@ -location __PATH__ { - alias __FINALPATH__/; +#sub_path_only rewrite ^__PATH__$ __PATH__/ permanent; +location __PATH__/ { + # Path to source + alias __FINALPATH__/ ; + + # Force usage of https if ($scheme = http) { rewrite ^ https://$server_name$request_uri? permanent; } @@ -21,7 +25,7 @@ location __PATH__ { include fastcgi_params; } - # show YunoHost panel access + # show YunoHost panel access include conf.d/yunohost_panel.conf.inc; } diff --git a/manifest.json b/manifest.json index ea3211f..330e323 100644 --- a/manifest.json +++ b/manifest.json @@ -6,22 +6,22 @@ "en": "Open Source Webmail software", "fr": "Webmail Open Source" }, + "version": "1.3.6~ynh2", "url": "https://roundcube.net/", "license": "GPL-3", - "version": "1.3.6~ynh1", "maintainer": { "name": "YunoHost Contributors", "email": "apps@yunohost.org" }, + "requirements": { + "yunohost": ">= 3.2.0" + }, "multi_instance": true, "services": [ "nginx", "php5-fpm", "mysql" ], - "requirements": { - "yunohost": ">= 2.7.2" - }, "arguments": { "install" : [ { diff --git a/scripts/_common.sh b/scripts/_common.sh index 959dc15..2272cdb 100644 --- a/scripts/_common.sh +++ b/scripts/_common.sh @@ -1,84 +1,60 @@ - +#!/bin/bash # ============================================================================= # COMMON VARIABLES # ============================================================================= # Package dependencies -pkg_dependencies="php5-cli php5-common php5-intl php5-json php5-mcrypt php-pear php-auth-sasl php-mail-mime php-patchwork-utf8 php-net-smtp php-net-socket php-net-ldap2 php-net-ldap3" -if [ "$(lsb_release --codename --short)" != "jessie" ]; then - pkg_dependencies="$pkg_dependencies php-zip php-gd php-mbstring" -else - pkg_dependencies="$pkg_dependencies php-crypt-gpg" -fi +pkg_dependencies="php-cli php-common php-intl php-json php-mcrypt php-pear php-auth-sasl php-mail-mime php-patchwork-utf8 php-net-smtp php-net-socket php-net-ldap2 php-net-ldap3 php-zip php-gd php-mbstring" # Plugins version contextmenu_version=2.3 automatic_addressbook_version=v0.4.3 carddav_version=2.0.4 -# ============================================================================= -# COMMON ROUNDCUBE FUNCTIONS -# ============================================================================= +#================================================= +# EXPERIMENTAL HELPERS +#================================================= -# Execute a composer command from a given directory -# usage: composer_exec workdir COMMAND [ARG ...] -exec_composer() { - local workdir=$1 - shift 1 +# Execute a command with Composer +# +# usage: ynh_composer_exec [--workdir=$final_path] --commands="commands" +# | arg: -w, --workdir - The directory from where the command will be executed. Default $final_path. +# | arg: -c, --commands - Commands to execute. +ynh_composer_exec () { + # Declare an array to define the options of this helper. + local legacy_args=wc + declare -Ar args_array=( [w]=workdir= [c]=commands= ) + local workdir + local commands + # Manage arguments with getopts + ynh_handle_getopts_args "$@" + workdir="${workdir:-$final_path}" - COMPOSER_HOME="${workdir}/.composer" \ - php "${workdir}/composer.phar" $@ \ - -d "${workdir}" --quiet --no-interaction + COMPOSER_HOME="$workdir/.composer" \ + php "$workdir/composer.phar" $commands \ + -d "$workdir" --quiet --no-interaction } # Install and initialize Composer in the given directory -# usage: init_composer destdir -init_composer() { - local destdir=$1 +# +# usage: ynh_install_composer [--workdir=$final_path] +# | arg: -w, --workdir - The directory from where the command will be executed. Default $final_path. +ynh_install_composer () { + # Declare an array to define the options of this helper. + local legacy_args=w + declare -Ar args_array=( [w]=workdir= ) + local workdir + # Manage arguments with getopts + ynh_handle_getopts_args "$@" + workdir="${workdir:-$final_path}" - # install composer - curl -sS https://getcomposer.org/installer \ - | COMPOSER_HOME="${destdir}/.composer" \ - php -- --quiet --install-dir="$destdir" \ - || ynh_die "Unable to install Composer" + curl -sS https://getcomposer.org/installer \ + | COMPOSER_HOME="$workdir/.composer" \ + php -- --quiet --install-dir="$workdir" \ + || ynh_die "Unable to install Composer." - # install composer.json - cp "${destdir}/composer.json-dist" "${destdir}/composer.json" - - # update dependencies to create composer.lock - exec_composer "$destdir" install --no-dev \ - || ynh_die "Unable to update Roundcube core dependencies" -} - -# Install and configure CardDAV plugin for Roundcube -# usage: install_carddav destdir -# https://plugins.roundcube.net/packages/roundcube/carddav -install_carddav() { - local destdir=$1 - - local carddav_config="${destdir}/plugins/carddav/config.inc.php" - local carddav_tmp_config="../conf/carddav.config.inc.php" - - exec_composer "$destdir" require \ - "roundcube/carddav $carddav_version" - - # Look for installed and supported CardDAV servers - for carddav_app in "owncloud" "baikal"; do - local app_id=$(yunohost app list --installed -f "$carddav_app" \ - --output-as json | grep -Po '"id":[ ]?"\K.*?(?=")' | head -1) - [[ -z "$app_id" ]] || { - # Retrieve app settings and enable relevant preset - carddav_domain=$(ynh_app_setting_get "$app_id" domain) - carddav_path=$(ynh_app_setting_get "$app_id" path) - carddav_url="https://${carddav_domain}${carddav_path%/}" - sed -i "s#{${carddav_app}_url}#${carddav_url}#g" "$carddav_tmp_config" - sed -i \ -"/\/\/\/\/ PRESET FOR: ${carddav_app}/\ -,/\/\/\/\/ END: ${carddav_app}/s/^\/\///" "$carddav_tmp_config" - } - done - - # Copy plugin the configuration file - cp "$carddav_tmp_config" "$carddav_config" + # update dependencies to create composer.lock + ynh_composer_exec --workdir="$workdir" --commands="install --no-dev" \ + || ynh_die "Unable to update core dependencies with Composer." } diff --git a/scripts/_getopts_fix.sh b/scripts/_getopts_fix.sh new file mode 100644 index 0000000..25a71be --- /dev/null +++ b/scripts/_getopts_fix.sh @@ -0,0 +1,213 @@ +#!/bin/bash + +#================================================= +# FIX OF YNH_HANDLE_GETOPTS_ARGS FROM UNSTABLE +#================================================= + +# Internal helper design to allow helpers to use getopts to manage their arguments +# +# [internal] +# +# example: function my_helper() +# { +# declare -Ar args_array=( [a]=arg1= [b]=arg2= [c]=arg3 ) +# local arg1 +# local arg2 +# local arg3 +# ynh_handle_getopts_args "$@" +# +# [...] +# } +# my_helper --arg1 "val1" -b val2 -c +# +# usage: ynh_handle_getopts_args "$@" +# | arg: $@ - Simply "$@" to tranfert all the positionnal arguments to the function +# +# This helper need an array, named "args_array" with all the arguments used by the helper +# that want to use ynh_handle_getopts_args +# Be carreful, this array has to be an associative array, as the following example: +# declare -Ar args_array=( [a]=arg1 [b]=arg2= [c]=arg3 ) +# Let's explain this array: +# a, b and c are short options, -a, -b and -c +# arg1, arg2 and arg3 are the long options associated to the previous short ones. --arg1, --arg2 and --arg3 +# For each option, a short and long version has to be defined. +# Let's see something more significant +# declare -Ar args_array=( [u]=user [f]=finalpath= [d]=database ) +# +# NB: Because we're using 'declare' without -g, the array will be declared as a local variable. +# +# Please keep in mind that the long option will be used as a variable to store the values for this option. +# For the previous example, that means that $finalpath will be fill with the value given as argument for this option. +# +# Also, in the previous example, finalpath has a '=' at the end. That means this option need a value. +# So, the helper has to be call with --finalpath /final/path, --finalpath=/final/path or -f /final/path, the variable $finalpath will get the value /final/path +# If there's many values for an option, -f /final /path, the value will be separated by a ';' $finalpath=/final;/path +# For an option without value, like --user in the example, the helper can be called only with --user or -u. $user will then get the value 1. +# +# To keep a retrocompatibility, a package can still call a helper, using getopts, with positional arguments. +# The "legacy mode" will manage the positional arguments and fill the variable in the same order than they are given in $args_array. +# e.g. for `my_helper "val1" val2`, arg1 will be filled with val1, and arg2 with val2. +ynh_handle_getopts_args () { + # Manage arguments only if there's some provided + set +x + if [ $# -ne 0 ] + then + # Store arguments in an array to keep each argument separated + local arguments=("$@") + + # For each option in the array, reduce to short options for getopts (e.g. for [u]=user, --user will be -u) + # And built parameters string for getopts + # ${!args_array[@]} is the list of all option_flags in the array (An option_flag is 'u' in [u]=user, user is a value) + local getopts_parameters="" + local option_flag="" + for option_flag in "${!args_array[@]}" + do + # Concatenate each option_flags of the array to build the string of arguments for getopts + # Will looks like 'abcd' for -a -b -c -d + # If the value of an option_flag finish by =, it's an option with additionnal values. (e.g. --user bob or -u bob) + # Check the last character of the value associate to the option_flag + if [ "${args_array[$option_flag]: -1}" = "=" ] + then + # For an option with additionnal values, add a ':' after the letter for getopts. + getopts_parameters="${getopts_parameters}${option_flag}:" + else + getopts_parameters="${getopts_parameters}${option_flag}" + fi + # Check each argument given to the function + local arg="" + # ${#arguments[@]} is the size of the array + for arg in `seq 0 $(( ${#arguments[@]} - 1 ))` + do + # And replace long option (value of the option_flag) by the short option, the option_flag itself + # (e.g. for [u]=user, --user will be -u) + # Replace long option with = + arguments[arg]="${arguments[arg]//--${args_array[$option_flag]}/-${option_flag} }" + # And long option without = + arguments[arg]="${arguments[arg]//--${args_array[$option_flag]%=}/-${option_flag}}" + done + done + + # Read and parse all the arguments + # Use a function here, to use standart arguments $@ and be able to use shift. + parse_arg () { + # Read all arguments, until no arguments are left + while [ $# -ne 0 ] + do + # Initialize the index of getopts + OPTIND=1 + # Parse with getopts only if the argument begin by -, that means the argument is an option + # getopts will fill $parameter with the letter of the option it has read. + local parameter="" + getopts ":$getopts_parameters" parameter || true + + if [ "$parameter" = "?" ] + then + ynh_die --message="Invalid argument: -${OPTARG:-}" + elif [ "$parameter" = ":" ] + then + ynh_die --message="-$OPTARG parameter requires an argument." + else + local shift_value=1 + # Use the long option, corresponding to the short option read by getopts, as a variable + # (e.g. for [u]=user, 'user' will be used as a variable) + # Also, remove '=' at the end of the long option + # The variable name will be stored in 'option_var' + local option_var="${args_array[$parameter]%=}" + # If this option doesn't take values + # if there's a '=' at the end of the long option name, this option takes values + if [ "${args_array[$parameter]: -1}" != "=" ] + then + # 'eval ${option_var}' will use the content of 'option_var' + eval ${option_var}=1 + else + # Read all other arguments to find multiple value for this option. + # Load args in a array + local all_args=("$@") + + # If the first argument is longer than 2 characters, + # There's a value attached to the option, in the same array cell + if [ ${#all_args[0]} -gt 2 ]; then + # Remove the option and the space, so keep only the value itself. + all_args[0]="${all_args[0]#-${parameter} }" + # Reduce the value of shift, because the option has been removed manually + shift_value=$(( shift_value - 1 )) + fi + + # Declare the content of option_var as a variable. + eval ${option_var}="" + # Then read the array value per value + local i + for i in `seq 0 $(( ${#all_args[@]} - 1 ))` + do + # If this argument is an option, end here. + if [ "${all_args[$i]:0:1}" == "-" ] + then + # Ignore the first value of the array, which is the option itself + if [ "$i" -ne 0 ]; then + break + fi + else + # Else, add this value to this option + # Each value will be separated by ';' + if [ -n "${!option_var}" ] + then + # If there's already another value for this option, add a ; before adding the new value + eval ${option_var}+="\;" + fi + # Escape double quote to prevent any interpretation during the eval + all_args[$i]="${all_args[$i]//\"/\\\"}" + + eval ${option_var}+=\"${all_args[$i]}\" + shift_value=$(( shift_value + 1 )) + fi + done + fi + fi + + # Shift the parameter and its argument(s) + shift $shift_value + done + } + + # LEGACY MODE + # Check if there's getopts arguments + if [ "${arguments[0]:0:1}" != "-" ] + then + # If not, enter in legacy mode and manage the arguments as positionnal ones.. + # Dot not echo, to prevent to go through a helper output. But print only in the log. + set -x; echo "! Helper used in legacy mode !" > /dev/null; set +x + local i + for i in `seq 0 $(( ${#arguments[@]} -1 ))` + do + # Try to use legacy_args as a list of option_flag of the array args_array + # Otherwise, fallback to getopts_parameters to get the option_flag. But an associative arrays isn't always sorted in the correct order... + # Remove all ':' in getopts_parameters + getopts_parameters=${legacy_args:-${getopts_parameters//:}} + # Get the option_flag from getopts_parameters, by using the option_flag according to the position of the argument. + option_flag=${getopts_parameters:$i:1} + if [ -z "$option_flag" ]; then + ynh_print_warn --message="Too many arguments ! \"${arguments[$i]}\" will be ignored." + continue + fi + # Use the long option, corresponding to the option_flag, as a variable + # (e.g. for [u]=user, 'user' will be used as a variable) + # Also, remove '=' at the end of the long option + # The variable name will be stored in 'option_var' + local option_var="${args_array[$option_flag]%=}" + + # Escape double quote to prevent any interpretation during the eval + arguments[$i]="${arguments[$i]//\"/\\\"}" + + # Store each value given as argument in the corresponding variable + # The values will be stored in the same order than $args_array + eval ${option_var}+=\"${arguments[$i]}\" + done + unset legacy_args + else + # END LEGACY MODE + # Call parse_arg and pass the modified list of args as an array of arguments. + parse_arg "${arguments[@]}" + fi + fi + set -x +} diff --git a/scripts/backup b/scripts/backup index 4deae33..f7090cb 100644 --- a/scripts/backup +++ b/scripts/backup @@ -2,25 +2,20 @@ #================================================= # GENERIC START -#================================================= -# MANAGE SCRIPT FAILURE -#================================================= - -# Exit on command errors and treat access to unset variables as an error -set -eu - #================================================= # IMPORT GENERIC HELPERS #================================================= -if [ ! -e _common.sh ]; then - # Get the _common.sh file if it's not in the current directory - cp ../settings/scripts/_common.sh ./_common.sh - chmod a+rx _common.sh -fi -source _common.sh +source ../settings/scripts/_common.sh source /usr/share/yunohost/helpers +#================================================= +# MANAGE SCRIPT FAILURE +#================================================= + +# Exit if an error occurs during the execution of the script +ynh_abort_if_errors + #================================================= # LOAD SETTINGS #================================================= diff --git a/scripts/install b/scripts/install index bcdb8f1..409aed0 100644 --- a/scripts/install +++ b/scripts/install @@ -6,8 +6,11 @@ # IMPORT GENERIC HELPERS #================================================= -source ./_common.sh +source _common.sh source /usr/share/yunohost/helpers +# Overload the helper ynh_handle_getopts_args to have fixes from unstable. +# Needed for composer helpers +source _getopts_fix.sh #================================================= # MANAGE SCRIPT FAILURE @@ -31,14 +34,12 @@ app=$YNH_APP_INSTANCE_NAME # CHECK IF THE APP CAN BE INSTALLED WITH THESE ARGS #================================================= -# Normalize the url path syntax -path_url=$(ynh_normalize_url_path $path_url) - final_path=/var/www/$app test ! -e "$final_path" || ynh_die "This path already contains a folder" -# Check web path availability -ynh_webpath_available $domain $path_url +# Normalize the url path syntax +path_url=$(ynh_normalize_url_path $path_url) + # Register (book) web path ynh_webpath_register $app $domain $path_url @@ -57,14 +58,6 @@ ynh_app_setting_set $app with_enigma $with_enigma # INSTALL DEPENDENCIES #================================================= -# jessie-backports is needed for php-net-ldap3 -if [ "$(lsb_release --codename --short)" = "jessie" ]; then - grep -q -R 'jessie-backports' /etc/apt/sources.list{,.d} || { - echo "deb http://httpredir.debian.org/debian jessie-backports main" \ - | tee -a /etc/apt/sources.list.d/backports.list >/dev/null - } -fi - ynh_install_app_dependencies "$pkg_dependencies" #================================================= @@ -110,69 +103,96 @@ ynh_add_fpm_config # INSTALL AND INITIALIZE COMPOSER #================================================= -init_composer "$final_path" +# Install composer.json +cp "$final_path/composer.json-dist" "$final_path/composer.json" + +# Install composer +ynh_install_composer #================================================= # INITIALIZE DATABASE #================================================= ynh_mysql_connect_as "$db_name" "$db_pwd" "$db_name" \ - < "${final_path}/SQL/mysql.initial.sql" + < "$final_path/SQL/mysql.initial.sql" #================================================= # CONFIGURE ROUNDCUBE #================================================= +rc_conf="$final_path/config/config.inc.php" -rc_conf="${final_path}/config/config.inc.php" cp ../conf/config.inc.php "$rc_conf" -ynh_replace_string "#DESKEY#" "$(ynh_string_random 24)" "$rc_conf" -ynh_replace_string "#DBUSER#" "$db_name" "$rc_conf" -ynh_replace_string "#DBPASS#" "$db_pwd" "$rc_conf" -ynh_replace_string "#DBNAME#" "$db_name" "$rc_conf" +ynh_replace_string "__DESKEY__" "$(ynh_string_random 24)" "$rc_conf" +ynh_replace_string "__DBUSER__" $db_name "$rc_conf" +ynh_replace_string "__DBPASS__" "$db_pwd" "$rc_conf" +ynh_replace_string "__DBNAME__" $db_name "$rc_conf" #================================================= # INSTALL ADDITIONAL PLUGINS #================================================= # Create logs and temp directories -mkdir -p "${final_path}/logs" "${final_path}/temp" +mkdir -p "$final_path/"{logs,temp} # Install contextmenu and automatic_addressbook plugins # https://plugins.roundcube.net/packages/sblaisot/automatic_addressbook # https://plugins.roundcube.net/packages/johndoh/contextmenu -exec_composer "$final_path" require \ - "johndoh/contextmenu $contextmenu_version" \ - "sblaisot/automatic_addressbook $automatic_addressbook_version" +ynh_composer_exec --commands="require \ + johndoh/contextmenu $contextmenu_version \ + sblaisot/automatic_addressbook $automatic_addressbook_version" + installed_plugins+=" 'contextmenu', 'automatic_addressbook'," # Install CardDAV plugin -if [[ $with_carddav -eq 1 ]]; then - install_carddav "$final_path" \ - && installed_plugins+=" 'carddav'," \ - || echo "Unable to install CardDAV plugin" >&2 +if [ $with_carddav -eq 1 ] +then + ynh_composer_exec --commands="require roundcube/carddav $carddav_version" + + carddav_tmp_config="../conf/carddav.config.inc.php" + + # Look for installed and supported CardDAV servers + for carddav_app in "owncloud" "baikal" + do + carddav_app_id=$(yunohost app list --installed -f $carddav_app \ + --output-as json | grep -Po '"id":[ ]?"\K.*?(?=")' | head -1) + if [ -n "$carddav_app_id" ] + then + # Retrieve app settings and enable relevant preset + carddav_domain=$(ynh_app_setting_get $carddav_app_id domain) + carddav_path=$(ynh_app_setting_get $carddav_app_id path) + carddav_url="https://${carddav_domain}${carddav_path%/}" + ynh_replace_string "{${carddav_app}_url}" "$carddav_url" "$carddav_tmp_config" + sed -i "/\/\/\/\/ PRESET FOR: $carddav_app/,/\/\/\/\/ END: $carddav_app/s/^\/\///" "$carddav_tmp_config" + fi + done + + # Copy the plugin configuration file + cp "$carddav_tmp_config" ""$final_path/plugins/carddav/config.inc.php"" + + installed_plugins+=" 'carddav'," fi # Install Enigma plugin -if [[ $with_enigma -eq 1 ]]; then - cp -a "$final_path/plugins/enigma/config.inc.php.dist" "$final_path/plugins/enigma/config.inc.php" \ - && installed_plugins+=" 'enigma'," \ - || echo "Unable to install Enigma plugin" >&2 +if [ $with_enigma -eq 1 ] +then + cp -a "$final_path/plugins/enigma/config.inc.php.dist" "$final_path/plugins/enigma/config.inc.php" \ + && installed_plugins+=" 'enigma'," \ + || ynh_print_warn "Unable to install Enigma plugin" fi #================================================= # UPDATE ROUNDCUBE CONFIGURATION #================================================= -sed -i "s#^\s*// installed plugins#&\n ${installed_plugins}#" \ - "${final_path}/config/config.inc.php" +ynh_replace_string "^\s*// installed plugins" "&\n $installed_plugins" "$rc_conf" # Update javascript dependencies -(cd "${final_path}" +(cd "$final_path" /usr/bin/php -q ./bin/install-jsdeps.sh) # Store the config file checksum into the app settings -ynh_store_file_checksum "${final_path}/config/config.inc.php" +ynh_store_file_checksum "$rc_conf" #================================================= # GENERIC FINALIZATION @@ -182,8 +202,7 @@ ynh_store_file_checksum "${final_path}/config/config.inc.php" # Set permissions to app files chown -R root: "$final_path" -chown -R $app: "${final_path}/temp/" "${final_path}/logs/" -chown -R $app: "$final_path/plugins/enigma/home" +chown -R $app: "$final_path/"{temp,logs,plugins/enigma/home} #================================================= # RELOAD NGINX diff --git a/scripts/remove b/scripts/remove index eb2be9e..6b9efce 100644 --- a/scripts/remove +++ b/scripts/remove @@ -6,12 +6,6 @@ # IMPORT GENERIC HELPERS #================================================= -if [ ! -e _common.sh ]; then - # Get file fonction if not been to the current directory - cp ../settings/scripts/_common.sh ./_common.sh - chmod a+rx _common.sh -fi -# Source app helpers source _common.sh source /usr/share/yunohost/helpers @@ -23,6 +17,7 @@ app=$YNH_APP_INSTANCE_NAME domain=$(ynh_app_setting_get $app domain) db_name=$(ynh_app_setting_get $app db_name) +final_path=$(ynh_app_setting_get $app final_path) #================================================= # STANDARD REMOVE @@ -45,7 +40,7 @@ ynh_mysql_remove_db $db_name $db_name #================================================= # Remove the app directory securely -ynh_secure_remove "/var/www/$app" +ynh_secure_remove "$final_path" #================================================= # REMOVE NGINX CONFIGURATION @@ -61,14 +56,6 @@ ynh_remove_nginx_config # Remove the dedicated php-fpm config ynh_remove_fpm_config -#================================================= -# SPECIFIC REMOVE -#================================================= - -# The following command is kept as a matter of transition with the previous way -# of managing dependencies -ynh_package_autoremove "roundcube-ynh-deps" || true - #================================================= # GENERIC FINALIZATION #================================================= diff --git a/scripts/restore b/scripts/restore index db99773..852ce8a 100644 --- a/scripts/restore +++ b/scripts/restore @@ -2,25 +2,20 @@ #================================================= # GENERIC START -#================================================= -# MANAGE SCRIPT FAILURE -#================================================= - -# Exit on command errors and treat access to unset variables as an error -set -eu - #================================================= # IMPORT GENERIC HELPERS #================================================= -if [ ! -e _common.sh ]; then - # Get the _common.sh file if it's not in the current directory - cp ../settings/scripts/_common.sh ./_common.sh - chmod a+rx _common.sh -fi -source _common.sh +source ../settings/scripts/_common.sh source /usr/share/yunohost/helpers +#================================================= +# MANAGE SCRIPT FAILURE +#================================================= + +# Exit if an error occurs during the execution of the script +ynh_abort_if_errors + #================================================= # LOAD SETTINGS #================================================= @@ -41,20 +36,6 @@ ynh_webpath_available $domain $path_url \ test ! -d $final_path \ || ynh_die "There is already a directory: $final_path " -#================================================= -# INSTALL DEPENDENCIES -#================================================= - -# jessie-backports is needed for php-net-ldap3 -if [ "$(lsb_release --codename --short)" = "jessie" ]; then - grep -q -R 'jessie-backports' /etc/apt/sources.list{,.d} || { - echo "deb http://httpredir.debian.org/debian jessie-backports main" \ - | tee -a /etc/apt/sources.list.d/backports.list >/dev/null - } -fi - -ynh_install_app_dependencies "$pkg_dependencies" - #================================================= # STANDARD RESTORATION STEPS #================================================= @@ -69,14 +50,6 @@ ynh_restore_file "/etc/nginx/conf.d/$domain.d/$app.conf" ynh_restore_file "$final_path" -#================================================= -# RESTORE THE MYSQL DATABASE -#================================================= - -db_pwd=$(ynh_app_setting_get $app mysqlpwd) -ynh_mysql_setup_db $db_name $db_name $db_pwd -ynh_mysql_connect_as $db_name $db_pwd $db_name < ./db.sql - #================================================= # RECREATE THE DEDICATED USER #================================================= @@ -90,19 +63,37 @@ ynh_system_user_create $app # Restore permissions on app files chown -R root: "$final_path" -chown -R $app: "${final_path}/temp/" "${final_path}/logs/" +chown -R $app: "$final_path/"{temp,logs,plugins/enigma/home} #================================================= # RESTORE THE PHP-FPM CONFIGURATION #================================================= -ynh_restore_file "/etc/php5/fpm/pool.d/$app.conf" +ynh_restore_file "/etc/php/7.0/fpm/pool.d/$app.conf" #================================================= -# GENERIC FINALISATION +# SPECIFIC RESTORATION +#================================================= +# REINSTALL DEPENDENCIES +#================================================= + +# Define and install dependencies +ynh_install_app_dependencies "$pkg_dependencies" + +#================================================= +# RESTORE THE MYSQL DATABASE +#================================================= + +db_pwd=$(ynh_app_setting_get $app mysqlpwd) +ynh_mysql_setup_db $db_name $db_name $db_pwd +ynh_mysql_connect_as $db_name $db_pwd $db_name < ./db.sql + +#================================================= +# GENERIC FINALIZATION #================================================= # RELOAD NGINX AND PHP-FPM #================================================= systemctl reload php5-fpm systemctl reload nginx + diff --git a/scripts/upgrade b/scripts/upgrade index 29b9259..0735540 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -8,6 +8,9 @@ source _common.sh source /usr/share/yunohost/helpers +# Overload the helper ynh_handle_getopts_args to have fixes from unstable. +# Needed for composer helpers +source _getopts_fix.sh #================================================= # LOAD SETTINGS @@ -38,15 +41,40 @@ if [ -z "$final_path" ]; then ynh_app_setting_set $app final_path $final_path fi +# If with_carddav doesn't exist, create it +if [ -z "$with_carddav" ]; then + if [ -f "$final_path/plugins/carddav/config.inc.php" ] + then + with_carddav=1 + else + with_carddav=0 + fi + ynh_app_setting_set $app with_carddav $with_carddav +fi + +# If with_enigma doesn't exist, create it +if [ -z "$with_enigma" ]; then + if [ -f "${final_path}/plugins/enigma/config.inc.php" ] + then + with_enigma=1 + else + with_enigma=0 + fi + ynh_app_setting_set $app with_enigma $with_enigma +fi + #================================================= # BACKUP BEFORE UPGRADE THEN ACTIVE TRAP #================================================= -ynh_backup_before_upgrade # Backup the current version of the app +# Backup the current version of the app +ynh_backup_before_upgrade ynh_clean_setup () { - ynh_restore_upgradebackup # restore it if the upgrade fails + # restore it if the upgrade fails + ynh_restore_upgradebackup } -ynh_abort_if_errors # Active trap pour arrêter le script si une erreur est détectée. +# Exit if an error occurs during the execution of the script +ynh_abort_if_errors #================================================= # CHECK THE PATH @@ -57,27 +85,6 @@ path_url=$(ynh_normalize_url_path $path_url) #================================================= # STANDARD UPGRADE STEPS -#================================================= -# INSTALL DEPENDENCIES -#================================================= - -# jessie-backports is needed for php-net-ldap3 -if [ "$(lsb_release --codename --short)" = "jessie" ]; then - grep -q -R 'jessie-backports' /etc/apt/sources.list{,.d} || { - echo "deb http://httpredir.debian.org/debian jessie-backports main" \ - | tee -a /etc/apt/sources.list.d/backports.list >/dev/null - } -fi - -ynh_install_app_dependencies "$pkg_dependencies" - -#================================================= -# CREATE DEDICATED USER -#================================================= - -# Create a system user -ynh_system_user_create $app - #================================================= # DOWNLOAD, CHECK AND UNPACK SOURCE #================================================= @@ -95,6 +102,19 @@ ynh_setup_source "$final_path" # Create a dedicated nginx config ynh_add_nginx_config +#================================================= +# UPGRADE DEPENDENCIES +#================================================= + +ynh_install_app_dependencies "$pkg_dependencies" + +#================================================= +# CREATE DEDICATED USER +#================================================= + +# Create a dedicated user (if not existing) +ynh_system_user_create $app + #================================================= # PHP-FPM CONFIGURATION #================================================= @@ -108,93 +128,106 @@ ynh_add_fpm_config # CONFIGURE ROUNDCUBE #================================================= -# Verify the checksum and backup the file if it's different -ynh_backup_if_checksum_is_different "${final_path}/config/config.inc.php" +rc_conf="$final_path/config/config.inc.php" + +# Verify the checksum and backup the file if it's different +ynh_backup_if_checksum_is_different "$rc_conf" -rc_conf="${final_path}/config/config.inc.php" cp ../conf/config.inc.php "$rc_conf" -ynh_replace_string "#DESKEY#" "$(ynh_string_random 24)" "$rc_conf" -ynh_replace_string "#DBUSER#" "$db_name" "$rc_conf" + +ynh_replace_string "__DESKEY__" "$(ynh_string_random 24)" "$rc_conf" +ynh_replace_string "__DBUSER__" $db_name "$rc_conf" db_pwd=$(ynh_app_setting_get $app mysqlpwd) -ynh_replace_string "#DBPASS#" "$db_pwd" "$rc_conf" -ynh_replace_string "#DBNAME#" "$db_name" "$rc_conf" +ynh_replace_string "__DBPASS__" "$db_pwd" "$rc_conf" +ynh_replace_string "__DBNAME__" $db_name "$rc_conf" #================================================= # UPDATE DEPENDENCIES WITH COMPOSER #================================================= # Check if dependencies need to be updated with composer -if [ -f "${final_path}/composer.json" ]; then - exec_composer "${final_path}" update --no-dev --prefer-dist +if [ -f "$final_path/composer.json" ] +then + ynh_exec_warn_less ynh_composer_exec --commands=\"update --no-dev --prefer-dist\" else - init_composer "${final_path}" -fi + # Install composer.json + cp "$final_path/composer.json-dist" "$final_path/composer.json" + # Install composer + ynh_install_composer +fi #================================================= # UPGRADE ADDITIONAL PLUGINS #================================================= # Create logs and temp directories -mkdir -p "${final_path}/logs" "${final_path}/temp" +mkdir -p "$final_path/"{logs,temp} # Update or install contextmenu and automatic_addressbook plugins # https://plugins.roundcube.net/packages/sblaisot/automatic_addressbook # https://plugins.roundcube.net/packages/johndoh/contextmenu -exec_composer "${final_path}" update --no-dev --prefer-dist \ - "johndoh/contextmenu $contextmenu_version" \ - "sblaisot/automatic_addressbook $automatic_addressbook_version" +ynh_composer_exec --commands="update --no-dev --prefer-dist \ + johndoh/contextmenu $contextmenu_version \ + sblaisot/automatic_addressbook $automatic_addressbook_version" + installed_plugins+=" 'contextmenu', 'automatic_addressbook'," -# Guess with_carddav value if empty -if [[ -z "${with_carddav:-}" ]]; then - [[ -f "${final_path}/plugins/carddav/config.inc.php" ]] \ - && with_carddav=1 \ - || with_carddav=0 - ynh_app_setting_set "$app" with_carddav "$with_carddav" -fi - # Update or install CardDAV plugin -if [[ $with_carddav -eq 1 ]]; then - install_carddav "${final_path}" \ - && installed_plugins+=" 'carddav'," \ - || echo "Unable to install CardDAV plugin" >&2 -fi +if [ $with_carddav -eq 1 ] +then + ynh_composer_exec --commands="require roundcube/carddav $carddav_version" -# Guess with_enigma value if empty -if [[ -z "${with_enigma:-}" ]]; then - [[ -f "${final_path}/plugins/enigma/config.inc.php" ]] \ - && with_enigma=1 \ - || with_enigma=0 - ynh_app_setting_set "$app" with_enigma "$with_enigma" + carddav_tmp_config="../conf/carddav.config.inc.php" + + # Look for installed and supported CardDAV servers + for carddav_app in "owncloud" "baikal" + do + carddav_app_id=$(yunohost app list --installed -f $carddav_app \ + --output-as json | grep -Po '"id":[ ]?"\K.*?(?=")' | head -1) + if [ -n "$carddav_app_id" ] + then + # Retrieve app settings and enable relevant preset + carddav_domain=$(ynh_app_setting_get $carddav_app_id domain) + carddav_path=$(ynh_app_setting_get $carddav_app_id path) + carddav_url="https://${carddav_domain}${carddav_path%/}" + ynh_replace_string "{${carddav_app}_url}" "$carddav_url" "$carddav_tmp_config" + sed -i "/\/\/\/\/ PRESET FOR: $carddav_app/,/\/\/\/\/ END: $carddav_app/s/^\/\///" "$carddav_tmp_config" + fi + done + + # Copy the plugin configuration file + cp "$carddav_tmp_config" ""$final_path/plugins/carddav/config.inc.php"" + + installed_plugins+=" 'carddav'," fi # Install Enigma plugin -if [[ $with_enigma -eq 1 ]]; then - cp -a "$final_path/plugins/enigma/config.inc.php.dist" "$final_path/plugins/enigma/config.inc.php" \ - && installed_plugins+=" 'enigma'," \ - || echo "Unable to install Enigma plugin" >&2 +if [ $with_enigma -eq 1 ] +then + cp -a "$final_path/plugins/enigma/config.inc.php.dist" "$final_path/plugins/enigma/config.inc.php" \ + && installed_plugins+=" 'enigma'," \ + || ynh_print_warn "Unable to install Enigma plugin" fi #================================================= # UPDATE ROUNDCUBE CONFIGURATION #================================================= -sed -i "s#^\s*// installed plugins#&\n ${installed_plugins}#" \ - "$rc_conf" +ynh_replace_string "^\s*// installed plugins" "&\n $installed_plugins" "$rc_conf" # Update javascript dependencies -( cd "${final_path}" +(cd "$final_path" /usr/bin/php -q ./bin/install-jsdeps.sh) # Store the config file checksum into the app settings -ynh_store_file_checksum "${final_path}/config/config.inc.php" +ynh_store_file_checksum "$rc_conf" #================================================= # UPDATE ROUNDCUBE CORE #================================================= -( cd "${final_path}" -./bin/update.sh --version=$oldversion -y) >&2 +( cd "$final_path" +ynh_exec_warn ./bin/update.sh --version=$oldversion -y) #================================================= # GENERIC FINALIZATION @@ -204,9 +237,7 @@ ynh_store_file_checksum "${final_path}/config/config.inc.php" # Set permissions to app files chown -R root: "$final_path" -chown -R $app: "${final_path}/temp/" "${final_path}/logs/" -chown -R $app: "$final_path/plugins/enigma/home" - +chown -R $app: "$final_path/"{temp,logs,plugins/enigma/home} #================================================= # RELOAD NGINX From 63a640c5def1b4f61d7965a391ac86fd6b1d2ecc Mon Sep 17 00:00:00 2001 From: Maniack Crudelis Date: Sun, 3 Mar 2019 18:13:57 +0100 Subject: [PATCH 08/13] Add progression with ynh_print_info --- scripts/backup | 11 +++++++++++ scripts/install | 21 +++++++++++++++++++++ scripts/remove | 13 +++++++++++++ scripts/restore | 12 ++++++++++++ scripts/upgrade | 20 ++++++++++++++++++++ 5 files changed, 77 insertions(+) diff --git a/scripts/backup b/scripts/backup index f7090cb..8d583c5 100644 --- a/scripts/backup +++ b/scripts/backup @@ -19,6 +19,7 @@ ynh_abort_if_errors #================================================= # LOAD SETTINGS #================================================= +ynh_print_info "Loading installation settings..." app=$YNH_APP_INSTANCE_NAME @@ -31,23 +32,33 @@ db_name=$(ynh_app_setting_get $app db_name) #================================================= # BACKUP THE APP MAIN DIR #================================================= +ynh_print_info "Backing up the main app directory..." ynh_backup "$final_path" #================================================= # BACKUP THE NGINX CONFIGURATION #================================================= +ynh_print_info "Backing up nginx web server configuration..." ynh_backup "/etc/nginx/conf.d/$domain.d/$app.conf" #================================================= # BACKUP THE PHP-FPM CONFIGURATION #================================================= +ynh_print_info "Backing up php-fpm configuration..." ynh_backup "/etc/php5/fpm/pool.d/$app.conf" #================================================= # BACKUP THE MYSQL DATABASE #================================================= +ynh_print_info "Backing up the MySQL database..." ynh_mysql_dump_db "$db_name" > db.sql + +#================================================= +# END OF SCRIPT +#================================================= + +ynh_print_info "Backup script completed for $app. (YunoHost will then actually copy those files to the archive)." diff --git a/scripts/install b/scripts/install index 409aed0..49b0870 100644 --- a/scripts/install +++ b/scripts/install @@ -33,6 +33,7 @@ app=$YNH_APP_INSTANCE_NAME #================================================= # CHECK IF THE APP CAN BE INSTALLED WITH THESE ARGS #================================================= +ynh_print_info "Validating installation parameters..." final_path=/var/www/$app test ! -e "$final_path" || ynh_die "This path already contains a folder" @@ -46,6 +47,7 @@ ynh_webpath_register $app $domain $path_url #================================================= # STORE SETTINGS FROM MANIFEST #================================================= +ynh_print_info "Storing installation settings..." ynh_app_setting_set $app domain $domain ynh_app_setting_set $app path $path_url @@ -57,12 +59,14 @@ ynh_app_setting_set $app with_enigma $with_enigma #================================================= # INSTALL DEPENDENCIES #================================================= +ynh_print_info "Installing dependencies..." ynh_install_app_dependencies "$pkg_dependencies" #================================================= # CREATE A MYSQL DATABASE #================================================= +ynh_print_info "Creating a MySQL database..." db_name=$(ynh_sanitize_dbid $app) ynh_app_setting_set $app db_name $db_name @@ -71,6 +75,7 @@ ynh_mysql_setup_db $db_name $db_name #================================================= # DOWNLOAD, CHECK AND UNPACK SOURCE #================================================= +ynh_print_info "Setting up source files..." ynh_app_setting_set $app final_path $final_path # Download, check integrity, uncompress and patch the source from app.src @@ -79,6 +84,7 @@ ynh_setup_source "$final_path" #================================================= # NGINX CONFIGURATION #================================================= +ynh_print_info "Configuring nginx web server..." # Create a dedicated nginx config ynh_add_nginx_config @@ -86,6 +92,7 @@ ynh_add_nginx_config #================================================= # CREATE DEDICATED USER #================================================= +ynh_print_info "Configuring system user..." # Create a system user ynh_system_user_create $app @@ -93,6 +100,7 @@ ynh_system_user_create $app #================================================= # PHP-FPM CONFIGURATION #================================================= +ynh_print_info "Configuring php-fpm..." # Create a dedicated php-fpm config ynh_add_fpm_config @@ -102,6 +110,7 @@ ynh_add_fpm_config #================================================= # INSTALL AND INITIALIZE COMPOSER #================================================= +ynh_print_info "Installing roundcube with composer..." # Install composer.json cp "$final_path/composer.json-dist" "$final_path/composer.json" @@ -112,6 +121,7 @@ ynh_install_composer #================================================= # INITIALIZE DATABASE #================================================= +ynh_print_info "Initializing database..." ynh_mysql_connect_as "$db_name" "$db_pwd" "$db_name" \ < "$final_path/SQL/mysql.initial.sql" @@ -119,6 +129,8 @@ ynh_mysql_connect_as "$db_name" "$db_pwd" "$db_name" \ #================================================= # CONFIGURE ROUNDCUBE #================================================= +ynh_print_info "Configuring roundcube..." + rc_conf="$final_path/config/config.inc.php" cp ../conf/config.inc.php "$rc_conf" @@ -131,6 +143,7 @@ ynh_replace_string "__DBNAME__" $db_name "$rc_conf" #================================================= # INSTALL ADDITIONAL PLUGINS #================================================= +ynh_print_info "Installing additional plugins..." # Create logs and temp directories mkdir -p "$final_path/"{logs,temp} @@ -184,6 +197,7 @@ fi #================================================= # UPDATE ROUNDCUBE CONFIGURATION #================================================= +ynh_print_info "Updating roundcube configuration..." ynh_replace_string "^\s*// installed plugins" "&\n $installed_plugins" "$rc_conf" @@ -207,5 +221,12 @@ chown -R $app: "$final_path/"{temp,logs,plugins/enigma/home} #================================================= # RELOAD NGINX #================================================= +ynh_print_info "Reloading nginx web server..." systemctl reload nginx + +#================================================= +# END OF SCRIPT +#================================================= + +ynh_print_info "Installation of $app completed" diff --git a/scripts/remove b/scripts/remove index 6b9efce..94679f2 100644 --- a/scripts/remove +++ b/scripts/remove @@ -12,6 +12,7 @@ source /usr/share/yunohost/helpers #================================================= # LOAD SETTINGS #================================================= +ynh_print_info "Loading installation settings..." app=$YNH_APP_INSTANCE_NAME @@ -24,6 +25,7 @@ final_path=$(ynh_app_setting_get $app final_path) #================================================= # REMOVE DEPENDENCIES #================================================= +ynh_print_info "Removing dependencies" # Remove metapackage and its dependencies ynh_remove_app_dependencies @@ -31,6 +33,7 @@ ynh_remove_app_dependencies #================================================= # REMOVE THE MYSQL DATABASE #================================================= +ynh_print_info "Removing the MySQL database" # Remove a database if it exists, along with the associated user ynh_mysql_remove_db $db_name $db_name @@ -38,6 +41,7 @@ ynh_mysql_remove_db $db_name $db_name #================================================= # REMOVE APP MAIN DIR #================================================= +ynh_print_info "Removing app main directory" # Remove the app directory securely ynh_secure_remove "$final_path" @@ -45,6 +49,7 @@ ynh_secure_remove "$final_path" #================================================= # REMOVE NGINX CONFIGURATION #================================================= +ynh_print_info "Removing nginx web server configuration" # Remove the dedicated nginx config ynh_remove_nginx_config @@ -52,6 +57,7 @@ ynh_remove_nginx_config #================================================= # REMOVE PHP-FPM CONFIGURATION #================================================= +ynh_print_info "Removing php-fpm configuration" # Remove the dedicated php-fpm config ynh_remove_fpm_config @@ -61,6 +67,13 @@ ynh_remove_fpm_config #================================================= # REMOVE DEDICATED USER #================================================= +ynh_print_info "Removing the dedicated system user" # Delete a system user ynh_system_user_delete $app + +#================================================= +# END OF SCRIPT +#================================================= + +ynh_print_info "Removal of $app completed" diff --git a/scripts/restore b/scripts/restore index 852ce8a..39fd866 100644 --- a/scripts/restore +++ b/scripts/restore @@ -19,6 +19,7 @@ ynh_abort_if_errors #================================================= # LOAD SETTINGS #================================================= +ynh_print_info "Loading settings..." app=$YNH_APP_INSTANCE_NAME @@ -30,6 +31,7 @@ db_name=$(ynh_app_setting_get $app db_name) #================================================= # CHECK IF THE APP CAN BE RESTORED #================================================= +ynh_print_info "Validating restoration parameters..." ynh_webpath_available $domain $path_url \ || ynh_die "Path not available: ${domain}${path_url}" @@ -47,12 +49,14 @@ ynh_restore_file "/etc/nginx/conf.d/$domain.d/$app.conf" #================================================= # RESTORE THE APP MAIN DIR #================================================= +ynh_print_info "Restoring the app main directory..." ynh_restore_file "$final_path" #================================================= # RECREATE THE DEDICATED USER #================================================= +ynh_print_info "Recreating the dedicated system user..." # Create the dedicated user (if not existing) ynh_system_user_create $app @@ -76,6 +80,7 @@ ynh_restore_file "/etc/php/7.0/fpm/pool.d/$app.conf" #================================================= # REINSTALL DEPENDENCIES #================================================= +ynh_print_info "Reinstalling dependencies..." # Define and install dependencies ynh_install_app_dependencies "$pkg_dependencies" @@ -83,6 +88,7 @@ ynh_install_app_dependencies "$pkg_dependencies" #================================================= # RESTORE THE MYSQL DATABASE #================================================= +ynh_print_info "Restoring the MySQL database..." db_pwd=$(ynh_app_setting_get $app mysqlpwd) ynh_mysql_setup_db $db_name $db_name $db_pwd @@ -93,7 +99,13 @@ ynh_mysql_connect_as $db_name $db_pwd $db_name < ./db.sql #================================================= # RELOAD NGINX AND PHP-FPM #================================================= +ynh_print_info "Reloading nginx web server and php-fpm..." systemctl reload php5-fpm systemctl reload nginx +#================================================= +# END OF SCRIPT +#================================================= + +ynh_print_info "Restoration completed for $app" diff --git a/scripts/upgrade b/scripts/upgrade index 0735540..66db67b 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -15,6 +15,7 @@ source _getopts_fix.sh #================================================= # LOAD SETTINGS #================================================= +ynh_print_info "Loading installation settings..." app=$YNH_APP_INSTANCE_NAME @@ -28,6 +29,7 @@ with_enigma=$(ynh_app_setting_get $app with_enigma) #================================================= # ENSURE DOWNWARD COMPATIBILITY #================================================= +ynh_print_info "Ensuring downward compatibility..." # If db_name doesn't exist, create it if [ -z "$db_name" ]; then @@ -66,6 +68,7 @@ fi #================================================= # BACKUP BEFORE UPGRADE THEN ACTIVE TRAP #================================================= +ynh_print_info "Backing up the app before upgrading (may take a while)..." # Backup the current version of the app ynh_backup_before_upgrade @@ -88,6 +91,7 @@ path_url=$(ynh_normalize_url_path $path_url) #================================================= # DOWNLOAD, CHECK AND UNPACK SOURCE #================================================= +ynh_print_info "Upgrading source files..." # Get the current version of roundcube oldversion=$(grep RCMAIL_VERSION "$final_path/program/include/iniset.php" | cut -d\' -f4) @@ -98,6 +102,7 @@ ynh_setup_source "$final_path" #================================================= # NGINX CONFIGURATION #================================================= +ynh_print_info "Upgrading nginx web server configuration..." # Create a dedicated nginx config ynh_add_nginx_config @@ -105,12 +110,14 @@ ynh_add_nginx_config #================================================= # UPGRADE DEPENDENCIES #================================================= +ynh_print_info "Upgrading dependencies..." ynh_install_app_dependencies "$pkg_dependencies" #================================================= # CREATE DEDICATED USER #================================================= +ynh_print_info "Making sure dedicated system user exists..." # Create a dedicated user (if not existing) ynh_system_user_create $app @@ -118,6 +125,7 @@ ynh_system_user_create $app #================================================= # PHP-FPM CONFIGURATION #================================================= +ynh_print_info "Upgrading php-fpm configuration..." # Create a dedicated php-fpm config ynh_add_fpm_config @@ -127,6 +135,7 @@ ynh_add_fpm_config #================================================= # CONFIGURE ROUNDCUBE #================================================= +ynh_print_info "Reconfiguring roundcube..." rc_conf="$final_path/config/config.inc.php" @@ -144,6 +153,7 @@ ynh_replace_string "__DBNAME__" $db_name "$rc_conf" #================================================= # UPDATE DEPENDENCIES WITH COMPOSER #================================================= +ynh_print_info "Updating dependencies with composer..." # Check if dependencies need to be updated with composer if [ -f "$final_path/composer.json" ] @@ -159,6 +169,7 @@ fi #================================================= # UPGRADE ADDITIONAL PLUGINS #================================================= +ynh_print_info "Upgrading additional plugins..." # Create logs and temp directories mkdir -p "$final_path/"{logs,temp} @@ -212,6 +223,7 @@ fi #================================================= # UPDATE ROUNDCUBE CONFIGURATION #================================================= +ynh_print_info "Updating roundcube configuration..." ynh_replace_string "^\s*// installed plugins" "&\n $installed_plugins" "$rc_conf" @@ -225,6 +237,7 @@ ynh_store_file_checksum "$rc_conf" #================================================= # UPDATE ROUNDCUBE CORE #================================================= +ynh_print_info "Updating roundcube core..." ( cd "$final_path" ynh_exec_warn ./bin/update.sh --version=$oldversion -y) @@ -242,5 +255,12 @@ chown -R $app: "$final_path/"{temp,logs,plugins/enigma/home} #================================================= # RELOAD NGINX #================================================= +ynh_print_info "Reloading nginx web server..." systemctl reload nginx + +#================================================= +# END OF SCRIPT +#================================================= + +ynh_print_info "Upgrade of $app completed" From 352513f59790fde1a25c037058e5a65d000246c8 Mon Sep 17 00:00:00 2001 From: Maniack Crudelis Date: Sun, 3 Mar 2019 18:14:38 +0100 Subject: [PATCH 09/13] Use php7 --- conf/nginx.conf | 2 +- conf/php-fpm.conf | 112 +++++++++++++++++++++++++++++++--------------- manifest.json | 2 +- scripts/backup | 2 +- scripts/restore | 2 +- 5 files changed, 79 insertions(+), 41 deletions(-) diff --git a/conf/nginx.conf b/conf/nginx.conf index 729c27d..5dc0acc 100644 --- a/conf/nginx.conf +++ b/conf/nginx.conf @@ -17,7 +17,7 @@ location __PATH__/ { location ~ [^/]\.php(/|$) { fastcgi_split_path_info ^(.+?\.php)(/.*)$; - fastcgi_pass unix:/var/run/php5-fpm-__NAME__.sock; + fastcgi_pass unix:/var/run/php/php7.0-fpm-__NAME__.sock; fastcgi_index index.php; fastcgi_param REMOTE_USER $remote_user; fastcgi_param PATH_INFO $fastcgi_path_info; diff --git a/conf/php-fpm.conf b/conf/php-fpm.conf index cec73f5..2b5d7b2 100644 --- a/conf/php-fpm.conf +++ b/conf/php-fpm.conf @@ -1,10 +1,11 @@ ; Start a new pool named 'www'. -; the variable $pool can we used in any directive and will be replaced by the +; the variable $pool can be used in any directive and will be replaced by the ; pool name ('www' here) [__NAMETOCHANGE__] ; Per pool prefix ; It only applies on the following directives: +; - 'access.log' ; - 'slowlog' ; - 'listen' (unixsocket) ; - 'chroot' @@ -24,28 +25,35 @@ group = __USER__ ; The address on which to accept FastCGI requests. ; Valid syntaxes are: -; 'ip.add.re.ss:port' - to listen on a TCP socket to a specific address on +; 'ip.add.re.ss:port' - to listen on a TCP socket to a specific IPv4 address on ; a specific port; -; 'port' - to listen on a TCP socket to all addresses on a -; specific port; +; '[ip:6:addr:ess]:port' - to listen on a TCP socket to a specific IPv6 address on +; a specific port; +; 'port' - to listen on a TCP socket to all addresses +; (IPv6 and IPv4-mapped) on a specific port; ; '/path/to/unix/socket' - to listen on a unix socket. ; Note: This value is mandatory. -listen = /var/run/php5-fpm-__NAMETOCHANGE__.sock +listen = /var/run/php/php7.0-fpm-__NAMETOCHANGE__.sock ; Set listen(2) backlog. -; Default Value: 128 (-1 on FreeBSD and OpenBSD) -;listen.backlog = 128 +; Default Value: 511 (-1 on FreeBSD and OpenBSD) +;listen.backlog = 511 ; Set permissions for unix socket, if one is used. In Linux, read/write ; permissions must be set in order to allow connections from a web server. Many -; BSD-derived systems allow connections regardless of permissions. +; BSD-derived systems allow connections regardless of permissions. ; Default Values: user and group are set as the running user ; mode is set to 0660 listen.owner = www-data listen.group = www-data ;listen.mode = 0660 - -; List of ipv4 addresses of FastCGI clients which are allowed to connect. +; When POSIX Access Control Lists are supported you can set them using +; these options, value is a comma separated list of user/group names. +; When set, listen.owner and listen.group are ignored +;listen.acl_users = +;listen.acl_groups = + +; List of addresses (IPv4/IPv6) of FastCGI clients which are allowed to connect. ; Equivalent to the FCGI_WEB_SERVER_ADDRS environment variable in the original ; PHP FCGI (5.2.2+). Makes sense only with a tcp listening socket. Each address ; must be separated by a comma. If this value is left blank, connections will be @@ -59,7 +67,13 @@ listen.group = www-data ; - The pool processes will inherit the master process priority ; unless it specified otherwise ; Default Value: no set -; priority = -19 +; process.priority = -19 + +; Set the process dumpable flag (PR_SET_DUMPABLE prctl) even if the process user +; or group is differrent than the master process user. It allows to create process +; core dump and ptrace the process for the pool user. +; Default Value: no +; process.dumpable = yes ; Choose how the process manager will control the number of child processes. ; Possible Values: @@ -96,7 +110,7 @@ pm = dynamic ; forget to tweak pm.* to fit your needs. ; Note: Used when pm is set to 'static', 'dynamic' or 'ondemand' ; Note: This value is mandatory. -pm.max_children = 10 +pm.max_children = 5 ; The number of child processes created on startup. ; Note: Used only when pm is set to 'dynamic' @@ -117,12 +131,12 @@ pm.max_spare_servers = 3 ; Note: Used only when pm is set to 'ondemand' ; Default Value: 10s ;pm.process_idle_timeout = 10s; - + ; The number of requests each child process should execute before respawning. ; This can be useful to work around memory leaks in 3rd party libraries. For ; endless request processing specify '0'. Equivalent to PHP_FCGI_MAX_REQUESTS. ; Default Value: 0 -pm.max_requests = 500 +;pm.max_requests = 500 ; The URI to view the FPM status page. If this value is not set, no URI will be ; recognized as a status page. It shows the following informations: @@ -170,7 +184,7 @@ pm.max_requests = 500 ; ; By default the status page only outputs short status. Passing 'full' in the ; query string will also return status for each pool process. -; Example: +; Example: ; http://www.foo.bar/status?full ; http://www.foo.bar/status?json&full ; http://www.foo.bar/status?html&full @@ -215,14 +229,14 @@ pm.max_requests = 500 ; last request memory: 0 ; ; Note: There is a real-time FPM status monitoring sample web page available -; It's available in: ${prefix}/share/fpm/status.html +; It's available in: /usr/share/php/7.0/fpm/status.html ; ; Note: The value must start with a leading slash (/). The value can be ; anything, but it may not be a good idea to use the .php extension or it ; may conflict with a real PHP file. -; Default Value: not set +; Default Value: not set ;pm.status_path = /status - + ; The ping URI to call the monitoring page of FPM. If this value is not set, no ; URI will be recognized as a ping page. This could be used to test from outside ; that FPM is alive and responding, or to @@ -275,7 +289,7 @@ pm.max_requests = 500 ; - %{megabytes}M ; - %{mega}M ; %n: pool name -; %o: ouput header +; %o: output header ; it must be associated with embraces to specify the name of the header: ; - %{Content-Type}o ; - %{X-Powered-By}o @@ -283,7 +297,7 @@ pm.max_requests = 500 ; - .... ; %p: PID of the child that serviced the request ; %P: PID of the parent of the child that serviced the request -; %q: the query string +; %q: the query string ; %Q: the '?' character if query string exists ; %r: the request URI (without the query string, see %q and %Q) ; %R: remote IP address @@ -291,72 +305,85 @@ pm.max_requests = 500 ; %t: server time the request was received ; it can accept a strftime(3) format: ; %d/%b/%Y:%H:%M:%S %z (default) +; The strftime(3) format must be encapsuled in a %{}t tag +; e.g. for a ISO8601 formatted timestring, use: %{%Y-%m-%dT%H:%M:%S%z}t ; %T: time the log has been written (the request has finished) ; it can accept a strftime(3) format: ; %d/%b/%Y:%H:%M:%S %z (default) +; The strftime(3) format must be encapsuled in a %{}t tag +; e.g. for a ISO8601 formatted timestring, use: %{%Y-%m-%dT%H:%M:%S%z}t ; %u: remote user ; ; Default: "%R - %u %t \"%m %r\" %s" ;access.format = "%R - %u %t \"%m %r%Q%q\" %s %f %{mili}d %{kilo}M %C%%" - + ; The log file for slow requests ; Default Value: not set ; Note: slowlog is mandatory if request_slowlog_timeout is set -slowlog = /var/log/nginx/__NAMETOCHANGE__.slow.log - +;slowlog = log/$pool.log.slow + ; The timeout for serving a single request after which a PHP backtrace will be ; dumped to the 'slowlog' file. A value of '0s' means 'off'. ; Available units: s(econds)(default), m(inutes), h(ours), or d(ays) ; Default Value: 0 -request_slowlog_timeout = 5s - +;request_slowlog_timeout = 0 + ; The timeout for serving a single request after which the worker process will ; be killed. This option should be used when the 'max_execution_time' ini option ; does not stop script execution for some reason. A value of '0' means 'off'. ; Available units: s(econds)(default), m(inutes), h(ours), or d(ays) ; Default Value: 0 request_terminate_timeout = 1d - + ; Set open file descriptor rlimit. ; Default Value: system defined value ;rlimit_files = 1024 - + ; Set max core size rlimit. ; Possible Values: 'unlimited' or an integer greater or equal to 0 ; Default Value: system defined value ;rlimit_core = 0 - + ; Chroot to this directory at the start. This value must be defined as an ; absolute path. When this value is not set, chroot is not used. ; Note: you can prefix with '$prefix' to chroot to the pool prefix or one ; of its subdirectories. If the pool prefix is not set, the global prefix ; will be used instead. -; Note: chrooting is a great security feature and should be used whenever +; Note: chrooting is a great security feature and should be used whenever ; possible. However, all PHP paths will be relative to the chroot ; (error_log, sessions.save_path, ...). ; Default Value: not set -;chroot = - +;chroot = + ; Chdir to this directory at the start. ; Note: relative path can be used. ; Default Value: current directory or / when chroot chdir = __FINALPATH__ - + ; Redirect worker stdout and stderr into main error log. If not set, stdout and ; stderr will be redirected to /dev/null according to FastCGI specs. ; Note: on highloaded environement, this can cause some delay in the page ; process time (several ms). ; Default Value: no -catch_workers_output = yes +;catch_workers_output = yes + +; Clear environment in FPM workers +; Prevents arbitrary environment variables from reaching FPM worker processes +; by clearing the environment in workers before env vars specified in this +; pool configuration are added. +; Setting to "no" will make all environment variables available to PHP code +; via getenv(), $_ENV and $_SERVER. +; Default Value: yes +;clear_env = no ; Limits the extensions of the main script FPM will allow to parse. This can ; prevent configuration mistakes on the web server side. You should only limit ; FPM to .php extensions to prevent malicious users to use other extensions to -; exectute php code. +; execute php code. ; Note: set an empty value to allow all extensions. ; Default Value: .php -;security.limit_extensions = .php .php3 .php4 .php5 - +;security.limit_extensions = .php .php3 .php4 .php5 .php7 + ; Pass environment variables like LD_LIBRARY_PATH. All $VARIABLEs are taken from ; the current environment. ; Default Value: clean env @@ -370,7 +397,7 @@ catch_workers_output = yes ; overwrite the values previously defined in the php.ini. The directives are the ; same as the PHP SAPI: ; php_value/php_flag - you can set classic ini defines which can -; be overwritten from PHP call 'ini_set'. +; be overwritten from PHP call 'ini_set'. ; php_admin_value/php_admin_flag - these directives won't be overwritten by ; PHP call 'ini_set' ; For php_*flag, valid values are on, off, 1, 0, true, false, yes or no. @@ -391,5 +418,16 @@ catch_workers_output = yes ;php_admin_flag[log_errors] = on ;php_admin_value[memory_limit] = 32M +; Common values to change to increase file upload limit +; php_admin_value[upload_max_filesize] = 50M +; php_admin_value[post_max_size] = 50M +; php_admin_flag[mail.add_x_header] = Off + +; Other common parameters +; php_admin_value[max_execution_time] = 600 +; php_admin_value[max_input_time] = 300 +; php_admin_value[memory_limit] = 256M +; php_admin_flag[short_open_tag] = On + php_admin_value[upload_max_filesize] = 30M php_admin_value[post_max_size] = 30M diff --git a/manifest.json b/manifest.json index 330e323..1c93296 100644 --- a/manifest.json +++ b/manifest.json @@ -19,7 +19,7 @@ "multi_instance": true, "services": [ "nginx", - "php5-fpm", + "php7.0-fpm", "mysql" ], "arguments": { diff --git a/scripts/backup b/scripts/backup index 8d583c5..271844f 100644 --- a/scripts/backup +++ b/scripts/backup @@ -48,7 +48,7 @@ ynh_backup "/etc/nginx/conf.d/$domain.d/$app.conf" #================================================= ynh_print_info "Backing up php-fpm configuration..." -ynh_backup "/etc/php5/fpm/pool.d/$app.conf" +ynh_backup "/etc/php/7.0/fpm/pool.d/$app.conf" #================================================= # BACKUP THE MYSQL DATABASE diff --git a/scripts/restore b/scripts/restore index 39fd866..952928a 100644 --- a/scripts/restore +++ b/scripts/restore @@ -101,7 +101,7 @@ ynh_mysql_connect_as $db_name $db_pwd $db_name < ./db.sql #================================================= ynh_print_info "Reloading nginx web server and php-fpm..." -systemctl reload php5-fpm +systemctl reload php7.0-fpm systemctl reload nginx #================================================= From eae12566bff72d0c89a100abea23b7cfe7c2ddff Mon Sep 17 00:00:00 2001 From: Maniack Crudelis Date: Mon, 4 Mar 2019 15:23:53 +0100 Subject: [PATCH 10/13] Add support for nextcloud --- scripts/install | 2 +- scripts/upgrade | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/scripts/install b/scripts/install index 49b0870..87df807 100644 --- a/scripts/install +++ b/scripts/install @@ -165,7 +165,7 @@ then carddav_tmp_config="../conf/carddav.config.inc.php" # Look for installed and supported CardDAV servers - for carddav_app in "owncloud" "baikal" + for carddav_app in "owncloud" "nextcloud" "baikal" do carddav_app_id=$(yunohost app list --installed -f $carddav_app \ --output-as json | grep -Po '"id":[ ]?"\K.*?(?=")' | head -1) diff --git a/scripts/upgrade b/scripts/upgrade index 66db67b..61b6dca 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -191,7 +191,7 @@ then carddav_tmp_config="../conf/carddav.config.inc.php" # Look for installed and supported CardDAV servers - for carddav_app in "owncloud" "baikal" + for carddav_app in "owncloud" "nextcloud" "baikal" do carddav_app_id=$(yunohost app list --installed -f $carddav_app \ --output-as json | grep -Po '"id":[ ]?"\K.*?(?=")' | head -1) From f420fe6e6d9e2d8bed8d747208d6c75b12647e46 Mon Sep 17 00:00:00 2001 From: Kayou Date: Tue, 5 Mar 2019 00:47:16 +0100 Subject: [PATCH 11/13] Add nextcloud support, and remove sed -i --- conf/carddav.config.inc.php | 90 ++++++++++++++++++++++--------------- scripts/install | 3 +- scripts/upgrade | 3 +- 3 files changed, 58 insertions(+), 38 deletions(-) diff --git a/conf/carddav.config.inc.php b/conf/carddav.config.inc.php index 75bd9a4..13c4509 100644 --- a/conf/carddav.config.inc.php +++ b/conf/carddav.config.inc.php @@ -1,41 +1,59 @@ 'Baïkal', -// 'username' => '%u', -// 'password' => '%p', -// 'url' => '{baikal_url}/card.php/addressbooks/%u/', -// -// // optional attributes -// 'active' => true, -// 'readonly' => false, -// 'refresh_time' => '00:05:00', -// -// 'fixed' => array('username', 'password'), -// 'hide' => false, -//); -//// END: baikal +/* PRESET FOR: baikal +$prefs['Baïkal'] = array( + // required attributes + 'name' => 'Baïkal', + 'username' => '%u', + 'password' => '%p', + 'url' => '{baikal_url}/card.php/addressbooks/%u/', -//// PRESET FOR: owncloud -//$prefs['ownCloud'] = array( -// // required attributes -// 'name' => 'ownCloud', -// 'username' => '%u', -// 'password' => '%p', -// 'url' => '{owncloud_url}/remote.php/dav/addressbooks/users/%u/default/', -// -// // optional attributes -// 'active' => true, -// 'readonly' => false, -// 'refresh_time' => '00:05:00', -// -// 'fixed' => array('username', 'password'), -// 'hide' => false, -//); -//// END: owncloud + // optional attributes + 'active' => true, + 'readonly' => false, + 'refresh_time' => '00:05:00', + + 'fixed' => array('username', 'password'), + 'hide' => false, +); +END: baikal */ + +/* PRESET FOR: owncloud +$prefs['ownCloud'] = array( + // required attributes + 'name' => 'ownCloud', + 'username' => '%u', + 'password' => '%p', + 'url' => '{owncloud_url}/remote.php/dav/addressbooks/users/%u/default/', + + // optional attributes + 'active' => true, + 'readonly' => false, + 'refresh_time' => '00:05:00', + + 'fixed' => array('username', 'password'), + 'hide' => false, +); +END: owncloud */ + +/* PRESET FOR: nextcloud +$prefs['NextCloud'] = array( + // required attributes + 'name' => 'nextCloud', + 'username' => '%u', + 'password' => '%p', + 'url' => '{nextcloud_url}/remote.php/dav/addressbooks/users/%u/contacts/', + + // optional attributes + 'active' => true, + 'readonly' => false, + 'refresh_time' => '00:05:00', + + 'fixed' => array('username', 'password'), + 'hide' => false, +); +END: nextcloud */ diff --git a/scripts/install b/scripts/install index 87df807..8cf810d 100644 --- a/scripts/install +++ b/scripts/install @@ -176,7 +176,8 @@ then carddav_path=$(ynh_app_setting_get $carddav_app_id path) carddav_url="https://${carddav_domain}${carddav_path%/}" ynh_replace_string "{${carddav_app}_url}" "$carddav_url" "$carddav_tmp_config" - sed -i "/\/\/\/\/ PRESET FOR: $carddav_app/,/\/\/\/\/ END: $carddav_app/s/^\/\///" "$carddav_tmp_config" + ynh_replace_string "/* PRESET FOR: $carddav_app" "" "$carddav_tmp_config" + ynh_replace_string "END: $carddav_app */" "" "$carddav_tmp_config" fi done diff --git a/scripts/upgrade b/scripts/upgrade index 61b6dca..d1eb374 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -202,7 +202,8 @@ then carddav_path=$(ynh_app_setting_get $carddav_app_id path) carddav_url="https://${carddav_domain}${carddav_path%/}" ynh_replace_string "{${carddav_app}_url}" "$carddav_url" "$carddav_tmp_config" - sed -i "/\/\/\/\/ PRESET FOR: $carddav_app/,/\/\/\/\/ END: $carddav_app/s/^\/\///" "$carddav_tmp_config" + ynh_replace_string "\/\* PRESET FOR: $carddav_app" "" "$carddav_tmp_config" + ynh_replace_string "END: $carddav_app \*\/" "" "$carddav_tmp_config" fi done From f20c0493b4d0c0614364bee54ab2eba1224d3da5 Mon Sep 17 00:00:00 2001 From: Jimmy Monin Date: Wed, 6 Mar 2019 08:51:13 +0100 Subject: [PATCH 12/13] Slight README reorganization + screenshot URL fix --- README.md | 36 +++++++++++++++--------------------- 1 file changed, 15 insertions(+), 21 deletions(-) diff --git a/README.md b/README.md index 129dc25..4c705cb 100644 --- a/README.md +++ b/README.md @@ -13,28 +13,12 @@ an application-like user interface. **Shipped version:** 1.3.8 -![](https://roundcube.net/images/screens/mailview.jpg) +![](https://roundcube.net/images/screens/mailbox.png) ## Licence LICENCE: GPL-3.0-only -## Features - -In addition to Roundcube core features, the following are made available with -this package: - - * Integrate with YunoHost users and SSO - i.e. logout button, YunoHost users - search - * Synchronize your email aliases as identities in Roundcube - * Install the [contextmenu](https://plugins.roundcube.net/packages/johndoh/contextmenu) - and [automatic addressbook](https://plugins.roundcube.net/packages/sblaisot/automatic_addressbook) - plugins by default - * Allow to install the [CardDAV](https://plugins.roundcube.net/packages/roundcube/carddav) - (address book) synchronization plugin at the installation - note that if - you have installed ownCloud or Baïkal, it will automatically add the - corresponding and existing address book. - ## Extend and tweak ### Configuration @@ -89,11 +73,21 @@ case, do not forget to change ownerships of this folder to `roundcube`. ## YunoHost specific features +In addition to Roundcube core features, the following are made available with +this package: + + * Synchronize your email aliases as identities in Roundcube + * Install the [contextmenu](https://plugins.roundcube.net/packages/johndoh/contextmenu) + and [automatic addressbook](https://plugins.roundcube.net/packages/sblaisot/automatic_addressbook) + plugins by default + * Allow to install the [CardDAV](https://plugins.roundcube.net/packages/roundcube/carddav) + (address book) synchronization plugin at the installation - note that if + you have installed ownCloud or Baïkal, it will automatically add the + corresponding and existing address book. + #### Multi-users support - -Are LDAP and HTTP auth supported? -Can the app be used by multiple users? - +* Integrate with YunoHost users and SSO - i.e. logout button, YunoHost users + search #### Supported architectures * x86-64b - [![Build Status](https://ci-apps.yunohost.org/ci/logs/roundcube%20%28Official%29.svg)](https://ci-apps.yunohost.org/ci/apps/roundcube/) From d2a665043598a4057add3b66a47d2c12f4bb949f Mon Sep 17 00:00:00 2001 From: Maniack Crudelis Date: Sun, 24 Mar 2019 16:47:20 +0100 Subject: [PATCH 13/13] Update pull_request_template.md --- pull_request_template.md | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/pull_request_template.md b/pull_request_template.md index 51b9114..ca05668 100644 --- a/pull_request_template.md +++ b/pull_request_template.md @@ -19,7 +19,6 @@ - [ ] **Approval (LGTM)** : - [ ] **Approval (LGTM)** : - **CI succeeded** : -[![Build Status](https://ci-apps-dev.yunohost.org/jenkins/job/roundcube_ynh%20-BRANCH-%20(Official)/badge/icon)](https://ci-apps-dev.yunohost.org/jenkins/job/roundcube_ynh%20-BRANCH-%20(Official)/) *Please replace '-BRANCH-' in this link for a PR from a local branch.* -or -[![Build Status](https://ci-apps-dev.yunohost.org/jenkins/job/roundcube_ynh%20PR-NUM-%20(Official_fork)/badge/icon)](https://ci-apps-dev.yunohost.org/jenkins/job/roundcube_ynh%20PR-NUM-%20(Official_fork)/) *Replace '-NUM-' by the PR number in this link for a PR from a forked repository.* +[![Build Status](https://ci-apps-dev.yunohost.org/jenkins/job/roundcube_ynh%20PR-NUM-/badge/icon)](https://ci-apps-dev.yunohost.org/jenkins/job/roundcube_ynh%20PR-NUM-/) +*Please replace '-NUM-' in this link by the PR number.* When the PR is marked as ready to merge, you have to wait for 3 days before really merging it.