-
Notifications
You must be signed in to change notification settings - Fork 7
/
provision.sh
74 lines (56 loc) · 3 KB
/
provision.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
#!/usr/bin/env bash
# only export does not seem to be enough for installing mysql
export DEBIAN_FRONTEND=noninteractive
sudo add-apt-repository ppa:ondrej/php
echo 'debconf debconf/frontend select Noninteractive' | debconf-set-selections
sudo apt-get update && sudo apt-get upgrade
# Force a blank root password for mysql
echo "mysql-server mysql-server/root_password password " | debconf-set-selections
echo "mysql-server mysql-server/root_password_again password " | debconf-set-selections
# Install mysql, nginx, php8.0-fpm
sudo apt-get install -q -y -f git mysql-server mysql-client nginx php8.0 php8.0-fpm php8.0-xdebug
# Install commonly used php packages
sudo apt-get install -q -y -f php8.0-curl php8.0-cli php8.0-mysqli php8.0-gd php8.0-dom php8.0-zip php8.0-mbstring php8.0-intl php8.0-redis
sudo apt-get upgrade libpcre3
sudo apt-get -y install curl dirmngr apt-transport-https lsb-release ca-certificates unzip
curl -fsSL https://deb.nodesource.com/setup_16.x | sudo -E bash -
sudo apt-get install -y nodejs
npm install --global yarn
sudo rm /etc/nginx/sites-available/default
sudo cp /var/www/etoa/vagrant/nginx-default /etc/nginx/sites-available/default
sudo cp /var/www/etoa/vagrant/xdebug.ini /etc/php/8.0/mods-available/xdebug.ini
cp /var/www/etoa/vagrant/db.conf /var/www/etoa/htdocs/config
cp /var/www/etoa/vagrant/roundx.conf /vagrant/htdocs/config/eventhandler.conf
sudo service nginx restart
sudo service php8.0-fpm restart
sudo chown -R www-data:www-data /var/lib/php/sessions
MYSQL=`which mysql`
PHP=`which php`
# Setup dummy client files
cd /var/www/etoa && mkdir htdocs/web/build && echo "{}" > htdocs/web/build/manifest.json && echo '{"entrypoints": {"admin": {}}}' > htdocs/web/build/entrypoints.json
# Install PHP composer dependencies
cd /var/www/etoa && export COMPOSER_ALLOW_SUPERUSER=1;php composer.phar install --no-interaction
# Install node dependencies and trigger build
cd /vagrant && yarn install --frozen-lockfile
cd /var/www/etoa && yarn run build
# Setup database
Q0="SET GLOBAL sql_mode=(SELECT REPLACE(@@sql_mode,'ONLY_FULL_GROUP_BY',''));"
Q1="CREATE DATABASE IF NOT EXISTS etoa;"
Q2="GRANT USAGE ON *.* TO etoa@localhost IDENTIFIED BY 'etoa';"
Q3="GRANT ALL PRIVILEGES ON etoa.* TO etoa@localhost;"
Q4="CREATE DATABASE IF NOT EXISTS etoa_test;"
Q5="GRANT USAGE ON *.* TO etoa_test@localhost IDENTIFIED BY 'etoa';"
Q6="GRANT ALL PRIVILEGES ON etoa_test.* TO etoa@localhost;"
Q7="FLUSH PRIVILEGES;"
SQL="${Q0}${Q1}${Q2}${Q3}${Q4}${Q5}${Q6}${Q7}"
$MYSQL -uroot -e "$SQL"
$PHP /var/www/etoa/bin/console database:migrate
$PHP /var/www/etoa/bin/console database:migrate --env=test
Q8="INSERT INTO config (config_name, config_value, config_param1, config_param2) VALUES ('loginurl','', '', '') ON DUPLICATE KEY UPDATE config_value='';"
$MYSQL -uroot -D etoa -e "$Q8"
# Setup cronjob
echo "* * * * * php /var/www/etoa/bin/console cron:run" | crontab
# Install deps for eventhandler
sudo apt-get install -q -y -f cmake libboost-all-dev libmysql++-dev g++
# Build eventhandler
cd /var/www/etoa && make eventhandler