Class: UcbDeployer::ConfluenceDeployer

Inherits:
Deployer
  • Object
show all
Defined in:
lib/ucb_deployer/confluence_deployer.rb

Constant Summary

Constants inherited from Deployer

Deployer::CONFIG_OPTIONS

Instance Attribute Summary

Attributes inherited from Deployer

#debug_mode, #version

Instance Method Summary collapse

Methods inherited from Deployer

#debug, #disable_web, #enable_web, #info, #load_config, #maintenance_template

Constructor Details

#initialize(config_file = "#{ENV['HOME']}/.ucb_deployer/config/confluence/deploy.yml") ⇒ ConfluenceDeployer

Returns a new instance of ConfluenceDeployer.



5
6
7
8
9
# File 'lib/ucb_deployer/confluence_deployer.rb', line 5

def initialize(config_file = "#{ENV['HOME']}/.ucb_deployer/config/confluence/deploy.yml")
  debug("Using config file: #{config_file}")
  debug("")
  load_config(config_file)
end

Instance Method Details

#buildObject



29
30
31
32
33
# File 'lib/ucb_deployer/confluence_deployer.rb', line 29

def build()
  Dir.chdir("#{build_dir}/src") do
    `sh #{build_dir}/src/build.sh`
  end
end

#cas_authenticator_classObject



88
89
90
# File 'lib/ucb_deployer/confluence_deployer.rb', line 88

def cas_authenticator_class()
  "org.soulwing.cas.apps.atlassian.ConfluenceCasAuthenticator"
end

#config_confluence_init_propertiesObject

Sets the confluence.home property in the file: confluence-init.properties.



138
139
140
141
142
# File 'lib/ucb_deployer/confluence_deployer.rb', line 138

def config_confluence_init_properties()
  File.open(self.confluence_init_properties, "w") do |io|
    io.puts("confluence.home=#{data_dir}")
  end
end

#config_seraph_config_xmlObject

Updates the confluence seraph_config.xml file with the soulwing authenticator.



117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
# File 'lib/ucb_deployer/confluence_deployer.rb', line 117

