2017-12-05 00:06:25 +01:00
|
|
|
#!/usr/bin/env bash
|
|
|
|
|
|
|
|
#== Import script args ==
|
|
|
|
|
|
|
|
timezone=$(echo "$1")
|
2020-09-04 20:19:20 +01:00
|
|
|
readonly IP=$2
|
2017-12-05 00:06:25 +01:00
|
|
|
|
|
|
|
#== Bash helpers ==
|
|
|
|
|
|
|
|
function info {
|
|
|
|
echo " "
|
|
|
|
echo "--> $1"
|
|
|
|
echo " "
|
|
|
|
}
|
|
|
|
|
|
|
|
#== Provision script ==
|
|
|
|
|
|
|
|
info "Provision-script user: `whoami`"
|
|
|
|
|
|
|
|
export DEBIAN_FRONTEND=noninteractive
|
|
|
|
|
|
|
|
info "Configure timezone"
|
|
|
|
timedatectl set-timezone ${timezone} --no-ask-password
|
|
|
|
|
2020-09-04 20:19:20 +01:00
|
|
|
info "Add the VM IP to the list of allowed IPs"
|
|
|
|
awk -v ip=$IP -f /app/vagrant/provision/provision.awk /app/config/web.php
|
|
|
|
|
2017-12-05 00:06:25 +01:00
|
|
|
info "Prepare root password for MySQL"
|
2020-09-04 18:33:21 +01:00
|
|
|
debconf-set-selections <<< 'mariadb-server mysql-server/root_password password'
|
|
|
|
debconf-set-selections <<< 'mariadb-server mysql-server/root_password_again password'
|
2017-12-05 00:06:25 +01:00
|
|
|
echo "Done!"
|
|
|
|
|
|
|
|
info "Update OS software"
|
|
|
|
apt-get update
|
|
|
|
apt-get upgrade -y
|
|
|
|
|
|
|
|
info "Install additional software"
|
2020-09-06 13:54:51 +01:00
|
|
|
apt-get install -y php7.2-curl php7.2-cli php7.2-intl php7.2-mysqlnd php7.2-gd php7.2-fpm php7.2-mbstring php7.2-xml unzip nginx mariadb-server-10.1 php.xdebug
|
2017-12-05 00:06:25 +01:00
|
|
|
|
|
|
|
info "Configure MySQL"
|
2020-09-04 18:33:21 +01:00
|
|
|
sed -i 's/.*bind-address.*/bind-address = 0.0.0.0/' /etc/mysql/mariadb.conf.d/50-server.cnf
|
|
|
|
mysql <<< "CREATE USER 'root'@'%' IDENTIFIED BY ''"
|
|
|
|
mysql <<< "GRANT ALL PRIVILEGES ON *.* TO 'root'@'%'"
|
|
|
|
mysql <<< "DROP USER 'root'@'localhost'"
|
|
|
|
mysql <<< 'FLUSH PRIVILEGES'
|
2017-12-05 00:06:25 +01:00
|
|
|
echo "Done!"
|
|
|
|
|
|
|
|
info "Configure PHP-FPM"
|
2020-09-06 13:54:51 +01:00
|
|
|
sed -i 's/user = www-data/user = vagrant/g' /etc/php/7.2/fpm/pool.d/www.conf
|
|
|
|
sed -i 's/group = www-data/group = vagrant/g' /etc/php/7.2/fpm/pool.d/www.conf
|
|
|
|
sed -i 's/owner = www-data/owner = vagrant/g' /etc/php/7.2/fpm/pool.d/www.conf
|
|
|
|
cat << EOF > /etc/php/7.2/mods-available/xdebug.ini
|
2017-12-05 00:06:25 +01:00
|
|
|
zend_extension=xdebug.so
|
|
|
|
xdebug.remote_enable=1
|
|
|
|
xdebug.remote_connect_back=1
|
|
|
|
xdebug.remote_port=9000
|
|
|
|
xdebug.remote_autostart=1
|
|
|
|
EOF
|
|
|
|
echo "Done!"
|
|
|
|
|
|
|
|
info "Configure NGINX"
|
|
|
|
sed -i 's/user www-data/user vagrant/g' /etc/nginx/nginx.conf
|
|
|
|
echo "Done!"
|
|
|
|
|
|
|
|
info "Enabling site configuration"
|
|
|
|
ln -s /app/vagrant/nginx/app.conf /etc/nginx/sites-enabled/app.conf
|
|
|
|
echo "Done!"
|
|
|
|
|
2018-04-01 04:54:23 -05:00
|
|
|
info "Removing default site configuration"
|
|
|
|
rm /etc/nginx/sites-enabled/default
|
|
|
|
echo "Done!"
|
|
|
|
|
2021-10-02 12:21:51 +05:00
|
|
|
info "Initialize databases for MySQL"
|
2020-09-04 18:33:21 +01:00
|
|
|
mysql <<< 'CREATE DATABASE yii2basic'
|
|
|
|
mysql <<< 'CREATE DATABASE yii2basic_test'
|
2017-12-05 00:06:25 +01:00
|
|
|
echo "Done!"
|
|
|
|
|
|
|
|
info "Install composer"
|
2020-09-06 13:54:51 +01:00
|
|
|
curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer
|