ucb_deployer 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
data/Manifest ADDED
@@ -0,0 +1,19 @@
1
+ README.txt
2
+ Rakefile
3
+ bin/deployer
4
+ cas_web.xml
5
+ lib/confluence_deployer.rb
6
+ spec/build/confluence/lib/soulwing-casclient-x.x.x.jar
7
+ spec/build/confluence/src/confluence/WEB-INF/classes/confluence-init.properties
8
+ spec/build/confluence/src/confluence/WEB-INF/classes/seraph-config.xml
9
+ spec/build/confluence/src/confluence/WEB-INF/lib/postgresql-x.x.x.jar
10
+ spec/build/confluence/src/confluence/WEB-INF/lib/soulwing-casclient-x.x.x.jar
11
+ spec/build/confluence/src/confluence/WEB-INF/web.xml
12
+ spec/confluence_deployer/confluence_deployer_spec.rb
13
+ spec/fixtures/bad_dot_cdeprc
14
+ spec/fixtures/confluence-init.properties
15
+ spec/fixtures/dot_cdeprc
16
+ spec/fixtures/seraph-config.xml
17
+ spec/fixtures/web.xml
18
+ spec/spec_helper.rb
19
+ Manifest
data/README.txt ADDED
File without changes
data/Rakefile ADDED
@@ -0,0 +1,22 @@
1
+ require 'rubygems'
2
+ require 'rake'
3
+ require 'echoe'
4
+ require 'spec/rake/spectask'
5
+
6
+ Echoe.new('ucb_deployer', '0.0.1') do |p|
7
+ p.description = "Tool for deploying java applications"
8
+ p.url = "http://ucbrb.rubyforge.org"
9
+ p.author = "Steven Hansen"
10
+ p.email = "runner@berkeley.edu"
11
+ p.ignore_pattern = ["svn_user.yml", "svn_project.rake"]
12
+ p.project = "ucbrb"
13
+ p.rdoc_pattern = "README.txt", "lib/**/**"
14
+ # p.rdoc_options = "-o doc --inline-source -T hanna lib/*.rb"
15
+ end
16
+
17
+ desc "Run RSpec tests"
18
+ Spec::Rake::SpecTask.new(:spec) do |t|
19
+ t.spec_files = FileList['spec/*_spec.rb']
20
+ t.spec_opts = ["--format", "s", "--colour"]
21
+ end
22
+
data/bin/deployer ADDED
@@ -0,0 +1,36 @@
1
+ #!/usr/bin/env ruby
2
+ require 'rake'
3
+ require 'confluence_deployer'
4
+
5
+ Rake.application.init("deployer")
6
+
7
+ task :deploy => [:build] do
8
+ @deployer.deploy()
9
+ end
10
+
11
+ task :build => [:configure] do
12
+ @deployer.build()
13
+ end
14
+
15
+ task :configure => [:export] do
16
+ @deployer.configure()
17
+ end
18
+
19
+ task :export => [:init] do
20
+ @deployer.export()
21
+ end
22
+
23
+ task :init => [:check_usage] do
24
+ # @deployer = Deployer.factory(:confluence)
25
+ @deployer = ConfluenceDeployer.new()
26
+ @deployer.version = ENV["VERSION"]
27
+ end
28
+
29
+ task :check_usage do
30
+ if ENV["VERSION"].nil?
31
+ $stderr.puts("Usage: rake deploy VERSION=x.x.x")
32
+ exit(1)
33
+ end
34
+ end
35
+
36
+ Rake.application.top_level
data/cas_web.xml ADDED
@@ -0,0 +1,100 @@
1
+
2
+ <context-param>
3
+ <param-name>casServerUrl</param-name>
4
+ <param-value><%= cas_server_url %></param-value>
5
+ </context-param>
6
+ <context-param>
7
+ <param-name>casServiceUrl</param-name>
8
+ <param-value><%= cas_service_url %></param-value>
9
+ </context-param>
10
+
11
+ <listener>
12
+ <listener-class>org.soulwing.cas.filter.ProtocolConfigurationListener</listener-class>
13
+ </listener>
14
+
15
+ <filter>
16
+ <filter-name>CAS-Session-Bypass</filter-name>
17
+ <filter-class>org.soulwing.cas.filter.SessionBypassFilter</filter-class>
18
+ <init-param>
19
+ <param-name>logoutPath</param-name>
20
+ <param-value>/logout.action</param-value>
21
+ </init-param>
22
+ <init-param>
23
+ <param-name>applicationLogout</param-name>
24
+ <param-value>true</param-value>
25
+ </init-param>
26
+ <init-param>
27
+ <param-name>globalLogout</param-name>
28
+ <param-value>true</param-value>
29
+ </init-param>
30
+ <init-param>
31
+ <param-name>bypassPaths</param-name>
32
+ <param-value>
33
+ /sr/jira.issueviews:searchrequest*
34
+ </param-value>
35
+ </init-param>
36
+ </filter>
37
+
38
+ <filter>
39
+ <filter-name>CAS-Simple-Bypass</filter-name>
40
+ <filter-class>org.soulwing.cas.filter.SimpleBypassFilter</filter-class>
41
+ <init-param>
42
+ <param-name>bypassPaths</param-name>
43
+ <param-value>
44
+ /logout.action, /rpc/*, /images/*, /styles/*, /createrssfeed.action
45
+ </param-value>
46
+ </init-param>
47
+ </filter>
48
+
49
+ <filter>
50
+ <filter-name>CAS-Service-Validation</filter-name>
51
+ <filter-class>org.soulwing.cas.filter.ServiceValidationFilter</filter-class>
52
+ <init-param>
53
+ <param-name>filterPath</param-name>
54
+ <param-value>/login.action</param-value>
55
+ </init-param>
56
+ <init-param>
57
+ <param-name>postValidationRedirectParameter</param-name>
58
+ <param-value>os_destination</param-value>
59
+ </init-param>
60
+ </filter>
61
+
62
+ <filter>
63
+ <filter-name>CAS-Logout</filter-name>
64
+ <filter-class>
65
+ org.soulwing.cas.filter.LogoutFilter
66
+ </filter-class>
67
+ <init-param>
68
+ <param-name>logoutPath</param-name>
69
+ <param-value>/logout.action</param-value>
70
+ </init-param>
71
+ <init-param>
72
+ <param-name>applicationLogout</param-name>
73
+ <param-value>true</param-value>
74
+ </init-param>
75
+ <init-param>
76
+ <param-name>globalLogout</param-name>
77
+ <param-value>false</param-value>
78
+ </init-param>
79
+ </filter>
80
+
81
+ <filter-mapping>
82
+ <filter-name>CAS-Logout</filter-name>
83
+ <url-pattern>/*</url-pattern>
84
+ </filter-mapping>
85
+
86
+ <filter-mapping>
87
+ <filter-name>CAS-Session-Bypass</filter-name>
88
+ <url-pattern>/*</url-pattern>
89
+ </filter-mapping>
90
+
91
+ <filter-mapping>
92
+ <filter-name>CAS-Simple-Bypass</filter-name>
93
+ <url-pattern>/*</url-pattern>
94
+ </filter-mapping>
95
+
96
+ <filter-mapping>
97
+ <filter-name>CAS-Service-Validation</filter-name>
98
+ <url-pattern>/*</url-pattern>
99
+ </filter-mapping>
100
+
@@ -0,0 +1,228 @@
1
+ require 'yaml'
2
+ require 'net/http'
3
+ require 'erb'
4
+
5
+ class ConfluenceDeployer
6
+ class ConfigError < RuntimeError; end
7
+
8
+ DEPLOYER_HOME = File.expand_path(File.dirname(__FILE__) + '/..') unless defined?(DEPLOYER_HOME)
9
+ CONFIG_OPTIONS = [
10
+ :build_dir,
11
+ :deploy_dir,
12
+ :war_name,
13
+ :cas_service_url,
14
+ :cas_server_url,
15
+ :confluence_home_dir,
16
+ :svn_username,
17
+ :svn_project_url,
18
+ ]
19
+
20
+ attr_accessor *CONFIG_OPTIONS
21
+ attr_accessor :version, :debug_mode
22
+
23
+ def initialize(config_file = "~/cdeprc")
24
+ FileUtils.touch(config_file) if !File.exists?(config_file)
25
+ load_config(config_file)
26
+ end
27
+
28
+ ##
29
+ # Configuration options are:
30
+ #
31
+ # +build_dir+
32
+ # +deploy_dir+
33
+ # +war_name+
34
+ # +svn_project_url+
35
+ # +svn_username+
36
+ # +cas_service_url+
37
+ # +cas_server_url+
38
+ # +confluence_home_dir+
39
+ #
40
+ def load_config(config_file)
41
+ hash = YAML.load_file(config_file)
42
+ hash.each do |k, v|
43
+ CONFIG_OPTIONS.include?(k.to_sym) ? self.send("#{k}=", v) : raise(ConfigError, "Unrecognized Option: #{k}")
44
+ end
45
+ end
46
+
47
+ def export()
48
+ debug("Exporting from: #{svn_project_url}")
49
+ pwd = Dir.getwd
50
+ Dir.chdir("#{build_dir}/confluence")
51
+ `svn export svn+ssh://#{svn_username}@#{svn_project_url}/confluence-#{version}`
52
+ FileUtils.mv("confluence-#{version}", "src")
53
+ Dir.chdir(pwd)
54
+ $stdout.puts("Export Completed")
55
+ end
56
+
57
+ def configure
58
+ config_web_xml
59
+ config_seraph_config_xml
60
+ config_confluence_init_properties
61
+ reshuffle_jars
62
+ end
63
+
64
+ def build
65
+ exec("sh #{build_dir}/confluence/src/build.sh")
66
+ end
67
+
68
+ def deploy
69
+ display_maintenance_file
70
+ FileUtils.rm_rf(Dir["#{deploy_dir}/#{war_name}*"])
71
+ FileUtils.mkdir("#{deploy_dir}/#{war_name}")
72
+ FileUtils.cp(Dir["#{build_dir}/confluence/src/dist/*.war"], "#{deploy_dir}/#{war_name}")
73
+ exec("jar -xvf #{deploy_dir}/#{war_name}/#{war_name}.war")
74
+ FileUtils.rm("#{deploy_dir}/#{war_name}/#{war_name}.war")
75
+ end
76
+
77
+ def rollback
78
+ end
79
+
80
+ def svn_username
81
+ @svn_username || "app_relmgt"
82
+ end
83
+
84
+ def svn_base_url
85
+ @svn_base_url || "svn.berkeley.edu/svn/ist-svn/berkeley/projects/ist/as/webapps/confluence_archives"
86
+ end
87
+
88
+ ##
89
+ # Shortcut to confluence web.xml file
90
+ #
91
+ def web_xml()
92
+ "#{build_dir}/confluence/src/confluence/WEB-INF/web.xml"
93
+ end
94
+
95
+ ##
96
+ # Shortcut to confluence seraph-config.xml file
97
+ #
98
+ def seraph_config_xml()
99
+ "#{build_dir}/confluence/src/confluence/WEB-INF/classes/seraph-config.xml"
100
+ end
101
+
102
+ ##
103
+ # Shortcut to confluence confluence-init.properties file
104
+ #
105
+ def confluence_init_properties()
106
+ "#{build_dir}/confluence/src/confluence/WEB-INF/classes/confluence-init.properties"
107
+ end
108
+
109
+ def web_xml_token()
110
+ "<!-- Uncomment the following to disable the space export long running task. -->"
111
+ end
112
+
113
+ def seraph_config_xml_token()
114
+ "com.atlassian.confluence.user.ConfluenceAuthenticator"
115
+ end
116
+
117
+ def cas_authenticator_class()
118
+ "org.soulwing.cas.apps.atlassian.ConfluenceCasAuthenticator"
119
+ end
120
+
121
+ ##
122
+ # Updates the confluence web.xml file with the soulwing (CAS library)
123
+ # authentication configuration
124
+ #
125
+ def config_web_xml()
126
+ web_xml = File.readlines(self.web_xml)
127
+
128
+ web_xml = web_xml.map do |line|
129
+ if line =~ /#{web_xml_token}/
130
+ template = File.open("#{DEPLOYER_HOME}/cas_web.xml") { |f| f.read }
131
+ ERB.new(template).result(self.send(:binding))
132
+ else
133
+ line
134
+ end
135
+ end
136
+
137
+ File.open(self.web_xml, "w") do |io|
138
+ web_xml.each { |line| io.puts(line) }
139
+ end
140
+ end
141
+
142
+ ##
143
+ # Updates the confluence seraph_config.xml file with the soulwing
144
+ # authenticator.
145
+ #
146
+ def config_seraph_config_xml()
147
+ seraph_xml = File.readlines(self.seraph_config_xml)
148
+
149
+ seraph_xml = seraph_xml.map do |line|
150
+ if m = /(#{Regexp.quote(seraph_config_xml_token)})/.match(line)
151
+ puts m[0]
152
+ puts "#{m.pre_match}#{cas_authenticator_class}#{m.post_match}"
153
+ "#{m.pre_match}#{cas_authenticator_class}#{m.post_match}"
154
+ else
155
+ line
156
+ end
157
+ end
158
+
159
+ File.open(self.seraph_config_xml, "w") do |io|
160
+ seraph_xml.each { |line| io.puts(line) }
161
+ end
162
+ end
163
+
164
+ ##
165
+ # Sets the confluence.home property in the file: confluence-init.properties
166
+ #
167
+ def config_confluence_init_properties()
168
+ File.open(self.confluence_init_properties, "w") { |io| io.puts("confluence.home=#{confluence_home_dir}") }
169
+ end
170
+
171
+ def reshuffle_jars()
172
+ FileUtils.cp(Dir["#{build_dir}/confluence/lib/soulwing-casclient-*"],
173
+ "#{build_dir}/confluence/src/confluence/WEB-INF/lib")
174
+ FileUtils.rm_rf(Dir["#{build_dir}/confluence/src/confluence/WEB-INF/lib/postgresql-*"])
175
+ end
176
+
177
+ def debug(str)
178
+ if debug_mode
179
+ $stdout.puts(str)
180
+ end
181
+ end
182
+
183
+ def display_maintenance_file()
184
+ maint_start = Time.now.strftime("%m-%d-%Y %H:%M:%S")
185
+ template = ERB.new(maintenance_template)
186
+ File.open("/var/www/html/confluence/maintenance.html", "w") do |f|
187
+ f.puts template.result(binding)
188
+ end
189
+ end
190
+
191
+ def maintenance_template()
192
+ %q{
193
+ <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
194
+ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
195
+
196
+ <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
197
+
198
+ <head>
199
+ <meta http-equiv="content-type" content="text/html; charset=UTF-8" />
200
+ <title>Site Maintenance<title>
201
+ <style type="text/css">
202
+ body { background-color: #fff; color: #666; text-align: center; font-family: arial, sans-serif; }
203
+ div.dialog {
204
+ width: 35em;
205
+ padding: 0 3em;
206
+ margin: 3em auto 0 auto;
207
+ border: 1px solid #ccc;
208
+ border-right-color: #999;
209
+ border-bottom-color: #999;
210
+ }
211
+ h1 { font-size: 100%; color: #f00; line-height: 1.5em; }
212
+ </style>
213
+ </head>
214
+
215
+ <body>
216
+ <div class="dialog">
217
+ <h1>Site Maintenance</h1>
218
+ <p>
219
+ The site is down for maintenance as of: <strong><%= maint_start %></strong> <br/>
220
+ it should be available shortly.
221
+ </p>
222
+ </div>
223
+ </body>
224
+ </html>
225
+ }
226
+ end
227
+
228
+ end
@@ -0,0 +1,41 @@
1
+ # This file allows you to set the directory for Confluence to store its configuration files.
2
+ #
3
+ ###########################
4
+ # Note for Windows Users #
5
+ ###########################
6
+ #
7
+ # Each backslash in your path must be written as a forward slash.
8
+ # - For example:
9
+ # c:\confluence\data
10
+ #
11
+ # should be written as:
12
+ #
13
+ # c:/confluence/data
14
+
15
+ ###########################
16
+ # Note for Unix Users #
17
+ ###########################
18
+ # - For example:
19
+ # confluence.home=/var/confluence
20
+ #
21
+ # NOTE: If the path of your confluence.home directory contains symlinks,
22
+ # please set confluence.home to the absolute path, otherwise problems may occur.
23
+ # - For example:
24
+ # confluence.home=/data/confluence/ (where /data is a symlink to -> /var/data/)
25
+ # should be written as:
26
+ # confluence.home=/var/data/confluence/
27
+
28
+ ###########################
29
+ # Configuration Directory #
30
+ ###########################
31
+
32
+ # specify your directory below (don't forget to remove the '#' in front)
33
+
34
+ # confluence.home=c:/confluence/data
35
+
36
+ ###########################
37
+ # Daily Backups Directory #
38
+ ###########################
39
+
40
+ ## Set this to true to enable setting of the daily backups directory in the admin section.
41
+ #confluence.backup.path.set.allowed=false
@@ -0,0 +1,46 @@
1
+ <security-config>
2
+ <parameters>
3
+ <init-param>
4
+ <param-name>login.url</param-name>
5
+ <param-value>/login.action?os_destination=${originalurl}</param-value>
6
+ </init-param>
7
+ <init-param>
8
+ <param-name>link.login.url</param-name>
9
+ <param-value>/login.action</param-value>
10
+ </init-param>
11
+ <init-param>
12
+ <param-name>cookie.encoding</param-name>
13
+ <param-value>cNf</param-value>
14
+ </init-param>
15
+ <init-param>
16
+ <param-name>login.cookie.key</param-name>
17
+ <param-value>seraph.confluence</param-value>
18
+ </init-param>
19
+
20
+ <!--only basic authentication available-->
21
+ <init-param>
22
+ <param-name>authentication.type</param-name>
23
+ <param-value>os_authType</param-value>
24
+ </init-param>
25
+ </parameters>
26
+
27
+ <rolemapper class="com.atlassian.confluence.security.ConfluenceRoleMapper"/>
28
+ <controller class="com.atlassian.confluence.setup.seraph.ConfluenceSecurityController"/>
29
+ <authenticator class="com.atlassian.confluence.user.ConfluenceAuthenticator"/>
30
+
31
+ <services>
32
+ <service class="com.atlassian.seraph.service.PathService">
33
+ <init-param>
34
+ <param-name>config.file</param-name>
35
+ <param-value>seraph-paths.xml</param-value>
36
+ </init-param>
37
+ </service>
38
+ </services>
39
+
40
+ <elevatedsecurityguard class="com.atlassian.confluence.security.seraph.ConfluenceElevatedSecurityGuard"/>
41
+
42
+ <interceptors>
43
+ <interceptor name="session-invalidator" class="com.atlassian.confluence.security.seraph.SessionInvalidatingLoginInterceptor"/>
44
+ <interceptor name="login-logger" class="com.atlassian.confluence.user.ConfluenceLoginInterceptor"/>
45
+ </interceptors>
46
+ </security-config>