Skip to content

Commit 37c62dc

Browse files
committedSep 30, 2015
update stream as of homestead v2.1.7
1 parent dd2567d commit 37c62dc

28 files changed

+964
-489
lines changed
 

‎scripts/blackfire.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -26,4 +26,4 @@ echo "$client" > "/home/vagrant/.blackfire.ini"
2626
php5dismod xdebug
2727
service hhvm restart
2828
service php5-fpm restart
29-
service blackfire-agent restart
29+
service blackfire-agent restart

‎scripts/clear-nginx.sh

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
# Clear The Old Nginx Sites
2+
3+
rm -f /etc/nginx/sites-enabled/*
4+
rm -f /etc/nginx/sites-available/*

‎scripts/clear-variables.sh

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
# Clear The Old Environment Variables
2+
3+
sed -i '/# Set Homestead Environment Variable/,+1d' /home/vagrant/.profile
4+
sed -i '/env\[.*/,+1d' /etc/php5/fpm/php-fpm.conf

‎scripts/create-mysql.sh

+1-2
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,4 @@
22

33
DB=$1;
44

5-
mysql -uhomestead -psecret -e "DROP DATABASE IF EXISTS \`$DB\`";
6-
mysql -uhomestead -psecret -e "CREATE DATABASE \`$DB\` DEFAULT CHARACTER SET utf8 DEFAULT COLLATE utf8_unicode_ci";
5+
mysql -uhomestead -psecret -e "CREATE DATABASE IF NOT EXISTS \`$DB\` DEFAULT CHARACTER SET utf8 DEFAULT COLLATE utf8_unicode_ci";

‎scripts/create-postgres.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#!/usr/bin/env bash
22

33
DB=$1;
4-
su postgres -c "dropdb $DB --if-exists"
4+
# su postgres -c "dropdb $DB --if-exists"
55
su postgres -c "createdb -O homestead '$DB' || true"

‎scripts/homestead.rb

+86-31
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,19 @@ def Homestead.configure(config, settings, hostsupdater)
1010
config.ssh.shell = "bash -c 'BASH_ENV=/etc/profile exec bash'"
1111

1212
# Configure The Box
13-
config.vm.box = "laravel/homestead"
14-
config.vm.hostname = "homestead"
13+
config.vm.box = settings["box"] ||= "laravel/homestead"
14+
config.vm.hostname = settings["hostname"] ||= "homestead"
1515

1616
# Configure A Private Network IP
1717
config.vm.network :private_network, ip: settings["ip"] ||= "192.168.10.10"
1818

19+
# Configure Additional Networks
20+
if settings.has_key?("networks")
21+
settings["networks"].each do |network|
22+
config.vm.network network["type"], ip: network["ip"], bridge: network["bridge"] ||= nil
23+
end
24+
end
25+
1926
# Configure A Few VirtualBox Settings
2027
config.vm.provider "virtualbox" do |vb|
2128
vb.name = 'homestead-oracle'
@@ -29,13 +36,21 @@ def Homestead.configure(config, settings, hostsupdater)
2936
# Configure A Few VMware Settings
3037
["vmware_fusion", "vmware_workstation"].each do |vmware|
3138
config.vm.provider vmware do |v|
32-
v.vmx["displayName"] = "homestead"
39+
v.vmx["displayName"] = "homestead-oracle"
3340
v.vmx["memsize"] = settings["memory"] ||= 2048
3441
v.vmx["numvcpus"] = settings["cpus"] ||= 1
3542
v.vmx["guestOS"] = "ubuntu-64"
3643
end
3744
end
3845

46+
# Configure A Few Parallels Settings
47+
config.vm.provider "parallels" do |v|
48+
v.update_guest_tools = true
49+
v.optimize_power_consumption = false
50+
v.memory = settings["memory"] ||= 2048
51+
v.cpus = settings["cpus"] ||= 1
52+
end
53+
3954
# enable/disable vbguest update
4055
config.vbguest.auto_update = false
4156

@@ -58,17 +73,37 @@ def Homestead.configure(config, settings, hostsupdater)
5873
s.path = "./scripts/install-oci8.sh"
5974
end
6075

