From 50a4d08add362d8ef2c4cfea5f8e1c96be82b519 Mon Sep 17 00:00:00 2001 From: Alexandre Aubin Date: Thu, 13 Jun 2024 01:00:52 +0200 Subject: [PATCH] helpers2.1: fixes after tests on the battlefield --- helpers/helpers | 2 +- helpers/helpers.v2.1.d/apt | 2 +- helpers/helpers.v2.1.d/php | 26 ++------------------------ helpers/helpers.v2.1.d/string | 2 +- helpers/helpers.v2.1.d/utils | 4 ++-- helpers/helpers.v2.1.d/vendor | 1 + 6 files changed, 8 insertions(+), 29 deletions(-) create mode 120000 helpers/helpers.v2.1.d/vendor diff --git a/helpers/helpers b/helpers/helpers index 01b6fa7e3..64f9322ae 100644 --- a/helpers/helpers +++ b/helpers/helpers @@ -11,7 +11,7 @@ set +x YNH_HELPERS_DIR="$SCRIPT_DIR/helpers.v${YNH_HELPERS_VERSION}.d" case "$YNH_HELPERS_VERSION" in - "1" | "2") + "1" | "2" | "2.1") readarray -t HELPERS < <(find -L "$YNH_HELPERS_DIR" -mindepth 1 -maxdepth 1 -type f) for helper in "${HELPERS[@]}"; do [ -r "$helper" ] && source "$helper" diff --git a/helpers/helpers.v2.1.d/apt b/helpers/helpers.v2.1.d/apt index 3b8666078..fa35aa45c 100644 --- a/helpers/helpers.v2.1.d/apt +++ b/helpers/helpers.v2.1.d/apt @@ -234,7 +234,7 @@ ynh_install_app_dependencies() { dependencies="$(echo "$dependencies" | sed 's/\([^\<=\>]\)\ \([^(]\)/\1, \2/g')" local dependencies=${dependencies//|/ | } - local version=$(ynh_read_manifest --manifest_key="version") + local version=$(ynh_read_manifest "version") if [ -z "${version}" ] || [ "$version" == "null" ]; then version="1.0" fi diff --git a/helpers/helpers.v2.1.d/php b/helpers/helpers.v2.1.d/php index 2c0500eb5..37fe76785 100644 --- a/helpers/helpers.v2.1.d/php +++ b/helpers/helpers.v2.1.d/php @@ -217,7 +217,7 @@ ynh_get_scalable_phpfpm() { fi # Get the total of RAM available, except swap. - local max_ram=$(ynh_get_ram --total --ignore_swap) + local max_ram=$(ynh_get_ram --total) at_least_one() { # Do not allow value below 1 @@ -267,28 +267,6 @@ ynh_get_scalable_phpfpm() { php_max_spare_servers=0 php_start_servers=0 fi - - if [ $print -eq 1 ]; then - ynh_print_warn --message="Footprint=${footprint}Mb by pool." - ynh_print_warn --message="Process manager=$php_pm" - ynh_print_warn --message="Max RAM=${max_ram}Mb" - if [ "$php_pm" != "static" ]; then - ynh_print_warn --message="\nMax estimated footprint=$(($php_max_children * $footprint))" - ynh_print_warn --message="Min estimated footprint=$(($php_min_spare_servers * $footprint))" - fi - if [ "$php_pm" = "dynamic" ]; then - ynh_print_warn --message="Estimated average footprint=$(($php_max_spare_servers * $footprint))" - elif [ "$php_pm" = "static" ]; then - ynh_print_warn --message="Estimated footprint=$(($php_max_children * $footprint))" - fi - ynh_print_warn --message="\nRaw php-fpm values:" - ynh_print_warn --message="pm.max_children = $php_max_children" - if [ "$php_pm" = "dynamic" ]; then - ynh_print_warn --message="pm.start_servers = $php_start_servers" - ynh_print_warn --message="pm.min_spare_servers = $php_min_spare_servers" - ynh_print_warn --message="pm.max_spare_servers = $php_max_spare_servers" - fi - fi } # Execute a command with Composer @@ -342,7 +320,7 @@ ynh_install_composer() { # because local always return 0 ... local out # Timeout option is here to enforce the timeout on dns query and tcp connect (c.f. man wget) - out=$(wget --tries 3 --no-dns-cache --timeout 900 --no-verbose --output-document=$workdir $composer_url 2>&1) \ + out=$(wget --tries 3 --no-dns-cache --timeout 900 --no-verbose --output-document=$workdir/composer.phar $composer_url 2>&1) \ || ynh_die --message="$out" # install dependencies diff --git a/helpers/helpers.v2.1.d/string b/helpers/helpers.v2.1.d/string index bacb95f93..8a0fbab93 100644 --- a/helpers/helpers.v2.1.d/string +++ b/helpers/helpers.v2.1.d/string @@ -38,7 +38,7 @@ ynh_string_random() { # Requires YunoHost version 2.6.4 or higher. ynh_replace() { # ============ Argument parsing ============= - local -A args_array=([m]=match= [r]=replaceg= [f]=file=) + local -A args_array=([m]=match= [r]=replace= [f]=file=) local match local replace local file diff --git a/helpers/helpers.v2.1.d/utils b/helpers/helpers.v2.1.d/utils index 889075968..8326f644f 100644 --- a/helpers/helpers.v2.1.d/utils +++ b/helpers/helpers.v2.1.d/utils @@ -388,7 +388,7 @@ ynh_local_curl() { chmod 700 $cookiefile # Temporarily enable visitors if needed... - local visitors_enabled=$(ynh_permission_has_user "main" "visitors" && echo yes || echo no) + local visitors_enabled=$(ynh_permission_has_user --permission="main" --user="visitors" && echo yes || echo no) if [[ $visitors_enabled == "no" ]]; then ynh_permission_update --permission="main" --add="visitors" fi @@ -456,7 +456,7 @@ ynh_safe_rm() { # # Requires YunoHost version 3.5.0 or higher. ynh_read_manifest() { - cat $YNH_APP_BASEDIR/manifest.toml | toml_to_json | jq ".$manifest_key" --raw-output + cat $YNH_APP_BASEDIR/manifest.toml | toml_to_json | jq "$1" --raw-output } # Return the app upstream version, deduced from `$YNH_APP_MANIFEST_VERSION` and strippig the `~ynhX` part diff --git a/helpers/helpers.v2.1.d/vendor b/helpers/helpers.v2.1.d/vendor new file mode 120000 index 000000000..9c39cc9f8 --- /dev/null +++ b/helpers/helpers.v2.1.d/vendor @@ -0,0 +1 @@ +../vendor \ No newline at end of file