-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathprovision.sh
103 lines (84 loc) · 2.55 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
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
#!/usr/bin/env bash
# {{{ Ubuntu utilities
<%= render 'vagrant-shell-scripts/ubuntu.sh' %>
# }}}
# Use Google Public DNS for resolving domain names.
# The default is host-only DNS which may not be installed.
nameservers-local-purge
nameservers-append '8.8.8.8'
nameservers-append '8.8.4.4'
# Use a local Ubuntu mirror, results in faster downloads.
apt-mirror-pick 'us'
# Add MongoDB repo
apt-packages-repository 'deb http://downloads-distro.mongodb.org/repo/ubuntu-upstart dist 10gen' '7F0CEB10'
# Add NodeJS repo
apt-packages-ppa ppa:chris-lea/node.js
# Update packages cache.
apt-packages-update
# Upgrade packages
apt-packages-upgrade
# Install VM packages.
apt-packages-install \
git-core \
mercurial \
nodejs \
npm \
imagemagick \
curl \
memcached \
mongodb-10gen \
mysql-server \
nginx-full \
php5-fpm \
php5-cli \
php-apc \
php5-gd \
php5-imagick \
php5-curl \
php5-memcache \
php5-memcached \
php5-mcrypt \
php5-mysqlnd \
ack-grep
# Rename ack-grep to ack, this is preferential only
dpkg-divert --local --divert /usr/bin/ack --rename --add /usr/bin/ack-grep
# Disable default nginx vhost
nginx-sites-disable 'default'
mkdir -p /var/www
# Configure SSH for task automation
mkdir -p ~/.ssh
touch ~/.ssh/known_hosts
# Add git host to known hosts
ssh-keyscan -H <%[email protected]('^(?:(?:(?:git|https?)://)?(?:[\w\d-]+(?::[\w\d-]+)?@)?)?([^@:/]+)')[1]%> >> ~/.ssh/known_hosts
# {{{ Import repo bootstraps
<%
repos = []
bootstraps = Dir.glob('repo-bootstraps/*.sh')
bootstraps.each do |r|
repo = r[16..-4]
repos << repo
@vhostExtra = ''
%>
[ -d /vagrant/repos/<%=repo%> ] || (cd /vagrant/repos; git clone <%=@gitUri+repo+'.git'%>)
[ -L /var/www/<%=repo%> ] || ln -sf /vagrant/repos/<%=repo%> /var/www/<%=repo%>
<%= render r %>
PHP=true EXTRA='
server_name <%=repo%>.vagrant;
location / {
try_files $uri $uri/ /index.php?$args;
}
<%=@vhostExtra%>
' nginx-sites-create '<%=repo%>' '/var/www/<%=repo%>/public' 'vagrant'
nginx-sites-enable '<%=repo%>'
<%
end
%>
echo '127.0.0.1 <%=repos.join('.vagrant ')%>.vagrant' >> /etc/hosts
# }}}
# Allow unsecured remote access to MySQL.
mysql-remote-access-allow
# Restart all services
php5-fpm-restart
nginx-restart
mysql-restart
echo '!!! Provisioning is complete. If vagrant has not yet exited, please press CTRL-C twice. !!!'