OW2 Consortium elastic-grid

Rev

Rev 472 | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
445 jeje 1
/**
2
 * Elastic Grid
530 jeje 3
 * Copyright (C) 2008-2010 Elastic Grid, LLC.
445 jeje 4
 *
5
 * This program is free software: you can redistribute it and/or modify
6
 * it under the terms of the GNU Affero General Public License as
7
 * published by the Free Software Foundation, either version 3 of the
8
 * License, or (at your option) any later version.
9
 *
10
 * This program is distributed in the hope that it will be useful,
11
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13
 * GNU Affero General Public License for more details.
14
 *
15
 * You should have received a copy of the GNU Affero General Public License
16
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
17
 */
10 jeje 18
package com.elasticgrid.substrates.tomcat6
19
 
20
import com.elasticgrid.substrates.AbstractSubstrate
21
import groovy.xml.MarkupBuilder
18 jeje 22
import com.elasticgrid.substrates.FirewallRule
23
import com.elasticgrid.substrates.FirewallRule.IpProtocol
10 jeje 24
 
25
class Tomcat6Substrate extends AbstractSubstrate {
472 jeje 26
  def defaultVersion = '6.0.20'
10 jeje 27
 
472 jeje 28
  public String getName() {
29
    return "Tomcat 6"
30
  }
10 jeje 31
 
472 jeje 32
  public void addDomainSpecificLanguageFeatures(MarkupBuilder builder, ExpandoMetaClass emc) {
33
    emc.tomcat = {Map attributes, Closure cl ->
34
      version = attributes.version ?: defaultVersion
35
      def removeOnDestroy = attributes.removeOnDestroy ?: true
36
      serviceExec(name: 'Tomcat') {
37
        software(name: 'Tomcat', version: version, removeOnDestroy: removeOnDestroy) {
38
          install source: "https://elastic-grid-substrates.s3.amazonaws.com/tomcat/apache-tomcat-${version}.zip",
39
                  target: 'tomcat', unarchive: true
40
          postInstall(removeOnCompletion: removeOnDestroy) {
41
            execute command: "/bin/chmod +x bin/*.sh"
42
          }
10 jeje 43
        }
472 jeje 44
        execute inDirectory: 'bin', command: 'catalina.sh run'
45
        cl()
46
        maintain 1
47
        maxPerMachine 1
48
      }
10 jeje 49
    }
472 jeje 50
    emc.webapp = {Map attributes ->
51
      data source: attributes.source,
52
              target: "tomcat/apache-tomcat-$version/webapps"
18 jeje 53
    }
472 jeje 54
  }
10 jeje 55
 
472 jeje 56
  /**
57
   * Open port 8080 for TCP from anywhere.
58
   * @todo temporary situation until we have the Apache frontend working fine.
59
   */
60
  @Override
61
  public List<FirewallRule> getFirewallRules() {
62
    [new FirewallRule(getName(), IpProtocol.TCP, 8080, '??')]
63
  }
64
 
196 jeje 65
}