diff --git a/.github/workflows/updater.sh b/.github/workflows/updater.sh deleted file mode 100644 index 00febba..0000000 --- a/.github/workflows/updater.sh +++ /dev/null @@ -1,106 +0,0 @@ -#!/bin/bash - -#================================================= -# PACKAGE UPDATING HELPER -#================================================= - -# This script is meant to be run by GitHub Actions -# The YunoHost-Apps organisation offers a template Action to run this script periodically -# Since each app is different, maintainers can adapt its contents so as to perform -# automatic actions when a new upstream release is detected. - -#================================================= -# FETCHING LATEST RELEASE AND ITS ASSETS -#================================================= - -# Fetching information -current_version=$(cat manifest.json | jq -j '.version|split("~")[0]') -repo=$(cat manifest.json | jq -j '.upstream.code|split("https://github.com/")[1]') -# Some jq magic is needed, because the latest upstream release is not always the latest version (e.g. security patches for older versions) -version=$(curl --silent "https://api.github.com/repos/$repo/releases" | jq -r '.[] | select( .prerelease != true ) | .tag_name' | sort -V | tail -1) -assets="https://github.com/Z-Hub/Z-Push/archive/$version.tar.gz" - -# Later down the script, we assume the version has only digits and dots -# Sometimes the release name starts with a "v", so let's filter it out. -# You may need more tweaks here if the upstream repository has different naming conventions. -if [[ ${version:0:1} == "v" || ${version:0:1} == "V" ]]; then - version=${version:1} -fi - -# Setting up the environment variables -echo "Current version: $current_version" -echo "Latest release from upstream: $version" -echo "VERSION=$version" >> $GITHUB_ENV -# For the time being, let's assume the script will fail -echo "PROCEED=false" >> $GITHUB_ENV - -# Proceed only if the retrieved version is greater than the current one -if ! dpkg --compare-versions "$current_version" "lt" "$version" ; then - echo "::warning ::No new version available" - exit 0 -# Proceed only if a PR for this new version does not already exist -elif git ls-remote -q --exit-code --heads https://github.com/$GITHUB_REPOSITORY.git ci-auto-update-v$version ; then - echo "::warning ::A branch already exists for this update" - exit 0 -fi - -#================================================= -# UPDATE SOURCE FILES -#================================================= - -# Let's download source tarball -asset_url=$assets - -echo "Handling asset at $asset_url" - -src="app" - -# Create the temporary directory -tempdir="$(mktemp -d)" - -# Download sources and calculate checksum -filename=${asset_url##*/} -curl --silent -4 -L $asset_url -o "$tempdir/$filename" -checksum=$(sha256sum "$tempdir/$filename" | head -c 64) - -# Delete temporary directory -rm -rf $tempdir - -# Get extension -if [[ $filename == *.tar.gz ]]; then - extension=tar.gz -else - extension=${filename##*.} -fi - -# Rewrite source file -cat < conf/$src.src -SOURCE_URL=$asset_url -SOURCE_SUM=$checksum -SOURCE_SUM_PRG=sha256sum -SOURCE_FORMAT=$extension -SOURCE_IN_SUBDIR=true -SOURCE_FILENAME= -SOURCE_EXTRACT=true -EOT -echo "... conf/$src.src updated" - -#================================================= -# SPECIFIC UPDATE STEPS -#================================================= - -# Any action on the app's source code can be done. -# The GitHub Action workflow takes care of committing all changes after this script ends. - -#================================================= -# GENERIC FINALIZATION -#================================================= - -# Replace new version in manifest -echo "$(jq -s --indent 4 ".[] | .version = \"$version~ynh1\"" manifest.json)" > manifest.json - -# No need to update the README, yunohost-bot takes care of it - -# The Action will proceed only if the PROCEED environment variable is set to true -echo "PROCEED=true" >> $GITHUB_ENV -exit 0 diff --git a/.github/workflows/updater.yml b/.github/workflows/updater.yml deleted file mode 100644 index a56d7cb..0000000 --- a/.github/workflows/updater.yml +++ /dev/null @@ -1,49 +0,0 @@ -# This workflow allows GitHub Actions to automagically update your app whenever a new upstream release is detected. -# You need to enable Actions in your repository settings, and fetch this Action from the YunoHost-Apps organization. -# This file should be enough by itself, but feel free to tune it to your needs. -# It calls updater.sh, which is where you should put the app-specific update steps. -name: Check for new upstream releases -on: - # Allow to manually trigger the workflow - workflow_dispatch: - # Run it every day at 6:00 UTC - schedule: - - cron: '0 6 * * *' -jobs: - updater: - runs-on: ubuntu-latest - steps: - - name: Fetch the source code - uses: actions/checkout@v3 - with: - token: ${{ secrets.GITHUB_TOKEN }} - - name: Run the updater script - id: run_updater - run: | - # Setting up Git user - git config --global user.name 'yunohost-bot' - git config --global user.email 'yunohost-bot@users.noreply.github.com' - # Run the updater script - /bin/bash .github/workflows/updater.sh - - name: Commit changes - id: commit - if: ${{ env.PROCEED == 'true' }} - run: | - git commit -am "Upgrade to v$VERSION" - - name: Create Pull Request - id: cpr - if: ${{ env.PROCEED == 'true' }} - uses: peter-evans/create-pull-request@v4 - with: - token: ${{ secrets.GITHUB_TOKEN }} - commit-message: Update to version ${{ env.VERSION }} - committer: 'yunohost-bot ' - author: 'yunohost-bot ' - signoff: false - base: testing - branch: ci-auto-update-v${{ env.VERSION }} - delete-branch: true - title: 'Upgrade to version ${{ env.VERSION }}' - body: | - Upgrade to v${{ env.VERSION }} - draft: false diff --git a/README.md b/README.md index b39d099..3c2f16d 100644 --- a/README.md +++ b/README.md @@ -19,11 +19,7 @@ If you don't have YunoHost, please consult [the guide](https://yunohost.org/#/in Z-Push is an Exchange ActiveSync fronted written in PHP which lets you synchronize emails (IMAP/SMTP backend) and calendar/contacts (cardDAV and caldDAV backend) -**Shipped version:** 2.7.0~ynh3 -## Disclaimers / important information - -* would be better to create a dedicated domain: autodiscover.yourdomain.org - +**Shipped version:** 2.7.1~ynh1 ## Documentation and resources * Official app website: diff --git a/README_fr.md b/README_fr.md index c0a1b47..219a37b 100644 --- a/README_fr.md +++ b/README_fr.md @@ -19,11 +19,7 @@ Si vous n’avez pas YunoHost, regardez [ici](https://yunohost.org/#/install) po Z-Push is an Exchange ActiveSync fronted written in PHP which lets you synchronize emails (IMAP/SMTP backend) and calendar/contacts (cardDAV and caldDAV backend) -**Version incluse :** 2.7.0~ynh3 -## Avertissements / informations importantes - -* would be better to create a dedicated domain: autodiscover.yourdomain.org - +**Version incluse :** 2.7.1~ynh1 ## Documentations et ressources * Site officiel de l’app : diff --git a/check_process b/check_process deleted file mode 100644 index 16cea20..0000000 --- a/check_process +++ /dev/null @@ -1,31 +0,0 @@ -;; Test complet - ; Manifest - domain="domain.tld" - path="/Microsoft-Server-ActiveSync" - ; Checks - pkg_linter=1 - setup_sub_dir=1 - setup_root=0 - setup_nourl=0 - setup_private=0 - setup_public=1 - upgrade=1 - # 2.5.1~ynh3 - # upgrade=1 from_commit=9e8a72669814237122dfc6f901c9377895c193db - # 2.5.2~ynh1 - # upgrade=1 from_commit=a857788c1fb369baa5f0608da12013b003cceed3 - # 2.6.1~ynh1 - # upgrade=1 from_commit=a05896f0e4f2b015dcf643c644ac6c98c2f6695b - # 2.6.1~ynh2 - upgrade=1 from_commit=8e99ec37fb90d1ac4f8eb2c838e6d2e1f5b0c905 - # 2.6.1~ynh3 - upgrade=1 from_commit=f101d8cb5701c46db0d6cf5aaa02b1e7f8e0dec2 - # 2.6.4~ynh1 - upgrade=1 from_commit=065dc9bf0076090cb6457ef54c87ef0200d72103 - backup_restore=1 - multi_instance=1 - port_already_use=0 - change_url=0 -;;; Options -Email=yalh@yahoo.com -Notification=all diff --git a/conf/app.src b/conf/app.src deleted file mode 100644 index 31e3573..0000000 --- a/conf/app.src +++ /dev/null @@ -1,7 +0,0 @@ -SOURCE_URL=https://github.com/Z-Hub/Z-Push/archive/2.7.0.tar.gz -SOURCE_SUM=0d3507af509723c0a145a910c707dce81adb5535b83455c05ebf070880988c66 -SOURCE_SUM_PRG=sha256sum -SOURCE_FORMAT=tar.gz -SOURCE_IN_SUBDIR=true -SOURCE_FILENAME= -SOURCE_EXTRACT=true diff --git a/conf/backend/config-autodiscover.php b/conf/backend/config-autodiscover.php index 2c232f9..6930b36 100644 --- a/conf/backend/config-autodiscover.php +++ b/conf/backend/config-autodiscover.php @@ -87,7 +87,7 @@ define('LOGBACKEND', 'filelog'); - define('LOGFILEDIR', '__FINAL_LOGPATH__/'); + define('LOGFILEDIR', '__LOG_DIR__/'); define('LOGFILE', LOGFILEDIR . 'autodiscover.log'); define('LOGERRORFILE', LOGFILEDIR . 'autodiscover-error.log'); define('LOGLEVEL', LOGLEVEL_ERROR); diff --git a/conf/backend/config-imap.php b/conf/backend/config-imap.php index e48d50b..156c120 100644 --- a/conf/backend/config-imap.php +++ b/conf/backend/config-imap.php @@ -217,7 +217,7 @@ define('SYSTEM_MIME_TYPES_MAPPING', '/etc/mime.types'); // Use BackendCalDAV for Meetings. You cannot hope to get that functionality working without a caldav backend. -define('IMAP_MEETING_USE_CALDAV', __FLAGTOCHANGE__); +define('IMAP_MEETING_USE_CALDAV', __IMAP_MEETING_USE_CALDAV__); // If your IMAP server allows authenticating via GSSAPI, php-imap will not fall back properly to other authentication // methods and you will be unable to log in. Uncomment the following line to disable that authentication method. diff --git a/conf/config.php b/conf/config.php index 14cabe9..19154b0 100644 --- a/conf/config.php +++ b/conf/config.php @@ -65,7 +65,7 @@ * State migration script is available, more informations: https://wiki.z-hub.io/x/xIAa */ define('STATE_MACHINE', 'FILE'); - define('STATE_DIR', '__DATADIR__/'); + define('STATE_DIR', '__DATA_DIR__/'); /********************************************************************************** * IPC - InterProcessCommunication @@ -120,7 +120,7 @@ $specialLogUsers = array(); // Filelog settings - define('LOGFILEDIR', '__FINAL_LOGPATH__/'); + define('LOGFILEDIR', '__LOG_DIR__'); define('LOGFILE', LOGFILEDIR . 'z-push.log'); define('LOGERRORFILE', LOGFILEDIR . 'z-push-error.log'); diff --git a/conf/nginx.conf b/conf/nginx.conf index 2b61559..8c759d7 100644 --- a/conf/nginx.conf +++ b/conf/nginx.conf @@ -1,8 +1,9 @@ #sub_path_only rewrite ^Microsoft-Server-ActiveSync$ Microsoft-Server-ActiveSync/ permanent; -location /Microsoft-Server-ActiveSync { +rewrite ^/$ Microsoft-Server-ActiveSync/ permanent; +location /Microsoft-Server-ActiveSync/ { # Path to source - alias __FINALPATH__/; + alias __INSTALL_DIR__/; index index.php; @@ -27,7 +28,7 @@ location /Microsoft-Server-ActiveSync { } location /AutoDiscover/AutoDiscover.xml { - alias __FINALPATH__/autodiscover/autodiscover.php; + alias __INSTALL_DIR__/autodiscover/autodiscover.php; fastcgi_pass unix:/var/run/php/php__PHPVERSION__-fpm-__NAME__.sock; include fastcgi_params; fastcgi_param HTTPS on; @@ -35,7 +36,7 @@ location /AutoDiscover/AutoDiscover.xml { } location /Autodiscover/Autodiscover.xml { - alias __FINALPATH__/autodiscover/autodiscover.php; + alias __INSTALL_DIR__/autodiscover/autodiscover.php; fastcgi_pass unix:/var/run/php/php__PHPVERSION__-fpm-__NAME__.sock; include fastcgi_params; fastcgi_param HTTPS on; @@ -43,7 +44,7 @@ location /Autodiscover/Autodiscover.xml { } location /autodiscover/autodiscover.xml { - alias __FINALPATH__/autodiscover/autodiscover.php; + alias __INSTALL_DIR__/autodiscover/autodiscover.php; fastcgi_pass unix:/var/run/php/php__PHPVERSION__-fpm-__NAME__.sock; include fastcgi_params; fastcgi_param HTTPS on; diff --git a/doc/DISCLAIMER.md b/doc/DISCLAIMER.md deleted file mode 100644 index c5645eb..0000000 --- a/doc/DISCLAIMER.md +++ /dev/null @@ -1 +0,0 @@ -* would be better to create a dedicated domain: autodiscover.yourdomain.org diff --git a/manifest.json b/manifest.json deleted file mode 100644 index 900c066..0000000 --- a/manifest.json +++ /dev/null @@ -1,45 +0,0 @@ -{ - "name": "Z-Push", - "id": "z-push", - "packaging_format": 1, - "description": { - "en": "ActiveSync frontend that helps you synchronize emails, calendar and contacts", - "fr": "Frontend ActiveSync qui permet de synchroniser emails, calendrier et contacts" - }, - "version": "2.7.0~ynh3", - "url": "https://z-push.org", - "upstream": { - "license": "AGPL-3.0-or-later", - "website": "http://z-push.org", - "admindoc": "https://wiki.z-hub.io/display/ZP/Documentation", - "code": "https://github.com/Z-Hub/Z-Push" - }, - "license": "AGPL-3.0-or-later", - "maintainer": { - "name": "yalh76" - }, - "previous_maintainer": [ - { - "name": "beudbeud" - }, - { - "name": "polytan02" - } - ], - "requirements": { - "yunohost": ">= 11.0.9" - }, - "multi_instance": true, - "services": [ - "nginx", - "php7.4-fpm" - ], - "arguments": { - "install": [ - { - "name": "domain", - "type": "domain" - } - ] - } -} diff --git a/manifest.toml b/manifest.toml new file mode 100644 index 0000000..7fad824 --- /dev/null +++ b/manifest.toml @@ -0,0 +1,56 @@ +packaging_format = 2 + +id = "z-push" +name = "Z-Push" +description.en = "ActiveSync frontend that helps you synchronize emails, calendar and contacts" +description.fr = "Frontend ActiveSync qui permet de synchroniser emails, calendrier et contacts" + +version = "2.7.1~ynh1" + +maintainers = ["yalh76"] + +[upstream] +license = "AGPL-3.0-or-later" +website = "http://z-push.org" +admindoc = "https://wiki.z-hub.io/display/ZP/Documentation" +code = "https://github.com/Z-Hub/Z-Push" + +[integration] +yunohost = ">= 11.2" +architectures = "all" +multi_instance = true + +ldap = false + +sso = false + +disk = "50M" +ram.build = "50M" +ram.runtime = "50M" + +[install] + + [install.domain] + type = "domain" + +[resources] + [resources.sources.main] + url = "https://github.com/Z-Hub/Z-Push/archive/2.7.1.tar.gz" + sha256 = "7aadddb5da06494a35c79e4b70d6ade6b2f62203f3df343077731f8952b64a41" + + + [resources.system_user] + + [resources.install_dir] + + [resources.data_dir] + + [resources.permissions] + main.url = "/" + main.allowed = "visitors" # should it always be public ? + + # FIXME: watdo with this ... + #REMOVEME? ynh_permission_create --permission="autodiscover" --url="re:$domain_regex/[Aa]uto[Dd]iscover/.*" --allowed="visitors" --show_tile="false" --protected="true" + + [resources.apt] + packages = "php7.4-soap, php7.4-imap, php7.4-xsl, php7.4-curl, php7.4-xml, php7.4-ldap, php7.4-cli, php7.4-mbstring, php7.4-memcached, libawl-php" diff --git a/scripts/_common.sh b/scripts/_common.sh index 1c72e28..944a65e 100644 --- a/scripts/_common.sh +++ b/scripts/_common.sh @@ -4,14 +4,6 @@ # COMMON VARIABLES #================================================= -YNH_PHP_VERSION="7.4" - -php_dependencies="php${YNH_PHP_VERSION}-soap php${YNH_PHP_VERSION}-imap php${YNH_PHP_VERSION}-xsl php${YNH_PHP_VERSION}-curl php${YNH_PHP_VERSION}-xml php${YNH_PHP_VERSION}-ldap php${YNH_PHP_VERSION}-cli php${YNH_PHP_VERSION}-mbstring php${YNH_PHP_VERSION}-memcached" - -# dependencies used by the app (must be on a single line) -pkg_dependencies="libawl-php $php_dependencies" - - #================================================= # PERSONAL HELPERS #================================================= diff --git a/scripts/backup b/scripts/backup index c271a32..b0b2b76 100755 --- a/scripts/backup +++ b/scripts/backup @@ -10,29 +10,6 @@ source ../settings/scripts/_common.sh source /usr/share/yunohost/helpers -#================================================= -# MANAGE SCRIPT FAILURE -#================================================= - -ynh_clean_setup () { - true -} -# Exit if an error occurs during the execution of the script -ynh_abort_if_errors - -#================================================= -# LOAD SETTINGS -#================================================= -ynh_print_info --message="Loading settings..." - -app=$YNH_APP_INSTANCE_NAME - -final_path=$(ynh_app_setting_get --app=$app --key=final_path) -domain=$(ynh_app_setting_get --app=$app --key=domain) -phpversion=$(ynh_app_setting_get --app=$app --key=phpversion) -datadir=$(ynh_app_setting_get --app=$app --key=datadir) -final_logpath=$(ynh_app_setting_get --app=$app --key=final_logpath) - #================================================= # DECLARE DATA AND CONF FILES TO BACKUP #================================================= @@ -42,13 +19,13 @@ ynh_print_info --message="Declaring files to be backed up..." # BACKUP THE APP MAIN DIR #================================================= -ynh_backup --src_path="$final_path" +ynh_backup --src_path="$install_dir" #================================================= # BACKUP THE DATA DIR #================================================= -ynh_backup --src_path="$datadir" --is_big +ynh_backup --src_path="$data_dir" --is_big #================================================= # BACKUP THE NGINX CONFIGURATION diff --git a/scripts/install b/scripts/install index f3825c3..8ae9a48 100755 --- a/scripts/install +++ b/scripts/install @@ -9,170 +9,75 @@ source _common.sh source /usr/share/yunohost/helpers -#================================================= -# MANAGE SCRIPT FAILURE -#================================================= - -ynh_clean_setup () { - true -} -# Exit if an error occurs during the execution of the script -ynh_abort_if_errors - #================================================= # RETRIEVE ARGUMENTS FROM THE MANIFEST #================================================= -domain=$YNH_APP_ARG_DOMAIN -path_url="/Microsoft-Server-ActiveSync" - -app=$YNH_APP_INSTANCE_NAME - -#================================================= -# CHECK IF THE APP CAN BE INSTALLED WITH THESE ARGS -#================================================= -ynh_script_progression --message="Validating installation parameters..." --weight=1 - -final_path=/var/www/$app -test ! -e "$final_path" || ynh_die --message="This path already contains a folder" - -# Register (book) web path -ynh_webpath_register --app=$app --domain=$domain --path_url=$path_url - -#================================================= -# STORE SETTINGS FROM MANIFEST -#================================================= -ynh_script_progression --message="Storing installation settings..." --weight=1 - -ynh_app_setting_set --app=$app --key=domain --value=$domain -ynh_app_setting_set --app=$app --key=path --value=$path_url - -#================================================= -# STANDARD MODIFICATIONS -#================================================= -# INSTALL DEPENDENCIES -#================================================= -ynh_script_progression --message="Installing dependencies..." --weight=1 -ynh_script_progression --message="Installing dependencies..." --weight=1 -ynh_script_progression --message="Installing dependencies..." --weight=1 -ynh_script_progression --message="Installing dependencies..." --weight=1 - -ynh_install_app_dependencies $pkg_dependencies - -#================================================= -# CREATE DEDICATED USER -#================================================= -ynh_script_progression --message="Configuring system user..." --weight=1 - -# Create a system user -ynh_system_user_create --username=$app --home_dir="$final_path" +path="/Microsoft-Server-ActiveSync" +timezone="$(cat /etc/timezone)" +log_dir="/var/log/$app/" #================================================= # DOWNLOAD, CHECK AND UNPACK SOURCE #================================================= -ynh_script_progression --message="Setting up source files..." --weight=1 +ynh_script_progression --message="Setting up source files..." -ynh_app_setting_set --app=$app --key=final_path --value=$final_path # Download, check integrity, uncompress and patch the source from app.src -mkdir -p "$final_path/tmp" -ynh_setup_source --dest_dir="$final_path/tmp" -cp -af "$final_path/tmp/src/." "$final_path/." -ynh_secure_remove "$final_path/tmp" +mkdir -p "$install_dir/tmp" +ynh_setup_source --dest_dir="$install_dir/tmp" +cp -af "$install_dir/tmp/src/." "$install_dir/." +ynh_secure_remove "$install_dir/tmp" -chmod 750 "$final_path" -chmod -R o-rwx "$final_path" -chown -R $app:www-data "$final_path" +chmod -R o-rwx "$install_dir" +chown -R $app:www-data "$install_dir" #================================================= # PHP-FPM CONFIGURATION #================================================= -ynh_script_progression --message="Configuring PHP-FPM..." --weight=1 +ynh_script_progression --message="Installing system configurations..." # Create a dedicated PHP-FPM config -ynh_add_fpm_config --usage=low --footprint=low -phpversion=$(ynh_app_setting_get --app=$app --key=phpversion) - -#================================================= -# NGINX CONFIGURATION -#================================================= -ynh_script_progression --message="Configuring NGINX web server..." --weight=1 +ynh_add_fpm_config # Create a dedicated NGINX config ynh_add_nginx_config -#================================================= -# SPECIFIC SETUP -#================================================= -# CREATE DATA DIRECTORY -#================================================= -ynh_script_progression --message="Creating a data directory..." --weight=1 +mkdir -p $log_dir +chmod 750 "$log_dir" +chmod -R o-rwx "$log_dir" +chown -R $app:www-data "$log_dir" -datadir=/home/yunohost.app/$app -ynh_app_setting_set --app=$app --key=datadir --value=$datadir - -mkdir -p $datadir - -chmod 750 "$datadir" -chmod -R o-rwx "$datadir" -chown -R $app:www-data "$datadir" - -#================================================= -# CREATE FINAL LOG PATH -#================================================= -ynh_script_progression --message="Creating a final log path..." --weight=1 - -final_logpath="/var/log/$app" -ynh_app_setting_set --app=$app --key=final_logpath --value=$final_logpath - -mkdir -p $final_logpath - -chmod 750 "$final_logpath" -chmod -R o-rwx "$final_logpath" -chown -R $app:www-data "$final_logpath" +ynh_use_logrotate #================================================= # ADD A CONFIGURATION #================================================= -ynh_script_progression --message="Adding a configuration file..." --weight=1 - -# Configuration -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 --match_string="__DATADIR__" --replace_string=$datadir --target_file="../conf/config.php" +ynh_script_progression --message="Adding a configuration file..." # Enable caldav carddav support if yunohost app list | grep -q 'id: baikal' ; then echo "Detected Baikal" - bailkaldomain=$(ynh_app_setting_get --app="baikal" --key=domain) - bailkalpath=$(ynh_app_setting_get --app="baikal" --key=path) - bailkalpath=${bailkalpath%/} + baikaldomain=$(ynh_app_setting_get --app="baikal" --key=domain) + baikalpath=$(ynh_app_setting_get --app="baikal" --key=path) + baikalpath=${baikalpath%/} - # Configuration of backend - 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" + # Variables to hydrate template + backend="BackendCombined" + caldav_server="$baikaldomain" + caldav_path="${baikalpath}/cal.php/calendars/%u/" + caldav_personal="default" - # Configuration baikal - 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" + carddav_server="$baikaldomain" + carddav_path="${baikalpath}/card.php/addressbooks/%u/" + carddav_default_path="${baikalpath}/card.php/addressbooks/%u/default" - 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" + imap_server="$domain" + imap_meeting_use_caldav="true" - 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 -af ../conf/backend/config-caldav.php $final_path/backend/caldav/config.php - cp -af ../conf/backend/config-carddav.php $final_path/backend/carddav/config.php - cp -af ../conf/backend/config-imap.php $final_path/backend/imap/config.php - cp -af ../conf/backend/config-combined.php $final_path/backend/combined/config.php + ynh_add_config --template="backend/config-caldav.php" --destination="$install_dir/backend/caldav/config.php" + ynh_add_config --template="backend/config-carddav.php" --destination="$install_dir/backend/carddav/config.php" + ynh_add_config --template="backend/config-imap.php" --destination="$install_dir/backend/imap/config.php" + ynh_add_config --template="backend/config-combined.php" --destination="$install_dir/backend/combined/config.php" elif yunohost app list | grep -q 'id: nextcloud' ; then echo "Detected NextCloud" @@ -180,75 +85,40 @@ elif yunohost app list | grep -q 'id: nextcloud' ; then nextcloudpath=$(ynh_app_setting_get --app="nextcloud" --key=path) nextcloudpath=${nextcloudpath%/} - # Configuration of backend - 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" + # Variables to hydrate template + backend="BackendCombined" + caldav_server="$nextclouddomain" + caldav_path="${nextcloudpath}/remote.php/dav/calendars/%u/" + caldav_personal="personal" - # Configuration nextcloud - 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" + carddav_server="$nextclouddomain" + carddav_path="${nextcloudpath}/remote.php/dav/addressbooks/users/%u/" + carddav_default_path="${nextcloudpath}/remote.php/dav/addressbooks/users/%u/" - 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/" --target_file="../conf/backend/config-carddav.php" - ynh_replace_string --match_string="__CARDDAV_DEFAULT_PATH__" --replace_string="${nextcloudpath}/remote.php/dav/addressbooks/users/%u/" --target_file="../conf/backend/config-carddav.php" + imap_server="$domain" + imap_meeting_use_caldav="true" - 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" + ynh_add_config --template="backend/config-caldav.php" --destination="$install_dir/backend/caldav/config.php" + ynh_add_config --template="backend/config-carddav.php" --destination="$install_dir/backend/carddav/config.php" + ynh_add_config --template="backend/config-imap.php" --destination="$install_dir/backend/imap/config.php" + ynh_add_config --template="backend/config-combined.php" --destination="$install_dir/backend/combined/config.php" - # Copy config - cp -af ../conf/backend/config-caldav.php $final_path/backend/caldav/config.php - cp -af ../conf/backend/config-carddav.php $final_path/backend/carddav/config.php - cp -af ../conf/backend/config-imap.php $final_path/backend/imap/config.php - cp -af ../conf/backend/config-combined.php $final_path/backend/combined/config.php else - # Configuration of backend - ynh_replace_string --match_string="__BACKEND__" --replace_string="BackendIMAP" --target_file="../conf/config.php" - ynh_replace_string --match_string="__BACKEND__" --replace_string="BackendIMAP" --target_file="../conf/backend/config-autodiscover.php" - - # Configuration imap - 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 -af ../conf/backend/config-imap.php $final_path/backend/imap/config.php + backend="BackendIMAP" + imap_server="$domain" + imap_meeting_use_caldav="false" + + ynh_add_config --template="backend/config-imap.php" --destination="$install_dir/backend/imap/config.php" fi # Copy config -cp -af ../conf/config.php $final_path/config.php -cp -af ../conf/backend/config-autodiscover.php $final_path/autodiscover/config.php -cp -af ../conf/backend/config-searchldap.php $final_path/backend/searchldap/config.php +ynh_add_config --template="config.php" --destination="$install_dir/config.php" +ynh_add_config --template="backend/config-autodiscover.php" --destination="$install_dir/autodiscover/config.php" +ynh_add_config --template="backend/config-searchldap.php" --destination="$install_dir/backend/searchldap/config.php" #Copy XMLElement.php ln -s /usr/share/awl/inc/XML* /var/www/$app/include/ -#================================================= -# GENERIC FINALIZATION -#================================================= -# SETUP LOGROTATE -#================================================= -ynh_script_progression --message="Configuring log rotation..." --weight=1 - -# Use logrotate to manage application logfile(s) -ynh_use_logrotate - -#================================================= -# SETUP SSOWAT -#================================================= -ynh_script_progression --message="Configuring permissions..." --weight=1 - -# Make app public -ynh_permission_update --permission="main" --add="visitors" - -domain_regex=$(echo "$domain" | sed 's@-@.@g') -ynh_permission_create --permission="autodiscover" --url="re:$domain_regex/[Aa]uto[Dd]iscover/.*" --allowed="visitors" --show_tile="false" --protected="true" - -#================================================= -# RELOAD NGINX -#================================================= -ynh_script_progression --message="Reloading NGINX web server..." --weight=1 - -ynh_systemd_action --service_name=nginx --action=reload #================================================= # END OF SCRIPT diff --git a/scripts/remove b/scripts/remove index d45761b..6822235 100755 --- a/scripts/remove +++ b/scripts/remove @@ -9,18 +9,6 @@ source _common.sh source /usr/share/yunohost/helpers -#================================================= -# LOAD SETTINGS -#================================================= -ynh_script_progression --message="Loading settings..." --weight=1 - -app=$YNH_APP_INSTANCE_NAME - -domain=$(ynh_app_setting_get --app=$app --key=domain) -final_path=$(ynh_app_setting_get --app=$app --key=final_path) -datadir=$(ynh_app_setting_get --app=$app --key=datadir) -final_logpath=$(ynh_app_setting_get --app=$app --key=final_logpath) - #================================================= # STANDARD REMOVE #================================================= @@ -31,67 +19,13 @@ ynh_script_progression --message="Removing logrotate configuration..." --weight= # Remove the app-specific logrotate config ynh_remove_logrotate -#================================================= -# REMOVE APP MAIN DIR -#================================================= -ynh_script_progression --message="Removing app main directory..." --weight=1 - -# Remove the app directory securely -ynh_secure_remove --file="$final_path" - -#================================================= -# REMOVE DATA DIR -#================================================= - -# Remove the data directory if --purge option is used -if [ "${YNH_APP_PURGE:-0}" -eq 1 ] -then - ynh_script_progression --message="Removing app data directory..." --weight=1 - ynh_secure_remove --file="$datadir" -fi - -#================================================= -# REMOVE NGINX CONFIGURATION -#================================================= -ynh_script_progression --message="Removing NGINX web server configuration..." --weight=1 - # Remove the dedicated NGINX config ynh_remove_nginx_config -#================================================= -# REMOVE PHP-FPM CONFIGURATION -#================================================= -ynh_script_progression --message="Removing PHP-FPM configuration..." --weight=1 - # Remove the dedicated PHP-FPM config ynh_remove_fpm_config -#================================================= -# REMOVE DEPENDENCIES -#================================================= -ynh_script_progression --message="Removing dependencies..." --weight=1 - -# Remove metapackage and its dependencies -ynh_remove_app_dependencies - -#================================================= -# SPECIFIC REMOVE -#================================================= -# REMOVE VARIOUS FILES -#================================================= -ynh_script_progression --message="Removing various files..." --weight=1 - -ynh_secure_remove --file="$final_logpath" - -#================================================= -# GENERIC FINALIZATION -#================================================= -# REMOVE DEDICATED USER -#================================================= -ynh_script_progression --message="Removing the dedicated system user..." --weight=1 - -# Delete a system user -ynh_system_user_delete --username=$app +ynh_secure_remove --file="$log_dir" #================================================= # END OF SCRIPT diff --git a/scripts/restore b/scripts/restore index ccf2024..6e26b08 100755 --- a/scripts/restore +++ b/scripts/restore @@ -10,81 +10,26 @@ source ../settings/scripts/_common.sh source /usr/share/yunohost/helpers -#================================================= -# MANAGE SCRIPT FAILURE -#================================================= - -ynh_clean_setup () { - true -} -# Exit if an error occurs during the execution of the script -ynh_abort_if_errors - -#================================================= -# LOAD SETTINGS -#================================================= -ynh_script_progression --message="Loading settings..." --weight=1 - -app=$YNH_APP_INSTANCE_NAME - -domain=$(ynh_app_setting_get --app=$app --key=domain) -path_url=$(ynh_app_setting_get --app=$app --key=path) -final_path=$(ynh_app_setting_get --app=$app --key=final_path) -phpversion=$(ynh_app_setting_get --app=$app --key=phpversion) -datadir=$(ynh_app_setting_get --app=$app --key=datadir) -final_logpath=$(ynh_app_setting_get --app=$app --key=final_logpath) - -#================================================= -# CHECK IF THE APP CAN BE RESTORED -#================================================= -ynh_script_progression --message="Validating restoration parameters..." --weight=1 - -test ! -d $final_path \ - || ynh_die --message="There is already a directory: $final_path " - -#================================================= -# STANDARD RESTORATION STEPS -#================================================= -# RECREATE THE DEDICATED USER -#================================================= -ynh_script_progression --message="Recreating the dedicated system user..." --weight=1 - -# Create the dedicated user (if not existing) -ynh_system_user_create --username=$app --home_dir="$final_path" +log_dir="/var/log/$app/" #================================================= # RESTORE THE APP MAIN DIR #================================================= ynh_script_progression --message="Restoring the app main directory..." --weight=1 -ynh_restore_file --origin_path="$final_path" +ynh_restore_file --origin_path="$install_dir" -chmod 750 "$final_path" -chmod -R o-rwx "$final_path" -chown -R $app:www-data "$final_path" +chmod -R o-rwx "$install_dir" +chown -R $app:www-data "$install_dir" #================================================= # RESTORE THE DATA DIRECTORY #================================================= ynh_script_progression --message="Restoring the data directory..." --weight=1 -ynh_restore_file --origin_path="$datadir" --not_mandatory +ynh_restore_file --origin_path="$data_dir" --not_mandatory -mkdir -p $datadir - -chmod 750 "$datadir" -chmod -R o-rwx "$datadir" -chown -R $app:www-data "$datadir" - -#================================================= -# SPECIFIC RESTORATION -#================================================= -# REINSTALL DEPENDENCIES -#================================================= -ynh_script_progression --message="Reinstalling dependencies..." --weight=1 - -# Define and install dependencies -ynh_install_app_dependencies $pkg_dependencies +chown -R $app:www-data "$data_dir" #================================================= # RESTORE THE PHP-FPM CONFIGURATION @@ -93,24 +38,15 @@ ynh_script_progression --message="Restoring the PHP-FPM configuration..." --weig ynh_restore_file --origin_path="/etc/php/$phpversion/fpm/pool.d/$app.conf" -# Recreate a dedicated php-fpm config -ynh_add_fpm_config --usage=low --footprint=low -phpversion=$(ynh_app_setting_get --app=$app --key=phpversion) - -#================================================= -# RESTORE THE NGINX CONFIGURATION -#================================================= -ynh_script_progression --message="Restoring the NGINX web server configuration..." --weight=1 - ynh_restore_file --origin_path="/etc/nginx/conf.d/$domain.d/$app.conf" -#================================================= -# RESTORE THE LOGROTATE CONFIGURATION -#================================================= -ynh_script_progression --message="Restoring the logrotate configuration..." --weight=1 - ynh_restore_file --origin_path="/etc/logrotate.d/$app" +mkdir -p $log_dir +chmod 750 "$log_dir" +chmod -R o-rwx "$log_dir" +chown -R $app:www-data "$log_dir" + #================================================= # GENERIC FINALIZATION #================================================= diff --git a/scripts/upgrade b/scripts/upgrade index 0e6ad2d..d148951 100755 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -9,76 +9,14 @@ source _common.sh source /usr/share/yunohost/helpers -#================================================= -# LOAD SETTINGS -#================================================= -ynh_script_progression --message="Loading settings..." --weight=1 - -app=$YNH_APP_INSTANCE_NAME - -domain=$(ynh_app_setting_get --app=$app --key=domain) -path_url=$(ynh_app_setting_get --app=$app --key=path) -final_path=$(ynh_app_setting_get --app=$app --key=final_path) -datadir=$(ynh_app_setting_get --app=$app --key=datadir) -final_logpath=$(ynh_app_setting_get --app=$app --key=final_logpath) - #================================================= # CHECK VERSION #================================================= -ynh_script_progression --message="Checking version..." --weight=1 upgrade_type=$(ynh_check_app_version_changed) -#================================================= -# BACKUP BEFORE UPGRADE THEN ACTIVE TRAP -#================================================= -ynh_script_progression --message="Backing up the app before upgrading (may take a while)..." --weight=1 - -# Backup the current version of the app -ynh_backup_before_upgrade -ynh_clean_setup () { - # Restore it if the upgrade fails - ynh_restore_upgradebackup -} -# Exit if an error occurs during the execution of the script -ynh_abort_if_errors - -#================================================= -# STANDARD UPGRADE STEPS -#================================================= -# ENSURE DOWNWARD COMPATIBILITY -#================================================= -ynh_script_progression --message="Ensuring downward compatibility..." --weight=1 - -# Cleaning legacy permissions -if ynh_legacy_permissions_exists; then - ynh_legacy_permissions_delete_all - - ynh_app_setting_delete --app=$app --key=is_public -fi - -if [ -z "$datadir" ]; -then - datadir="/home/yunohost.app/$app" - ynh_app_setting_set --app=$app --key=datadir --value=$datadir - ynh_app_setting_delete --app=$app --key=statedir - mkdir -p $datadir -fi - -if [ -z "$final_logpath" ]; -then - final_logpath="/var/log/$app" - ynh_app_setting_set --app=$app --key=final_logpath --value=$final_logpath - mkdir -p $final_logpath -fi - -#================================================= -# CREATE DEDICATED USER -#================================================= -ynh_script_progression --message="Making sure dedicated system user exists..." --weight=1 - -# Create a dedicated user (if not existing) -ynh_system_user_create --username=$app --home_dir="$final_path" +timezone="$(cat /etc/timezone)" +log_dir="/var/log/$app/" #================================================= # DOWNLOAD, CHECK AND UNPACK SOURCE @@ -86,153 +24,127 @@ ynh_system_user_create --username=$app --home_dir="$final_path" if [ "$upgrade_type" == "UPGRADE_APP" ] then - ynh_script_progression --message="Upgrading source files..." --weight=1 + ynh_script_progression --message="Upgrading source files..." - # Download, check integrity, uncompress and patch the source from app.src - mkdir "$final_path/tmp" - ynh_setup_source --dest_dir="$final_path/tmp" - cp -af "$final_path/tmp/src/." "$final_path/." - ynh_secure_remove --file="$final_path/tmp" + mkdir "$install_dir/bkp" + conf_files_to_keep="config.php backend/caldav/config.php backend/carddav/config.php backend/imap/config.php backend/combined/config.php autodiscover/config.php backend/searchldap/config.php" + for file in $conf_files_to_keep + do + if [ -e $install_dir/$file ] + then + mkdir -p $install_dir/bkp/$(dirname $file) + cp $install_dir/$file $install_dir/bkp/$file + fi + done + + # Download, check integrity, uncompress and patch the source from app.src + mkdir "$install_dir/tmp" + ynh_setup_source --dest_dir="$install_dir/tmp" + cp -af "$install_dir/tmp/src/." "$install_dir/." + ynh_secure_remove --file="$install_dir/tmp" + + for file in $conf_files_to_keep + do + if [ -e $install_dir/bkp/$file ] + then + cp $install_dir/bkp/$file $install_dir/$file + fi + done + ynh_secure_remove --file="$install_dir/bkp" fi -chmod 750 "$final_path" -chmod -R o-rwx "$final_path" -chown -R $app:www-data "$final_path" - -#================================================= -# UPGRADE DEPENDENCIES -#================================================= -ynh_script_progression --message="Upgrading dependencies..." --weight=1 - -ynh_install_app_dependencies $pkg_dependencies +chmod -R o-rwx "$install_dir" +chown -R $app:www-data "$install_dir" #================================================= # PHP-FPM CONFIGURATION #================================================= -ynh_script_progression --message="Upgrading PHP-FPM configuration..." --weight=1 +ynh_script_progression --message="Installing system configurations..." # Create a dedicated PHP-FPM config -ynh_add_fpm_config --usage=low --footprint=low -phpversion=$(ynh_app_setting_get --app=$app --key=phpversion) - -#================================================= -# NGINX CONFIGURATION -#================================================= -ynh_script_progression --message="Upgrading NGINX web server configuration..." --weight=1 +ynh_add_fpm_config # Create a dedicated NGINX config ynh_add_nginx_config +mkdir -p $log_dir +chmod 750 "$log_dir" +chmod -R o-rwx "$log_dir" +chown -R $app:www-data "$log_dir" + +ynh_use_logrotate --non-append + #================================================= # SPECIFIC UPGRADE #================================================= # UPDATE A CONFIG FILE #================================================= -ynh_script_progression --message="Updating a config file..." --weight=1 - -# Configuration -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 __DATADIR__ $datadir ../conf/config.php +ynh_script_progression --message="Updating a config file..." # Enable caldav carddav support if yunohost app list | grep -q 'id: baikal' ; then - echo "Detected Baikal" - bailkaldomain=$(ynh_app_setting_get --app=baikal --key=domain) - bailkalpath=$(ynh_app_setting_get --app=baikal --key=path) - bailkalpath=${bailkalpath%/} + echo "Detected Baikal" + baikaldomain=$(ynh_app_setting_get --app="baikal" --key=domain) + baikalpath=$(ynh_app_setting_get --app="baikal" --key=path) + baikalpath=${baikalpath%/} - # Configuration of backend - 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" + # Variables to hydrate template + backend="BackendCombined" + caldav_server="$baikaldomain" + caldav_path="${baikalpath}/cal.php/calendars/%u/" + caldav_personal="default" - # Configuration baikal - 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" + carddav_server="$baikaldomain" + carddav_path="${baikalpath}/card.php/addressbooks/%u/" + carddav_default_path="${baikalpath}/card.php/addressbooks/%u/default" - 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" + imap_server="$domain" + imap_meeting_use_caldav="true" - 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 -af ../conf/backend/config-caldav.php $final_path/backend/caldav/config.php - cp -af ../conf/backend/config-carddav.php $final_path/backend/carddav/config.php - cp -af ../conf/backend/config-imap.php $final_path/backend/imap/config.php - cp -af ../conf/backend/config-combined.php $final_path/backend/combined/config.php + ynh_add_config --template="backend/config-caldav.php" --destination="$install_dir/backend/caldav/config.php" + ynh_add_config --template="backend/config-carddav.php" --destination="$install_dir/backend/carddav/config.php" + ynh_add_config --template="backend/config-imap.php" --destination="$install_dir/backend/imap/config.php" + ynh_add_config --template="backend/config-combined.php" --destination="$install_dir/backend/combined/config.php" elif yunohost app list | grep -q 'id: nextcloud' ; then - echo "Detected NextCloud" - nextclouddomain=$(ynh_app_setting_get --app=nextcloud --key=domain) - nextcloudpath=$(ynh_app_setting_get --app=nextcloud --key=path) - nextcloudpath=${nextcloudpath%/} + echo "Detected NextCloud" + 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 --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" + # Variables to hydrate template + backend="BackendCombined" + caldav_server="$nextclouddomain" + caldav_path="${nextcloudpath}/remote.php/dav/calendars/%u/" + caldav_personal="personal" - # Configuration nextcloud - 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" + carddav_server="$nextclouddomain" + carddav_path="${nextcloudpath}/remote.php/dav/addressbooks/users/%u/" + carddav_default_path="${nextcloudpath}/remote.php/dav/addressbooks/users/%u/" - 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" + imap_server="$domain" + imap_meeting_use_caldav="true" - 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" + ynh_add_config --template="backend/config-caldav.php" --destination="$install_dir/backend/caldav/config.php" + ynh_add_config --template="backend/config-carddav.php" --destination="$install_dir/backend/carddav/config.php" + ynh_add_config --template="backend/config-imap.php" --destination="$install_dir/backend/imap/config.php" + ynh_add_config --template="backend/config-combined.php" --destination="$install_dir/backend/combined/config.php" - # Copy config - cp -af ../conf/backend/config-caldav.php $final_path/backend/caldav/config.php - cp -af ../conf/backend/config-carddav.php $final_path/backend/carddav/config.php - cp -af ../conf/backend/config-imap.php $final_path/backend/imap/config.php - cp -af ../conf/backend/config-combined.php $final_path/backend/combined/config.php else - # Configuration of backend - ynh_replace_string --match_string="__BACKEND__" --replace_string="BackendIMAP" --target_file="../conf/config.php" - ynh_replace_string --match_string="__BACKEND__" --replace_string="BackendIMAP" --target_file="../conf/backend/config-autodiscover.php" - - # Configuration imap - 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 -af ../conf/backend/config-imap.php $final_path/backend/imap/config.php + backend="BackendIMAP" + imap_server="$domain" + imap_meeting_use_caldav="false" + + ynh_add_config --template="backend/config-imap.php" --destination="$install_dir/backend/imap/config.php" fi # Copy config -cp -af ../conf/config.php $final_path/config.php -cp -af ../conf/backend/config-autodiscover.php $final_path/autodiscover/config.php -cp -af ../conf/backend/config-searchldap.php $final_path/backend/searchldap/config.php +ynh_add_config --template="config.php" --destination="$install_dir/config.php" +ynh_add_config --template="backend/config-autodiscover.php" --destination="$install_dir/autodiscover/config.php" +ynh_add_config --template="backend/config-searchldap.php" --destination="$install_dir/backend/searchldap/config.php" # Fixstates to avoid full resync of devices after version upgrades -$final_path/z-push-admin.php -a fixstates - -#================================================= -# GENERIC FINALIZATION -#================================================= -# SETUP LOGROTATE -#================================================= -ynh_script_progression --message="Upgrading logrotate configuration..." --weight=1 - -# Use logrotate to manage app-specific logfile(s) -ynh_use_logrotate --non-append - -#================================================= -# RELOAD NGINX -#================================================= -ynh_script_progression --message="Reloading NGINX web server..." --weight=1 - -ynh_systemd_action --service_name=nginx --action=reload +$install_dir/z-push-admin.php -a fixstates #================================================= # END OF SCRIPT diff --git a/tests.toml b/tests.toml new file mode 100644 index 0000000..b55cdd8 --- /dev/null +++ b/tests.toml @@ -0,0 +1,9 @@ +test_format = 1.0 + +[default] + + # ------------ + # Tests to run + # ------------ + + exclude = ["change_url"] \ No newline at end of file