def config_seraph_config_xml()
  seraph_xml = File.readlines(self.seraph_config_xml)
  
  seraph_xml = seraph_xml.map do |line|
    if m = /(#{Regexp.quote(seraph_config_xml_token)})/.match(line)
      debug(m[0])
      debug("#{m.pre_match}#{cas_authenticator_class}#{m.post_match}")
      "#{m.pre_match}#{cas_authenticator_class}#{m.post_match}"
    else
      line
    end
  end
  
  File.open(self.seraph_config_xml, "w") do |io|
    seraph_xml.each { |line| io.puts(line) }
  end
end

#config_web_xmlObject

Updates the confluence web.xml file with the soulwing (CAS library) authentication configuration



96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
# File 'lib/ucb_deployer/confluence_deployer.rb', line 96

def config_web_xml()
  web_xml = File.readlines(self.web_xml)
  
  web_xml = web_xml.map do |line|
    if line =~ /#{web_xml_token}/
      template = File.open("#{DEPLOYER_HOME}/resources/confluence_cas_web.xml") { |f| f.read }
      ERB.new(template).result(self.send(:binding))
    else
      line
    end
  end
  
  File.open(self.web_xml, "w") do |io|
    web_xml.each { |line| io.puts(line) }
  end
end

#config_xwork_xmlObject

Alter xwork.xml so soulwing authenticator works with CAS



154
155
156
157
158
159
# File 'lib/ucb_deployer/confluence_deployer.rb', line 154

def config_xwork_xml()
  template = File.open("#{UcbDeployer::RESOURCES_DIR}/xwork.xml") { |f| f.read }
  xml = ERB.new(template).result(self.send(:binding))
  FileUtils.touch(xwork_xml())
  File.open(xwork_xml(), "w") { |io| io.puts(xml) }
end

#configureObject



21
22
23
24
25
26
27
# File 'lib/ucb_deployer/confluence_deployer.rb', line 21

def configure()
  config_web_xml()
  config_seraph_config_xml()
  config_confluence_init_properties()
  config_xwork_xml()
  reshuffle_jars()
end

#confluence_init_propertiesObject

Shortcut to confluence confluence-init.properties file



76
77
78
# File 'lib/ucb_deployer/confluence_deployer.rb', line 76

def confluence_init_properties()
  "#{build_dir}/src/confluence/WEB-INF/classes/confluence-init.properties"
end

#deployObject



35
36
37
38
39
40
41
42
43
44
45
46
# File 'lib/ucb_deployer/confluence_deployer.rb', line 35

def deploy()
  if File.exists?("#{deploy_dir}/#{war_name}")
    FileUtils.rm_rf(Dir["#{deploy_dir}/#{war_name}"])
  end

  FileUtils.mkdir("#{deploy_dir}/#{war_name}")
  FileUtils.mv("#{build_dir}/src/dist/confluence-#{version}.war",
               "#{deploy_dir}/#{war_name}/#{war_name}.war")

  `cd #{deploy_dir}/#{war_name}/ && jar -xvf #{war_name}.war`
  FileUtils.rm("#{deploy_dir}/#{war_name}/#{war_name}.war")
end

#exportObject



11
12
13
14
15
16
17
18
19
# File 'lib/ucb_deployer/confluence_deployer.rb', line 11

def export()
  UcbDeployer.debug("Exporting from: #{svn_project_url}/confluence-#{version}")
  Dir.chdir("#{build_dir}") do
    FileUtils.rm_rf("#{build_dir}/src")
    `svn export #{svn_project_url}/confluence-#{version}`
    FileUtils.mv("confluence-#{version}", "src")
  end
  $stdout.puts("Export Completed")
end

#reshuffle_jarsObject

Remove application jars that have been installed at the container level.



164
165
166
167
168
169
170
171
# File 'lib/ucb_deployer/confluence_deployer.rb', line 164

def reshuffle_jars()
  FileUtils.cp(Dir["#{UcbDeployer::RESOURCES_DIR}/soulwing-casclient-*"],
               "#{build_dir}/src/confluence/WEB-INF/lib/")
  # Remove the jars that are installed at the container level
  ["postgresql", "activation", "mail"].each do |jar|
    FileUtils.rm_rf(Dir["#{build_dir}/src/confluence/WEB-INF/lib/#{jar}-*"])
  end
end

#rollbackObject



48
49
# File 'lib/ucb_deployer/confluence_deployer.rb', line 48

def rollback()
end

#seraph_config_xmlObject

Shortcut to confluence seraph-config.xml file



69
70
71
# File 'lib/ucb_deployer/confluence_deployer.rb', line 69

def seraph_config_xml()
  "#{build_dir}/src/confluence/WEB-INF/classes/seraph-config.xml"
end

#seraph_config_xml_tokenObject



84
85
86
# File 'lib/ucb_deployer/confluence_deployer.rb', line 84

def seraph_config_xml_token()
  "com.atlassian.confluence.user.ConfluenceAuthenticator"
end

#svn_base_urlObject



55
56
57
# File 'lib/ucb_deployer/confluence_deployer.rb', line 55

def svn_base_url()
  @svn_base_url || "svn.berkeley.edu/svn/ist-svn/berkeley/projects/ist/as/webapps/confluence_archives"
end

#svn_usernameObject



51
52
53
# File 'lib/ucb_deployer/confluence_deployer.rb', line 51

def svn_username()
  @svn_username || "app_relmgt"
end

#web_xmlObject

Shortcut to confluence web.xml file



62
63
64
# File 'lib/ucb_deployer/confluence_deployer.rb', line 62

def web_xml()
  "#{build_dir}/src/confluence/WEB-INF/web.xml"
end

#web_xml_tokenObject



80
81
82
# File 'lib/ucb_deployer/confluence_deployer.rb', line 80

def web_xml_token()
  "<!-- Uncomment the following to disable the space export long running task. -->"
end

#xwork_xmlObject

Shortcut to xwork.xml file



147
148
149
# File 'lib/ucb_deployer/confluence_deployer.rb', line 147

def xwork_xml()
  "#{build_dir}/src/confluence/WEB-INF/classes/xwork.xml"
end