bonethug 0.0.80 → 0.0.81
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.
- data/TODO.txt +4 -1
- data/config/backup.rb +2 -2
- data/config/cnf.yml +7 -1
- data/config/deploy.rb +27 -52
- data/lib/bonethug/cli.rb +41 -0
- data/lib/bonethug/configurator.rb +90 -0
- data/lib/bonethug/syncer.rb +2 -2
- data/lib/bonethug/version.rb +2 -2
- data/scripts/ubuntu_setup_2.4.sh +2 -1
- data/skel/project_types/php/lib/Thug/Conf/Load.php +1 -1
- metadata +4 -9
data/TODO.txt
CHANGED
@@ -6,4 +6,7 @@
|
|
6
6
|
- thug update needs stil needs to be run twice because the current version gets loaded into memory - need to run some sort of two phase update
|
7
7
|
- some things need to run prior to there being a deploy copy - eg. init-db
|
8
8
|
- conf should return nil if it can't find a node
|
9
|
-
- rbenv library support - rbenv gays out with 2.x needs readline headers manually specified
|
9
|
+
- rbenv library support - rbenv gays out with 2.x needs readline headers manually specified
|
10
|
+
- nagios?
|
11
|
+
- need more modular configuration of server components for setup scripts
|
12
|
+
- thug vhost-local and thug deploy could share more code
|
data/config/backup.rb
CHANGED
@@ -35,7 +35,7 @@ raise "No backup configuraton available" unless backup
|
|
35
35
|
log_dirs.push('log') unless log_dirs.include? 'log'
|
36
36
|
|
37
37
|
# back up script
|
38
|
-
# --------------------------------
|
38
|
+
# --------------------------------
|
39
39
|
|
40
40
|
# safe
|
41
41
|
safe do
|
@@ -45,7 +45,7 @@ safe do
|
|
45
45
|
local :path => "#{exec_path}/backups/:kind/:id"
|
46
46
|
|
47
47
|
# use ftp to back stuff up
|
48
|
-
if backup.get('ftp')
|
48
|
+
if backup.get('ftp')
|
49
49
|
ftp do
|
50
50
|
host backup.get('ftp.host')
|
51
51
|
user backup.get('ftp.user')
|
data/config/cnf.yml
CHANGED
@@ -97,8 +97,10 @@ mail:
|
|
97
97
|
secure: tls
|
98
98
|
charset_encoding: utf-8
|
99
99
|
port: 587
|
100
|
-
|
100
|
+
vhost:
|
101
101
|
development:
|
102
|
+
conf_path: /etc/apache2/sites-available
|
103
|
+
type: apache
|
102
104
|
version: 2.4
|
103
105
|
server_name: development.domain.local
|
104
106
|
server_aliases:
|
@@ -107,6 +109,8 @@ apache:
|
|
107
109
|
RAILS_ENV: development
|
108
110
|
APPLICATION_ENV: development
|
109
111
|
staging:
|
112
|
+
conf_path: /etc/apache2/sites-available
|
113
|
+
type: apache
|
110
114
|
version: 2.2
|
111
115
|
server_name: staging.domain.com
|
112
116
|
server_aliases:
|
@@ -122,6 +126,8 @@ apache:
|
|
122
126
|
user: username2
|
123
127
|
pass: passw0rd2
|
124
128
|
production:
|
129
|
+
conf_path: /etc/apache2/sites-available
|
130
|
+
type: apache
|
125
131
|
version: 2.4
|
126
132
|
server_name: production.domain.com
|
127
133
|
server_aliases:
|
data/config/deploy.rb
CHANGED
@@ -15,6 +15,7 @@
|
|
15
15
|
require 'rubygems'
|
16
16
|
require 'bonethug/conf'
|
17
17
|
require 'bonethug/installer'
|
18
|
+
require 'bonethug/configurator'
|
18
19
|
# require 'mina/bundler' # does stupid stuff with symlinks
|
19
20
|
require 'mina/rails'
|
20
21
|
require 'mina/git'
|
@@ -34,6 +35,12 @@ conf.add(exec_path + '/config/database.yml' => { root: 'dbs.default' }) if File.
|
|
34
35
|
# generate a hash
|
35
36
|
cnf = conf.to_hash
|
36
37
|
|
38
|
+
# check if we have a deploy config
|
39
|
+
unless conf.get('deploy')
|
40
|
+
puts'could not find deployment config'
|
41
|
+
exit
|
42
|
+
end
|
43
|
+
|
37
44
|
# pull config from environment vars
|
38
45
|
env = ENV['to']
|
39
46
|
unless conf.get('deploy.environments').has_key? env
|
@@ -42,7 +49,7 @@ unless conf.get('deploy.environments').has_key? env
|
|
42
49
|
end
|
43
50
|
|
44
51
|
# build config
|
45
|
-
deploy = conf.node_merge
|
52
|
+
deploy = conf.node_merge 'deploy.common','deploy.environments.' + env
|
46
53
|
resources = conf.get('resources','Array') || []
|
47
54
|
log_dirs = conf.get('log_dirs','Array') || []
|
48
55
|
vendor = conf.get('vendor','Array') || []
|
@@ -260,6 +267,10 @@ task :deploy => :environment do
|
|
260
267
|
#{echo_cmd %[#{bundle_bin} install #{bundle_options}]}
|
261
268
|
}
|
262
269
|
|
270
|
+
# !!!!!!
|
271
|
+
# COMPOSER INSTALL AND BOWER INSTALL NEEDS TO RUN HERE!!!!!!! - ASSET PRECOMPILE WILL FAIL IF DEPENDENCIES ARE NOT INCLUDED!!!!
|
272
|
+
# !!!!!!
|
273
|
+
|
263
274
|
# rails deploy tasks
|
264
275
|
if deploy.get('project_type') =~ /rails[0-9]?/
|
265
276
|
invoke :'rails:db_migrate'
|
@@ -267,64 +278,27 @@ task :deploy => :environment do
|
|
267
278
|
end
|
268
279
|
|
269
280
|
# build the vhosts
|
270
|
-
vh_cnf = conf.get
|
271
|
-
|
272
|
-
|
273
|
-
|
274
|
-
aliases = vh_cnf.get('server_aliases')
|
275
|
-
if aliases
|
276
|
-
aliases.each do |index, server_alias|
|
277
|
-
server_aliases += 'ServerAlias '+server_alias + "\n"
|
278
|
-
end
|
279
|
-
end
|
280
|
-
|
281
|
-
# environment variables
|
282
|
-
env_vars = ''
|
283
|
-
vars = vh_cnf.get('env_vars')
|
284
|
-
if vars
|
285
|
-
vars.each do |k, v|
|
286
|
-
env_vars += 'SetEnv ' + k + ' ' + v + "\n"
|
287
|
-
end
|
288
|
-
end
|
289
|
-
|
290
|
-
# server admin
|
291
|
-
admin = vh_cnf.get('server_admin')
|
292
|
-
server_admin = admin ? 'ServerAdmin '+admin : ''
|
293
|
-
|
294
|
-
vh = "
|
295
|
-
<VirtualHost *:80>
|
296
|
-
|
297
|
-
ServerName #{vh_cnf.get('server_name')}
|
298
|
-
#{server_aliases}
|
281
|
+
vh_cnf = conf.get 'vhost'
|
282
|
+
vh_cnf = conf.get 'apache' unless vh_cnf
|
283
|
+
vh_cnf = vh_cnf.get env
|
284
|
+
conf_path = vh_cnf.get('conf_path') || '/etc/apache2/sites-available'
|
299
285
|
|
300
|
-
|
286
|
+
vh = Bonethug::Configurator.vhost vh_cnf, deploy_to, true
|
301
287
|
|
302
|
-
|
288
|
+
case vh_cnf.get('type')
|
303
289
|
|
304
|
-
|
305
|
-
PassEnv PATH
|
290
|
+
when "nginx"
|
306
291
|
|
307
|
-
|
308
|
-
|
309
|
-
|
292
|
+
# to be implemented
|
293
|
+
puts 'to be implemented'
|
294
|
+
exit
|
310
295
|
|
311
|
-
|
296
|
+
else # apache
|
312
297
|
|
313
|
-
|
314
|
-
|
315
|
-
Order allow,deny
|
316
|
-
Allow from all
|
317
|
-
#{vh_cnf.get('version').to_f > 2.4 ? 'Require all granted' : ''}
|
298
|
+
# install the vhost
|
299
|
+
queue! %[sudo echo "#{vh}" > #{conf_path}/#{vhost}.conf]
|
318
300
|
|
319
|
-
|
320
|
-
|
321
|
-
</VirtualHost>
|
322
|
-
"
|
323
|
-
|
324
|
-
# install the vhost
|
325
|
-
queue! %[touch /etc/apache2/sites-available/#{vhost}.conf]
|
326
|
-
queue! %[rm /etc/apache2/sites-available/#{vhost}.conf]
|
327
|
-
queue! %[echo "#{vh}" > /etc/apache2/sites-available/#{vhost}.conf]
|
301
|
+
end
|
328
302
|
|
329
303
|
to :launch do
|
330
304
|
|
@@ -407,6 +381,7 @@ task :deploy => :environment do
|
|
407
381
|
# write to the .htpasswd file
|
408
382
|
queue! %[touch #{deploy_to}/current/.htpasswd]
|
409
383
|
queue! %[echo "#{htpass}" > #{deploy_to}/current/.htpasswd]
|
384
|
+
|
410
385
|
else
|
411
386
|
|
412
387
|
# write the to the .haccess file
|
data/lib/bonethug/cli.rb
CHANGED
@@ -1,4 +1,6 @@
|
|
1
1
|
require 'rbconfig'
|
2
|
+
require 'bonethug/conf'
|
3
|
+
require 'bonethug/configurator'
|
2
4
|
|
3
5
|
module Bonethug
|
4
6
|
class CLI
|
@@ -102,6 +104,45 @@ module Bonethug
|
|
102
104
|
|
103
105
|
end
|
104
106
|
|
107
|
+
when 'vhost-local'
|
108
|
+
|
109
|
+
# get env
|
110
|
+
env = ARGV.last
|
111
|
+
|
112
|
+
# exec env
|
113
|
+
exec_path = File.expand_path('.')
|
114
|
+
|
115
|
+
# load config
|
116
|
+
conf = Conf.new.add(exec_path + '/config/cnf.yml')
|
117
|
+
conf.add(exec_path + '/config/database.yml' => { root: 'dbs.default' }) if File.exist? exec_path + '/config/database.yml'
|
118
|
+
deploy = conf.node_merge 'deploy.common', 'deploy.environments.' + env
|
119
|
+
|
120
|
+
# vhost name
|
121
|
+
vhost = deploy.get('project_slug') + '_' + env
|
122
|
+
|
123
|
+
# build the vhosts
|
124
|
+
vh_cnf = conf.get 'vhost'
|
125
|
+
vh_cnf = conf.get 'apache' unless vh_cnf
|
126
|
+
vh_cnf = vh_cnf.get env
|
127
|
+
conf_path = vh_cnf.get('conf_path') || '/etc/apache2/sites-available'
|
128
|
+
|
129
|
+
vh = Configurator.vhost vh_cnf, exec_path
|
130
|
+
|
131
|
+
case vh_cnf.get('type')
|
132
|
+
|
133
|
+
when "nginx"
|
134
|
+
|
135
|
+
# to be implemented
|
136
|
+
puts 'to be implemented'
|
137
|
+
exit
|
138
|
+
|
139
|
+
else # apache
|
140
|
+
|
141
|
+
# install the vhost
|
142
|
+
exec "echo \"#{vh}\" > #{conf_path}/#{vhost}.conf"
|
143
|
+
|
144
|
+
end
|
145
|
+
|
105
146
|
when 'init', 'update'
|
106
147
|
|
107
148
|
# handle args
|
@@ -0,0 +1,90 @@
|
|
1
|
+
# Class for generating configurations
|
2
|
+
|
3
|
+
require 'bonethug/conf'
|
4
|
+
require 'fileutils'
|
5
|
+
require 'find'
|
6
|
+
require 'digest/md5'
|
7
|
+
require 'yaml'
|
8
|
+
require 'rbconfig'
|
9
|
+
|
10
|
+
module Bonethug
|
11
|
+
|
12
|
+
class Configurator
|
13
|
+
|
14
|
+
include FileUtils
|
15
|
+
include Digest
|
16
|
+
|
17
|
+
def self.vhost(vh_cnf, base_path, is_remote = false)
|
18
|
+
|
19
|
+
# server aliases
|
20
|
+
server_aliases = ''
|
21
|
+
aliases = vh_cnf.get('server_aliases')
|
22
|
+
if aliases
|
23
|
+
aliases.each do |index, server_alias|
|
24
|
+
server_aliases += 'ServerAlias ' + server_alias + "\n"
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
# environment variables
|
29
|
+
env_vars = ''
|
30
|
+
vars = vh_cnf.get('env_vars')
|
31
|
+
if vars
|
32
|
+
vars.each do |k, v|
|
33
|
+
env_vars += 'SetEnv ' + k + ' ' + v + "\n"
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
# server admin
|
38
|
+
admin = vh_cnf.get('server_admin')
|
39
|
+
server_admin = admin ? 'ServerAdmin ' + admin : ''
|
40
|
+
|
41
|
+
# paths
|
42
|
+
shared_path = is_remote ? '/shared' : ''
|
43
|
+
current_path = is_remote ? '/current' : ''
|
44
|
+
|
45
|
+
case vh_cnf.get('type')
|
46
|
+
|
47
|
+
when "nginx"
|
48
|
+
|
49
|
+
vh = ""
|
50
|
+
|
51
|
+
else # apache
|
52
|
+
|
53
|
+
vh = "
|
54
|
+
<VirtualHost *:80>
|
55
|
+
|
56
|
+
ServerName #{vh_cnf.get('server_name')}
|
57
|
+
#{server_aliases}
|
58
|
+
|
59
|
+
#{server_admin}
|
60
|
+
|
61
|
+
DocumentRoot #{base_path + current_path}/public
|
62
|
+
|
63
|
+
#{env_vars}
|
64
|
+
PassEnv PATH
|
65
|
+
|
66
|
+
CustomLog #{base_path + shared_path}/log/bytes.log bytes
|
67
|
+
CustomLog #{base_path + shared_path}/log/combined.log combined
|
68
|
+
ErrorLog #{base_path + shared_path}/log/error.log
|
69
|
+
|
70
|
+
<Directory #{base_path + current_path}/public>
|
71
|
+
|
72
|
+
Options Indexes MultiViews FollowSymLinks
|
73
|
+
AllowOverride All
|
74
|
+
Order allow,deny
|
75
|
+
Allow from all
|
76
|
+
#{vh_cnf.get('version').to_f > 2.4 ? 'Require all granted' : ''}
|
77
|
+
|
78
|
+
</Directory>
|
79
|
+
|
80
|
+
</VirtualHost>
|
81
|
+
"
|
82
|
+
end
|
83
|
+
|
84
|
+
vh
|
85
|
+
|
86
|
+
end
|
87
|
+
|
88
|
+
end
|
89
|
+
|
90
|
+
end
|
data/lib/bonethug/syncer.rb
CHANGED
@@ -77,9 +77,9 @@ module Bonethug
|
|
77
77
|
db_local = db.get env_local
|
78
78
|
|
79
79
|
if push == 'local' and pull == 'remote'
|
80
|
-
cmd = "#{remote_ssh} \"mysqldump -u #{db_remote.get 'user'} -p#{db_remote.get 'pass'} #{db_remote.get 'name'} --verbose | bzip2 -c\" | bunzip2 -c | mysql -u #{db_local.get 'user'} -p#{db_local.get 'pass'} #{db_local.get 'name'}"
|
80
|
+
cmd = "#{remote_ssh} \"mysqldump -u #{db_remote.get 'user'} -p#{db_remote.get 'pass'} #{db_remote.get 'name'} --verbose --single-transaction -CceKq | bzip2 -c\" | bunzip2 -c | mysql -u #{db_local.get 'user'} -p#{db_local.get 'pass'} #{db_local.get 'name'}"
|
81
81
|
elsif pull == 'local' and push == 'remote'
|
82
|
-
cmd = "mysqldump -u #{db_local.get 'user'} -p#{db_local.get 'pass'} #{db_local.get 'name'} --verbose | bzip2 -c | #{remote_ssh} \"bunzip2 -c | mysql -u #{db_remote.get 'user'} -p#{db_remote.get 'pass'} #{db_remote.get 'name'}\""
|
82
|
+
cmd = "mysqldump -u #{db_local.get 'user'} -p#{db_local.get 'pass'} #{db_local.get 'name'} --verbose --single-transaction -CceKq | bzip2 -c | #{remote_ssh} \"bunzip2 -c | mysql -u #{db_remote.get 'user'} -p#{db_remote.get 'pass'} #{db_remote.get 'name'}\""
|
83
83
|
end
|
84
84
|
|
85
85
|
puts cmd
|
data/lib/bonethug/version.rb
CHANGED
data/scripts/ubuntu_setup_2.4.sh
CHANGED
@@ -13,6 +13,7 @@ sudo add-apt-repository "deb http://archive.ubuntu.com/ubuntu $(lsb_release -sc)
|
|
13
13
|
sudo add-apt-repository "deb-src http://archive.ubuntu.com/ubuntu $(lsb_release -sc) main universe restricted multiverse"
|
14
14
|
sudo add-apt-repository ppa:ondrej/apache2
|
15
15
|
sudo add-apt-repository ppa:ondrej/php5
|
16
|
+
sudo add-apt-repository ppa:ondrej/mysql-5.6
|
16
17
|
|
17
18
|
# update
|
18
19
|
sudo apt-get update && sudo apt-get upgrade
|
@@ -65,7 +66,7 @@ sed -i -e "s/listen = \/var\/run\/php5-fpm.sock/listen = 127.0.0.1:9000/g" /etc/
|
|
65
66
|
|
66
67
|
#apache2.4
|
67
68
|
sudo echo -e "<IfModule mod_fastcgi.c>\n AddHandler php5-fcgi .php\n Action php5-fcgi /php5-fcgi\n Alias /php5-fcgi /usr/lib/cgi-bin/php5-fcgi\n FastCgiExternalServer /usr/lib/cgi-bin/php5-fcgi -host 127.0.0.1:9000 -idle-timeout 250 -pass-header Authorization\n <Directory />\nRequire all granted\n </Directory>\n </IfModule>" > /etc/apache2/conf-available/php-fpm.conf
|
68
|
-
a2enconf php-fpm.conf
|
69
|
+
sudo a2enconf php-fpm.conf
|
69
70
|
|
70
71
|
# Apache
|
71
72
|
# ------
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: bonethug
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.81
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2014-
|
12
|
+
date: 2014-06-01 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: bundler
|
@@ -389,6 +389,7 @@ files:
|
|
389
389
|
- lib/bonethug.rb
|
390
390
|
- lib/bonethug/cli.rb
|
391
391
|
- lib/bonethug/conf.rb
|
392
|
+
- lib/bonethug/configurator.rb
|
392
393
|
- lib/bonethug/installer.rb
|
393
394
|
- lib/bonethug/syncer.rb
|
394
395
|
- lib/bonethug/utils.rb
|
@@ -557,21 +558,15 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
557
558
|
- - ! '>='
|
558
559
|
- !ruby/object:Gem::Version
|
559
560
|
version: '0'
|
560
|
-
segments:
|
561
|
-
- 0
|
562
|
-
hash: -1758899776465409101
|
563
561
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
564
562
|
none: false
|
565
563
|
requirements:
|
566
564
|
- - ! '>='
|
567
565
|
- !ruby/object:Gem::Version
|
568
566
|
version: '0'
|
569
|
-
segments:
|
570
|
-
- 0
|
571
|
-
hash: -1758899776465409101
|
572
567
|
requirements: []
|
573
568
|
rubyforge_project:
|
574
|
-
rubygems_version: 1.8.23
|
569
|
+
rubygems_version: 1.8.23.2
|
575
570
|
signing_key:
|
576
571
|
specification_version: 3
|
577
572
|
summary: Bonethug
|