diff --git a/scripts/_common.sh b/scripts/_common.sh index 5714a73..5f9c99a 100644 --- a/scripts/_common.sh +++ b/scripts/_common.sh @@ -10,6 +10,30 @@ YNH_COMPOSER_VERSION="2.6.5" # PERSONAL HELPERS #================================================= +# Requires YunoHost version 4.2 or higher. +ynh_composer_execute() { + local _globalphpversion=${phpversion-:} + # 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:-${install_dir:-$final_path}}" + + if dpkg --compare-versions ${YNH_APP_PACKAGING_FORMAT:-0} lt 2; then + phpversion="${phpversion:-$YNH_PHP_VERSION}" + else + phpversion="${phpversion:-$_globalphpversion}" + fi + + COMPOSER_HOME="sudo -u $app $workdir/.composer" COMPOSER_MEMORY_LIMIT=-1 \ + php${phpversion} "$workdir/composer.phar" $commands \ + -d "$workdir" --no-interaction --no-ansi 2>&1 +} + #================================================= # EXPERIMENTAL HELPERS #================================================= diff --git a/scripts/install b/scripts/install index bfaef01..4ea7109 100644 --- a/scripts/install +++ b/scripts/install @@ -59,7 +59,7 @@ ynh_install_composer ln -s $(which php$phpversion) $install_dir/php PATH=$install_dir:$PATH -ynh_exec_warn_less ynh_composer_exec --commands="movim:migrate" +ynh_exec_warn_less ynh_composer_execute --commands="movim:migrate" rm $install_dir/php ynh_exec_as "$app" "php$phpversion" "$install_dir/daemon.php" config --username="$admin" --password="$password" --quiet