61-
# Configure Port Forwarding To The Box
62-
config.vm.network "forwarded_port", guest: 80, host: 8000
63-
config.vm.network "forwarded_port", guest: 443, host: 44300
64-
config.vm.network "forwarded_port", guest: 3306, host: 33060
65-
config.vm.network "forwarded_port", guest: 5432, host: 54320
66-
config.vm.network "forwarded_port", guest: 1521, host: 1521
76+
# Standardize Ports Naming Schema
77+
if (settings.has_key?("ports"))
78+
settings["ports"].each do |port|
79+
port["guest"] ||= port["to"]
80+
port["host"] ||= port["send"]
81+
port["protocol"] ||= "tcp"
82+
end
83+
else
84+
settings["ports"] = []
85+
end
86+
87+
# Default Port Forwarding
88+
default_ports = {
89+
80 => 8000,
90+
443 => 44300,
91+
3306 => 33060,
92+
5432 => 54320,
93+
1521 => 1521
94+
}
95+
96+
# Use Default Port Forwarding Unless Overridden
97+
default_ports.each do |guest, host|
98+
unless settings["ports"].any? { |mapping| mapping["guest"] == guest }
99+
config.vm.network "forwarded_port", guest: guest, host: host, auto_correct: true
100+
end
101+
end
67102

68103
# Add Custom Ports From Configuration
69104
if settings.has_key?("ports")
70105
settings["ports"].each do |port|
71-
config.vm.network "forwarded_port", guest: port["guest"] || port["to"], host: port["host"] || port["send"], protocol: port["protocol"] ||= "tcp"
106+
config.vm.network "forwarded_port", guest: port["guest"], host: port["host"], protocol: port["protocol"], auto_correct: true
72107
end
73108
end
74109

@@ -94,39 +129,55 @@ def Homestead.configure(config, settings, hostsupdater)
94129
# Register All Of The Configured Shared Folders
95130
if settings.include? 'folders'
96131
settings["folders"].each do |folder|
97-
mount_opts = folder["type"] == "nfs" ? ['actimeo=1'] : []
132+
mount_opts = []
133+
134+
if (folder["type"] == "nfs")
135+
mount_opts = folder["mount_opts"] ? folder["mount_opts"] : ['actimeo=1']
136+
end
137+
98138
config.vm.synced_folder folder["map"], folder["to"], type: folder["type"] ||= nil, mount_options: mount_opts
99139
end
100140
end
101141

102142
# Install All The Configured Nginx Sites
143+
config.vm.provision "shell" do |s|
144+
s.path = scriptDir + "/clear-nginx.sh"
145+
end
146+
103147
settings["sites"].each do |site|
104-
config.vm.provision "shell" do |s|
105-
if (site.has_key?("hhvm") && site["hhvm"])
106-
s.path = scriptDir + "/serve-hhvm.sh"
107-
s.args = [site["map"], site["to"], site["port"] ||= "80", site["ssl"] ||= "443"]
108-
else
109-
s.path = scriptDir + "/serve.sh"
110-
s.args = [site["map"], site["to"], site["port"] ||= "80", site["ssl"] ||= "443"]
111-
end
148+
type = site["type"] ||= "laravel"
149+
150+
if (site.has_key?("hhvm") && site["hhvm"])
151+
type = "hhvm"
112152
end
113-
end
114153

115-
# Configure All Of The Configured Databases
116-
settings["databases"].each do |db|
117-
config.vm.provision "shell" do |s|
118-
s.path = scriptDir + "/create-mysql.sh"
119-
s.args = [db]
154+
if (type == "symfony")
155+
type = "symfony2"
120156
end
121157

122158
config.vm.provision "shell" do |s|
123-
s.path = scriptDir + "/create-postgres.sh"
124-
s.args = [db]
159+
s.path = scriptDir + "/serve-#{type}.sh"
160+
s.args = [site["map"], site["to"], site["port"] ||= "80", site["ssl"] ||= "443"]
125161
end
162+
end
126163

127-
config.vm.provision "shell" do |s|
128-
s.path = scriptDir + "/create-oracle.sh"
129-
s.args = [db]
164+
# Configure All Of The Configured Databases
165+
if settings.has_key?("databases")
166+
settings["databases"].each do |db|
167+
config.vm.provision "shell" do |s|
168+
s.path = scriptDir + "/create-mysql.sh"
169+
s.args = [db]
170+
end
171+
172+
config.vm.provision "shell" do |s|
173+
s.path = scriptDir + "/create-postgres.sh"
174+
s.args = [db]
175+
end
176+
177+
config.vm.provision "shell" do |s|
178+
s.path = scriptDir + "/create-oracle.sh"
179+
s.args = [db]
180+
end
130181
end
131182
end
132183

