diff --git a/scripts/_common.sh b/scripts/_common.sh index a24ea85..cd5fa99 100644 --- a/scripts/_common.sh +++ b/scripts/_common.sh @@ -95,8 +95,7 @@ init_composer() { || ynh_die "Unable to install Composer" # update dependencies to create composer.lock - exec_composer "$DESTDIR" update symfony/flex --no-plugins --no-scripts - exec_composer "$DESTDIR" install --no-dev --prefer-dist --no-scripts \ + exec_composer "$DESTDIR" install --no-dev --optimize-autoloader \ || ynh_die "Unable to update Kimai2 core dependencies" } @@ -104,6 +103,27 @@ sudo_path () { sudo env "PATH=$PATH" $@ } +# Install and initialize Composer for upgrade script in the given directory +# usage: init_composer DESTDIR [AS_USER] +init_composer_update() { + local DESTDIR=$1 + local AS_USER=${2:-admin} + + # install composer for upgrade script + curl -sS https://getcomposer.org/installer \ + | COMPOSER_HOME="${DESTDIR}/.composer" \ + sudo /usr/bin/php7.2 -- --install-dir="$DESTDIR" \ + || ynh_die "Unable to install Composer" + + # update dependencies to create composer.lock + exec_composer "$DESTDIR" update symfony/flex --no-plugins + exec_composer "$DESTDIR" install --no-dev --optimize-autoloader \ + || ynh_die "Unable to update Kimai2 core dependencies" +} + +sudo_path () { + sudo env "PATH=$PATH" $@ +} # # php7.2 helpers # diff --git a/scripts/upgrade b/scripts/upgrade index 273ce22..fe30ac5 100755 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -76,7 +76,9 @@ ynh_install_php7 # Download, check integrity, uncompress and patch the source from app.src ynh_setup_source "$final_path" -init_composer $final_path +init_composer_update $final_path +cd $final_path && sudo /usr/bin/php7.2 cache:clear --env=prod +cd $final_path && sudo /usr/bin/php7.2 cache:warmup --env=prod cd $final_path && sudo /usr/bin/php7.2 bin/console doctrine:migrations:migrate #================================================= # NGINX CONFIGURATION