2017-03-17 11:38:37 +01:00
|
|
|
#!/usr/bin/env bash
|
|
|
|
|
2019-11-13 11:26:58 +01:00
|
|
|
RED='\033[0;31m'
|
|
|
|
GREEN='\033[0;32m'
|
|
|
|
NC='\033[0m' # No Color
|
|
|
|
|
2017-03-17 11:38:37 +01:00
|
|
|
bypass=0
|
|
|
|
forceClearCache=0
|
|
|
|
while getopts "hbc" option
|
|
|
|
do
|
|
|
|
case $option in
|
|
|
|
h)
|
|
|
|
echo -e "Update or install all Monarc modules, frontend views and migrate database."
|
|
|
|
echo -e "\t-b\tbypass migrate database"
|
|
|
|
echo -e "\t-c\tforce clear cache"
|
|
|
|
echo -e "\t-h\tdisplay this message"
|
|
|
|
exit 1
|
|
|
|
;;
|
|
|
|
b)
|
|
|
|
bypass=1
|
|
|
|
echo "Migrate database don't execute !!!"
|
|
|
|
;;
|
|
|
|
c)
|
|
|
|
forceClearCache=1
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
done
|
2016-04-27 16:59:05 +02:00
|
|
|
|
2022-10-11 09:26:03 +02:00
|
|
|
checkout_to_latest_tag() {
|
|
|
|
if [ -d $1 ]; then
|
|
|
|
pushd $1
|
|
|
|
git fetch --tags
|
|
|
|
tag=$(git describe --tags `git rev-list --tags --max-count=1`)
|
|
|
|
git checkout $tag -b $tag
|
|
|
|
git pull origin $tag
|
|
|
|
popd
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
2016-04-27 16:59:05 +02:00
|
|
|
pull_if_exists() {
|
|
|
|
if [ -d $1 ]; then
|
|
|
|
pushd $1
|
|
|
|
git pull
|
|
|
|
popd
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
2017-03-17 11:38:37 +01:00
|
|
|
migrate_module() {
|
2019-11-13 11:26:58 +01:00
|
|
|
if [[ -d $1 ]]; then
|
|
|
|
php ./vendor/robmorgan/phinx/bin/phinx migrate -c ./$1/migrations/phinx.php
|
2017-03-17 11:38:37 +01:00
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
2017-03-17 14:20:56 +01:00
|
|
|
if [[ ! -f "config/autoload/local.php" && $bypass -eq 0 ]]; then
|
2017-08-25 09:42:36 +02:00
|
|
|
echo "Configure Monarc (config/autoload/local.php)"
|
2017-03-10 14:53:48 +01:00
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
2019-11-13 11:26:58 +01:00
|
|
|
git pull
|
2016-04-27 16:59:05 +02:00
|
|
|
|
2019-06-11 10:46:52 +02:00
|
|
|
if [ $? != 0 ]; then
|
|
|
|
echo "A problem occurred while retrieving remote files from repository."
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
2020-02-24 14:03:45 +01:00
|
|
|
./scripts/check_composer.sh
|
|
|
|
if [[ $? -eq 1 ]]; then
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
|
|
|
composer install -o --no-dev
|
2016-06-02 12:16:03 +02:00
|
|
|
|
2019-10-30 14:52:53 +01:00
|
|
|
pathCore="module/Monarc/Core"
|
|
|
|
pathBO="module/Monarc/BackOffice"
|
|
|
|
|
2022-10-11 09:26:03 +02:00
|
|
|
if [[ $bypass -eq 0 ]]; then
|
|
|
|
migrate_module $pathCore
|
|
|
|
migrate_module $pathBO
|
|
|
|
fi
|
|
|
|
|
2017-03-01 10:26:21 +01:00
|
|
|
if [[ -d node_modules && -d node_modules/ng_anr ]]; then
|
|
|
|
if [[ -d node_modules/ng_anr/.git ]]; then
|
2022-10-11 09:26:03 +02:00
|
|
|
checkout_to_latest_tag node_modules/ng_backoffice
|
|
|
|
checkout_to_latest_tag node_modules/ng_anr
|
2017-03-01 10:26:21 +01:00
|
|
|
else
|
|
|
|
npm update
|
|
|
|
fi
|
2016-08-25 15:42:05 +02:00
|
|
|
fi
|
|
|
|
|
2019-10-30 14:52:53 +01:00
|
|
|
cd node_modules/ng_backoffice
|
2022-10-11 09:26:03 +02:00
|
|
|
npm ci
|
2019-10-30 14:52:53 +01:00
|
|
|
cd ../..
|
2016-08-25 15:42:05 +02:00
|
|
|
|
2016-04-27 16:59:05 +02:00
|
|
|
./scripts/link_modules_resources.sh
|
2016-06-28 10:02:53 +02:00
|
|
|
./scripts/compile_translations.sh
|
2016-11-07 14:16:58 +01:00
|
|
|
|
2019-10-30 14:52:53 +01:00
|
|
|
|
2017-03-17 11:38:37 +01:00
|
|
|
if [[ $forceClearCache -eq 1 ]]; then
|
|
|
|
# Clear doctrine cache
|
2019-10-30 14:52:53 +01:00
|
|
|
# Move to Monarc/Core Module.php
|
2019-11-13 11:26:58 +01:00
|
|
|
php ./public/index.php orm:clear-cache:metadata
|
|
|
|
php ./public/index.php orm:clear-cache:query
|
|
|
|
php ./public/index.php orm:clear-cache:result
|
2017-03-17 11:38:37 +01:00
|
|
|
|
2019-10-30 14:52:53 +01:00
|
|
|
# Clear cache
|
2017-08-25 09:42:36 +02:00
|
|
|
if [ -e ./data/cache/upgrade ]
|
|
|
|
then
|
|
|
|
touch ./data/cache/upgrade && chmod 777 ./data/cache/upgrade
|
|
|
|
fi
|
2017-03-17 11:38:37 +01:00
|
|
|
fi
|
2016-11-07 14:16:58 +01:00
|
|
|
|
2017-03-17 11:38:37 +01:00
|
|
|
if [[ $forceClearCache -eq 0 && $bypass -eq 0 ]]; then
|
2019-10-30 14:52:53 +01:00
|
|
|
# Clear cache
|
2017-08-25 09:42:36 +02:00
|
|
|
if [ -e ./data/cache/upgrade ]
|
|
|
|
then
|
|
|
|
touch ./data/cache/upgrade && chmod 777 ./data/cache/upgrade
|
|
|
|
fi
|
2017-03-17 11:38:37 +01:00
|
|
|
fi
|
2017-08-25 09:42:36 +02:00
|
|
|
|
|
|
|
exit 0
|