vagrant-conductor 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (68) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +11 -0
  3. data/.rspec +2 -0
  4. data/.travis.yml +4 -0
  5. data/CODE_OF_CONDUCT.md +13 -0
  6. data/Gemfile +12 -0
  7. data/LICENSE.txt +21 -0
  8. data/README.md +41 -0
  9. data/Rakefile +6 -0
  10. data/Vagrantfile +10 -0
  11. data/bin/console +14 -0
  12. data/bin/setup +7 -0
  13. data/config.yml +20 -0
  14. data/lib/vagrant/conductor/configure.rb +97 -0
  15. data/lib/vagrant/conductor/modules/_base/_base.rb +38 -0
  16. data/lib/vagrant/conductor/modules/_base/config.yml +3 -0
  17. data/lib/vagrant/conductor/modules/_base/scripts/beanstalkd.sh +8 -0
  18. data/lib/vagrant/conductor/modules/_base/scripts/composer.sh +8 -0
  19. data/lib/vagrant/conductor/modules/_base/scripts/grub.sh +10 -0
  20. data/lib/vagrant/conductor/modules/_base/scripts/memcache.sh +4 -0
  21. data/lib/vagrant/conductor/modules/_base/scripts/mysql.sh +21 -0
  22. data/lib/vagrant/conductor/modules/_base/scripts/nginx.sh +45 -0
  23. data/lib/vagrant/conductor/modules/_base/scripts/nodejs.sh +14 -0
  24. data/lib/vagrant/conductor/modules/_base/scripts/php.sh +52 -0
  25. data/lib/vagrant/conductor/modules/_base/scripts/postgresql.sh +21 -0
  26. data/lib/vagrant/conductor/modules/_base/scripts/python-pip.sh +7 -0
  27. data/lib/vagrant/conductor/modules/_base/scripts/redis.sh +14 -0
  28. data/lib/vagrant/conductor/modules/_base/scripts/sqlite.sh +4 -0
  29. data/lib/vagrant/conductor/modules/_base/scripts/system.sh +48 -0
  30. data/lib/vagrant/conductor/modules/_base/scripts/xdebug.sh +22 -0
  31. data/lib/vagrant/conductor/modules/aws/aws.rb +38 -0
  32. data/lib/vagrant/conductor/modules/aws/config.yml +10 -0
  33. data/lib/vagrant/conductor/modules/aws/scripts/awscli.sh +16 -0
  34. data/lib/vagrant/conductor/modules/aws/scripts/awsconfig.sh +11 -0
  35. data/lib/vagrant/conductor/modules/aws/scripts/elasticbeanstalk.sh +8 -0
  36. data/lib/vagrant/conductor/modules/aws/templates/config.erb +5 -0
  37. data/lib/vagrant/conductor/modules/aws/templates/credentials.erb +5 -0
  38. data/lib/vagrant/conductor/modules/docker/config.yml +2 -0
  39. data/lib/vagrant/conductor/modules/docker/docker.rb +13 -0
  40. data/lib/vagrant/conductor/modules/docker/scripts/install.sh +3 -0
  41. data/lib/vagrant/conductor/modules/folders/config.yml +2 -0
  42. data/lib/vagrant/conductor/modules/folders/folders.rb +14 -0
  43. data/lib/vagrant/conductor/modules/git-config/config.yml +5 -0
  44. data/lib/vagrant/conductor/modules/git-config/git-config.rb +42 -0
  45. data/lib/vagrant/conductor/modules/known-hosts/config.yml +6 -0
  46. data/lib/vagrant/conductor/modules/known-hosts/known-hosts.rb +14 -0
  47. data/lib/vagrant/conductor/modules/known-hosts/scripts/add-domain.sh +8 -0
  48. data/lib/vagrant/conductor/modules/module.rb +31 -0
  49. data/lib/vagrant/conductor/modules/modules.rb +58 -0
  50. data/lib/vagrant/conductor/modules/oh-my-zsh/config.yml +6 -0
  51. data/lib/vagrant/conductor/modules/oh-my-zsh/oh-my-zsh.rb +27 -0
  52. data/lib/vagrant/conductor/modules/oh-my-zsh/scripts/install-oh-my-zsh.sh +19 -0
  53. data/lib/vagrant/conductor/modules/sites/config.yml +20 -0
  54. data/lib/vagrant/conductor/modules/sites/scripts/clone.sh +35 -0
  55. data/lib/vagrant/conductor/modules/sites/scripts/dotenv.sh +12 -0
  56. data/lib/vagrant/conductor/modules/sites/scripts/server.sh +8 -0
  57. data/lib/vagrant/conductor/modules/sites/sites.rb +193 -0
  58. data/lib/vagrant/conductor/modules/sites/templates/dotenv-array.erb +7 -0
  59. data/lib/vagrant/conductor/modules/sites/templates/server.erb +53 -0
  60. data/lib/vagrant/conductor/modules/ssh/config.yml +2 -0
  61. data/lib/vagrant/conductor/modules/ssh/ssh.rb +29 -0
  62. data/lib/vagrant/conductor/plugin.rb +14 -0
  63. data/lib/vagrant/conductor/provisioner.rb +48 -0
  64. data/lib/vagrant/conductor/util/hash.rb +19 -0
  65. data/lib/vagrant/conductor/version.rb +5 -0
  66. data/lib/vagrant/conductor.rb +48 -0
  67. data/vagrant-conductor.gemspec +33 -0
  68. metadata +152 -0
