vagrant-conductor 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +11 -0
- data/.rspec +2 -0
- data/.travis.yml +4 -0
- data/CODE_OF_CONDUCT.md +13 -0
- data/Gemfile +12 -0
- data/LICENSE.txt +21 -0
- data/README.md +41 -0
- data/Rakefile +6 -0
- data/Vagrantfile +10 -0
- data/bin/console +14 -0
- data/bin/setup +7 -0
- data/config.yml +20 -0
- data/lib/vagrant/conductor/configure.rb +97 -0
- data/lib/vagrant/conductor/modules/_base/_base.rb +38 -0
- data/lib/vagrant/conductor/modules/_base/config.yml +3 -0
- data/lib/vagrant/conductor/modules/_base/scripts/beanstalkd.sh +8 -0
- data/lib/vagrant/conductor/modules/_base/scripts/composer.sh +8 -0
- data/lib/vagrant/conductor/modules/_base/scripts/grub.sh +10 -0
- data/lib/vagrant/conductor/modules/_base/scripts/memcache.sh +4 -0
- data/lib/vagrant/conductor/modules/_base/scripts/mysql.sh +21 -0
- data/lib/vagrant/conductor/modules/_base/scripts/nginx.sh +45 -0
- data/lib/vagrant/conductor/modules/_base/scripts/nodejs.sh +14 -0
- data/lib/vagrant/conductor/modules/_base/scripts/php.sh +52 -0
- data/lib/vagrant/conductor/modules/_base/scripts/postgresql.sh +21 -0
- data/lib/vagrant/conductor/modules/_base/scripts/python-pip.sh +7 -0
- data/lib/vagrant/conductor/modules/_base/scripts/redis.sh +14 -0
- data/lib/vagrant/conductor/modules/_base/scripts/sqlite.sh +4 -0
- data/lib/vagrant/conductor/modules/_base/scripts/system.sh +48 -0
- data/lib/vagrant/conductor/modules/_base/scripts/xdebug.sh +22 -0
- data/lib/vagrant/conductor/modules/aws/aws.rb +38 -0
- data/lib/vagrant/conductor/modules/aws/config.yml +10 -0
- data/lib/vagrant/conductor/modules/aws/scripts/awscli.sh +16 -0
- data/lib/vagrant/conductor/modules/aws/scripts/awsconfig.sh +11 -0
- data/lib/vagrant/conductor/modules/aws/scripts/elasticbeanstalk.sh +8 -0
- data/lib/vagrant/conductor/modules/aws/templates/config.erb +5 -0
- data/lib/vagrant/conductor/modules/aws/templates/credentials.erb +5 -0
- data/lib/vagrant/conductor/modules/docker/config.yml +2 -0
- data/lib/vagrant/conductor/modules/docker/docker.rb +13 -0
- data/lib/vagrant/conductor/modules/docker/scripts/install.sh +3 -0
- data/lib/vagrant/conductor/modules/folders/config.yml +2 -0
- data/lib/vagrant/conductor/modules/folders/folders.rb +14 -0
- data/lib/vagrant/conductor/modules/git-config/config.yml +5 -0
- data/lib/vagrant/conductor/modules/git-config/git-config.rb +42 -0
- data/lib/vagrant/conductor/modules/known-hosts/config.yml +6 -0
- data/lib/vagrant/conductor/modules/known-hosts/known-hosts.rb +14 -0
- data/lib/vagrant/conductor/modules/known-hosts/scripts/add-domain.sh +8 -0
- data/lib/vagrant/conductor/modules/module.rb +31 -0
- data/lib/vagrant/conductor/modules/modules.rb +58 -0
- data/lib/vagrant/conductor/modules/oh-my-zsh/config.yml +6 -0
- data/lib/vagrant/conductor/modules/oh-my-zsh/oh-my-zsh.rb +27 -0
- data/lib/vagrant/conductor/modules/oh-my-zsh/scripts/install-oh-my-zsh.sh +19 -0
- data/lib/vagrant/conductor/modules/sites/config.yml +20 -0
- data/lib/vagrant/conductor/modules/sites/scripts/clone.sh +35 -0
- data/lib/vagrant/conductor/modules/sites/scripts/dotenv.sh +12 -0
- data/lib/vagrant/conductor/modules/sites/scripts/server.sh +8 -0
- data/lib/vagrant/conductor/modules/sites/sites.rb +193 -0
- data/lib/vagrant/conductor/modules/sites/templates/dotenv-array.erb +7 -0
- data/lib/vagrant/conductor/modules/sites/templates/server.erb +53 -0
- data/lib/vagrant/conductor/modules/ssh/config.yml +2 -0
- data/lib/vagrant/conductor/modules/ssh/ssh.rb +29 -0
- data/lib/vagrant/conductor/plugin.rb +14 -0
- data/lib/vagrant/conductor/provisioner.rb +48 -0
- data/lib/vagrant/conductor/util/hash.rb +19 -0
- data/lib/vagrant/conductor/version.rb +5 -0
- data/lib/vagrant/conductor.rb +48 -0
- data/vagrant-conductor.gemspec +33 -0
- metadata +152 -0
@@ -0,0 +1,16 @@
|
|
1
|
+
#!/usr/bin/env bash
|
2
|
+
|
3
|
+
home=$(sudo -u vagrant pwd)
|
4
|
+
upgrade='--upgrade'
|
5
|
+
|
6
|
+
if [ ! -d $home/.aws ]; then
|
7
|
+
mkdir $home/.aws;
|
8
|
+
fi
|
9
|
+
|
10
|
+
if [ ! -f $home/.aws/installed ]; then
|
11
|
+
upgrade=''
|
12
|
+
touch $home/.aws/installed
|
13
|
+
fi
|
14
|
+
|
15
|
+
# Run the install script
|
16
|
+
pip install $upgrade awscli awsebcli
|
@@ -0,0 +1,14 @@
|
|
1
|
+
class Folders < StationModule
|
2
|
+
|
3
|
+
def provision
|
4
|
+
# Register All Of The Configured Shared Folders
|
5
|
+
args.find?('folders', []).each do |folder|
|
6
|
+
if folder.find?('type', nil) === 'nfs'
|
7
|
+
config.vm.synced_folder folder["map"], folder["to"], create: folder["create"] ||= false, disabled: folder["disabled"] ||= false, mount_options: folder["mount_options"] ||= [], type: folder["type"] ||= nil
|
8
|
+
else
|
9
|
+
config.vm.synced_folder folder["map"], folder["to"], create: folder["create"] ||= false, disabled: folder["disabled"] ||= false, group: folder["group"] ||= 'vagrant', owner: folder["owner"] ||= 'vagrant', mount_options: folder["mount_options"] ||= [], type: folder["type"] ||= nil
|
10
|
+
end
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
end
|
@@ -0,0 +1,42 @@
|
|
1
|
+
# todo: add option for mapping local .git-config file
|
2
|
+
class GitConfig < StationModule
|
3
|
+
|
4
|
+
def set(key, value, global = false, path = '~/')
|
5
|
+
|
6
|
+
Station.module('commands').execute(
|
7
|
+
"git config #{global ? '--global' : ''} #{key} \"#{value}\"",
|
8
|
+
path
|
9
|
+
)
|
10
|
+
|
11
|
+
end
|
12
|
+
|
13
|
+
def fill(hash, global = false, path = '~/')
|
14
|
+
hash.each do |key, value|
|
15
|
+
set(key, value, global, path)
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
def provision
|
20
|
+
|
21
|
+
# Delete existing global .gitconfig file
|
22
|
+
shell_provision('
|
23
|
+
echo "Setting git config"
|
24
|
+
home=$(sudo -u vagrant pwd)
|
25
|
+
|
26
|
+
if [ -f $home/.gitconfig ]; then
|
27
|
+
rm -f $home/.gitconfig
|
28
|
+
fi
|
29
|
+
')
|
30
|
+
|
31
|
+
if args.is_a? String
|
32
|
+
shell_provision(
|
33
|
+
"echo \"$1\" > .gitconfig",
|
34
|
+
[File.read(File.expand_path(args))],
|
35
|
+
false
|
36
|
+
)
|
37
|
+
elsif args.is_a? Hash
|
38
|
+
fill(args, true)
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
end
|
@@ -0,0 +1,14 @@
|
|
1
|
+
class KnownHosts < StationModule
|
2
|
+
|
3
|
+
def add_domain(domain)
|
4
|
+
shell_provision("bash #{@scripts}/add-domain.sh #{domain}")
|
5
|
+
end
|
6
|
+
|
7
|
+
def provision
|
8
|
+
# Add known hosts
|
9
|
+
args.find?('domains', []).each do |domain|
|
10
|
+
add_domain(domain)
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
end
|
@@ -0,0 +1,31 @@
|
|
1
|
+
module VagrantPlugins
|
2
|
+
module Conductor
|
3
|
+
module Module
|
4
|
+
|
5
|
+
attr_accessor :config, :args, :scripts, :templates
|
6
|
+
|
7
|
+
def initialize(config, args, path, sync_path)
|
8
|
+
@config = config
|
9
|
+
@args = args
|
10
|
+
@scripts = sync_path + "/scripts"
|
11
|
+
@templates = path + "/templates"
|
12
|
+
end
|
13
|
+
|
14
|
+
# Create the template
|
15
|
+
def generate_template(vars, template_file)
|
16
|
+
require 'erb'
|
17
|
+
template = File.read(@templates + "/#{template_file}.erb")
|
18
|
+
ERB.new(template).result(binding)
|
19
|
+
end
|
20
|
+
|
21
|
+
def shell_provision(inline, args = nil, privileged = true)
|
22
|
+
@config.vm.provision "shell" do |s|
|
23
|
+
s.inline = inline
|
24
|
+
s.args = args
|
25
|
+
s.privileged = privileged
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
@@ -0,0 +1,58 @@
|
|
1
|
+
module VagrantPlugins
|
2
|
+
module Conductor
|
3
|
+
class Modules
|
4
|
+
|
5
|
+
attr_accessor :modules
|
6
|
+
attr_accessor :args
|
7
|
+
attr_accessor :config
|
8
|
+
attr_accessor :sync_path
|
9
|
+
|
10
|
+
def initialize(modules, args, config, sync_path)
|
11
|
+
@modules = modules
|
12
|
+
@args = args
|
13
|
+
@config = config
|
14
|
+
@sync_path = sync_path
|
15
|
+
end
|
16
|
+
|
17
|
+
def get_defaults(path)
|
18
|
+
YAML::load(File.read(path + '/config.yml'))
|
19
|
+
end
|
20
|
+
|
21
|
+
def get_classname(hash)
|
22
|
+
classname = hash.find?('classname', nil)
|
23
|
+
hash.delete('classname')
|
24
|
+
classname
|
25
|
+
end
|
26
|
+
|
27
|
+
def merge_defaults(name, args, defaults)
|
28
|
+
if args.kind_of?(Array)
|
29
|
+
defaults.deep_merge({name => args})
|
30
|
+
elsif args.kind_of?(Hash)
|
31
|
+
defaults.deep_merge(args)
|
32
|
+
elsif args.kind_of?(String)
|
33
|
+
args;
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
def init()
|
38
|
+
initialized = Hash.new
|
39
|
+
@modules.each do |path|
|
40
|
+
name = File.basename(path)
|
41
|
+
params = args.find?(name, nil)
|
42
|
+
|
43
|
+
# Skip if module not requested
|
44
|
+
next if params.nil?
|
45
|
+
|
46
|
+
require path + "/#{name}"
|
47
|
+
defaults = get_defaults(path)
|
48
|
+
classname = get_classname(defaults)
|
49
|
+
params = merge_defaults(name, params, defaults)
|
50
|
+
|
51
|
+
initialized[name] = Kernel.const_get(classname).new(@config, params, path, @sync_path + "/#{name}")
|
52
|
+
end
|
53
|
+
initialized
|
54
|
+
end
|
55
|
+
|
56
|
+
end
|
57
|
+
end
|
58
|
+
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
class OhMyZsh < StationModule
|
2
|
+
|
3
|
+
def install_zsh
|
4
|
+
shell_provision("sudo apt-get -y install zsh")
|
5
|
+
end
|
6
|
+
|
7
|
+
def install_oh_my_zsh
|
8
|
+
shell_provision("bash #{scripts}/install-oh-my-zsh.sh")
|
9
|
+
end
|
10
|
+
|
11
|
+
def provision
|
12
|
+
|
13
|
+
# Install Oh My Zsh
|
14
|
+
if args.find?('install.oh-my-zsh', false)
|
15
|
+
args['install']['zsh'] = false
|
16
|
+
install_zsh
|
17
|
+
install_oh_my_zsh
|
18
|
+
end
|
19
|
+
|
20
|
+
# Install zsh
|
21
|
+
if args.find?('install.zsh', false)
|
22
|
+
install_zsh
|
23
|
+
end
|
24
|
+
|
25
|
+
end
|
26
|
+
|
27
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
#!/usr/bin/env bash
|
2
|
+
|
3
|
+
# Add composer to path
|
4
|
+
composer_path='PATH=\$PATH:~/.composer/vendor/bin'
|
5
|
+
|
6
|
+
su vagrant <<EOF
|
7
|
+
|
8
|
+
# install git-flow and oh-my-zsh
|
9
|
+
if [ ! -d ~/.oh-my-zsh ]; then
|
10
|
+
sudo apt-get -y install git-flow
|
11
|
+
sudo apt-get -y install zsh
|
12
|
+
sudo apt-get install git-core
|
13
|
+
wget https://github.com/robbyrussell/oh-my-zsh/raw/master/tools/install.sh
|
14
|
+
zsh install.sh
|
15
|
+
echo 'vagrant' | chsh -s `which zsh`
|
16
|
+
echo -e "export $composer_path" >> $(sudo -u vagrant pwd)/.zshrc
|
17
|
+
fi
|
18
|
+
|
19
|
+
EOF
|
@@ -0,0 +1,20 @@
|
|
1
|
+
---
|
2
|
+
classname: Sites
|
3
|
+
|
4
|
+
defaults:
|
5
|
+
|
6
|
+
fastcgi-server:
|
7
|
+
split_path_info: '^(.+\.php)(/.+)$'
|
8
|
+
pass: "unix:/var/run/php5-fpm.sock"
|
9
|
+
index: index.php
|
10
|
+
buffers: "8 16k"
|
11
|
+
buffer_size: 32k
|
12
|
+
connect_timeout: 300s
|
13
|
+
send_timeout: 60
|
14
|
+
read_timeout: 60
|
15
|
+
|
16
|
+
fastcgi-hhvm:
|
17
|
+
split_path_info: '^(.+\.php)(/.+)$'
|
18
|
+
pass: '127.0.0.1:9000'
|
19
|
+
index: index.php
|
20
|
+
param: 'SCRIPT_FILENAME \$document_root$fastcgi_script_name'
|
@@ -0,0 +1,35 @@
|
|
1
|
+
#!/usr/bin/env bash
|
2
|
+
|
3
|
+
NAME=$1
|
4
|
+
URL=$2
|
5
|
+
SITEPATH=$3
|
6
|
+
|
7
|
+
su vagrant <<EOF
|
8
|
+
|
9
|
+
# Check if directory doesn't exist
|
10
|
+
if [ ! -d "$SITEPATH" ]; then
|
11
|
+
sudo mkdir -p "$SITEPATH"
|
12
|
+
fi
|
13
|
+
|
14
|
+
# Check if the folder is empty and clone
|
15
|
+
if [ "$(ls -A $SITEPATH)" ]; then
|
16
|
+
echo "$NAME has already been cloned. Please update manually"
|
17
|
+
else
|
18
|
+
echo "Cloning $NAME";
|
19
|
+
echo $URL;
|
20
|
+
echo $SITEPATH;
|
21
|
+
git clone $URL $SITEPATH;
|
22
|
+
#echo "Setting up git flow";
|
23
|
+
#cd $SITEPATH;
|
24
|
+
#git flow init -fd;
|
25
|
+
fi
|
26
|
+
|
27
|
+
# Install Composer Dependencies
|
28
|
+
# if [ -f "$SITEPATH/composer.json" ]; then
|
29
|
+
# if [ ! -f "$SITEPATH/composer.lock" ]; then
|
30
|
+
# cd $SITEPATH
|
31
|
+
# sudo composer install
|
32
|
+
# fi
|
33
|
+
# fi
|
34
|
+
|
35
|
+
EOF
|
@@ -0,0 +1,193 @@
|
|
1
|
+
class Sites < StationModule
|
2
|
+
|
3
|
+
attr_accessor :path, :installing, :variables
|
4
|
+
|
5
|
+
def initialize(config, args, module_path, station)
|
6
|
+
super
|
7
|
+
@path = "#{File.dirname(__FILE__)}"
|
8
|
+
@installing = ENV.has_key?('INSTALL')
|
9
|
+
@variables = {}
|
10
|
+
end
|
11
|
+
|
12
|
+
def sites_available(site)
|
13
|
+
|
14
|
+
# compile fastcgi params
|
15
|
+
hhvm_restart = ''
|
16
|
+
if site.find?('hhvm', false) && site['hhvm'] === true
|
17
|
+
hhvm_restart = 'service hhvm restart;'
|
18
|
+
fastcgi = args["defaults"]["fastcgi-hhvm"]
|
19
|
+
else
|
20
|
+
fastcgi = args["defaults"]["fastcgi-server"]
|
21
|
+
end
|
22
|
+
|
23
|
+
if site.has_key?("fastcgi") && !site["fastcgi"].empty?
|
24
|
+
fastcgi = fastcgi.deep_merge(site["fastcgi"])
|
25
|
+
end
|
26
|
+
|
27
|
+
# compile php value overrides
|
28
|
+
php_values = args["defaults"]["php-values"] ||= {}
|
29
|
+
if site.has_key?("php-values") && !site["php-values"].empty?
|
30
|
+
php_values = php_values.deep_merge(site["php-values"])
|
31
|
+
end
|
32
|
+
|
33
|
+
# add xdebug values
|
34
|
+
site.find?('xdebug', []).each do |key, value|
|
35
|
+
php_values["xdebug.#{key}"] = value
|
36
|
+
end
|
37
|
+
|
38
|
+
# add environment variables
|
39
|
+
|
40
|
+
variables = args["defaults"]["variables"] ||= {}
|
41
|
+
if site.has_key?("variables") && !site["variables"].empty?
|
42
|
+
variables = variables.deep_merge(site["variables"])
|
43
|
+
end
|
44
|
+
@variables = variables
|
45
|
+
|
46
|
+
if site.has_key?('dotenv') && site["dotenv"] === true
|
47
|
+
|
48
|
+
template = File.read(path + "/templates/dotenv-array.erb")
|
49
|
+
result = ERB.new(template, nil, '>').result(binding)
|
50
|
+
|
51
|
+
shell_provision(
|
52
|
+
"bash #{@scripts}/dotenv.sh $1 \"$2\"",
|
53
|
+
[site.find?('root', site["to"]) + '/.env.local.php', result]
|
54
|
+
)
|
55
|
+
|
56
|
+
end
|
57
|
+
|
58
|
+
# Create the server template
|
59
|
+
template = File.read(path + "/templates/server.erb")
|
60
|
+
result = ERB.new(template).result(binding)
|
61
|
+
|
62
|
+
# Add site to nginx
|
63
|
+
script = %{
|
64
|
+
echo "#{result}" > "/etc/nginx/sites-available/#{site["map"]}";
|
65
|
+
ln -fs "/etc/nginx/sites-available/#{site["map"]}" "/etc/nginx/sites-enabled/#{site["map"]}";
|
66
|
+
service nginx restart;
|
67
|
+
service php5-fpm restart;
|
68
|
+
#{hhvm_restart}
|
69
|
+
}
|
70
|
+
|
71
|
+
shell_provision(script)
|
72
|
+
|
73
|
+
end
|
74
|
+
|
75
|
+
def git_clone(name, url, path)
|
76
|
+
|
77
|
+
# Set installing var as true
|
78
|
+
@installing = true if Dir.exists?(path)
|
79
|
+
|
80
|
+
# Clone the site
|
81
|
+
shell_provision(
|
82
|
+
"bash #{scripts}/clone.sh $1 \"$2\" $3",
|
83
|
+
[name, url, path]
|
84
|
+
)
|
85
|
+
|
86
|
+
end
|
87
|
+
|
88
|
+
# @param [Object] vars
|
89
|
+
def env_vars(vars)
|
90
|
+
|
91
|
+
config.vm.provision 'shell' do |s|
|
92
|
+
s.inline = "if [ ! -f #{env_path} ]; then touch #{env_path} ; else echo '' > #{env_path} ; fi"
|
93
|
+
end
|
94
|
+
|
95
|
+
shell_provision(
|
96
|
+
"if [ ! -f #{env_path} ]; then touch #{env_path} ; else echo '' > #{env_path} ; fi"
|
97
|
+
)
|
98
|
+
|
99
|
+
unless vars.empty?
|
100
|
+
vars.each do |key, value|
|
101
|
+
shell_provision(
|
102
|
+
"echo \"$1 = '$2'\" >> #{env_path}",
|
103
|
+
[key, value]
|
104
|
+
)
|
105
|
+
end
|
106
|
+
end
|
107
|
+
end
|
108
|
+
|
109
|
+
def commands_exec(commands, path)
|
110
|
+
|
111
|
+
path = commands.find?('path', path)
|
112
|
+
|
113
|
+
if installing
|
114
|
+
# install commands
|
115
|
+
commands.find?('install', []).each do |cmd|
|
116
|
+
Station.module('commands').execute(cmd, path, @variables)
|
117
|
+
end
|
118
|
+
else
|
119
|
+
# update commands
|
120
|
+
commands.find?('update', []).each do |cmd|
|
121
|
+
Station.module('commands').execute(cmd, path, @variables)
|
122
|
+
end
|
123
|
+
end
|
124
|
+
|
125
|
+
# always commands
|
126
|
+
commands.find?('always', []).each do |cmd|
|
127
|
+
Station.module('commands').execute(cmd, path, @variables)
|
128
|
+
end
|
129
|
+
|
130
|
+
end
|
131
|
+
|
132
|
+
def create_db(db)
|
133
|
+
case db.find?('type', '')
|
134
|
+
when "mysql"
|
135
|
+
Station.module('mysql').create(db)
|
136
|
+
when "postgresql"
|
137
|
+
Station.module('postgresql').create(db)
|
138
|
+
else
|
139
|
+
Station.module('mysql').create(db)
|
140
|
+
Station.module('postgresql').create(db)
|
141
|
+
end
|
142
|
+
end
|
143
|
+
|
144
|
+
def add_site_queue(site)
|
145
|
+
|
146
|
+
Station.module('supervisor').create_config(
|
147
|
+
site["map"],
|
148
|
+
{
|
149
|
+
:command => "php #{site['root']}/artisan queue:work --daemon --env=local --sleep=5 --queue=#{site['queue']}",
|
150
|
+
:directory => site["root"],
|
151
|
+
:log_path => site["root"] + '/app/storage/logs'
|
152
|
+
}
|
153
|
+
)
|
154
|
+
|
155
|
+
end
|
156
|
+
|
157
|
+
def provision
|
158
|
+
|
159
|
+
args.find?('sites', []).each do |site|
|
160
|
+
|
161
|
+
base_path = site.find?('git-clone.path', site["to"])
|
162
|
+
|
163
|
+
# install configured nginx sites
|
164
|
+
sites_available(site)
|
165
|
+
|
166
|
+
# install/clone git repository
|
167
|
+
url = site.find?('git-clone.url')
|
168
|
+
if url
|
169
|
+
git_clone(site.find?('git-clone.name', ''), url, base_path)
|
170
|
+
end
|
171
|
+
|
172
|
+
# Add site db
|
173
|
+
db = site.find?('db')
|
174
|
+
if db
|
175
|
+
create_db(db)
|
176
|
+
end
|
177
|
+
|
178
|
+
# Run commands in installed site
|
179
|
+
commands_exec(site.find?('commands', {}), base_path)
|
180
|
+
|
181
|
+
# Add git config variables
|
182
|
+
Station.module('git-config').fill(site.find?('git-config', {},), false, base_path)
|
183
|
+
|
184
|
+
# Add ssl cert
|
185
|
+
Station.module('ssl').generate(site["map"], {})
|
186
|
+
|
187
|
+
# Add queues
|
188
|
+
add_site_queue(site)
|
189
|
+
|
190
|
+
end
|
191
|
+
|
192
|
+
end
|
193
|
+
end
|
@@ -0,0 +1,53 @@
|
|
1
|
+
server {
|
2
|
+
listen 80;
|
3
|
+
listen 443 ssl;
|
4
|
+
|
5
|
+
server_name <%= site["map"] %>;
|
6
|
+
root <%= site["to"] %>;
|
7
|
+
|
8
|
+
ssl_certificate /etc/ssl/<%= site["map"] %>.crt;
|
9
|
+
ssl_certificate_key /etc/ssl/<%= site["map"] %>.key;
|
10
|
+
|
11
|
+
index index.html index.htm index.php;
|
12
|
+
|
13
|
+
charset utf-8;
|
14
|
+
|
15
|
+
location / {
|
16
|
+
<% if site.find?("ssl", "") == 'force' %>
|
17
|
+
if ( \$scheme != 'https') { rewrite ^ https://\$host\$request_uri? permanent; }
|
18
|
+
<% elsif site.find?("ssl", false) != true %>
|
19
|
+
if ( \$scheme != 'http') { rewrite ^ http://\$host\$request_uri? permanent; }
|
20
|
+
<% end %>
|
21
|
+
try_files \$uri \$uri/ /index.php?\$query_string;
|
22
|
+
}
|
23
|
+
|
24
|
+
location = /favicon.ico { access_log off; log_not_found off; }
|
25
|
+
location = /robots.txt { access_log off; log_not_found off; }
|
26
|
+
|
27
|
+
access_log off;
|
28
|
+
error_log /var/log/nginx/<%= site["map"] %>-error.log error;
|
29
|
+
|
30
|
+
error_page 404 /index.php;
|
31
|
+
|
32
|
+
sendfile off;
|
33
|
+
|
34
|
+
location ~ \.php$ {
|
35
|
+
<% fastcgi.each do |key, value| %>
|
36
|
+
fastcgi_<%= key %> <%= value %>;
|
37
|
+
<% end %>
|
38
|
+
|
39
|
+
include fastcgi_params;
|
40
|
+
|
41
|
+
<% php_values.each do |key, value| %>
|
42
|
+
fastcgi_param PHP_VALUE \"<%= key %>=<%= value %>\";
|
43
|
+
<% end %>
|
44
|
+
|
45
|
+
<% variables.each do |key, value| %>
|
46
|
+
fastcgi_param <%= key %> <%= value %>;
|
47
|
+
<% end %>
|
48
|
+
}
|
49
|
+
|
50
|
+
location ~ /\.ht {
|
51
|
+
deny all;
|
52
|
+
}
|
53
|
+
}
|