2017-08-25 08:25:11 +02:00
|
|
|
#! /usr/bin/env bash
|
|
|
|
|
2021-05-17 22:37:29 +02:00
|
|
|
RED='\033[0;31m'
|
|
|
|
GREEN='\033[0;32m'
|
|
|
|
NC='\033[0m' # No Color
|
|
|
|
|
|
|
|
PATH_TO_MONARC='/home/vagrant/monarc'
|
2017-08-25 08:25:11 +02:00
|
|
|
|
|
|
|
APPENV='local'
|
2019-10-30 14:52:53 +01:00
|
|
|
ENVIRONMENT='development'
|
2017-08-25 08:25:11 +02:00
|
|
|
|
|
|
|
DBHOST='localhost'
|
|
|
|
DBNAME_COMMON='monarc_common'
|
|
|
|
DBNAME_MASTER='monarc_master'
|
2018-01-26 08:30:08 +01:00
|
|
|
DBUSER_ADMIN='root'
|
2019-10-30 14:52:53 +01:00
|
|
|
DBPASSWORD_ADMIN='root'
|
2017-08-25 08:25:11 +02:00
|
|
|
DBUSER_MONARC='sqlmonarcuser'
|
2019-10-30 14:52:53 +01:00
|
|
|
DBPASSWORD_MONARC='sqlmonarcuser'
|
2017-08-25 08:25:11 +02:00
|
|
|
|
|
|
|
upload_max_filesize=200M
|
|
|
|
post_max_size=50M
|
|
|
|
max_execution_time=100
|
|
|
|
max_input_time=223
|
|
|
|
memory_limit=512M
|
2021-05-17 22:37:29 +02:00
|
|
|
|
2023-03-09 15:05:40 +01:00
|
|
|
PHP_INI=/etc/php/8.1/apache2/php.ini
|
|
|
|
XDEBUG_CFG=/etc/php/8.1/apache2/conf.d/20-xdebug.ini
|
2019-10-30 14:52:53 +01:00
|
|
|
MARIA_DB_CFG=/etc/mysql/mariadb.conf.d/50-server.cnf
|
2017-08-25 08:25:11 +02:00
|
|
|
|
2018-01-26 08:30:08 +01:00
|
|
|
export DEBIAN_FRONTEND=noninteractive
|
|
|
|
export LANGUAGE=en_US.UTF-8
|
|
|
|
export LANG=en_US.UTF-8
|
|
|
|
export LC_ALL=en_US.UTF-8
|
2021-05-10 18:23:56 +02:00
|
|
|
sudo -E locale-gen en_US.UTF-8
|
|
|
|
sudo -E dpkg-reconfigure locales
|
2017-08-25 08:25:11 +02:00
|
|
|
|
2019-10-30 14:52:53 +01:00
|
|
|
|
2018-01-26 08:30:08 +01:00
|
|
|
echo -e "\n--- Installing now… ---\n"
|
2017-08-25 08:25:11 +02:00
|
|
|
|
|
|
|
echo -e "\n--- Updating packages list ---\n"
|
2021-05-10 18:23:56 +02:00
|
|
|
sudo apt-get update && sudo apt-get upgrade -y
|
2017-08-25 08:25:11 +02:00
|
|
|
|
2018-01-26 08:30:08 +01:00
|
|
|
echo -e "\n--- Install base packages… ---\n"
|
2021-05-10 18:23:56 +02:00
|
|
|
sudo apt-get -y install vim zip unzip git gettext curl gsfonts > /dev/null
|
2017-08-25 08:25:11 +02:00
|
|
|
|
2019-10-30 14:52:53 +01:00
|
|
|
|
2018-01-26 09:58:22 +01:00
|
|
|
echo -e "\n--- Install MariaDB specific packages and settings… ---\n"
|
2021-05-10 18:23:56 +02:00
|
|
|
sudo apt-get -y install mariadb-server mariadb-client > /dev/null
|
2023-03-09 15:05:40 +01:00
|
|
|
|
2018-09-21 15:33:20 +02:00
|
|
|
# Secure the MariaDB installation (especially by setting a strong root password)
|
2021-05-10 18:23:56 +02:00
|
|
|
sudo systemctl restart mariadb.service > /dev/null
|
2018-01-26 08:30:08 +01:00
|
|
|
sleep 5
|
2021-05-10 18:23:56 +02:00
|
|
|
sudo apt-get -y install expect > /dev/null
|
2018-09-21 15:33:20 +02:00
|
|
|
expect -f - <<-EOF
|
|
|
|
set timeout 10
|
2021-05-21 11:47:05 +02:00
|
|
|
spawn sudo mysql_secure_installation
|
2018-09-21 15:33:20 +02:00
|
|
|
expect "Enter current password for root (enter for none):"
|
|
|
|
send -- "\r"
|
|
|
|
expect "Set root password?"
|
|
|
|
send -- "y\r"
|
|
|
|
expect "New password:"
|
|
|
|
send -- "${DBPASSWORD_ADMIN}\r"
|
|
|
|
expect "Re-enter new password:"
|
|
|
|
send -- "${DBPASSWORD_ADMIN}\r"
|
|
|
|
expect "Remove anonymous users?"
|
|
|
|
send -- "y\r"
|
|
|
|
expect "Disallow root login remotely?"
|
|
|
|
send -- "y\r"
|
|
|
|
expect "Remove test database and access to it?"
|
|
|
|
send -- "y\r"
|
|
|
|
expect "Reload privilege tables now?"
|
|
|
|
send -- "y\r"
|
|
|
|
expect eof
|
|
|
|
EOF
|
2023-03-09 15:05:40 +01:00
|
|
|
sudo apt-get purge -y expect > /dev/null 2>&1
|
|
|
|
|
2019-10-30 14:52:53 +01:00
|
|
|
echo -e "\n--- Configuring… ---\n"
|
2021-05-10 18:23:56 +02:00
|
|
|
sudo sed -i "s/skip-external-locking/#skip-external-locking/g" $MARIA_DB_CFG
|
|
|
|
sudo sed -i "s/.*bind-address.*/bind-address = 0.0.0.0/" $MARIA_DB_CFG
|
2023-03-09 15:05:40 +01:00
|
|
|
sudo sed -i "s/.*character-set-server.*/character-set-server = utf8mb4/" $MARIA_DB_CFG
|
|
|
|
sudo sed -i "s/.*collation-server.*/collation-server = utf8mb4_general_ci/" $MARIA_DB_CFG
|
2019-10-30 14:52:53 +01:00
|
|
|
|
|
|
|
echo -e "\n--- Setting up our MariaDB user for MONARC… ---\n"
|
2021-05-10 18:23:56 +02:00
|
|
|
sudo mysql -u root -p$DBPASSWORD_ADMIN -e "CREATE USER '$DBUSER_MONARC'@'%' IDENTIFIED BY '$DBPASSWORD_MONARC';"
|
|
|
|
sudo mysql -u root -p$DBPASSWORD_ADMIN -e "GRANT ALL PRIVILEGES ON * . * TO '$DBUSER_MONARC'@'%';"
|
|
|
|
sudo mysql -u root -p$DBPASSWORD_ADMIN -e "FLUSH PRIVILEGES;"
|
|
|
|
sudo systemctl restart mariadb.service > /dev/null
|
2019-10-30 14:52:53 +01:00
|
|
|
|
2023-03-09 15:05:40 +01:00
|
|
|
echo -e "\n--- Installing Apache… ---\n"
|
|
|
|
sudo apt install apache2 -y
|
|
|
|
|
2018-01-26 08:30:08 +01:00
|
|
|
echo -e "\n--- Installing PHP-specific packages… ---\n"
|
2023-03-09 15:05:40 +01:00
|
|
|
sudo apt-get install -y php8.1 php8.1-cli php8.1-common php8.1-mysql php8.1-zip php8.1-gd php8.1-mbstring php8.1-curl php8.1-xml php8.1-bcmath php8.1-intl php8.1-imagic php8.1-xdebug > /dev/null
|
2017-08-25 08:25:11 +02:00
|
|
|
|
2019-10-30 14:52:53 +01:00
|
|
|
echo -e "\n--- Configuring PHP… ---\n"
|
2017-08-25 08:25:11 +02:00
|
|
|
for key in upload_max_filesize post_max_size max_execution_time max_input_time memory_limit
|
|
|
|
do
|
2021-05-10 18:23:56 +02:00
|
|
|
sudo sed -i "s/^\($key\).*/\1 = $(eval echo \${$key})/" $PHP_INI
|
2017-08-25 08:25:11 +02:00
|
|
|
done
|
|
|
|
|
2019-10-30 14:52:53 +01:00
|
|
|
echo -e "\n--- Configuring Xdebug for development ---\n"
|
2023-03-09 15:05:40 +01:00
|
|
|
sudo bash -c "cat << EOF > $XDEBUG_CFG
|
2019-10-31 10:27:09 +01:00
|
|
|
zend_extension=xdebug.so
|
2023-03-09 15:05:40 +01:00
|
|
|
xdebug.mode=debug
|
|
|
|
xdebug.discover_client_host=1
|
2019-10-30 14:52:53 +01:00
|
|
|
xdebug.idekey=IDEKEY
|
2021-05-10 18:23:56 +02:00
|
|
|
EOF"
|
2019-10-30 14:52:53 +01:00
|
|
|
|
2018-01-26 08:30:08 +01:00
|
|
|
echo -e "\n--- Enabling mod-rewrite and ssl… ---\n"
|
2021-05-10 18:23:56 +02:00
|
|
|
sudo a2enmod rewrite > /dev/null 2>&1
|
|
|
|
sudo a2enmod ssl > /dev/null 2>&1
|
|
|
|
sudo a2enmod headers > /dev/null 2>&1
|
2017-08-25 08:25:11 +02:00
|
|
|
|
|
|
|
echo -e "\n--- Allowing Apache override to all ---\n"
|
2021-05-10 18:23:56 +02:00
|
|
|
sudo sed -i "s/AllowOverride None/AllowOverride All/g" /etc/apache2/apache2.conf
|
2017-08-25 08:25:11 +02:00
|
|
|
|
|
|
|
|
2018-01-26 08:30:08 +01:00
|
|
|
echo -e "\n--- Installing composer… ---\n"
|
2021-05-18 09:34:44 +02:00
|
|
|
curl -sS https://getcomposer.org/installer | sudo php -- --install-dir=/usr/local/bin --filename=composer > /dev/null 2>&1
|
2017-08-25 08:25:11 +02:00
|
|
|
if [ $? -ne 0 ]; then
|
|
|
|
echo "\nERROR: unable to install composer\n"
|
|
|
|
exit 1;
|
|
|
|
fi
|
|
|
|
composer self-update
|
|
|
|
|
2018-01-26 08:30:08 +01:00
|
|
|
echo -e "\n--- Installing MONARC… ---\n"
|
2017-08-25 08:25:11 +02:00
|
|
|
cd $PATH_TO_MONARC
|
|
|
|
git config core.fileMode false
|
|
|
|
|
2018-01-26 08:30:08 +01:00
|
|
|
echo -e "\n--- Retrieving MONARC libraries… ---\n"
|
2021-05-18 09:34:44 +02:00
|
|
|
composer ins
|
2017-08-25 08:25:11 +02:00
|
|
|
|
|
|
|
|
2019-10-30 14:52:53 +01:00
|
|
|
# Make modules symlinks.
|
2019-11-13 10:53:14 +01:00
|
|
|
mkdir -p module/Monarc
|
2019-10-30 14:52:53 +01:00
|
|
|
cd module/Monarc
|
|
|
|
ln -s ./../../vendor/monarc/core Core
|
|
|
|
ln -s ./../../vendor/monarc/backoffice BackOffice
|
|
|
|
cd $PATH_TO_MONARC
|
|
|
|
|
|
|
|
|
2019-11-21 08:51:19 +01:00
|
|
|
mkdir -p $PATH_TO_MONARC/data/cache
|
|
|
|
mkdir -p $PATH_TO_MONARC/data/LazyServices/Proxy
|
|
|
|
mkdir -p $PATH_TO_MONARC/data/DoctrineORMModule/Proxy
|
|
|
|
|
|
|
|
|
2019-10-30 14:52:53 +01:00
|
|
|
# Front-end
|
2023-03-09 15:05:40 +01:00
|
|
|
echo -e "\n--- Installation of Node, NPM… ---\n"
|
|
|
|
curl -sL https://deb.nodesource.com/setup_15.x | sudo bash -
|
|
|
|
sudo apt-get install -y nodejs npm
|
|
|
|
|
2021-05-10 18:23:56 +02:00
|
|
|
mkdir -p node_modules
|
2017-08-25 08:25:11 +02:00
|
|
|
cd node_modules
|
2021-05-10 18:23:56 +02:00
|
|
|
if [ ! -d "ng_backoffice" ]; then
|
|
|
|
git clone --config core.filemode=false https://github.com/monarc-project/ng-backoffice.git ng_backoffice > /dev/null
|
|
|
|
fi
|
2017-08-25 08:25:11 +02:00
|
|
|
if [ $? -ne 0 ]; then
|
|
|
|
echo "\nERROR: unable to clone the ng-backoffice repository\n"
|
|
|
|
exit 1;
|
|
|
|
fi
|
2021-05-10 18:23:56 +02:00
|
|
|
if [ ! -d "ng_anr" ]; then
|
|
|
|
git clone --config core.filemode=false https://github.com/monarc-project/ng-anr.git ng_anr > /dev/null
|
|
|
|
fi
|
2017-08-25 08:25:11 +02:00
|
|
|
if [ $? -ne 0 ]; then
|
|
|
|
echo "\nERROR: unable to clone the ng-anr repository\n"
|
|
|
|
exit 1;
|
|
|
|
fi
|
|
|
|
cd ..
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
echo -e "\n--- Add a VirtualHost for MONARC ---\n"
|
2021-05-21 11:47:05 +02:00
|
|
|
sudo bash -c "cat << EOF > /etc/apache2/sites-enabled/000-default.conf
|
2017-08-25 08:25:11 +02:00
|
|
|
<VirtualHost *:80>
|
|
|
|
ServerName localhost
|
|
|
|
DocumentRoot $PATH_TO_MONARC/public
|
2019-10-30 14:52:53 +01:00
|
|
|
|
2017-08-25 08:25:11 +02:00
|
|
|
<Directory $PATH_TO_MONARC/public>
|
|
|
|
DirectoryIndex index.php
|
|
|
|
AllowOverride All
|
|
|
|
Require all granted
|
|
|
|
</Directory>
|
2019-10-30 14:52:53 +01:00
|
|
|
|
2017-08-25 08:25:11 +02:00
|
|
|
SetEnv APP_ENV $APPENV
|
2019-10-30 14:52:53 +01:00
|
|
|
SetEnv APP_DIR $PATH_TO_MONARC
|
|
|
|
|
2017-08-25 08:25:11 +02:00
|
|
|
SetEnv DB_HOST $DBHOST
|
|
|
|
SetEnv DB_NAME $DBNAME
|
|
|
|
SetEnv DB_USER $DBUSER
|
|
|
|
SetEnv DB_PASS $DBPASSWD
|
|
|
|
</VirtualHost>
|
2021-05-21 11:47:05 +02:00
|
|
|
EOF"
|
2018-01-26 08:30:08 +01:00
|
|
|
echo -e "\n--- Restarting Apache… ---\n"
|
2021-05-10 18:23:56 +02:00
|
|
|
sudo systemctl restart apache2.service > /dev/null
|
2017-08-25 08:25:11 +02:00
|
|
|
|
|
|
|
|
2019-10-30 14:52:53 +01:00
|
|
|
echo -e "\n--- Configuration of MONARC database connection ---\n"
|
2017-08-25 08:25:11 +02:00
|
|
|
cat > config/autoload/local.php <<EOF
|
|
|
|
<?php
|
|
|
|
return array(
|
2021-05-10 18:23:56 +02:00
|
|
|
'doctrine' => [
|
|
|
|
'connection' => [
|
|
|
|
'orm_default' => [
|
|
|
|
'params' => [
|
2017-08-25 08:25:11 +02:00
|
|
|
'host' => '$DBHOST',
|
|
|
|
'user' => '$DBUSER_MONARC',
|
|
|
|
'password' => '$DBPASSWORD_MONARC',
|
|
|
|
'dbname' => '$DBNAME_COMMON',
|
2021-05-10 18:23:56 +02:00
|
|
|
],
|
|
|
|
],
|
|
|
|
'orm_cli' => [
|
|
|
|
'params' => [
|
2017-08-25 08:25:11 +02:00
|
|
|
'host' => '$DBHOST',
|
|
|
|
'user' => '$DBUSER_MONARC',
|
|
|
|
'password' => '$DBPASSWORD_MONARC',
|
|
|
|
'dbname' => '$DBNAME_MASTER',
|
2021-05-10 18:23:56 +02:00
|
|
|
],
|
|
|
|
],
|
|
|
|
],
|
|
|
|
],
|
|
|
|
|
|
|
|
'activeLanguages' => ['fr','en','de','nl'],
|
|
|
|
|
|
|
|
'monarc' => [
|
|
|
|
'ttl' => 60,
|
|
|
|
'salt' => '',
|
|
|
|
],
|
2017-08-25 08:25:11 +02:00
|
|
|
);
|
|
|
|
EOF
|
|
|
|
|
|
|
|
|
2018-01-26 08:30:08 +01:00
|
|
|
echo -e "\n--- Creation of the data bases… ---\n"
|
|
|
|
mysql -u $DBUSER_MONARC -p$DBPASSWORD_MONARC -e "CREATE DATABASE monarc_master DEFAULT CHARACTER SET utf8 DEFAULT COLLATE utf8_general_ci;" > /dev/null
|
|
|
|
mysql -u $DBUSER_MONARC -p$DBPASSWORD_MONARC -e "CREATE DATABASE monarc_common DEFAULT CHARACTER SET utf8 DEFAULT COLLATE utf8_general_ci;" > /dev/null
|
|
|
|
echo -e "\n--- Populating MONARC DB… ---\n"
|
|
|
|
mysql -u $DBUSER_MONARC -p$DBPASSWORD_MONARC monarc_common < db-bootstrap/monarc_structure.sql > /dev/null
|
|
|
|
mysql -u $DBUSER_MONARC -p$DBPASSWORD_MONARC monarc_common < db-bootstrap/monarc_data.sql > /dev/null
|
2017-08-25 08:25:11 +02:00
|
|
|
|
|
|
|
|
2021-05-17 22:37:29 +02:00
|
|
|
echo -e "\n--- Adjusting user mod… ---\n"
|
|
|
|
sudo usermod -aG www-data vagrant
|
|
|
|
sudo usermod -aG vagrant www-data
|
2017-08-25 08:25:11 +02:00
|
|
|
|
|
|
|
|
2018-01-26 08:30:08 +01:00
|
|
|
echo -e "\n--- Update the project… ---\n"
|
2021-05-17 22:37:29 +02:00
|
|
|
sudo npm install -g grunt-cli
|
2021-05-21 11:47:05 +02:00
|
|
|
sudo npm install -g node-gyp
|
|
|
|
./scripts/update-all.sh -d
|
2017-08-25 08:25:11 +02:00
|
|
|
|
|
|
|
|
|
|
|
echo -e "\n--- Create initial user and client ---\n"
|
2019-10-31 10:27:09 +01:00
|
|
|
php ./vendor/robmorgan/phinx/bin/phinx seed:run -c ./module/Monarc/BackOffice/migrations/phinx.php > /dev/null
|
2017-08-25 08:25:11 +02:00
|
|
|
|
|
|
|
|
2018-01-26 08:30:08 +01:00
|
|
|
echo -e "\n--- Restarting Apache… ---\n"
|
2021-05-10 18:23:56 +02:00
|
|
|
sudo systemctl restart apache2.service > /dev/null
|
2017-08-25 08:25:11 +02:00
|
|
|
|
|
|
|
|
|
|
|
echo -e "\n--- MONARC is ready! Point your Web browser to http://127.0.0.1:5000 ---\n"
|