capistrano-froxlor 0.0.1
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.
- checksums.yaml +7 -0
- data/.gitignore +14 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +22 -0
- data/README.md +31 -0
- data/Rakefile +2 -0
- data/capistrano-froxlor.gemspec +23 -0
- data/lib/capistrano/froxlor.rb +2 -0
- data/lib/capistrano/froxlor/version.rb +5 -0
- data/lib/capistrano/tasks/froxlor.cap +137 -0
- metadata +82 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: e6603d672f2bc8b30ddca9f2b128f1c79aac625a
|
4
|
+
data.tar.gz: 0e290f0b33fedeae91bd08e36104285c009e5bf3
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 089d64238decc4588007608b2682c9ff8741c8d55c9205774f5689bb39f9a481346f81aa13ee9f1dc9142b50cf3d6ccb84048f896eb51024757ebc0e390a854a
|
7
|
+
data.tar.gz: 1865d6f93a70dfd1af7b52889575a289928ac1f14ad7d4d0c4c7df0f2d128be5980e164808076f211dbca49b707c07a3337ed2197d6e83a111b447339759f9b6
|
data/.gitignore
ADDED
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2014 Pim Snel
|
2
|
+
|
3
|
+
MIT License
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,31 @@
|
|
1
|
+
# Capistrano::Froxlor
|
2
|
+
|
3
|
+
TODO: Write a gem description
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
Add this line to your application's Gemfile:
|
8
|
+
|
9
|
+
```ruby
|
10
|
+
gem 'capistrano-froxlor'
|
11
|
+
```
|
12
|
+
|
13
|
+
And then execute:
|
14
|
+
|
15
|
+
$ bundle
|
16
|
+
|
17
|
+
Or install it yourself as:
|
18
|
+
|
19
|
+
$ gem install capistrano-froxlor
|
20
|
+
|
21
|
+
## Usage
|
22
|
+
|
23
|
+
TODO: Write usage instructions here
|
24
|
+
|
25
|
+
## Contributing
|
26
|
+
|
27
|
+
1. Fork it ( https://github.com/[my-github-username]/capistrano-froxlor/fork )
|
28
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
29
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
30
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
31
|
+
5. Create a new Pull Request
|
data/Rakefile
ADDED
@@ -0,0 +1,23 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'capistrano/froxlor/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "capistrano-froxlor"
|
8
|
+
spec.version = Capistrano::Froxlor::VERSION
|
9
|
+
spec.authors = ["Pim Snel"]
|
10
|
+
spec.email = ["pim@lingewoud.nl"]
|
11
|
+
spec.summary = %q{Froxlor cli functionality for capistrano 3}
|
12
|
+
spec.description = %q{Add Froxlor cli functions to capistrano. This gem does not deploy Froxlor itself.}
|
13
|
+
spec.homepage = "https://github.com/mipmip/capistrano-froxlor"
|
14
|
+
spec.license = "MIT"
|
15
|
+
|
16
|
+
spec.files = `git ls-files -z`.split("\x0")
|
17
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
18
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
19
|
+
spec.require_paths = ["lib"]
|
20
|
+
|
21
|
+
spec.add_development_dependency "bundler", "~> 1.7"
|
22
|
+
spec.add_development_dependency "rake", "~> 10.0"
|
23
|
+
end
|
@@ -0,0 +1,137 @@
|
|
1
|
+
# vim: ft=ruby:sts=2:expandtab
|
2
|
+
set :frx_db_name, 'froxlor'
|
3
|
+
|
4
|
+
namespace :froxlor do
|
5
|
+
|
6
|
+
namespace :admin do
|
7
|
+
desc "run master cron job. Apply froxlor changes, normally run from cron"
|
8
|
+
task :master_cronjob do
|
9
|
+
on roles(:all) do
|
10
|
+
execute "sudo /usr/bin/php5 -q /var/www/froxlor/scripts/froxlor_master_cronjob.php --force"
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
namespace :customer do
|
16
|
+
|
17
|
+
desc "create db for customer based on latest name"
|
18
|
+
task :create_db do
|
19
|
+
on roles(:all) do
|
20
|
+
customer = fetch(:frx_customer)
|
21
|
+
dbcon = fetch(:frx_db_auth).split(':')
|
22
|
+
dbname = fetch(:frx_db_name)
|
23
|
+
dbuser = dbcon[0]
|
24
|
+
dbpass = dbcon[1].split('@')[0]
|
25
|
+
dbhost = dbcon[1].split('@')[1]
|
26
|
+
|
27
|
+
#find latest db for user
|
28
|
+
dbs = capture "mysql -p#{dbpass} -u#{dbuser} -h#{dbhost} #{dbname} --execute='show databases;' | grep #{customer}| sort --version-sort | tail -n 1"
|
29
|
+
version = dbs["#{customer}sql".length..dbs.length].strip.to_i
|
30
|
+
version += 1
|
31
|
+
|
32
|
+
new_db_name = "#{customer}sql#{version.to_s}"
|
33
|
+
|
34
|
+
#create new password
|
35
|
+
charset = "abcdefghjkmnpqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ#{'0123456789' * 5}".split(//)
|
36
|
+
new_db_password = (0...10).map{ charset[rand(charset.size)] }.join
|
37
|
+
|
38
|
+
customer_id = capture "mysql -p#{dbpass} -u#{dbuser} -h#{dbhost} #{dbname} --execute='select customerid from panel_customers where loginname =\"userdev\";' -B -N".strip
|
39
|
+
|
40
|
+
execute "echo \"" \
|
41
|
+
"CREATE USER #{new_db_name}@localhost IDENTIFIED BY '#{new_db_password}';" \
|
42
|
+
"CREATE DATABASE #{new_db_name};" \
|
43
|
+
"GRANT ALL PRIVILEGES ON #{new_db_name}.* TO #{new_db_name};" \
|
44
|
+
"INSERT INTO panel_databases (customerid, databasename, description, dbserver, apsdb) VALUES (#{customer_id}, '#{new_db_name}', '#{fetch(:application)}:#{fetch(:stage).to_s} (auto created by capfroxlor)', 0, 0);" \
|
45
|
+
"\" | mysql -p#{dbpass} -u#{dbuser} -h#{dbhost} #{dbname}"
|
46
|
+
|
47
|
+
open("config/deploy/#{fetch(:stage).to_s}.rb", 'a') { |f|
|
48
|
+
f.puts "### ----- ALERT"
|
49
|
+
f.puts "### New db settings. Remove old"
|
50
|
+
f.puts "set :dbname, '#{new_db_name}'"
|
51
|
+
f.puts "set :dbuser, '#{new_db_name}'"
|
52
|
+
f.puts "set :dbpass, '#{new_db_password}'"
|
53
|
+
f.puts "set :dbhost, 'localhost'"
|
54
|
+
}
|
55
|
+
end
|
56
|
+
end
|
57
|
+
|
58
|
+
desc "create or recreate (sub)domains"
|
59
|
+
task :create_domains do
|
60
|
+
on roles(:all) do
|
61
|
+
|
62
|
+
|
63
|
+
run_master_job=false
|
64
|
+
|
65
|
+
customer = fetch(:frx_customer)
|
66
|
+
dbcon = fetch(:frx_db_auth).split(':')
|
67
|
+
dbname = fetch(:frx_db_name)
|
68
|
+
dbuser = dbcon[0]
|
69
|
+
dbpass = dbcon[1].split('@')[0]
|
70
|
+
dbhost = dbcon[1].split('@')[1]
|
71
|
+
|
72
|
+
customer_id = capture "mysql -p#{dbpass} -u#{dbuser} -h#{dbhost} #{dbname} --execute='select customerid from panel_customers where loginname =\"userdev\";' -B -N".strip
|
73
|
+
|
74
|
+
fetch(:frx_domains).each do |dom|
|
75
|
+
dom.each do | dname,dsettings|
|
76
|
+
|
77
|
+
if dsettings.has_key?(:sub_domain_parent)
|
78
|
+
# p dsettings
|
79
|
+
|
80
|
+
#TODO ME
|
81
|
+
#check if domain exist but owner is not correct
|
82
|
+
owner_dom_id = capture "mysql -p#{dbpass} -u#{dbuser} -h#{dbhost} #{dbname} --execute='select customerid from panel_domains where "\
|
83
|
+
"domain =\"#{dname}\";' -B -N".strip
|
84
|
+
# p "existing owner = #{owner_dom_id}"
|
85
|
+
if owner_dom_id.to_i > 0 && owner_dom_id.to_i != customer_id.to_i
|
86
|
+
raise "Domain exists but is has a different owner. Check your settings."
|
87
|
+
end
|
88
|
+
|
89
|
+
#if is parent find parent
|
90
|
+
parent_dom_id = capture "mysql -p#{dbpass} -u#{dbuser} -h#{dbhost} #{dbname} --execute='select id from panel_domains where "\
|
91
|
+
"domain =\"#{dsettings[:sub_domain_parent]}\" and customerid =#{customer_id};' -B -N".strip
|
92
|
+
|
93
|
+
# p parent_dom_id
|
94
|
+
if parent_dom_id.to_i > 0
|
95
|
+
|
96
|
+
#domain does not exist
|
97
|
+
new_dom_id = capture "mysql -p#{dbpass} -u#{dbuser} -h#{dbhost} #{dbname} --execute='select id from panel_domains where "\
|
98
|
+
"domain =\"#{dname}\";' -B -N".strip
|
99
|
+
|
100
|
+
if new_dom_id.to_i > 0
|
101
|
+
#update
|
102
|
+
run_master_job = true
|
103
|
+
sql = "UPDATE panel_domains SET domain=\"#{dname}\", customerid = #{customer_id.to_i}, documentroot=\"#{dsettings[:domain_docroot]}\" WHERE id = #{new_dom_id}"
|
104
|
+
else
|
105
|
+
run_master_job = true
|
106
|
+
sql = "INSERT INTO panel_domains ("\
|
107
|
+
" domain, adminid, customerid, aliasdomain, documentroot, ipandport, isbinddomain, isemaildomain, " \
|
108
|
+
" email_only, iswildcarddomain, subcanemaildomain, caneditdomain, zonefile, dkim, dkim_id, dkim_privkey, dkim_pubkey,"\
|
109
|
+
" wwwserveralias, parentdomainid, openbasedir, openbasedir_path, speciallogfile, specialsettings,"\
|
110
|
+
" deactivated, bindserial, add_date, registration_date, phpsettingid, mod_fcgid_starter, mod_fcgid_maxrequests, ismainbutsubto) " \
|
111
|
+
" VALUES " \
|
112
|
+
"(\"#{dname}\", 0, #{customer_id.to_i}, NULL, \"#{dsettings[:domain_docroot]}\", 2, 0, 0,"\
|
113
|
+
" 0, 0, 0, 1, \"\", 0, 0, \"\", \"\","\
|
114
|
+
" 1, #{parent_dom_id}, 0, 1, 0, \"\","\
|
115
|
+
" 0, \"2000010100\", 0, \"0000-00-00\", 1, -1, -1, 0);"
|
116
|
+
#insert
|
117
|
+
end
|
118
|
+
|
119
|
+
execute "echo '#{sql}' | mysql -p#{dbpass} -u#{dbuser} -h#{dbhost} #{dbname}"
|
120
|
+
|
121
|
+
else
|
122
|
+
print "Domain does not exist or is not owned by #{customer}"
|
123
|
+
end
|
124
|
+
|
125
|
+
end
|
126
|
+
end
|
127
|
+
end
|
128
|
+
|
129
|
+
if(run_master_job)
|
130
|
+
execute "sudo /usr/bin/php5 -q /var/www/froxlor/scripts/froxlor_master_cronjob.php --force"
|
131
|
+
end
|
132
|
+
|
133
|
+
end
|
134
|
+
end
|
135
|
+
|
136
|
+
end
|
137
|
+
end
|
metadata
ADDED
@@ -0,0 +1,82 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: capistrano-froxlor
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Pim Snel
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2014-11-20 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: bundler
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ~>
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '1.7'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ~>
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.7'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rake
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ~>
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '10.0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ~>
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '10.0'
|
41
|
+
description: Add Froxlor cli functions to capistrano. This gem does not deploy Froxlor
|
42
|
+
itself.
|
43
|
+
email:
|
44
|
+
- pim@lingewoud.nl
|
45
|
+
executables: []
|
46
|
+
extensions: []
|
47
|
+
extra_rdoc_files: []
|
48
|
+
files:
|
49
|
+
- .gitignore
|
50
|
+
- Gemfile
|
51
|
+
- LICENSE.txt
|
52
|
+
- README.md
|
53
|
+
- Rakefile
|
54
|
+
- capistrano-froxlor.gemspec
|
55
|
+
- lib/capistrano/froxlor.rb
|
56
|
+
- lib/capistrano/froxlor/version.rb
|
57
|
+
- lib/capistrano/tasks/froxlor.cap
|
58
|
+
homepage: https://github.com/mipmip/capistrano-froxlor
|
59
|
+
licenses:
|
60
|
+
- MIT
|
61
|
+
metadata: {}
|
62
|
+
post_install_message:
|
63
|
+
rdoc_options: []
|
64
|
+
require_paths:
|
65
|
+
- lib
|
66
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
67
|
+
requirements:
|
68
|
+
- - '>='
|
69
|
+
- !ruby/object:Gem::Version
|
70
|
+
version: '0'
|
71
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - '>='
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '0'
|
76
|
+
requirements: []
|
77
|
+
rubyforge_project:
|
78
|
+
rubygems_version: 2.4.2
|
79
|
+
signing_key:
|
80
|
+
specification_version: 4
|
81
|
+
summary: Froxlor cli functionality for capistrano 3
|
82
|
+
test_files: []
|