ktec-subtrac 0.1.43 → 0.1.44
Sign up to get free protection for your applications and to get access to all the features.
- data/VERSION.yml +1 -1
- data/lib/subtrac.rb +36 -221
- data/lib/subtrac/apache.rb +14 -12
- data/lib/subtrac/client.rb +1 -0
- data/lib/subtrac/config.rb +224 -144
- data/lib/subtrac/svn.rb +5 -10
- data/lib/subtrac/template.rb +9 -4
- data/lib/subtrac/trac.rb +10 -13
- data/lib/subtrac/trac/trac.ini.erb +11 -11
- metadata +2 -2
data/VERSION.yml
CHANGED
data/lib/subtrac.rb
CHANGED
@@ -38,192 +38,16 @@ require 'subtrac/apache'
|
|
38
38
|
require 'subtrac/svn'
|
39
39
|
require 'subtrac/trac'
|
40
40
|
require 'subtrac/core_ext'
|
41
|
+
require 'subtrac/config'
|
41
42
|
|
42
43
|
module Subtrac
|
43
44
|
|
44
45
|
SUBTRAC_ROOT = "#{File.dirname(__FILE__)}/" unless defined?(SUBTRAC_ROOT)
|
45
46
|
SUBTRAC_ENV = (ENV['SUBTRAC_ENV'] || 'development').dup unless defined?(SUBTRAC_ENV)
|
46
|
-
|
47
|
-
|
48
|
-
class << self
|
49
|
-
|
50
|
-
# User configured options
|
51
|
-
def server_name
|
52
|
-
@server_name ||= @APP_CONFIG[:server_name]
|
53
|
-
end
|
54
|
-
|
55
|
-
def server_name=(name)
|
56
|
-
@APP_CONFIG[:server_name] = @server_name = name
|
57
|
-
end
|
58
|
-
|
59
|
-
def server_hostname
|
60
|
-
@server_hostname ||= @APP_CONFIG[:server_hostname]
|
61
|
-
end
|
62
|
-
|
63
|
-
def server_hostname=(name)
|
64
|
-
@APP_CONFIG[:server_hostname] = @server_hostname = name
|
65
|
-
end
|
66
|
-
|
67
|
-
def default_client
|
68
|
-
@default_client ||= @APP_CONFIG[:default_client]
|
69
|
-
end
|
70
|
-
|
71
|
-
def default_client=(name)
|
72
|
-
@APP_CONFIG[:default_client] = @default_client = name
|
73
|
-
end
|
74
|
-
|
75
|
-
def default_project
|
76
|
-
@default_project ||= @APP_CONFIG[:default_project]
|
77
|
-
end
|
78
|
-
|
79
|
-
def default_project=(name)
|
80
|
-
puts "Updating default_project to #{name}"
|
81
|
-
@APP_CONFIG[:default_project] = @default_project = name
|
82
|
-
end
|
83
|
-
|
84
|
-
def default_project_type
|
85
|
-
@default_project_type ||= @APP_CONFIG[:default_project_type]
|
86
|
-
end
|
87
|
-
|
88
|
-
def default_project_type=(name)
|
89
|
-
puts "Updating default_project_type to #{name}"
|
90
|
-
@APP_CONFIG[:default_project_type] = @default_project_type = name
|
91
|
-
end
|
92
|
-
|
93
|
-
|
94
|
-
# Filesystem directories
|
95
|
-
def root
|
96
|
-
Pathname.new(SUBTRAC_ROOT) if defined?(SUBTRAC_ROOT)
|
97
|
-
end
|
98
|
-
|
99
|
-
def public_path
|
100
|
-
@public_path ||= self.root ? File.join(self.root, "public") : "public"
|
101
|
-
end
|
102
|
-
|
103
|
-
def public_path=(path)
|
104
|
-
@public_path = path
|
105
|
-
end
|
106
|
-
|
107
|
-
def subtrac_path
|
108
|
-
@subtrac_path ||= self.root ? File.join(self.root, "subtrac") : "subtrac"
|
109
|
-
end
|
110
|
-
|
111
|
-
def install_dir
|
112
|
-
@install_dir ||= File.expand_path(@APP_CONFIG[:installation_dir])
|
113
|
-
end
|
114
|
-
|
115
|
-
def install_dir=(name)
|
116
|
-
puts "Setting new install_dir variable to #{name}"
|
117
|
-
@APP_CONFIG[:installation_dir] = @install_dir = name
|
118
|
-
end
|
119
|
-
|
120
|
-
def apache_conf_dir
|
121
|
-
@apache_conf_dir ||= @APP_CONFIG[:apache_conf_dir]
|
122
|
-
end
|
123
|
-
|
124
|
-
def apache_conf_dir=(name)
|
125
|
-
@APP_CONFIG[:apache_conf_dir] = @apache_conf_dir = name
|
126
|
-
end
|
127
|
-
|
128
|
-
def docs_dir
|
129
|
-
@docs_dir ||= File.join(install_dir,@APP_CONFIG[:dirs][:docs])
|
130
|
-
end
|
131
|
-
|
132
|
-
def svn_dir
|
133
|
-
@svn_dir ||= File.join(install_dir,@APP_CONFIG[:dirs][:svn])
|
134
|
-
end
|
135
|
-
|
136
|
-
def trac_dir
|
137
|
-
@trac_dir ||= File.join(install_dir,@APP_CONFIG[:dirs][:trac])
|
138
|
-
end
|
139
|
-
|
140
|
-
def temp_dir
|
141
|
-
@temp_dir ||= File.join(install_dir,@APP_CONFIG[:dirs][:temp])
|
142
|
-
end
|
143
|
-
|
144
|
-
def log_dir
|
145
|
-
@log_dir ||= File.join(install_dir,@APP_CONFIG[:dirs][:log])
|
146
|
-
end
|
147
|
-
|
148
|
-
def locations_dir
|
149
|
-
@locations_dir ||= File.join(install_dir,@APP_CONFIG[:dirs][:locations])
|
150
|
-
end
|
151
|
-
|
152
|
-
# Urls
|
153
|
-
def svn_url
|
154
|
-
@svn_url ||= @APP_CONFIG[:urls][:svn]
|
155
|
-
end
|
156
|
-
|
157
|
-
def trac_permissions
|
158
|
-
@trac_permissions ||= @APP_CONFIG[:trac][:permissions]
|
159
|
-
end
|
160
|
-
|
161
|
-
# LDAP
|
162
|
-
def enable_ldap
|
163
|
-
@enable_ldap ||= @APP_CONFIG[:ldap][:enable]
|
164
|
-
end
|
165
|
-
|
166
|
-
def enable_ldap=(value)
|
167
|
-
@APP_CONFIG[:ldap][:enable] = @enable_ldap = value
|
168
|
-
end
|
169
|
-
|
170
|
-
def ldap_bind_dn
|
171
|
-
@ldap_bind_dn ||= @APP_CONFIG[:ldap][:bind_dn]
|
172
|
-
end
|
173
|
-
|
174
|
-
def ldap_bind_dn=(value)
|
175
|
-
@APP_CONFIG[:ldap][:bind_dn] = @ldap_bind_dn = value
|
176
|
-
end
|
177
|
-
|
178
|
-
def ldap_bind_password
|
179
|
-
@ldap_bind_password ||= @APP_CONFIG[:ldap][:bind_password]
|
180
|
-
end
|
181
|
-
|
182
|
-
def ldap_bind_password=(value)
|
183
|
-
@APP_CONFIG[:ldap][:bind_password] = @ldap_bind_password = value
|
184
|
-
end
|
185
|
-
|
186
|
-
def ldap_bind_host
|
187
|
-
@ldap_bind_host ||= @APP_CONFIG[:ldap][:bind_host]
|
188
|
-
end
|
189
|
-
|
190
|
-
def ldap_bind_host=(value)
|
191
|
-
@APP_CONFIG[:ldap][:bind_host] = @ldap_bind_password = value
|
192
|
-
end
|
193
|
-
|
194
|
-
end
|
195
|
-
|
47
|
+
|
196
48
|
# Loads the configuration YML file
|
197
49
|
def self.load_config
|
198
|
-
|
199
|
-
puts "\n==== Loading configuration file ===="
|
200
|
-
# load configuration file
|
201
|
-
file_path = File.join(subtrac_path, USER_CONFIG_FILE)
|
202
|
-
file_path = File.join(subtrac_path,"/config/config.yml") if not File.exists?(file_path)
|
203
|
-
puts "Attempting to read config file: #{file_path}"
|
204
|
-
begin
|
205
|
-
yamlFile = YAML.load(File.read(file_path))
|
206
|
-
rescue Exception => e
|
207
|
-
raise StandardError, "Config #{file_path} could not be loaded."
|
208
|
-
end
|
209
|
-
if yamlFile
|
210
|
-
if yamlFile[SUBTRAC_ENV]
|
211
|
-
@APP_CONFIG = yamlFile[SUBTRAC_ENV]
|
212
|
-
else
|
213
|
-
raise StandardError, "config/config.yml exists, but doesn't have a configuration for #{SUBTRAC_ENV}."
|
214
|
-
end
|
215
|
-
else
|
216
|
-
raise StandardError, "config/config.yml does not exist."
|
217
|
-
end
|
218
|
-
say("Configuration loaded successfully...")
|
219
|
-
end
|
220
|
-
|
221
|
-
# Write the changes configuration to disk
|
222
|
-
def self.save_config
|
223
|
-
# save the things that might have changed
|
224
|
-
file_path = File.join(subtrac_path, USER_CONFIG_FILE)
|
225
|
-
user_config = {SUBTRAC_ENV => @APP_CONFIG}
|
226
|
-
open(file_path, 'w') {|f| YAML.dump(user_config, f)}
|
50
|
+
Config.load()
|
227
51
|
end
|
228
52
|
|
229
53
|
# Install
|
@@ -235,7 +59,7 @@ module Subtrac
|
|
235
59
|
confirm_default_client = true
|
236
60
|
else
|
237
61
|
# check where we are installing
|
238
|
-
|
62
|
+
Config.confirm_or_update(:install_dir,"install_dir")
|
239
63
|
|
240
64
|
unless !File.directory?(install_dir)
|
241
65
|
# Ask if the user agrees (yes or no)
|
@@ -244,24 +68,24 @@ module Subtrac
|
|
244
68
|
end
|
245
69
|
|
246
70
|
# confirm server
|
247
|
-
|
71
|
+
Config.confirm_or_update(:server_name,"server_name")
|
248
72
|
|
249
73
|
# ask for hostname
|
250
|
-
|
74
|
+
Config.confirm_or_update(:server_hostname,"server_hostname")
|
251
75
|
|
252
76
|
# default client/project name
|
253
|
-
|
254
|
-
|
77
|
+
Config.confirm_or_update(:default_client,"default_client")
|
78
|
+
Config.confirm_or_update(:default_project,"default_project")
|
255
79
|
|
256
80
|
end
|
257
81
|
|
258
82
|
say("Ok we're about to install now, these are the options you have chosen:
|
259
|
-
installation directory: #{install_dir}
|
83
|
+
installation directory: #{Config.install_dir}
|
260
84
|
overwrite: #{overwrite}
|
261
|
-
server name: #{server_name}
|
262
|
-
server hostname: #{server_hostname}
|
263
|
-
default client: #{default_client}
|
264
|
-
default project: #{default_project}")
|
85
|
+
server name: #{Config.server_name}
|
86
|
+
server hostname: #{Config.server_hostname}
|
87
|
+
default client: #{Config.default_client}
|
88
|
+
default project: #{Config.default_project}")
|
265
89
|
|
266
90
|
confirm = agree("Is this ok? [y/n]")
|
267
91
|
|
@@ -270,42 +94,44 @@ module Subtrac
|
|
270
94
|
create_environment_directories(overwrite)
|
271
95
|
|
272
96
|
#create a new virtual host
|
273
|
-
apache = Apache.new
|
97
|
+
apache = Apache.new
|
274
98
|
apache.create_virtual_host()
|
275
99
|
|
276
100
|
# create the trac site
|
277
|
-
trac = Trac.new
|
101
|
+
trac = Trac.new
|
278
102
|
trac.install_common_files()
|
279
103
|
|
280
104
|
install_common_files()
|
281
105
|
configure_admin_user()
|
282
106
|
|
283
107
|
# create default project
|
284
|
-
create_project(default_project,default_client)
|
108
|
+
create_project(Config.default_project,Config.default_client)
|
285
109
|
|
286
110
|
# store any user preferences for later use
|
287
|
-
|
111
|
+
Config.save()
|
288
112
|
|
289
113
|
end
|
290
114
|
|
291
115
|
def self.create_project(project,client)
|
292
116
|
|
293
117
|
# create default project
|
294
|
-
project = Project.new(project,client,default_project_type)
|
118
|
+
project = Project.new(project,client,Config.default_project_type)
|
295
119
|
|
296
120
|
# get these out for binding...we'll tidy up later
|
297
|
-
client = project.client
|
121
|
+
#client = project.client
|
122
|
+
Config.project = project
|
123
|
+
Config.client = project.client
|
298
124
|
|
299
125
|
# create the svn repo
|
300
|
-
svn = Svn.new
|
126
|
+
svn = Svn.new
|
301
127
|
svn.create_project(project)
|
302
128
|
|
303
129
|
# create the trac site
|
304
|
-
trac = Trac.new
|
130
|
+
trac = Trac.new
|
305
131
|
trac.create_project(project)
|
306
132
|
|
307
133
|
# create the apache configuration
|
308
|
-
apache = Apache.new
|
134
|
+
apache = Apache.new
|
309
135
|
apache.create_project(project)
|
310
136
|
|
311
137
|
# fix privileges
|
@@ -317,53 +143,42 @@ module Subtrac
|
|
317
143
|
|
318
144
|
def self.give_apache_privileges
|
319
145
|
# make sure apache can operate on these files
|
320
|
-
`sudo chown -R www-data:www-data #{install_dir}`
|
321
|
-
end
|
322
|
-
|
323
|
-
# confirms the current value with the user or accepts a new value if required
|
324
|
-
def self.confirm_or_replace_value(prop, name)
|
325
|
-
method(prop).call # initialise the property
|
326
|
-
current_value = instance_variable_get("@#{prop}")
|
327
|
-
accept_default = agree("The default value for #{prop} @#{prop} is \"#{current_value}\". Is this ok? [y/n]")
|
328
|
-
if !accept_default then
|
329
|
-
answer = ask("What would you like to change it to?")
|
330
|
-
send("#{prop}=", answer)
|
331
|
-
#instance_variable_set(prop, answer)
|
332
|
-
end
|
146
|
+
`sudo chown -R www-data:www-data #{Config.install_dir}`
|
333
147
|
end
|
334
148
|
|
335
|
-
def self.install_common_files
|
149
|
+
def self.install_common_files
|
336
150
|
puts "\n==== Installing common files ===="
|
337
151
|
# TODO: implement a mask for .svn folders
|
338
152
|
# TODO: refactor /common to the app config
|
339
|
-
FileUtils.cp_r(Dir.glob(File.join(subtrac_path, "common/.")),docs_dir)
|
153
|
+
FileUtils.cp_r(Dir.glob(File.join(Config.subtrac_path, "common/.")),Config.docs_dir)
|
340
154
|
end
|
341
155
|
|
342
156
|
def self.configure_admin_user
|
343
157
|
puts "\n==== Configure admin user ===="
|
344
158
|
# create admin user
|
345
|
-
passwd_file = File.join(install_dir, ".passwd")
|
346
159
|
admin_user = ask("New admin user: ") { |q| q.echo = true }
|
347
160
|
admin_pass = ask("New password: ") { |q| q.echo = "*" }
|
348
161
|
admin_pass_confirm = ask("Re-type new password: ") { |q| q.echo = "*" }
|
349
162
|
if (admin_pass == admin_pass_confirm) then
|
163
|
+
passwd_file = File.join(Config.install_dir, ".passwd")
|
350
164
|
`htpasswd -c -b #{passwd_file} #{admin_user} #{admin_pass}`
|
351
|
-
|
352
|
-
|
165
|
+
Config.data[:admin_user] = admin_user
|
166
|
+
Config.data[:admin_pass] = admin_pass
|
353
167
|
# ensure this guy is added to trac admin group
|
354
|
-
|
168
|
+
Config.data[:trac][:permissions][admin_user] = "admins"
|
355
169
|
else
|
356
170
|
# call the password chooser again
|
171
|
+
configure_admin_user()
|
357
172
|
end
|
358
173
|
end
|
359
174
|
|
360
175
|
def self.create_environment_directories(overwrite=false)
|
361
176
|
puts "\n==== Creating new environment directories ===="
|
362
|
-
FileUtils.rm_rf install_dir if overwrite
|
363
|
-
File.create_if_missing install_dir
|
177
|
+
FileUtils.rm_rf Config.install_dir if overwrite
|
178
|
+
File.create_if_missing Config.install_dir
|
364
179
|
# create the environment directories
|
365
|
-
|
366
|
-
dir = File.join(install_dir,value)
|
180
|
+
Config.data[:dirs].each do |key, value|
|
181
|
+
dir = File.join(Config.install_dir,value)
|
367
182
|
File.create_if_missing dir
|
368
183
|
end
|
369
184
|
end
|
data/lib/subtrac/apache.rb
CHANGED
@@ -7,27 +7,26 @@ require 'subtrac/template'
|
|
7
7
|
|
8
8
|
module Subtrac
|
9
9
|
class Apache
|
10
|
-
def initialize
|
11
|
-
|
12
|
-
@subtrac_path = Subtrac::subtrac_path
|
13
|
-
@server_hostname = Subtrac::server_hostname
|
14
|
-
@locations_dir = Subtrac::locations_dir
|
15
|
-
@binding = binding
|
10
|
+
def initialize
|
11
|
+
|
16
12
|
end
|
17
13
|
def create_virtual_host()
|
18
14
|
puts "\n==== Creating new virtual host ===="
|
19
15
|
# TODO: Place a file in apache2 conf with Include directive which points to our conf folder
|
20
|
-
template =
|
21
|
-
template.write(File.join(
|
16
|
+
template = get_template("vhost.conf.erb")
|
17
|
+
template.write(File.join(Config.apache_conf_dir,Config.server_hostname))
|
18
|
+
puts("template written")
|
22
19
|
enable_site()
|
20
|
+
puts("enabled site")
|
23
21
|
force_reload()
|
22
|
+
puts("apache reloaded")
|
24
23
|
end
|
25
24
|
# creates the files necessary for a new client
|
26
25
|
def create_client(client)
|
27
|
-
client_config = File.join(
|
26
|
+
client_config = File.join(Config.locations_dir,"#{Config.client.path}.conf")
|
28
27
|
if (!File.exists?(client_config)) then
|
29
|
-
template =
|
30
|
-
template.write(client_config
|
28
|
+
template = get_template("location.conf.erb")
|
29
|
+
template.write(client_config)
|
31
30
|
force_reload()
|
32
31
|
end
|
33
32
|
end
|
@@ -37,11 +36,14 @@ module Subtrac
|
|
37
36
|
end
|
38
37
|
def enable_site
|
39
38
|
# tell apache enable site
|
40
|
-
`a2ensite #{
|
39
|
+
`a2ensite #{Config.server_hostname}` if SUBTRAC_ENV != 'test'
|
41
40
|
end
|
42
41
|
def create_project(project)
|
43
42
|
# we dont need to do anything for each project, but we do need to ensure a client location exists
|
44
43
|
create_client(project.client)
|
45
44
|
end
|
45
|
+
def get_template(name)
|
46
|
+
Template.new(File.join(File.dirname(__FILE__), "apache", name))
|
47
|
+
end
|
46
48
|
end
|
47
49
|
end
|
data/lib/subtrac/client.rb
CHANGED
data/lib/subtrac/config.rb
CHANGED
@@ -7,191 +7,271 @@ require 'fileutils'
|
|
7
7
|
|
8
8
|
module Subtrac
|
9
9
|
class Config
|
10
|
-
|
11
|
-
USER_CONFIG_FILE = 'config/user.yml'
|
10
|
+
class << self
|
12
11
|
|
13
|
-
|
14
|
-
|
15
|
-
|
12
|
+
USER_CONFIG_FILE = 'config/user.yml'
|
13
|
+
|
14
|
+
attr_accessor :data
|
15
|
+
|
16
|
+
def initialize()
|
17
|
+
puts "config/initialize"
|
18
|
+
end
|
19
|
+
|
20
|
+
def get_binding
|
21
|
+
binding
|
22
|
+
end
|
16
23
|
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
24
|
+
# Loads the configuration YML file
|
25
|
+
def load
|
26
|
+
# TODO: We need to refactor this code so it will load the default configuration only if one has not been created
|
27
|
+
puts "\n==== Loading configuration file ===="
|
28
|
+
# load configuration file
|
29
|
+
file_path = File.join(subtrac_path, USER_CONFIG_FILE)
|
30
|
+
file_path = File.join(subtrac_path,"/config/config.yml") if not File.exists?(file_path)
|
31
|
+
puts "Attempting to read config file: #{file_path}"
|
32
|
+
begin
|
33
|
+
yamlFile = YAML.load(File.read(file_path))
|
34
|
+
rescue Exception => e
|
35
|
+
raise StandardError, "Config #{file_path} could not be loaded."
|
36
|
+
end
|
37
|
+
if yamlFile
|
38
|
+
if yamlFile[SUBTRAC_ENV]
|
39
|
+
@APP_CONFIG = yamlFile[SUBTRAC_ENV]
|
40
|
+
@data = @APP_CONFIG # TODO: Deprecate APP_CONFIG
|
41
|
+
else
|
42
|
+
raise StandardError, "config/config.yml exists, but doesn't have a configuration for #{SUBTRAC_ENV}."
|
43
|
+
end
|
33
44
|
else
|
34
|
-
raise StandardError, "config/config.yml
|
45
|
+
raise StandardError, "config/config.yml does not exist."
|
35
46
|
end
|
36
|
-
|
37
|
-
raise StandardError, "config/config.yml does not exist."
|
47
|
+
say("Configuration loaded successfully...")
|
38
48
|
end
|
39
|
-
say("Configuration loaded successfully...")
|
40
|
-
end
|
41
49
|
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
50
|
+
# Write the changes configuration to disk
|
51
|
+
def save
|
52
|
+
# save the things that might have changed
|
53
|
+
file_path = File.join(subtrac_path, USER_CONFIG_FILE)
|
54
|
+
user_config = {SUBTRAC_ENV => @APP_CONFIG}
|
55
|
+
open(file_path, 'w') {|f| YAML.dump(user_config, f)}
|
56
|
+
end
|
49
57
|
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
58
|
+
# confirms the current value with the user or accepts a new value if required
|
59
|
+
def confirm_or_update(prop, name)
|
60
|
+
method(prop).call # initialise the property
|
61
|
+
current_value = instance_variable_get("@#{prop}")
|
62
|
+
accept_default = agree("The default value for #{prop} is \"#{current_value}\". Is this ok? [y/n]")
|
63
|
+
if !accept_default then
|
64
|
+
answer = ask("What would you like to change it to?")
|
65
|
+
send("#{prop}=", answer)
|
66
|
+
#instance_variable_set(prop, answer)
|
67
|
+
end
|
68
|
+
end
|
69
|
+
|
70
|
+
def project
|
71
|
+
@project
|
72
|
+
end
|
54
73
|
|
55
|
-
|
56
|
-
|
57
|
-
|
74
|
+
def project=(name)
|
75
|
+
@project = name
|
76
|
+
end
|
77
|
+
|
78
|
+
def client
|
79
|
+
@client
|
80
|
+
end
|
81
|
+
|
82
|
+
def client=(name)
|
83
|
+
@client = name
|
84
|
+
end
|
58
85
|
|
59
|
-
|
60
|
-
|
61
|
-
|
86
|
+
# User configured options
|
87
|
+
def server_name
|
88
|
+
@server_name ||= @APP_CONFIG[:server_name]
|
89
|
+
end
|
62
90
|
|
63
|
-
|
64
|
-
|
65
|
-
|
91
|
+
def server_name=(name)
|
92
|
+
@APP_CONFIG[:server_name] = @server_name = name
|
93
|
+
end
|
66
94
|
|
67
|
-
|
68
|
-
|
69
|
-
|
95
|
+
def server_hostname
|
96
|
+
@server_hostname ||= @APP_CONFIG[:server_hostname]
|
97
|
+
end
|
70
98
|
|
71
|
-
|
72
|
-
|
73
|
-
|
99
|
+
def server_hostname=(name)
|
100
|
+
@APP_CONFIG[:server_hostname] = @server_hostname = name
|
101
|
+
end
|
74
102
|
|
75
|
-
|
76
|
-
|
77
|
-
|
103
|
+
def default_client
|
104
|
+
@default_client ||= @APP_CONFIG[:default_client]
|
105
|
+
end
|
78
106
|
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
end
|
107
|
+
def default_client=(name)
|
108
|
+
@APP_CONFIG[:default_client] = @default_client = name
|
109
|
+
end
|
83
110
|
|
84
|
-
|
85
|
-
|
86
|
-
|
111
|
+
def default_project
|
112
|
+
@default_project ||= @APP_CONFIG[:default_project]
|
113
|
+
end
|
87
114
|
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
115
|
+
def default_project=(name)
|
116
|
+
puts "Updating default_project to #{name}"
|
117
|
+
@APP_CONFIG[:default_project] = @default_project = name
|
118
|
+
end
|
119
|
+
|
120
|
+
def default_project_type
|
121
|
+
@default_project_type ||= @APP_CONFIG[:default_project_type]
|
122
|
+
end
|
123
|
+
|
124
|
+
def default_project_type=(name)
|
125
|
+
puts "Updating default_project_type to #{name}"
|
126
|
+
@APP_CONFIG[:default_project_type] = @default_project_type = name
|
127
|
+
end
|
92
128
|
|
93
129
|
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
130
|
+
# Filesystem directories
|
131
|
+
def root
|
132
|
+
Pathname.new(SUBTRAC_ROOT) if defined?(SUBTRAC_ROOT)
|
133
|
+
end
|
98
134
|
|
99
|
-
|
100
|
-
|
101
|
-
|
135
|
+
def public_path
|
136
|
+
@public_path ||= self.root ? File.join(self.root, "public") : "public"
|
137
|
+
end
|
102
138
|
|
103
|
-
|
104
|
-
|
105
|
-
|
139
|
+
def public_path=(path)
|
140
|
+
@public_path = path
|
141
|
+
end
|
106
142
|
|
107
|
-
|
108
|
-
|
109
|
-
|
143
|
+
def subtrac_path
|
144
|
+
@subtrac_path ||= self.root ? File.join(self.root, "subtrac") : "subtrac"
|
145
|
+
end
|
110
146
|
|
111
|
-
|
112
|
-
|
113
|
-
|
147
|
+
def install_dir
|
148
|
+
@install_dir ||= File.expand_path(@APP_CONFIG[:installation_dir])
|
149
|
+
end
|
114
150
|
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
151
|
+
def install_dir=(name)
|
152
|
+
puts "Setting new install_dir variable to #{name}"
|
153
|
+
@APP_CONFIG[:installation_dir] = @install_dir = name
|
154
|
+
end
|
119
155
|
|
120
|
-
|
121
|
-
|
122
|
-
|
156
|
+
def apache_conf_dir
|
157
|
+
@apache_conf_dir ||= @APP_CONFIG[:apache_conf_dir]
|
158
|
+
end
|
123
159
|
|
124
|
-
|
125
|
-
|
126
|
-
|
160
|
+
def apache_conf_dir=(name)
|
161
|
+
@APP_CONFIG[:apache_conf_dir] = @apache_conf_dir = name
|
162
|
+
end
|
127
163
|
|
128
|
-
|
129
|
-
|
130
|
-
|
164
|
+
def docs_dir
|
165
|
+
@docs_dir ||= File.join(install_dir,@APP_CONFIG[:dirs][:docs])
|
166
|
+
end
|
131
167
|
|
132
|
-
|
133
|
-
|
134
|
-
|
168
|
+
def svn_dir
|
169
|
+
@svn_dir ||= File.join(install_dir,@APP_CONFIG[:dirs][:svn])
|
170
|
+
end
|
135
171
|
|
136
|
-
|
137
|
-
|
138
|
-
|
172
|
+
def trac_dir
|
173
|
+
@trac_dir ||= File.join(install_dir,@APP_CONFIG[:dirs][:trac])
|
174
|
+
end
|
139
175
|
|
140
|
-
|
141
|
-
|
142
|
-
|
176
|
+
def temp_dir
|
177
|
+
@temp_dir ||= File.join(install_dir,@APP_CONFIG[:dirs][:temp])
|
178
|
+
end
|
143
179
|
|
144
|
-
|
145
|
-
|
146
|
-
|
180
|
+
def log_dir
|
181
|
+
@log_dir ||= File.join(install_dir,@APP_CONFIG[:dirs][:log])
|
182
|
+
end
|
147
183
|
|
148
|
-
|
149
|
-
|
150
|
-
|
184
|
+
def locations_dir
|
185
|
+
@locations_dir ||= File.join(install_dir,@APP_CONFIG[:dirs][:locations])
|
186
|
+
end
|
151
187
|
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
188
|
+
# Urls
|
189
|
+
def svn_url
|
190
|
+
@svn_url ||= @APP_CONFIG[:urls][:svn]
|
191
|
+
end
|
156
192
|
|
157
|
-
|
158
|
-
|
159
|
-
|
193
|
+
def trac_permissions
|
194
|
+
@trac_permissions ||= @APP_CONFIG[:trac][:permissions]
|
195
|
+
end
|
160
196
|
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
|
197
|
+
# LDAP
|
198
|
+
def enable_ldap
|
199
|
+
@enable_ldap ||= @APP_CONFIG[:ldap][:enable]
|
200
|
+
end
|
165
201
|
|
166
|
-
|
167
|
-
|
168
|
-
|
202
|
+
def enable_ldap=(value)
|
203
|
+
@APP_CONFIG[:ldap][:enable] = @enable_ldap = value
|
204
|
+
end
|
169
205
|
|
170
|
-
|
171
|
-
|
172
|
-
|
206
|
+
def ldap_host
|
207
|
+
@ldap_host ||= @APP_CONFIG[:ldap][:host]
|
208
|
+
end
|
173
209
|
|
174
|
-
|
175
|
-
|
176
|
-
|
177
|
-
|
178
|
-
def ldap_bind_password
|
179
|
-
@ldap_bind_password ||= @APP_CONFIG[:ldap][:bind_password]
|
180
|
-
end
|
210
|
+
def ldap_host=(value)
|
211
|
+
@APP_CONFIG[:ldap][:host] = @ldap_host = value
|
212
|
+
end
|
181
213
|
|
182
|
-
|
183
|
-
|
184
|
-
|
185
|
-
|
186
|
-
def ldap_bind_host
|
187
|
-
@ldap_bind_host ||= @APP_CONFIG[:ldap][:bind_host]
|
188
|
-
end
|
214
|
+
def ldap_port
|
215
|
+
@ldap_port ||= @APP_CONFIG[:ldap][:port]
|
216
|
+
end
|
189
217
|
|
190
|
-
|
191
|
-
|
192
|
-
|
218
|
+
def ldap_port=(value)
|
219
|
+
@APP_CONFIG[:ldap][:port] = @ldap_port = value
|
220
|
+
end
|
221
|
+
|
222
|
+
def ldap_basedn
|
223
|
+
@ldap_basedn ||= @APP_CONFIG[:ldap][:basedn]
|
224
|
+
end
|
225
|
+
|
226
|
+
def ldap_basedn=(value)
|
227
|
+
@APP_CONFIG[:ldap][:basedn] = @ldap_basedn = value
|
228
|
+
end
|
193
229
|
|
230
|
+
def ldap_user_rdn
|
231
|
+
@ldap_user_rdn ||= @APP_CONFIG[:ldap][:user_rdn]
|
232
|
+
end
|
194
233
|
|
234
|
+
def ldap_user_rdn=(value)
|
235
|
+
@APP_CONFIG[:ldap][:user_rdn] = @ldap_user_rdn = value
|
236
|
+
end
|
237
|
+
|
238
|
+
def ldap_group_rdn
|
239
|
+
@ldap_group_rdn ||= @APP_CONFIG[:ldap][:group_rdn]
|
240
|
+
end
|
241
|
+
|
242
|
+
def ldap_group_rdn=(value)
|
243
|
+
@APP_CONFIG[:ldap][:group_rdn] = @ldap_group_rdn = value
|
244
|
+
end
|
245
|
+
|
246
|
+
def ldap_store_bind
|
247
|
+
@ldap_store_bind ||= @APP_CONFIG[:ldap][:store_bind]
|
248
|
+
end
|
249
|
+
|
250
|
+
def ldap_store_bind=(value)
|
251
|
+
@APP_CONFIG[:ldap][:store_bind] = @ldap_store_bind = value
|
252
|
+
end
|
253
|
+
|
254
|
+
def ldap_store_bind
|
255
|
+
@ldap_bind_password ||= @APP_CONFIG[:ldap][:bind_password]
|
256
|
+
end
|
257
|
+
|
258
|
+
def ldap_bind_user
|
259
|
+
@ldap_bind_user ||= @APP_CONFIG[:ldap][:bind_user]
|
260
|
+
end
|
261
|
+
|
262
|
+
def ldap_bind_user=(value)
|
263
|
+
@APP_CONFIG[:ldap][:bind_user] = @ldap_bind_user = value
|
264
|
+
end
|
265
|
+
|
266
|
+
def ldap_bind_passwd
|
267
|
+
@ldap_bind_passwd ||= @APP_CONFIG[:ldap][:bind_passwd]
|
268
|
+
end
|
269
|
+
|
270
|
+
def ldap_bind_passwd=(value)
|
271
|
+
@APP_CONFIG[:ldap][:bind_passwd] = @ldap_bind_passwd = value
|
272
|
+
end
|
273
|
+
|
274
|
+
end
|
195
275
|
|
196
276
|
end
|
197
277
|
end
|
data/lib/subtrac/svn.rb
CHANGED
@@ -8,12 +8,8 @@ require 'fileutils'
|
|
8
8
|
module Subtrac
|
9
9
|
class Svn
|
10
10
|
|
11
|
-
def initialize
|
12
|
-
|
13
|
-
@svn_dir = svn_dir
|
14
|
-
File.create_if_missing(@svn_dir)
|
15
|
-
@temp_dir = Subtrac::temp_dir
|
16
|
-
@binding = binding
|
11
|
+
def initialize
|
12
|
+
File.create_if_missing(Config.svn_dir)
|
17
13
|
end
|
18
14
|
|
19
15
|
# creates a new svn repository for the project
|
@@ -23,10 +19,10 @@ module Subtrac
|
|
23
19
|
client = project.client
|
24
20
|
|
25
21
|
# create the client folder
|
26
|
-
File.create_if_missing(File.join(
|
22
|
+
File.create_if_missing(File.join(Config.svn_dir,client.path))
|
27
23
|
|
28
24
|
# create the project folder
|
29
|
-
project.svn_dir = File.join(
|
25
|
+
project.svn_dir = File.join(Config.svn_dir,client.path,project.path)
|
30
26
|
|
31
27
|
# TODO: Need to handle this exception...
|
32
28
|
if (File.directory? project.svn_dir) then
|
@@ -40,7 +36,7 @@ module Subtrac
|
|
40
36
|
# copy template svn project to a temp folder, then svn import it into the repo
|
41
37
|
say("Create temporary project directory and copy template files...")
|
42
38
|
svn_template_dir = File.join(project.template,"svn")
|
43
|
-
project_temp_dir = File.join(
|
39
|
+
project_temp_dir = File.join(Config.temp_dir,project.path)
|
44
40
|
FileUtils.cp_r(svn_template_dir,project_temp_dir)
|
45
41
|
|
46
42
|
# import into svn
|
@@ -54,7 +50,6 @@ module Subtrac
|
|
54
50
|
`sudo chmod 770 #{project.svn_dir}`
|
55
51
|
`sudo chmod 755 #{project.svn_dir}/dav/activities`
|
56
52
|
`sudo chown www-data:www-data #{project.svn_dir}/dav/activities`
|
57
|
-
|
58
53
|
|
59
54
|
end
|
60
55
|
|
data/lib/subtrac/template.rb
CHANGED
@@ -1,15 +1,20 @@
|
|
1
|
+
require 'subtrac/config'
|
1
2
|
module Subtrac
|
2
3
|
class Template
|
3
4
|
def initialize(template)
|
4
5
|
@template = template
|
5
6
|
end
|
6
|
-
def render
|
7
|
-
|
7
|
+
def render
|
8
|
+
puts "Template rendering #{@template}"
|
9
|
+
b = Config.get_binding
|
10
|
+
ERB.new(IO.read(@template)).result(b)
|
8
11
|
end
|
9
|
-
def write(outfile
|
12
|
+
def write(outfile)
|
10
13
|
file = File.open(outfile, 'w+')
|
11
14
|
if file
|
12
|
-
|
15
|
+
file_output = render()
|
16
|
+
#puts file_output
|
17
|
+
file.syswrite(file_output)
|
13
18
|
else
|
14
19
|
raise "Unable to open file for writing. file #{outfile}"
|
15
20
|
end
|
data/lib/subtrac/trac.rb
CHANGED
@@ -5,31 +5,28 @@
|
|
5
5
|
|
6
6
|
require 'fileutils'
|
7
7
|
require 'subtrac/template'
|
8
|
+
require 'subtrac/config'
|
8
9
|
|
9
10
|
module Subtrac
|
10
11
|
class Trac
|
11
12
|
|
12
|
-
def initialize
|
13
|
-
|
14
|
-
@subtrac_path = Subtrac::subtrac_path
|
15
|
-
@trac_permissions = Subtrac::trac_permissions
|
16
|
-
@temp_dir = Subtrac::temp_dir
|
17
|
-
@binding = binding
|
13
|
+
def initialize
|
14
|
+
File.create_if_missing(Config.trac_dir)
|
18
15
|
end
|
19
16
|
|
20
17
|
# Install the shared trac.ini file
|
21
18
|
def install_common_files
|
22
|
-
File.create_if_missing(File.join(
|
19
|
+
File.create_if_missing(File.join(Config.trac_dir, ".shared"))
|
23
20
|
# install trac.ini
|
24
21
|
trac_ini_template = Template.new(File.join(File.dirname(__FILE__), "trac", "common.trac.ini.erb"))
|
25
|
-
trac_ini_template.write(File.join(
|
22
|
+
trac_ini_template.write(File.join(Config.trac_dir,".shared","trac.ini"))
|
26
23
|
end
|
27
24
|
|
28
25
|
def create_project(project)
|
29
26
|
|
30
27
|
client = project.client
|
31
28
|
|
32
|
-
project.trac_dir = File.join(
|
29
|
+
project.trac_dir = File.join(Config.trac_dir,client.path,project.path)
|
33
30
|
|
34
31
|
# create new project directories
|
35
32
|
say("Create project directories...")
|
@@ -43,11 +40,11 @@ module Subtrac
|
|
43
40
|
say("Installing trac configuration...")
|
44
41
|
# install project trac.ini
|
45
42
|
trac_ini_template = Template.new(File.join(File.dirname(__FILE__), "trac", "trac.ini.erb"))
|
46
|
-
trac_ini_template.write(File.join(project.trac_dir,"/conf/trac.ini")
|
43
|
+
trac_ini_template.write(File.join(project.trac_dir,"/conf/trac.ini"))
|
47
44
|
|
48
45
|
say("Setting up default trac permissions...")
|
49
46
|
# set up trac permissions
|
50
|
-
|
47
|
+
Config.trac_permissions.each do |key, value|
|
51
48
|
`sudo trac-admin #{project.trac_dir} permission add #{key} #{value}`
|
52
49
|
end
|
53
50
|
|
@@ -56,9 +53,9 @@ module Subtrac
|
|
56
53
|
Dir.foreach("#{project.template}/trac/wiki/.") do |file|
|
57
54
|
# do something with the file here
|
58
55
|
unless ['.', '..','.svn'].include? file
|
59
|
-
temp_file = File.join(
|
56
|
+
temp_file = File.join(Config.temp_dir,file)
|
60
57
|
template = Template.new(File.join(project.template,"trac/wiki",file))
|
61
|
-
template.write(temp_file
|
58
|
+
template.write(temp_file)
|
62
59
|
`trac-admin #{project.trac_dir} wiki import #{file} #{temp_file}`
|
63
60
|
FileUtils.rm(temp_file)
|
64
61
|
end
|
@@ -22,16 +22,16 @@ width = -1
|
|
22
22
|
[trac]
|
23
23
|
repository_dir = ../../../svn/<%= client.path %>/<%= project.path %>
|
24
24
|
|
25
|
-
<% if
|
25
|
+
<% if enable_ldap then %>
|
26
26
|
[ldap]
|
27
|
-
enable =
|
28
|
-
host = <%=
|
29
|
-
port = <%=
|
30
|
-
basedn = <%=
|
31
|
-
user_rdn = <%=
|
32
|
-
group_rdn = <%=
|
33
|
-
store_bind = <%=
|
34
|
-
group_bind = <%=
|
35
|
-
bind_user = <%=
|
36
|
-
bind_passwd = <%=
|
27
|
+
enable = enable_ldap %>
|
28
|
+
host = <%= ldap_host %>
|
29
|
+
port = <%= ldap_port %>
|
30
|
+
basedn = <%= ldap_basedn %>
|
31
|
+
user_rdn = <%= ldap_user_rdn %>
|
32
|
+
group_rdn = <%= ldap_group_rdn %>
|
33
|
+
store_bind = <%= ldap_store_bind %>
|
34
|
+
group_bind = <%= ldap_group_bind %>
|
35
|
+
bind_user = <%= ldap_bind_user %>
|
36
|
+
bind_passwd = <%= ldap_bind_passwd %>
|
37
37
|
<% end %>
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ktec-subtrac
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.44
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Keith Salisbury
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2009-05-
|
12
|
+
date: 2009-05-03 00:00:00 -07:00
|
13
13
|
default_executable: subtrac
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|