Skip to content

Commit

Permalink
updated vagrant features for ports
Browse files Browse the repository at this point in the history
  • Loading branch information
edwardteach42 committed Oct 12, 2018
1 parent 5d327e0 commit ebe1432
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 1 deletion.
14 changes: 13 additions & 1 deletion Vagrantfile
@@ -1,5 +1,7 @@
# -*- mode: ruby -*-
# vi: set ft=ruby :
require 'securerandom'

# Globals
httpPort = 8181
mysqlPort = 8306
Expand All @@ -14,8 +16,17 @@ end
settings = JSON.parse(File.read('settings.json'))
env = settings['environment']

# Update enviromnemt db port
# Update environment db port
settings['db'][env]['port'] = mysqlPort

if settings['cron']['token'].empty?
settings['cron']['token'] = SecureRandom.uuid.split('-').join
end

if settings['deployment']['deploy_token'].empty?
settings['deployment']['deploy_token'] = SecureRandom.uuid.split('-').join
end

File.open("settings.json","w") do |f|
f.write(JSON.pretty_generate settings)
end
Expand Down Expand Up @@ -47,6 +58,7 @@ Vagrant.configure("2") do |config|
dbName,
dbUser,
dbPass,
mysqlPort,
]
# migrate push command
config.push.define "migrate", strategy: "local-exec" do |push|
Expand Down
5 changes: 5 additions & 0 deletions storage/vagrant/provision.sh
Expand Up @@ -4,6 +4,7 @@ ROOTPASS=$2
DBNAME=$3
DBUSER=$4
DBPASS=$5
DBPORT=$6
PMAUSER="phpmyadmin"
PMAPASS=$(perl -e 'print map{("a".."z","A".."Z",0..9)[int(rand(62))]}(1..32)');
DEBIANPASS=$(perl -e 'print map{("a".."z","A".."Z",0..9)[int(rand(62))]}(1..16)');
Expand Down Expand Up @@ -35,6 +36,7 @@ fi
if [ ! -f "/etc/mysql/mariadb.conf.d/dev.cnf" ]; then
printf "[mysqld]\nplugin-load-add = auth_socket.so" | sudo tee -a /etc/mysql/mariadb.conf.d/dev.cnf
sudo sed -i "s/^bind-address.*/bind-address = 0.0.0.0/" /etc/mysql/my.cnf
sudo sed -i "s/^port.*/port = ${DBPORT}/" /etc/mysql/my.cnf
sudo systemctl restart mariadb.service
fi

Expand Down Expand Up @@ -81,6 +83,9 @@ sudo sed -i "s|post_max_size = 8M|post_max_size = 200M|g" /etc/php/7.2/apache2/p

# update apache config
sudo sed -i "s|DocumentRoot /var/www/html|DocumentRoot /vagrant/public\n\tAlias /phpmyadmin /usr/share/phpmyadmin\n\t<Directory /vagrant/public>\n\t\tOptions Indexes FollowSymLinks Includes ExecCGI\n\t\tAllowOverride All\n\t\tRequire all granted\n\t</Directory>|g" /etc/apache2/sites-enabled/000-default.conf
sudo sed -i "s|:80|:${PORT}|g" /etc/apache2/sites-enabled/000-default.conf
sudo sed -i "s|Listen 80|Listen ${PORT}|g" /etc/apache2/ports.conf

sudo a2enmod rewrite
sudo service apache2 restart

Expand Down

0 comments on commit ebe1432

Please sign in to comment.