diff --git a/.gitignore b/.gitignore index ee4cd0b..cdbb82d 100644 --- a/.gitignore +++ b/.gitignore @@ -13,6 +13,7 @@ public/js/ public/img/ public/views/ public/flags/ +scripts/public module/ node_modules/ bin/ @@ -20,6 +21,5 @@ data/* !data/cache/.gitkeep !data/DoctrineORMModule/Proxy/.gitkeep !data/LazyServices/Proxy/.gitkeep -scripts/public/ vagrant/.vagrant/ vagrant/*.log diff --git a/INSTALL/INSTALL.ubuntu1804.md b/INSTALL/INSTALL.ubuntu1804.md index ed7adcc..55bab5e 100644 --- a/INSTALL/INSTALL.ubuntu1804.md +++ b/INSTALL/INSTALL.ubuntu1804.md @@ -81,15 +81,15 @@ You must create modules with symbolic links to libraries. Create two symbolic links: - $ mkdir module - $ cd module/ - $ ln -s ./../vendor/monarc/core MonarcCore - $ ln -s ./../vendor/monarc/backoffice MonarcBO + $ cd module/Monarc + $ ln -s ./../../vendor/monarc/core Core + $ ln -s ./../../vendor/monarc/frontoffice FrontOffice + $ cd ../.. There are 2 parts: -* MonarcBO is only for back office; -* MonarcCore is common to the front office and to the back office. +* Monarc\BackOffice is only for back office; +* Monarc\Core is common to the front office and to the back office. ### Frontend @@ -172,7 +172,7 @@ Update MONARC: # Create initial user - $ php ./vendor/robmorgan/phinx/bin/phinx seed:run -c ./module/MonarcBO/migrations/phinx.php + $ php ./vendor/robmorgan/phinx/bin/phinx seed:run -c ./module/Monarc/BackOffice/migrations/phinx.php The username is *admin@admin.test* and the password is *admin*. diff --git a/composer.json b/composer.json index aa6c7eb..8dbef09 100644 --- a/composer.json +++ b/composer.json @@ -1,6 +1,6 @@ { - "name": "monarc/skeleton", - "description": "Skeleton for Monarc project", + "name": "monarc/monarc-backoffice", + "description": "Monarc back office application", "authors": [ {"name": "Cyril Rouyer", "email": "cyril@netlor.fr"}, {"name": "Guillaume Lesniak", "email": "guillaume@netlor.fr"}, @@ -12,27 +12,23 @@ {"name": "Cédric Bonhomme", "email": "cedric.bonhomme@cases.lu"} ], "require": { - "php": ">=5.5", - "zendframework/zendframework": "2.5.3", - "doctrine/doctrine-orm-module": "^0.10", - "robmorgan/phinx": "0.5.*", - "monarc/core": "dev-master", - "monarc/backoffice": "dev-master", - "phing/phing": "~2.0", - "ramsey/uuid": "^3.8", - "ramsey/uuid-doctrine": "^1.5" + "php": "^7.2", + "ext-json": "*", + "ext-pdo": "*", + "monarc/core": "dev-feature/upgrade-to-zf3", + "monarc/backoffice": "dev-feature/upgrade-to-zf3", + "zendframework/zend-mvc": "^3.1", + "zendframework/zend-di": "^3.1", + "zendframework/zend-permissions-rbac": "^3.0", + "zendframework/zend-log": "^2.11", + "zendframework/zend-i18n": "^2.9" + } + , + "require-dev": { + "roave/security-advisories": "dev-master", + "zendframework/zend-component-installer": "^2.1" }, "config": { "bin-dir": "bin/" - }, - "repositories": [ - { - "type": "vcs", - "url": "https://github.com/monarc-project/zm-core" - }, - { - "type": "vcs", - "url": "https://github.com/monarc-project/zm-backoffice" - } - ] + } } diff --git a/config/application.config.php b/config/application.config.php index 557b90f..54e8cba 100644 --- a/config/application.config.php +++ b/config/application.config.php @@ -6,35 +6,38 @@ * @see https://github.com/zendframework/ZFTool */ $env = getenv('APP_ENV') ?: 'production'; -$appconfdir = getenv('APP_CONF_DIR') ? getenv('APP_CONF_DIR') : ''; +$appConfDir = getenv('APP_CONF_DIR') ?: ''; -$confpaths = [ 'config/autoload/{,*.}{global,local}.php' ]; -$datapath = "data"; -if( ! empty($appconfdir) ){ - $confpaths[] = $appconfdir.'/local.php'; - $datapath = $appconfdir.'/data'; - if(!is_dir($datapath.'/cache')){ - mkdir($datapath.'/cache'); +$confPaths = ['config/autoload/{,*.}{global,local}.php']; +$dataPath = 'data'; +if (!empty($appConfDir)) { + $confPaths[] = $appConfDir . '/local.php'; + $dataPath = $appConfDir . '/data'; + if (!is_dir($dataPath . '/cache') + && !mkdir($concurrentDirectory = $dataPath . '/cache') && !is_dir($concurrentDirectory) + ) { + throw new RuntimeException(sprintf('Directory "%s" was not created', $concurrentDirectory)); } } + return array( 'modules' => array( 'DoctrineModule', 'DoctrineORMModule', - 'MonarcCore', - 'MonarcBO', + 'Monarc\Core', + 'Monarc\BackOffice', ), 'module_listener_options' => array( 'module_paths' => array( './module', './vendor' ), - 'config_glob_paths' => $confpaths, - 'config_cache_enabled' => ($env == 'production'), + 'config_glob_paths' => $confPaths, + 'config_cache_enabled' => $env === 'production', 'config_cache_key' => 'c8aaaaa11586f8b1bf5565cc6064e70a', // md5('config_cache_key_monarc') - 'module_map_cache_enabled' => ($env == 'production'), + 'module_map_cache_enabled' => $env === 'production', 'module_map_cache_key' => '664579376c4dcdcaa0bcdd0f7e7bf25b', // md5('module_map_cache_key_monarc'), - 'cache_dir' => $datapath.'/cache/', - 'check_dependencies' => ($env != 'production'), + 'cache_dir' => $dataPath . '/cache/', + 'check_dependencies' => $env !== 'production', ), ); diff --git a/config/autoload/global.php b/config/autoload/global.php index 90a92a2..904b2d3 100755 --- a/config/autoload/global.php +++ b/config/autoload/global.php @@ -11,7 +11,11 @@ * file. */ -$appconfdir = getenv('APP_CONF_DIR') ? getenv('APP_CONF_DIR') : ''; +use Doctrine\DBAL\Driver\PDOMySql\Driver; +use Monarc\Core\Service\DoctrineCacheServiceFactory; +use Monarc\Core\Service\DoctrineLoggerFactory; + +$appconfdir = getenv('APP_CONF_DIR') ?: ''; $datapath = "data"; if( ! empty($appconfdir) ){ @@ -22,14 +26,14 @@ return array( // DOCTRINE CONF 'service_manager' => array( 'factories' => array( - 'doctrine.cache.mycache' => 'MonarcCore\Service\DoctrineCacheServiceFactory', - 'doctrine.monarc_logger' => 'MonarcCore\Service\DoctrineLoggerFactory', + 'doctrine.cache.mycache' => DoctrineCacheServiceFactory::class, + 'doctrine.monarc_logger' => DoctrineLoggerFactory::class, ), ), 'doctrine' => array( 'connection' => array( 'orm_default' => array( - 'driverClass' => 'Doctrine\DBAL\Driver\PDOMySql\Driver', + 'driverClass' => Driver::class, 'params' => array( 'host' => '127.0.0.1', 'port' => 3306, @@ -45,7 +49,7 @@ return array( ), ), 'orm_cli' => array( - 'driverClass' => 'Doctrine\DBAL\Driver\PDOMySql\Driver', + 'driverClass' => Driver::class, 'params' => array( 'host' => '127.0.0.1', 'port' => 3306, diff --git a/config/autoload/global.php.dist b/config/autoload/global.php.dist index 39d5722..5d94c35 100755 --- a/config/autoload/global.php.dist +++ b/config/autoload/global.php.dist @@ -14,7 +14,7 @@ return array( // DOCTRINE CONF 'service_manager' => array( 'factories' => array( - 'doctrine.cache.mycache' => 'MonarcCore\Service\DoctrineCacheServiceFactory', + 'doctrine.cache.mycache' => 'Monarc\Core\Service\DoctrineCacheServiceFactory', ), ), 'doctrine' => array( diff --git a/package.json b/package.json index c43815c..f9480cd 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "MONARC", - "version": "2.8.3", - "description": "MONARC back office", + "version": "2.9.1", + "description": "Monarc back office", "private": true, "repository": { "type": "git", diff --git a/public/index.php b/public/index.php index 2068bec..7b5d849 100644 --- a/public/index.php +++ b/public/index.php @@ -1,24 +1,34 @@ run(); +if (! class_exists(Application::class)) { + throw new RuntimeException( + "Unable to load application.\n" + . "- Type `composer install` if you are developing locally.\n" + ); +} + +$appConfig = require 'config/application.config.php'; +if (file_exists('config/development.config.php')) { + $appConfig = Zend\Stdlib\ArrayUtils::merge($appConfig, include 'config/development.config.php'); +} + +Application::init($appConfig)->run(); diff --git a/scripts/checkout.sh b/scripts/checkout.sh deleted file mode 100755 index b3166e0..0000000 --- a/scripts/checkout.sh +++ /dev/null @@ -1,18 +0,0 @@ -#!/bin/bash - -checkout_if_exists() { - if [ -d $1 ]; then - pushd $1 >/dev/null - git checkout $2 - popd >/dev/null - fi -} - - -checkout_if_exists . $1 -checkout_if_exists module/MonarcCore $1 -checkout_if_exists module/MonarcBO $1 -checkout_if_exists module/MonarcFO $1 -checkout_if_exists node_modules/ng_backoffice $1 -checkout_if_exists node_modules/ng_client $1 -checkout_if_exists node_modules/ng_anr $1 diff --git a/scripts/client-upgrade-db.sh b/scripts/client-upgrade-db.sh index b99df90..0f4c75e 100755 --- a/scripts/client-upgrade-db.sh +++ b/scripts/client-upgrade-db.sh @@ -1,7 +1,7 @@ #!/bin/bash # Usage: ./scripts/client-upgrade-db.sh -# Example: ./scripts/client-upgrade-db.sh MonarcBO localhost root derp monarc_backoffice +# Example: ./scripts/client-upgrade-db.sh Monarc\BackOffice localhost root derp monarc_backoffice MODULE=$1 SQLHOST=$2 @@ -11,20 +11,14 @@ SQLBASE=$5 path="" case $MODULE in - "MonarcCore"|"core") + "Monarc/Core"|"core") path="module/MonarcCore" if [ ! -d $path ]; then path="vendor/monarc/core" fi ;; - "MonarcFO"|"frontoffice") - path="module/MonarcFO" - if [ ! -d $path ]; then - path="vendor/monarc/frontoffice" - fi - ;; - "MonarcBO"|"backoffice") - path="module/MonarcBO" + "Monarc/BackOffice"|"backoffice") + path="module/Monarc/BackOffice" if [ ! -d $path ]; then path="vendor/monarc/backoffice" fi diff --git a/scripts/compile_translations.sh b/scripts/compile_translations.sh index 3285afc..0070b66 100755 --- a/scripts/compile_translations.sh +++ b/scripts/compile_translations.sh @@ -1,27 +1,12 @@ #!/bin/bash -if [ -d node_modules/ng_backoffice ]; then - pushd node_modules/ng_backoffice - grunt compile_translations - grunt concat +pushd node_modules/ng_backoffice +grunt compile_translations +grunt concat - if [ -d po ]; then - for i in $(ls po/*\.po); do - l=$(basename $i .po) - msgfmt -o ./po/$l.mo -v ./po/$l.po - done; - fi -fi - -if [ -d node_modules/ng_client ]; then - pushd node_modules/ng_client - grunt compile_translations - grunt concat - - if [ -d po ]; then - for i in $(ls po/*\.po); do - l=$(basename $i .po) - msgfmt -o ./po/$l.mo -v ./po/$l.po - done; - fi +if [ -d po ]; then + for i in $(ls po/*\.po); do + l=$(basename $i .po) + msgfmt -o ./po/$l.mo -v ./po/$l.po + done; fi diff --git a/scripts/extract_translations.sh b/scripts/extract_translations.sh index b3949f3..eaaa076 100755 --- a/scripts/extract_translations.sh +++ b/scripts/extract_translations.sh @@ -1,22 +1,10 @@ #!/bin/bash -if [ -d node_modules/ng_backoffice ]; then - pushd node_modules/ng_backoffice +pushd node_modules/ng_backoffice - if [ -f node_modules/.bin/grunt ]; then - node_modules/.bin/grunt extract_translations - else - grunt extract_translations - fi +if [ -f node_modules/.bin/grunt ]; then + node_modules/.bin/grunt extract_translations +else + grunt extract_translations fi - -if [ -d node_modules/ng_client ]; then - pushd node_modules/ng_client - - if [ -f node_modules/.bin/grunt ]; then - node_modules/.bin/grunt extract_translations - else - grunt extract_translations - fi -fi diff --git a/scripts/link_modules_resources.sh b/scripts/link_modules_resources.sh index b3bcfc6..a2e44d0 100755 --- a/scripts/link_modules_resources.sh +++ b/scripts/link_modules_resources.sh @@ -37,68 +37,32 @@ else find -L public/img -type l -exec rm {} \; fi -# Link modules resources -if [ -d node_modules/ng_backoffice ]; then - cd public/views/ && find ../../node_modules/ng_backoffice/views -maxdepth 1 -name "*.html" -exec ln -s {} \; 2>/dev/null - cd dialogs/ && find ../../../node_modules/ng_backoffice/views/dialogs -maxdepth 1 -name "*.html" -exec ln -s {} \; 2>/dev/null - cd ../partials/ && find ../../../node_modules/ng_backoffice/views/partials -maxdepth 1 -name "*.html" -exec ln -s {} \; 2>/dev/null - cd ../../js/ && find ../../node_modules/ng_backoffice/src -maxdepth 1 -name "*" -exec ln -s {} \; 2>/dev/null - cd ../css/ && find ../../node_modules/ng_backoffice/css -name "*" -exec ln -s {} \; 2>/dev/null - cd ../img/ && find ../../node_modules/ng_backoffice/img -name "*" -exec ln -s {} \; 2>/dev/null - cd ../flags/ && find ../../node_modules/ng_backoffice/node_modules/ng-country-flags/dist/flags -mindepth 1 -type d -exec ln -s {} \; 2>/dev/null +# Link modules resources. TODO: Replace with Grunt tasks to minify the JS and CSS. +cd public/views/ && find ../../node_modules/ng_backoffice/views -maxdepth 1 -name "*.html" -exec ln -s {} \; 2>/dev/null +cd dialogs/ && find ../../../node_modules/ng_backoffice/views/dialogs -maxdepth 1 -name "*.html" -exec ln -s {} \; 2>/dev/null +cd ../partials/ && find ../../../node_modules/ng_backoffice/views/partials -maxdepth 1 -name "*.html" -exec ln -s {} \; 2>/dev/null +cd ../../js/ && find ../../node_modules/ng_backoffice/src -maxdepth 1 -name "*" -exec ln -s {} \; 2>/dev/null +cd ../css/ && find ../../node_modules/ng_backoffice/css -name "*" -exec ln -s {} \; 2>/dev/null +cd ../img/ && find ../../node_modules/ng_backoffice/img -name "*" -exec ln -s {} \; 2>/dev/null +cd ../flags/ && find ../../node_modules/ng_backoffice/node_modules/ng-country-flags/dist/flags -mindepth 1 -type d -exec ln -s {} \; 2>/dev/null - if [ -d ../../node_modules/ng_anr ]; then - cd ../js/ - mkdir -p anr - cd anr && find ../../../node_modules/ng_anr/src -type f -maxdepth 1 -name "*" -exec ln -s {} \; 2>/dev/null - cd .. +cd ../js/ +mkdir -p anr +cd anr && find ../../../node_modules/ng_anr/src -type f -maxdepth 1 -name "*" -exec ln -s {} \; 2>/dev/null +cd .. - cd ../views/ - mkdir -p anr - cd anr && find ../../../node_modules/ng_anr/views -type f -maxdepth 1 -name "*" -exec ln -s {} \; 2>/dev/null - cd .. +cd ../views/ +mkdir -p anr +cd anr && find ../../../node_modules/ng_anr/views -type f -maxdepth 1 -name "*" -exec ln -s {} \; 2>/dev/null +cd .. - cd ../css/ - mkdir -p anr - cd anr && find ../../../node_modules/ng_anr/css -type f -maxdepth 1 -name "*" -exec ln -s {} \; 2>/dev/null - cd .. - fi +cd ../css/ +mkdir -p anr +cd anr && find ../../../node_modules/ng_anr/css -type f -maxdepth 1 -name "*" -exec ln -s {} \; 2>/dev/null +cd .. - cd ../.. +cd ../.. - pushd node_modules/ng_backoffice - grunt concat - popd -fi - -if [ -d node_modules/ng_client ]; then - cd public/views/ && find ../../node_modules/ng_client/views -name "*.html" -exec ln -s {} \; 2>/dev/null - cd dialogs/ && find ../../../node_modules/ng_client/views/dialogs -maxdepth 1 -name "*.html" -exec ln -s {} \; 2>/dev/null - cd ../../js/ && find ../../node_modules/ng_client/src -name "*" -exec ln -s {} \; 2>/dev/null - cd ../css/ && find ../../node_modules/ng_client/css -name "*" -exec ln -s {} \; 2>/dev/null - cd ../img/ && find ../../node_modules/ng_client/img -name "*" -exec ln -s {} \; 2>/dev/null - cd ../flags/ && find ../../node_modules/ng_client/node_modules/ng-country-flags/dist/flags -mindepth 1 -type d -exec ln -s {} \; 2>/dev/null - - if [ -d ../../node_modules/ng_anr ]; then - cd ../js/ - mkdir -p anr - cd anr && find ../../../node_modules/ng_anr/src -type f -maxdepth 1 -name "*" -exec ln -s {} \; 2>/dev/null - cd .. - - cd ../views/ - mkdir -p anr - cd anr && find ../../../node_modules/ng_anr/views -type f -maxdepth 1 -name "*" -exec ln -s {} \; 2>/dev/null - cd .. - - cd ../css/ - mkdir -p anr - cd anr && find ../../../node_modules/ng_anr/css -type f -maxdepth 1 -name "*" -exec ln -s {} \; 2>/dev/null - cd .. - fi - - cd ../.. - - pushd node_modules/ng_client - grunt concat - popd -fi +pushd node_modules/ng_backoffice +grunt concat +popd diff --git a/scripts/post-install.sh b/scripts/post-install.sh deleted file mode 100755 index c2eca07..0000000 --- a/scripts/post-install.sh +++ /dev/null @@ -1,12 +0,0 @@ -#!/bin/bash - -npm install - -cd node_modules/ng_backoffice -npm install - -cd ../.. - -# Compile stuff needed for the minified frontend -./scripts/compile_translations.sh -./scripts/link_modules_resources.sh \ No newline at end of file diff --git a/scripts/seed-db.sh b/scripts/seed-db.sh index 1426877..bf73943 100755 --- a/scripts/seed-db.sh +++ b/scripts/seed-db.sh @@ -1,14 +1,6 @@ #!/bin/bash -if [ -d module/MonarcCore ]; then - php ./vendor/robmorgan/phinx/bin/phinx seed:run -c ./module/MonarcCore/migrations/phinx.php -fi +php ./vendor/robmorgan/phinx/bin/phinx seed:run -c ./module/Monarc/Core/migrations/phinx.php -if [ -d module/MonarcBO ]; then - php ./vendor/robmorgan/phinx/bin/phinx seed:run -c ./module/MonarcBO/migrations/phinx.php -fi - -if [ -d module/MonarcFO ]; then - php ./vendor/robmorgan/phinx/bin/phinx seed:run -c ./module/MonarcFO/migrations/phinx.php -fi +php ./vendor/robmorgan/phinx/bin/phinx seed:run -c ./module/Monarc/BackOffice/migrations/phinx.php diff --git a/scripts/update-all.sh b/scripts/update-all.sh index 9588113..c612309 100755 --- a/scripts/update-all.sh +++ b/scripts/update-all.sh @@ -88,23 +88,23 @@ else fi currentPath=`pwd` -pathCore="module/MonarcCore" +pathCore="module/Monarc/Core" if [ -d $pathCore ]; then pull_if_exists $pathCore else pathCore="vendor/monarc/core" fi -pathBO="module/MonarcBO" +pathBO="module/Monarc/BackOffice" if [ -d $pathBO ]; then pull_if_exists $pathBO else pathBO="vendor/monarc/backoffice" fi + if [[ -d node_modules && -d node_modules/ng_anr ]]; then if [[ -d node_modules/ng_anr/.git ]]; then pull_if_exists node_modules/ng_backoffice - pull_if_exists node_modules/ng_client pull_if_exists node_modules/ng_anr else npm update @@ -118,29 +118,22 @@ if [[ $bypass -eq 0 ]]; then migrate_module $phpcommand $pathBO fi -if [ -d node_modules/ng_backoffice ]; then - cd node_modules/ng_backoffice - npm install - cd ../.. -fi - -if [ -d node_modules/ng_client ]; then - cd node_modules/ng_client - npm install - cd ../.. -fi +cd node_modules/ng_backoffice +npm install +cd ../.. ./scripts/link_modules_resources.sh ./scripts/compile_translations.sh + if [[ $forceClearCache -eq 1 ]]; then # Clear doctrine cache - # Move to MonarcCore Module.php + # Move to Monarc/Core Module.php $phpcommand ./public/index.php orm:clear-cache:metadata $phpcommand ./public/index.php orm:clear-cache:query $phpcommand ./public/index.php orm:clear-cache:result - # Clear ZF2 cache + # Clear cache if [ -e ./data/cache/upgrade ] then touch ./data/cache/upgrade && chmod 777 ./data/cache/upgrade @@ -148,7 +141,7 @@ if [[ $forceClearCache -eq 1 ]]; then fi if [[ $forceClearCache -eq 0 && $bypass -eq 0 ]]; then - # Clear ZF2 cache + # Clear cache if [ -e ./data/cache/upgrade ] then touch ./data/cache/upgrade && chmod 777 ./data/cache/upgrade diff --git a/scripts/upgrade-db.sh b/scripts/upgrade-db.sh index 90edf87..bdaa613 100755 --- a/scripts/upgrade-db.sh +++ b/scripts/upgrade-db.sh @@ -1,11 +1,5 @@ #!/bin/bash -php ./vendor/robmorgan/phinx/bin/phinx migrate -c ./module/MonarcCore/migrations/phinx.php +php ./vendor/robmorgan/phinx/bin/phinx migrate -c ./module/Monarc/Core/migrations/phinx.php -if [ -d module/MonarcBO ]; then - php ./vendor/robmorgan/phinx/bin/phinx migrate -c ./module/MonarcBO/migrations/phinx.php -fi - -if [ -d module/MonarcFO ]; then - php ./vendor/robmorgan/phinx/bin/phinx migrate -c ./module/MonarcFO/migrations/phinx.php -fi +php ./vendor/robmorgan/phinx/bin/phinx migrate -c ./module/Monarc/BackOffice/migrations/phinx.php diff --git a/vagrant/README.rst b/vagrant/README.rst index 7b88b8f..7b41195 100644 --- a/vagrant/README.rst +++ b/vagrant/README.rst @@ -26,7 +26,6 @@ MONARC will be automatically deployed in an Ubuntu Artful Server. $ git clone https://github.com/monarc-project/MonarcAppBO $ cd MonarcAppBO/vagrant - $ export GITHUB_AUTH_TOKEN= $ vagrant up Once the VM will be configured by Vagrant, go to the address diff --git a/vagrant/Vagrantfile b/vagrant/Vagrantfile index 3585101..5177c21 100644 --- a/vagrant/Vagrantfile +++ b/vagrant/Vagrantfile @@ -11,7 +11,7 @@ Vagrant.configure(VAGRANTFILE_API_VERSION) do |config| # Every Vagrant virtual environment requires a box to build off of. config.vm.box = "ubuntu/bionic64" - config.vm.provision :shell, path: "bootstrap.sh", args: "#{ENV['GITHUB_AUTH_TOKEN']}" + config.vm.provision :shell, path: "bootstrap.sh" # Disable automatic box update checking. If you disable this, then # boxes will only be checked for updates when the user runs @@ -22,6 +22,7 @@ Vagrant.configure(VAGRANTFILE_API_VERSION) do |config| # within the machine from a port on the host machine. In the example below, # accessing "localhost:8080" will access port 80 on the guest machine. config.vm.network "forwarded_port", guest: 80, host: 5000 + config.vm.network :forwarded_port, guest: 3306, host: 3307 # Create a private network, which allows host-only access to the machine # using a specific IP. diff --git a/vagrant/bootstrap.sh b/vagrant/bootstrap.sh index 7bc67bc..b210ec8 100644 --- a/vagrant/bootstrap.sh +++ b/vagrant/bootstrap.sh @@ -1,25 +1,17 @@ #! /usr/bin/env bash -# Variables -GITHUB_AUTH_TOKEN=$1 - -BRANCH='master' -#BRANCH='v0.1' -#TAG='v0.1' -TAG='' - PATH_TO_MONARC='/home/ubuntu/monarc' APPENV='local' -ENVIRONMENT='PRODUCTION' +ENVIRONMENT='development' DBHOST='localhost' DBNAME_COMMON='monarc_common' DBNAME_MASTER='monarc_master' DBUSER_ADMIN='root' -DBPASSWORD_ADMIN="$(openssl rand -hex 32)" +DBPASSWORD_ADMIN='root' DBUSER_MONARC='sqlmonarcuser' -DBPASSWORD_MONARC="$(openssl rand -hex 32)" +DBPASSWORD_MONARC='sqlmonarcuser' upload_max_filesize=200M post_max_size=50M @@ -27,6 +19,8 @@ max_execution_time=100 max_input_time=223 memory_limit=512M PHP_INI=/etc/php/7.2/apache2/php.ini +X_DEBUG_CFG=/etc/php/7.2/apache2/conf.d/20-xdebug.ini +MARIA_DB_CFG=/etc/mysql/mariadb.conf.d/50-server.cnf export DEBIAN_FRONTEND=noninteractive export LANGUAGE=en_US.UTF-8 @@ -35,6 +29,7 @@ export LC_ALL=en_US.UTF-8 locale-gen en_US.UTF-8 dpkg-reconfigure locales + echo -e "\n--- Installing now… ---\n" echo -e "\n--- Updating packages list ---\n" @@ -43,9 +38,8 @@ apt-get update echo -e "\n--- Install base packages… ---\n" apt-get -y install vim zip unzip git gettext > /dev/null + echo -e "\n--- Install MariaDB specific packages and settings… ---\n" -# echo "mysql-server mysql-server/root_password password $DBPASSWORD_ADMIN" | debconf-set-selections -# echo "mysql-server mysql-server/root_password_again password $DBPASSWORD_ADMIN" | debconf-set-selections apt-get -y install mariadb-server mariadb-client > /dev/null # Secure the MariaDB installation (especially by setting a strong root password) systemctl restart mariadb.service > /dev/null @@ -75,15 +69,32 @@ expect -f - <<-EOF EOF sudo apt-get purge -y expect > /dev/null 2>&1 -echo -e "\n--- Installing PHP-specific packages… ---\n" -apt-get -y install php apache2 libapache2-mod-php php-curl php-gd php-mysql php-pear php-apcu php-xml php-mbstring php-intl php-imagick php-zip > /dev/null +echo -e "\n--- Configuring… ---\n" +sed -i "s/skip-external-locking/#skip-external-locking/g" $MARIA_DB_CFG +sed -i "s/.*bind-address.*/bind-address = 0.0.0.0/" $MARIA_DB_CFG -echo -e "\n--- Configuring PHP ---\n" +echo -e "\n--- Setting up our MariaDB user for MONARC… ---\n" +mysql -u root -p$DBPASSWORD_ADMIN -e "CREATE USER '$DBUSER_MONARC'@'%' IDENTIFIED BY '$DBPASSWORD_MONARC';" +mysql -u root -p$DBPASSWORD_ADMIN -e "GRANT ALL PRIVILEGES ON * . * TO '$DBUSER_MONARC'@'%';" +mysql -u root -p$DBPASSWORD_ADMIN -e "FLUSH PRIVILEGES;" +systemctl restart mariadb.service > /dev/null + +echo -e "\n--- Installing PHP-specific packages… ---\n" +apt-get -y install php apache2 libapache2-mod-php php-curl php-gd php-mysql php-pear php-apcu php-xml php-mbstring php-intl php-imagick php-zip php-xdebug > /dev/null + +echo -e "\n--- Configuring PHP… ---\n" for key in upload_max_filesize post_max_size max_execution_time max_input_time memory_limit do sed -i "s/^\($key\).*/\1 = $(eval echo \${$key})/" $PHP_INI done +echo -e "\n--- Configuring Xdebug for development ---\n" +cat > $X_DEBUG_CFG < /dev/null a2enmod ssl > /dev/null @@ -91,14 +102,6 @@ a2enmod ssl > /dev/null echo -e "\n--- Allowing Apache override to all ---\n" sed -i "s/AllowOverride None/AllowOverride All/g" /etc/apache2/apache2.conf -#echo -e "\n--- We want to see the PHP errors, turning them on ---\n" -#sed -i "s/error_reporting = .*/error_reporting = E_ALL/" /etc/php/7.0/apache2/php.ini -#sed -i "s/display_errors = .*/display_errors = On/" /etc/php/7.0/apache2/php.ini - -echo -e "\n--- Setting up our MariaDB user for MONARC… ---\n" -mysql -u root -p$DBPASSWORD_ADMIN -e "CREATE USER '$DBUSER_MONARC'@'localhost' IDENTIFIED BY '$DBPASSWORD_MONARC';" -mysql -u root -p$DBPASSWORD_ADMIN -e "GRANT ALL PRIVILEGES ON * . * TO '$DBUSER_MONARC'@'localhost';" -mysql -u root -p$DBPASSWORD_ADMIN -e "FLUSH PRIVILEGES;" echo -e "\n--- Installing composer… ---\n" curl -sS https://getcomposer.org/installer | sudo php -- --install-dir=/usr/local/bin --filename=composer > /dev/null @@ -111,24 +114,19 @@ composer self-update echo -e "\n--- Installing MONARC… ---\n" cd $PATH_TO_MONARC git config core.fileMode false -if [ "$TAG" != '' ]; then - # Checkout the latest tag - #latestTag=$(git describe --tags `git rev-list --tags --max-count=1`) - git checkout $TAG -fi echo -e "\n--- Retrieving MONARC libraries… ---\n" -composer config -g github-oauth.github.com $GITHUB_AUTH_TOKEN composer install -o -# Modules -mkdir module -cd module -ln -s ./../vendor/monarc/core MonarcCore; -ln -s ./../vendor/monarc/backoffice MonarcBO; -cd .. -# Interfaces +# Make modules symlinks. +cd module/Monarc +ln -s ./../../vendor/monarc/core Core +ln -s ./../../vendor/monarc/backoffice BackOffice +cd $PATH_TO_MONARC + + +# Front-end mkdir node_modules cd node_modules git clone --config core.filemode=false https://github.com/monarc-project/ng-backoffice.git ng_backoffice > /dev/null @@ -154,13 +152,16 @@ cat > /etc/apache2/sites-enabled/000-default.conf < ServerName localhost DocumentRoot $PATH_TO_MONARC/public - SetEnv APPLICATION_ENV "development" + DirectoryIndex index.php AllowOverride All Require all granted + SetEnv APP_ENV $APPENV + SetEnv APP_DIR $PATH_TO_MONARC + SetEnv DB_HOST $DBHOST SetEnv DB_NAME $DBNAME SetEnv DB_USER $DBUSER @@ -171,7 +172,7 @@ echo -e "\n--- Restarting Apache… ---\n" systemctl restart apache2.service > /dev/null -echo -e "\n--- Configuration of MONARC data base connection ---\n" +echo -e "\n--- Configuration of MONARC database connection ---\n" cat > config/autoload/local.php < /dev/null -apt-get -y install npm > /dev/null +sudo apt-get -y install npm > /dev/null npm install -g grunt-cli > /dev/null @@ -248,4 +248,5 @@ echo -e "\n--- Restarting Apache… ---\n" systemctl restart apache2.service > /dev/null + echo -e "\n--- MONARC is ready! Point your Web browser to http://127.0.0.1:5000 ---\n"