From 8a20550a1c542cb5b3c5986dca6239121028ee82 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=B4me=20Lebleu?= Date: Sun, 10 Jul 2016 20:36:22 +0200 Subject: [PATCH] [fix] Handle the upgrade from the current app --- scripts/upgrade | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/scripts/upgrade b/scripts/upgrade index 5ae43d9..b78f169 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -22,6 +22,27 @@ timezone=`cat /etc/timezone` || ynh_die "Could not detect timezone, please check /etc/timezone." \ && echo "Detected timezone: $timezone" +# Init git repository as needed +if [ ! -d "${DESTDIR}/.git" ]; then + tmp_path=/tmp/movim-git + sudo rm -rf "$tmp_path" + + # Download Movim source code + (git clone --quiet "$GIT_REPO" "$tmp_path" \ + && cd "$tmp_path" && git checkout --quiet "$HEAD_COMMIT") \ + || ynh_die "Unable to download Movim source code." + sudo cp "${DESTDIR}/config/db.inc.php" "${tmp_path}/config/db.inc.php" + + # Replace current source code + sudo rm -rf "$DESTDIR" + sudo mv "$tmp_path" "$DESTDIR" + sudo chown -R movim:www-data "$DESTDIR" + + # Install composer for PHP dependencies + curl -sS https://getcomposer.org/installer \ + | exec_cmd php -- --quiet --install-dir="$DESTDIR" +fi + # Update Movim source code (exec_cmd git fetch --quiet origin \ && exec_cmd git reset --quiet --hard "$HEAD_COMMIT") \