From fc5511d51f652287c5bc84cad5f11afb6247b427 Mon Sep 17 00:00:00 2001 From: ericgaspar Date: Sun, 9 May 2021 11:07:54 +0200 Subject: [PATCH] Keep config --- manifest.json | 2 +- scripts/_common.sh | 19 +++------------ scripts/install | 1 - scripts/upgrade | 21 +--------------- scripts/ynh_composer__2 | 53 ----------------------------------------- 5 files changed, 5 insertions(+), 91 deletions(-) delete mode 100644 scripts/ynh_composer__2 diff --git a/manifest.json b/manifest.json index ad58315..cad6831 100644 --- a/manifest.json +++ b/manifest.json @@ -14,7 +14,7 @@ "email": "anmol@datamol.org" }, "requirements": { - "yunohost": ">= 4.1.7" + "yunohost": ">= 4.2.4" }, "multi_instance": true, "services": [ diff --git a/scripts/_common.sh b/scripts/_common.sh index c685199..b7778d4 100644 --- a/scripts/_common.sh +++ b/scripts/_common.sh @@ -8,6 +8,9 @@ YNH_PHP_VERSION="7.3" extra_php_dependencies="php${YNH_PHP_VERSION}-curl php${YNH_PHP_VERSION}-gd php${YNH_PHP_VERSION}-cli php${YNH_PHP_VERSION}-mysql php${YNH_PHP_VERSION}-xml php${YNH_PHP_VERSION}-mbstring" +# Composer version +composer_version=1.10.17 + #================================================= # PERSONAL HELPERS #================================================= @@ -76,19 +79,3 @@ $(yunohost tools diagnosis | grep -B 100 "services:" | sed '/services:/d')" # Send the email to the recipients echo "$mail_message" | $mail_bin -a "Content-Type: text/plain; charset=UTF-8" -s "$mail_subject" "$recipients" } - - - -# Execute a command as another user -# usage: ynh_exec_as USER COMMAND [ARG ...] -ynh_exec_as() { - local USER=$1 - shift 1 - - if [[ $USER = $(whoami) ]]; then - eval "$@" - else - sudo -u "$USER" "$@" - fi -} - diff --git a/scripts/install b/scripts/install index 37389a7..9c8d3a6 100755 --- a/scripts/install +++ b/scripts/install @@ -7,7 +7,6 @@ #================================================= source _common.sh -source ynh_composer__2 source /usr/share/yunohost/helpers #================================================= diff --git a/scripts/upgrade b/scripts/upgrade index dc54adc..eff80eb 100755 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -79,30 +79,11 @@ then ynh_script_progression --message="Upgrading source files..." if [[ ! -f "$final_path/config/config.ini.php" ]]; then - # config.ini.php is only created during the post-install process... - # it is therefore not present when the CI tests are carried out... - # This condition is only for CI test to go through the upgrade process - ynh_secure_remove --file="$final_path" # Download, check integrity, uncompress and patch the source from app.src ynh_setup_source --dest_dir="$final_path" else - # Create a temporary directory - tmpdir="$(mktemp -d)" - - # Backup the config file in the temp dir - cp -a "$final_path/config/config.ini.php" "$tmpdir/config.ini.php" - - # Remove the app directory securely - ynh_secure_remove --file="$final_path" - # Download, check integrity, uncompress and patch the source from app.src - ynh_setup_source --dest_dir="$final_path" #--keep="foo bar" to integrate when https://github.com/YunoHost/yunohost/pull/1200 is upstream - - # Copy the admin saved settings from tmp directory to final path - cp -a "$tmpdir/config.ini.php" "$final_path/config/config.ini.php" - - # Remove the tmp directory securely - ynh_secure_remove --file="$tmpdir" + ynh_setup_source --dest_dir="$final_path" --keep="$final_path/config/config.ini.php" fi fi diff --git a/scripts/ynh_composer__2 b/scripts/ynh_composer__2 deleted file mode 100644 index 762b7f7..0000000 --- a/scripts/ynh_composer__2 +++ /dev/null @@ -1,53 +0,0 @@ -#!/bin/bash - -# Execute a command with Composer -# -# usage: ynh_composer_exec [--phpversion=phpversion] [--workdir=$final_path] --commands="commands" -# | arg: -v, --phpversion - PHP version to use with composer -# | 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=vwc - declare -Ar args_array=( [v]=phpversion= [w]=workdir= [c]=commands= ) - local phpversion - local workdir - local commands - # Manage arguments with getopts - ynh_handle_getopts_args "$@" - workdir="${workdir:-$final_path}" - phpversion="${phpversion:-$YNH_PHP_VERSION}" - - COMPOSER_HOME="$workdir/.composer" \ - php${phpversion} "$workdir/composer.phar" $commands \ - -d "$workdir" --quiet --no-interaction -} - -# Install and initialize Composer in the given directory -# -# usage: ynh_install_composer [--phpversion=phpversion] [--workdir=$final_path] [--install_args="--optimize-autoloader"] -# | arg: -v, --phpversion - PHP version to use with composer -# | arg: -w, --workdir - The directory from where the command will be executed. Default $final_path. -# | arg: -a, --install_args - Additional arguments provided to the composer install. Argument --no-dev already include -ynh_install_composer () { - # Declare an array to define the options of this helper. - local legacy_args=vwa - declare -Ar args_array=( [v]=phpversion= [w]=workdir= [a]=install_args=) - local phpversion - local workdir - local install_args - # Manage arguments with getopts - ynh_handle_getopts_args "$@" - workdir="${workdir:-$final_path}" - phpversion="${phpversion:-$YNH_PHP_VERSION}" - install_args="${install_args:-}" - - curl -sS https://getcomposer.org/installer \ - | COMPOSER_HOME="$workdir/.composer" \ - php${phpversion} -- --quiet --install-dir="$workdir" \ - || ynh_die "Unable to install Composer." - - # update dependencies to create composer.lock - ynh_composer_exec --phpversion="${phpversion}" --workdir="$workdir" --commands="install --no-dev $install_args" \ - || ynh_die "Unable to update core dependencies with Composer." -}