capricorn 2.0.3.pre → 2.0.3.pre2
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/erlang/rel/reltool.config
CHANGED
@@ -9,7 +9,10 @@
|
|
9
9
|
bertio,
|
10
10
|
bertrpc,
|
11
11
|
emq,
|
12
|
-
capricorn
|
12
|
+
capricorn,
|
13
|
+
|
14
|
+
reltool,
|
15
|
+
compiler
|
13
16
|
]},
|
14
17
|
{rel, "start_clean", "", [
|
15
18
|
kernel,
|
@@ -21,7 +24,9 @@
|
|
21
24
|
{app, bertrpc, [{incl_cond, include}]},
|
22
25
|
{app, emq, [{incl_cond, include}]},
|
23
26
|
{app, capricorn, [{incl_cond, include}]},
|
24
|
-
{app, sasl, [{incl_cond, include}]}
|
27
|
+
{app, sasl, [{incl_cond, include}]},
|
28
|
+
{app, reltool, [{incl_cond, include}]},
|
29
|
+
{app, compiler, [{incl_cond, include}]}
|
25
30
|
]}.
|
26
31
|
|
27
32
|
{rebar, [
|
@@ -0,0 +1,162 @@
|
|
1
|
+
require 'digest/sha1'
|
2
|
+
|
3
|
+
basedomain = application[:domain].split('.')[-2, 2].join('.')
|
4
|
+
subdomain = application[:domain].split('.')[0..-3].join('.')
|
5
|
+
subdomain = nil if subdomain.nil? or subdomain.empty?
|
6
|
+
|
7
|
+
client = 'mrhenry'
|
8
|
+
|
9
|
+
user = application[:id].downcase.gsub(/[^a-z]+/, '_')
|
10
|
+
short_user = "#{user[0,14]}_#{Digest::SHA1.hexdigest(application[:id])[0,5]}"
|
11
|
+
passwd = (rand(1_000_000_000) + 10_000).to_s
|
12
|
+
|
13
|
+
db_name = application[:id].downcase.gsub(/[^a-z]+/, '_')
|
14
|
+
db_name = "#{db_name[0,58]}_#{Digest::SHA1.hexdigest(application[:id])[0,5]}"
|
15
|
+
db_user = application[:id].downcase.gsub(/[^a-z]+/, '_')
|
16
|
+
db_user = "#{db_user[0,8]}_#{Digest::SHA1.hexdigest(application[:id])[0,5]}"
|
17
|
+
db_pswd = (rand(1_000_000_000) + 10_000).to_s
|
18
|
+
|
19
|
+
###############################################################################
|
20
|
+
### Find Unused Username ###
|
21
|
+
###############################################################################
|
22
|
+
begin
|
23
|
+
Etc.getpwnam(short_user)
|
24
|
+
rescue ArgumentError
|
25
|
+
short_user = short_user.succ
|
26
|
+
# retry
|
27
|
+
end
|
28
|
+
|
29
|
+
###############################################################################
|
30
|
+
### Create Plesk Domain ###
|
31
|
+
###############################################################################
|
32
|
+
begin
|
33
|
+
### Check if the domain exists
|
34
|
+
box.bash(%{ /usr/local/psa/bin/domain -i #{basedomain} })
|
35
|
+
httpdocs_path = "/var/www/vhosts/#{basedomain}/httpdocs"
|
36
|
+
user = Etc.getpwuid(File.stat(httpdocs_path).uid).name
|
37
|
+
short_user = user
|
38
|
+
|
39
|
+
rescue Rush::BashFailed, Errno::ENOENT
|
40
|
+
### try to create the base domain
|
41
|
+
box.bash(%{ /usr/local/psa/bin/domain -c #{basedomain} -clogin #{client} -status enabled -hosting true -hst_type phys -dns true -www true -login #{short_user} -passwd #{passwd} -shell /bin/bash })
|
42
|
+
end
|
43
|
+
application_root = box["/var/www/vhosts/#{basedomain}/"]
|
44
|
+
|
45
|
+
###############################################################################
|
46
|
+
### Create Plesk Subdomain ###
|
47
|
+
###############################################################################
|
48
|
+
if subdomain
|
49
|
+
begin
|
50
|
+
### check is the subdomain exists
|
51
|
+
box.bash(%{ /usr/local/psa/bin/subdomain -i -s #{subdomain} -d #{basedomain} })
|
52
|
+
|
53
|
+
rescue Rush::BashFailed
|
54
|
+
### try to create the subdomain
|
55
|
+
box.bash(%{ /usr/local/psa/bin/subdomain -c #{subdomain} -d #{basedomain} })
|
56
|
+
end
|
57
|
+
application_root = application_root["subdomains/#{subdomain}/"]
|
58
|
+
end
|
59
|
+
|
60
|
+
###############################################################################
|
61
|
+
### Add Domain Aliasses ###
|
62
|
+
###############################################################################
|
63
|
+
unless subdomain
|
64
|
+
application[:aliases].each do |aliasd|
|
65
|
+
begin
|
66
|
+
box.bash(%{ /usr/local/psa/bin/domalias --create #{aliasd} -domain #{basedomain} -status enabled -mail true -web true -dns true })
|
67
|
+
rescue Rush::BashFailed
|
68
|
+
# ignore failed aliases
|
69
|
+
end
|
70
|
+
end
|
71
|
+
end
|
72
|
+
|
73
|
+
has_db = application_root['shared/settings/database.yml'].exists?
|
74
|
+
|
75
|
+
###############################################################################
|
76
|
+
### Create host app ###
|
77
|
+
###############################################################################
|
78
|
+
if application_root['host/'].exists?
|
79
|
+
application_root.bash %{ mv host host-#{Time.now.strftime('%Y%m%d%H%M%S')} }
|
80
|
+
end
|
81
|
+
application_root.bash %{ milkshake create.host "host" --git-data --shared-data "shared" }
|
82
|
+
|
83
|
+
unless has_db
|
84
|
+
###############################################################################
|
85
|
+
### Create Database ###
|
86
|
+
###############################################################################
|
87
|
+
begin
|
88
|
+
box.bash(%{ /usr/local/psa/bin/database -c #{db_name} -domain #{basedomain} -server localhost:3306 -add_user #{db_user} -passwd #{db_pswd} })
|
89
|
+
rescue Rush::BashFailed
|
90
|
+
# ignore failure
|
91
|
+
end
|
92
|
+
|
93
|
+
###############################################################################
|
94
|
+
### Configure Database ###
|
95
|
+
###############################################################################
|
96
|
+
database_conf = application_root['shared/settings/database.yml'].create
|
97
|
+
database_conf.write %{
|
98
|
+
default: &default
|
99
|
+
adapter: mysql
|
100
|
+
database: #{db_name}
|
101
|
+
username: #{db_user}
|
102
|
+
password: #{db_pswd}
|
103
|
+
host: localhost
|
104
|
+
encoding: utf8
|
105
|
+
socket: /var/lib/mysql/mysql.sock
|
106
|
+
|
107
|
+
development:
|
108
|
+
<<: *default
|
109
|
+
|
110
|
+
test:
|
111
|
+
<<: *default
|
112
|
+
|
113
|
+
staging:
|
114
|
+
<<: *default
|
115
|
+
|
116
|
+
production:
|
117
|
+
<<: *default
|
118
|
+
}
|
119
|
+
end
|
120
|
+
|
121
|
+
###############################################################################
|
122
|
+
### Configure VHost ###
|
123
|
+
###############################################################################
|
124
|
+
vhost_conf = application_root['conf/vhost.conf'].create
|
125
|
+
vhost_conf.write %{
|
126
|
+
DocumentRoot #{application_root.full_path}/host/public
|
127
|
+
RailsEnv #{application[:environment] || 'production'}
|
128
|
+
|
129
|
+
ErrorDocument 503 /503.html
|
130
|
+
RewriteEngine on
|
131
|
+
RewriteCond %{DOCUMENT_ROOT}/../tmp/stop.txt -f
|
132
|
+
RewriteCond %{DOCUMENT_ROOT}/%{REQUEST_FILENAME} !-f
|
133
|
+
RewriteRule ^(.*)$ /$1 [R=503,L]
|
134
|
+
|
135
|
+
<Directory "#{application_root.full_path}/host/public">
|
136
|
+
Options All
|
137
|
+
AllowOverride All
|
138
|
+
Order allow,deny
|
139
|
+
Allow from all
|
140
|
+
</Directory>
|
141
|
+
}
|
142
|
+
|
143
|
+
###############################################################################
|
144
|
+
### Set Owner of Host ###
|
145
|
+
###############################################################################
|
146
|
+
box.bash %{ chown #{short_user}:psaserv "#{application_root.full_path}" }
|
147
|
+
box.bash %{ chown -R #{short_user}:psaserv "#{application_root.full_path}/host" }
|
148
|
+
box.bash %{ chown -R #{short_user}:psaserv "#{application_root.full_path}/shared" }
|
149
|
+
|
150
|
+
###############################################################################
|
151
|
+
### Reconfigure vhost in Plesk ###
|
152
|
+
###############################################################################
|
153
|
+
box.bash %{ /usr/local/psa/admin/sbin/websrvmng --reconfigure-vhost --vhost-name=#{basedomain} }
|
154
|
+
|
155
|
+
###############################################################################
|
156
|
+
### Restart apache ###
|
157
|
+
###############################################################################
|
158
|
+
box.bash %{ /etc/init.d/apache2 restart }
|
159
|
+
|
160
|
+
set :root_path, application_root.full_path.to_s
|
161
|
+
set :www_user, short_user.to_s
|
162
|
+
set :www_group, 'psaserv'
|
data/lib/capricorn/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: capricorn
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 270495437
|
5
5
|
prerelease: true
|
6
6
|
segments:
|
7
7
|
- 2
|
8
8
|
- 0
|
9
9
|
- 3
|
10
|
-
-
|
11
|
-
version: 2.0.3.
|
10
|
+
- pre2
|
11
|
+
version: 2.0.3.pre2
|
12
12
|
platform: ruby
|
13
13
|
authors:
|
14
14
|
- Simon Menke
|
@@ -16,7 +16,7 @@ autorequire:
|
|
16
16
|
bindir: bin
|
17
17
|
cert_chain: []
|
18
18
|
|
19
|
-
date: 2010-06-
|
19
|
+
date: 2010-06-03 00:00:00 +02:00
|
20
20
|
default_executable:
|
21
21
|
dependencies:
|
22
22
|
- !ruby/object:Gem::Dependency
|
@@ -131,6 +131,7 @@ files:
|
|
131
131
|
- lib/capricorn/driver.rb
|
132
132
|
- lib/capricorn/recipes/apache-debian.rb
|
133
133
|
- lib/capricorn/recipes/centos-plesk.rb
|
134
|
+
- lib/capricorn/recipes/debian-plesk95.rb
|
134
135
|
- lib/capricorn/recipes/macports.rb
|
135
136
|
- lib/capricorn/system_context.rb
|
136
137
|
- lib/capricorn/version.rb
|