2017-03-17 11:38:37 +01:00
|
|
|
#!/usr/bin/env bash
|
|
|
|
|
2019-11-13 10:55:30 +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
|
2020-07-08 09:42:49 +02:00
|
|
|
isDevEnv=0
|
|
|
|
while getopts "hbcd" option
|
2017-03-17 11:38:37 +01:00
|
|
|
do
|
2022-06-08 14:29:55 +02:00
|
|
|
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
|
|
|
|
;;
|
|
|
|
d)
|
|
|
|
isDevEnv=1
|
|
|
|
esac
|
2017-03-17 11:38:37 +01:00
|
|
|
done
|
2016-04-27 16:59:05 +02:00
|
|
|
|
2021-05-05 12:41:12 +02:00
|
|
|
checkout_to_latest_tag() {
|
2022-06-08 14:29:55 +02:00
|
|
|
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
|
|
|
}
|
|
|
|
|
2017-03-17 11:45:46 +01:00
|
|
|
migrate_module() {
|
2022-06-08 14:29:55 +02:00
|
|
|
if [[ -d $1 ]]; then
|
|
|
|
php ./vendor/robmorgan/phinx/bin/phinx migrate -c ./$1/migrations/phinx.php
|
|
|
|
fi
|
2017-03-17 11:45:46 +01:00
|
|
|
}
|
|
|
|
|
2017-03-17 14:20:18 +01:00
|
|
|
if [[ ! -f "config/autoload/local.php" && $bypass -eq 0 ]]; then
|
2022-06-08 14:29:55 +02:00
|
|
|
echo "Configure Monarc (config/autoload/local.php)"
|
|
|
|
exit 1
|
2017-03-10 14:57:56 +01:00
|
|
|
fi
|
|
|
|
|
2019-11-13 10:44:35 +01:00
|
|
|
git pull
|
2016-04-27 16:59:05 +02:00
|
|
|
|
2019-06-11 10:47:32 +02:00
|
|
|
if [ $? != 0 ]; then
|
2022-06-08 14:29:55 +02:00
|
|
|
echo "A problem occurred while retrieving remote files from repository."
|
|
|
|
exit 1
|
2019-06-11 10:47:32 +02:00
|
|
|
fi
|
|
|
|
|
2020-02-24 13:29:30 +01:00
|
|
|
./scripts/check_composer.sh
|
|
|
|
if [[ $? -eq 1 ]]; then
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
2020-07-08 09:42:49 +02:00
|
|
|
if [[ $isDevEnv -eq 0 ]]; then
|
2022-06-08 14:29:55 +02:00
|
|
|
composer ins -o --no-dev
|
2020-07-08 09:42:49 +02:00
|
|
|
else
|
2022-06-08 14:29:55 +02:00
|
|
|
composer ins
|
2020-07-08 09:42:49 +02:00
|
|
|
fi
|
2016-06-02 12:16:03 +02:00
|
|
|
|
2019-09-12 14:38:30 +02:00
|
|
|
pathCore="module/Monarc/Core"
|
|
|
|
pathFO="module/Monarc/FrontOffice"
|
2017-03-01 09:14:00 +01:00
|
|
|
|
2017-03-17 11:38:37 +01:00
|
|
|
if [[ $bypass -eq 0 ]]; then
|
2022-06-08 14:29:55 +02:00
|
|
|
if [ -e data/backup/credentialsmysql.cnf ]; then
|
|
|
|
backupdir=data/backup/$(date +"%Y%m%d_%H%M%S")
|
|
|
|
mkdir $backupdir
|
|
|
|
echo -e "${GREEN}Dumping database to $backupdir...${NC}"
|
|
|
|
mysqldump --defaults-file=data/backup/credentialsmysql.cnf --databases monarc_common > $backupdir/dump-common.sql
|
|
|
|
mysqldump --defaults-file=data/backup/credentialsmysql.cnf --databases monarc_cli > $backupdir/dump-cli.sql
|
|
|
|
else
|
|
|
|
echo -e "${GREEN}Database backup not configured. Skipping.${NC}"
|
|
|
|
fi
|
2022-10-05 10:31:56 +02:00
|
|
|
|
2022-06-08 14:29:55 +02:00
|
|
|
migrate_module $pathCore
|
|
|
|
migrate_module $pathFO
|
2016-08-25 15:42:05 +02:00
|
|
|
fi
|
2016-06-02 12:16:03 +02:00
|
|
|
|
2019-11-14 08:08:49 +01:00
|
|
|
if [[ -d node_modules && -d node_modules/ng_anr ]]; then
|
2022-06-08 14:29:55 +02:00
|
|
|
if [[ -d node_modules/ng_anr/.git ]]; then
|
|
|
|
checkout_to_latest_tag node_modules/ng_client
|
|
|
|
checkout_to_latest_tag node_modules/ng_anr
|
|
|
|
else
|
|
|
|
npm update
|
|
|
|
fi
|
2019-11-14 08:08:49 +01:00
|
|
|
fi
|
|
|
|
|
2019-10-30 10:53:05 +01:00
|
|
|
cd node_modules/ng_client
|
2021-05-10 14:00:40 +02:00
|
|
|
npm ci
|
2019-10-30 10:53:05 +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-12-16 15:47:38 +01:00
|
|
|
|
2017-03-17 11:38:37 +01:00
|
|
|
if [[ $forceClearCache -eq 1 ]]; then
|
2022-06-08 14:29:55 +02:00
|
|
|
# Clear Laminas cache
|
2022-10-12 11:50:21 +02:00
|
|
|
rm -rf data/cache/*
|
|
|
|
rm -rf data/DoctrineORMModule/Proxy/*
|
|
|
|
rm -rf data/LazyServices/Proxy/*
|
2022-06-08 14:29:55 +02:00
|
|
|
|
|
|
|
# Clear Laminas cache
|
|
|
|
touch ./data/cache/upgrade && chmod 777 ./data/cache/upgrade
|
2017-03-17 11:38:37 +01:00
|
|
|
fi
|
2016-12-16 16:31:24 +01:00
|
|
|
|
2017-03-17 11:38:37 +01:00
|
|
|
if [[ $forceClearCache -eq 0 && $bypass -eq 0 ]]; then
|
2022-06-08 14:29:55 +02:00
|
|
|
# Clear Laminas cache
|
|
|
|
touch ./data/cache/upgrade && chmod 777 ./data/cache/upgrade
|
2017-03-17 11:38:37 +01:00
|
|
|
fi
|
2019-11-13 10:55:30 +01:00
|
|
|
|
2021-03-24 11:48:13 +01:00
|
|
|
./scripts/update_config_variables.sh
|
|
|
|
|
2019-11-13 10:55:30 +01:00
|
|
|
exit 0
|