@@ -140,6 +191,10 @@ def Homestead.configure(config, settings, hostsupdater)
140191
end
141192

142193
# Configure All Of The Server Environment Variables
194+
config.vm.provision "shell" do |s|
195+
s.path = scriptDir + "/clear-variables.sh"
196+
end
197+
143198
if settings.has_key?("variables")
144199
settings["variables"].each do |var|
145200
config.vm.provision "shell" do |s|
@@ -148,7 +203,7 @@ def Homestead.configure(config, settings, hostsupdater)
148203
end
149204

150205
config.vm.provision "shell" do |s|
151-
s.inline = "echo \"\n#Set Homestead environment variable\nexport $1=$2\" >> /home/vagrant/.profile"
206+
s.inline = "echo \"\n# Set Homestead Environment Variable\nexport $1=$2\" >> /home/vagrant/.profile"
152207
s.args = [var["key"], var["value"]]
153208
end
154209
end

‎scripts/serve-hhvm.sh

+1-34
Original file line numberDiff line numberDiff line change
@@ -7,39 +7,7 @@ openssl x509 -req -days 365 -in /etc/nginx/ssl/$1.csr -signkey /etc/nginx/ssl/$1
77

88
block="server {
99
listen ${3:-80};
10-
server_name $1;
11-
root \"$2\";
12-
13-
index index.html index.htm index.php;
14-
15-
charset utf-8;
16-
17-
location / {
18-
try_files \$uri \$uri/ /index.php?\$query_string;
19-
}
20-
21-
location = /favicon.ico { access_log off; log_not_found off; }
22-
location = /robots.txt { access_log off; log_not_found off; }
23-
24-
access_log off;
25-
error_log /var/log/nginx/$1-error.log error;
26-
27-
sendfile off;
28-
29-
location ~ \.php$ {
30-
fastcgi_split_path_info ^(.+\.php)(/.+)$;
31-
fastcgi_pass 127.0.0.1:9000;
32-
fastcgi_index index.php;
33-
fastcgi_param SCRIPT_FILENAME \$document_root\$fastcgi_script_name;
34-
include fastcgi_params;
35-
}
36-
37-
location ~ /\.ht {
38-
deny all;
39-
}
40-
}
41-
server {
42-
listen ${4:-443};
10+
listen ${4:-443} ssl;
4311
server_name $1;
4412
root \"$2\";
4513
@@ -71,7 +39,6 @@ server {
7139
deny all;
7240
}
7341
74-
ssl on;
7542
ssl_certificate /etc/nginx/ssl/$1.crt;
7643
ssl_certificate_key /etc/nginx/ssl/$1.key;
7744
}

‎scripts/serve-laravel.sh

+58
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
#!/usr/bin/env bash
2+
3+
mkdir /etc/nginx/ssl 2>/dev/null
4+
openssl genrsa -out "/etc/nginx/ssl/$1.key" 1024 2>/dev/null
5+
openssl req -new -key /etc/nginx/ssl/$1.key -out /etc/nginx/ssl/$1.csr -subj "/CN=$1/O=Vagrant/C=UK" 2>/dev/null
6+
openssl x509 -req -days 365 -in /etc/nginx/ssl/$1.csr -signkey /etc/nginx/ssl/$1.key -out /etc/nginx/ssl/$1.crt 2>/dev/null
7+
8+
block="server {
9+
listen ${3:-80};
10+
listen ${4:-443} ssl;
11+
server_name $1;
12+
root \"$2\";
13+
14+
index index.html index.htm index.php;
15+
16+
charset utf-8;
17+
18+
location / {
19+
try_files \$uri \$uri/ /index.php?\$query_string;
20+
}
21+
22+
location = /favicon.ico { access_log off; log_not_found off; }
23+
location = /robots.txt { access_log off; log_not_found off; }
24+
25+
access_log off;
26+
error_log /var/log/nginx/$1-error.log error;
27+
28+
sendfile off;
29+
30+
client_max_body_size 100m;
31+
32+
location ~ \.php$ {
33+
fastcgi_split_path_info ^(.+\.php)(/.+)$;
34+
fastcgi_pass unix:/var/run/php5-fpm.sock;
35+
fastcgi_index index.php;
36+
include fastcgi_params;
37+
fastcgi_param SCRIPT_FILENAME \$document_root\$fastcgi_script_name;
38+
fastcgi_intercept_errors off;
39+
fastcgi_buffer_size 16k;
40+
fastcgi_buffers 4 16k;
41+
fastcgi_connect_timeout 300;
42+
fastcgi_send_timeout 300;
43+
fastcgi_read_timeout 300;
44+
}
45+
46+
location ~ /\.ht {
47+
deny all;
48+
}
49+
50+
ssl_certificate /etc/nginx/ssl/$1.crt;
51+
ssl_certificate_key /etc/nginx/ssl/$1.key;
52+
}
53+
"
54+
55+
echo "$block" > "/etc/nginx/sites-available/$1"
56+
ln -fs "/etc/nginx/sites-available/$1" "/etc/nginx/sites-enabled/$1"
57+
service nginx restart
58+
service php5-fpm restart