@@ -0,0 +1,10 @@
1
+ classname: AmazonWebServices
2
+
3
+ install: false
4
+
5
+ profile:
6
+ name: default
7
+ access_key: N/A
8
+ access_secret: N/A
9
+ region: us-east-1
10
+ output: text
@@ -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,11 @@
1
+ #!/usr/bin/env bash
2
+
3
+ home=$(sudo -u vagrant pwd)
4
+ contents=$1
5
+ name=$2
6
+
7
+ su vagrant <<EOF
8
+
9
+ echo "$contents" > "$home/.aws/$name";
10
+
11
+ EOF
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env bash
2
+
3
+ # Install unzip
4
+ sudo pip install awsebcli
5
+
6
+ su vagrant <<EOF
7
+ sudo pip install awsebcli
8
+ EOF
@@ -0,0 +1,5 @@
1
+ <% vars.each do |values| %>
2
+ [<%= values["name"] %>]
3
+ region=<%= values["region"] %>
4
+ output=<%= values["output"] %>
5
+ <% end %>
@@ -0,0 +1,5 @@
1
+ <% vars.each do |values| %>
2
+ [<%= values["name"] %>]
3
+ aws_access_key_id=<%= values["access_key"] %>
4
+ aws_secret_access_key=<%= values["access_secret"] %>
5
+ <% end %>
@@ -0,0 +1,2 @@
1
+ ---
2
+ classname: Docker
@@ -0,0 +1,13 @@
1
+ class Docker < StationModule
2
+
3
+ def install
4
+ shell_provision("bash #{scripts}/install.sh")
5
+ end
6
+
7
+ def provision
8
+ if args.find?('install', false)
9
+ install
10
+ end
11
+ end
12
+
13
+ end
@@ -0,0 +1,3 @@
1
+ #!/usr/bin/env bash
2
+
3
+ curl -sSL https://get.docker.com/ubuntu/ | sudo sh
@@ -0,0 +1,2 @@
1
+ ---
2
+ classname: Folders
@@ -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,5 @@
1
+ ---
2
+ classname: GitConfig
3
+
4
+ colors.ui: "true"
5
+ push.default: simple
@@ -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,6 @@
1
+ ---
2
+ classname: KnownHosts
3
+
4
+ domains:
5
+ - github.com
6
+ - bitbucket.org
@@ -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,8 @@
1
+ #!/usr/bin/env bash
2
+
3
+ su vagrant <<EOF
4
+
5
+ # Add domain to known hosts
6
+ ssh-keyscan $1 > ~/.ssh/known_hosts
7
+
8
+ EOF
@@ -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,6 @@
1
+ ---
2
+ classname: OhMyZsh
3
+
4
+ install:
5
+ zsh: true
6
+ oh-my-zsh: true
@@ -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,12 @@
1
+ #!/usr/bin/env bash
2
+
3
+ path=$1
4
+ content=$2
5
+
6
+ su vagrant <<EOF
7
+
8
+ if [ ! -f $path ]; then touch $path; fi
9
+
10
+ echo "$content" > $path;
11
+
12
+ EOF
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env bash
2
+
3
+ block=$3
4
+
5
+ echo "$block" > "/etc/nginx/sites-available/$1"
6
+ ln -fs "/etc/nginx/sites-available/$1" "/etc/nginx/sites-enabled/$1"
7
+ service nginx restart
8
+ service php5-fpm restart
@@ -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,7 @@
1
+ <?php
2
+
3
+ return array(
4
+ <% variables.each do |key, value| %>
5
+ '<%= key %>' => <%= value.is_a?(Integer) ? value : "'#{value}'" %>,
6
+ <% end %>
7
+ );
@@ -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
+ }
@@ -0,0 +1,2 @@
1
+ ---
2
+ classname: SSH