‎scripts/serve-symfony2.sh

+70
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
#!/usr/bin/env bash
2+
3+
mkdir /etc/nginx/ssl 2>/dev/null
4+
openssl genrsa -out "/etc/nginx/ssl/$1.key" 1024 2>/dev/null
5+
openssl req -new -key /etc/nginx/ssl/$1.key -out /etc/nginx/ssl/$1.csr -subj "/CN=$1/O=Vagrant/C=UK" 2>/dev/null
6+
openssl x509 -req -days 365 -in /etc/nginx/ssl/$1.csr -signkey /etc/nginx/ssl/$1.key -out /etc/nginx/ssl/$1.crt 2>/dev/null
7+
8+
block="server {
9+
listen ${3:-80};
10+
listen ${4:-443} ssl;
11+
server_name $1;
12+
root \"$2\";
13+
14+
index index.html index.htm index.php app.php;
15+
16+
charset utf-8;
17+
18+
location / {
19+
try_files \$uri \$uri/ /app.php?\$query_string;
20+
}
21+
22+
location = /favicon.ico { access_log off; log_not_found off; }
23+
location = /robots.txt { access_log off; log_not_found off; }
24+
25+
access_log off;
26+
error_log /var/log/nginx/$1-ssl-error.log error;
27+
28+
sendfile off;
29+
30+
client_max_body_size 100m;
31+
32+
# DEV
33+
location ~ ^/(app_dev|config)\.php(/|\$) {
34+
fastcgi_split_path_info ^(.+\.php)(/.+)\$;
35+
fastcgi_pass unix:/var/run/php5-fpm.sock;
36+
include fastcgi_params;
37+
fastcgi_param SCRIPT_FILENAME \$document_root\$fastcgi_script_name;
38+
fastcgi_intercept_errors off;
39+
fastcgi_buffer_size 16k;
40+
fastcgi_buffers 4 16k;
41+
}
42+
43+
# PROD
44+
location ~ ^/app\.php(/|$) {
45+
fastcgi_split_path_info ^(.+\.php)(/.+)$;
46+
fastcgi_pass unix:/var/run/php5-fpm.sock;
47+
include fastcgi_params;
48+
fastcgi_param SCRIPT_FILENAME \$document_root\$fastcgi_script_name;
49+
fastcgi_intercept_errors off;
50+
fastcgi_buffer_size 16k;
51+
fastcgi_buffers 4 16k;
52+
# Prevents URIs that include the front controller. This will 404:
53+
# http://domain.tld/app.php/some-path
54+
# Remove the internal directive to allow URIs like this
55+
internal;
56+
}
57+
58+
location ~ /\.ht {
59+
deny all;
60+
}
61+
62+
ssl_certificate /etc/nginx/ssl/$1.crt;
63+
ssl_certificate_key /etc/nginx/ssl/$1.key;
64+
}
65+
"
66+
67+
echo "$block" > "/etc/nginx/sites-available/$1"
68+
ln -fs "/etc/nginx/sites-available/$1" "/etc/nginx/sites-enabled/$1"
69+
service nginx restart
70+
service php5-fpm restart

‎scripts/wilcard.sh

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
sudo openssl req -new -x509 -keyout cert.pem -out cert.pem -days 365 -nodes -subj '/C=US/ST=New York/L=New York/O=End Point/OU=Hosting Team/CN=leadrm.app emailAddress=aqangeles@gmail.com/ subjectAltName=DNS.1=leadrm.app, DNS.2=*.leadrm.app'
2+
sudo openssl req -new -x509 -keyout cert.pem -out cert.pem -days 365 -nodes

0 commit comments

Comments
 (0)
Please sign in to comment.