This repository has been archived by the owner on Nov 9, 2017. It is now read-only.
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Pull Request: #637 Squashed commit of the following: commit ac46d80 Author: Carlos A. Munoz <camunoz@redhat.com> Date: Mon Dec 15 15:57:40 2014 +1000 Minor zanata installer changes - Reverted to latest mysql driver info - Added a few log lines to know what's happening commit 4110de2 Author: Carlos A. Munoz <camunoz@redhat.com> Date: Wed Dec 10 16:54:00 2014 +1000 More review changes: Fix issues with the windows script for installation Change wording and correct spelling for installer messages. commit fc5daf1 Author: Carlos A. Munoz <camunoz@redhat.com> Date: Mon Dec 8 16:19:19 2014 +1000 Make sure the installation process is repeatable if there is a failure. Also, downgraded the mysql driver version as the one used before did not deploy on wildfly. commit 482604e Author: Carlos A. Munoz <camunoz@redhat.com> Date: Mon Dec 1 11:11:04 2014 +1000 Remove the need for a custom standalone.xml when installing Zanata. commit 362a265 Author: Carlos Munoz <chavo16@hotmail.com> Date: Fri Nov 28 15:38:48 2014 +1000 Add missing newline characters and change shell scripts. commit a99f931 Author: Carlos A. Munoz <camunoz@redhat.com> Date: Fri Nov 21 12:07:58 2014 +1000 Add zanata-overlay submodule. This submodule takes care of building an overlay zip file that when extracted on top of the different supported JBoss distributions, will supply the necessary components for Zanata to run. In this iteration it contains: - Necessary jboss submodules - Configuration and startup scripts for zanata - Installation scripts which fetches the war file from the web and configures some parts of the application. Currently, it builds 2 distributions: Wildfly 8.1 EAP 6 (6.3 recommended)
- Loading branch information
Carlos A. Munoz
committed
Dec 16, 2014
1 parent
16180cf
commit cc1b803
Showing
13 changed files
with
1,207 additions
and
145 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -64,3 +64,6 @@ bin/ | |
*.tmp | ||
/tmp* | ||
*.bak | ||
|
||
# Gradle files | ||
.gradle/ |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
!bin/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,103 @@ | ||
defaultTasks 'package' | ||
apply plugin: 'java' | ||
|
||
repositories { | ||
mavenCentral() | ||
} | ||
|
||
dependencies { | ||
runtime "mysql:mysql-connector-java:5.1.34" | ||
runtime "org.codehaus.groovy:groovy-all:2.1.5" | ||
} | ||
|
||
final def BUILD_DIR = "target" | ||
|
||
task 'package'(dependsOn: 'copyToLib') << { | ||
def distros = findAvailableDistros() | ||
def zanataVersion = readProjectVersion() | ||
|
||
distros.each { distro -> | ||
def distroName = "zanata-$zanataVersion-$distro" | ||
def distroDir = "$BUILD_DIR/$distroName" | ||
// Make a build directory fro the distribution | ||
ant.mkdir(dir: distroDir) | ||
// Copy the common files for all distributions | ||
ant.copy(todir: distroDir) { | ||
fileset(dir: "common") | ||
} | ||
// Make sure executable files have the right permissions | ||
ant.chmod(dir: "$distroDir/", perm: "ug+x", includes: "**/*.sh") | ||
// Copy specific distribution files | ||
ant.copy(todir: distroDir) { | ||
fileset(dir: "distros/$distro") | ||
} | ||
// Copy extra needed files | ||
ant.copy(todir: "$distroDir/standalone/deployments") { | ||
fileset(dir: "$BUILD_DIR/deps") { | ||
include(name: "mysql-connector-java-*.jar") | ||
} | ||
globmapper(from: "mysql-connector-java-*.jar", | ||
to: "mysql-connector-java.jar") | ||
} | ||
ant.copy(todir: "$distroDir/bin/zanata-installer") { | ||
fileset(dir: "$BUILD_DIR/deps") { | ||
include(name: "groovy-all-*.jar") | ||
} | ||
} | ||
// Download remote dependencies | ||
downloadRemoteDeps(distro, distroDir) | ||
// Replace templates | ||
replaceTemplates(distroDir, zanataVersion) | ||
// Zip it up | ||
ant.zip(destfile: "$BUILD_DIR/${distroName}.zip", basedir: distroDir) | ||
// Cleanup | ||
//ant.delete(dir: "$BUILD_DIR/deps") | ||
ant.delete(dir: distroDir) | ||
} | ||
} | ||
|
||
task copyToLib(type: Copy) { | ||
into "$BUILD_DIR/deps" | ||
from configurations.runtime | ||
} | ||
|
||
List findAvailableDistros() { | ||
new File("distros").listFiles() | ||
.findAll { !it.name.startsWith(".") && it.isDirectory() } | ||
.collect { it.name } | ||
} | ||
|
||
String readProjectVersion() { | ||
(new groovy.util.XmlParser()).parse(new File("../pom.xml")).version.text() | ||
} | ||
|
||
def replaceTemplates(String distroDir, String zanataVersion) { | ||
def engine = new groovy.text.SimpleTemplateEngine() | ||
def templateFile = new File(distroDir, | ||
"bin/zanata-installer/installer.properties") | ||
def template = engine.createTemplate(templateFile) | ||
def result = template.make(['version': zanataVersion]) | ||
templateFile.newWriter() << result | ||
} | ||
|
||
def downloadRemoteDeps(String distro, String distroDir) { | ||
def config = new groovy.util.ConfigSlurper(). | ||
parse(new File('config/remote-deps.groovy').toURL()) | ||
config."$distro"?.each { depName, value -> | ||
def dep = config."$distro"."$depName" | ||
def destFile = new File("$distroDir/${dep.toFile}") | ||
download(dep.url, destFile) | ||
if (dep.extract) { | ||
ant.unzip(src: "${destFile.absolutePath}", | ||
dest: "${destFile.parent}") | ||
ant.delete(file: "${destFile.absolutePath}") | ||
} | ||
} | ||
} | ||
|
||
def download(String url, File destFile) { | ||
def file = new FileOutputStream(destFile) | ||
def out = new BufferedOutputStream(file) | ||
out << new URL(url).openStream() | ||
out.close() | ||
} |
131 changes: 131 additions & 0 deletions
131
zanata-overlay/common/bin/zanata-installer/InstallZanata.groovy
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,131 @@ | ||
import groovy.xml.XmlUtil | ||
|
||
import java.nio.file.Files | ||
|
||
/** | ||
* Zanata installer script. | ||
* Downloads Zanata and configures certain parts of the application for first | ||
* use. | ||
* @author Carlos Munoz <a href="mailto:camunoz@redhat.com">camunoz@redhat.com</a> | ||
*/ | ||
Properties installerProps = new Properties() | ||
File propertiesFile = new File('installer.properties') | ||
propertiesFile.withInputStream { | ||
installerProps.load(it) | ||
} | ||
def ZANATA_VERSION = installerProps['zanata.version'] | ||
final JBOSS_CFG_DIR = "../../standalone/configuration" | ||
final CUSTOM_STANDALONE_XML_LOC = "${JBOSS_CFG_DIR}/standalone-zanata.xml" | ||
final ORIGINAL_STANDALONE_XML_LOC = "${JBOSS_CFG_DIR}/standalone.xml" | ||
final WAR_FILE_LOC = "../../standalone/deployments/zanata.war" | ||
|
||
boolean askYesNoQuestion(String question) { | ||
def reader = new BufferedReader(new InputStreamReader(System.in)) | ||
println "" | ||
println question | ||
def answer = reader.readLine() | ||
return answer.trim().equalsIgnoreCase("y") | ||
} | ||
|
||
println "=====================================================" | ||
println " Welcome to the Zanata Installer. This will install" | ||
println " Zanata ${ZANATA_VERSION} onto your JBoss or Wildfly" | ||
println "" | ||
println " Note: This installer will change your standalone.xml" | ||
println " file." | ||
println "=====================================================" | ||
|
||
def downloadWarFile = true | ||
if( new File(WAR_FILE_LOC).exists() ) { | ||
downloadWarFile = askYesNoQuestion("It seems Zanata is already installed. Do you wish to download it again? (y/N)") | ||
} | ||
|
||
def dbHost | ||
def dbPort | ||
def dbSchema | ||
def dbUsername | ||
def dbPassword | ||
|
||
// Download the war file | ||
if( downloadWarFile ) { | ||
def fileUrl = "http://sourceforge.net/projects/zanata/files/webapp/zanata-war-${ZANATA_VERSION}.war/download" | ||
println "Downloading $fileUrl" | ||
println "This might take a few minutes." | ||
|
||
try { | ||
def file = new FileOutputStream(WAR_FILE_LOC) | ||
def out = new BufferedOutputStream(file) | ||
out << new URL(fileUrl).openStream() | ||
out.close() | ||
println "Downloaded Zanata ${ZANATA_VERSION}..." | ||
} catch (Exception ex) { | ||
println "Could not download zanata-war-${ZANATA_VERSION}.war" | ||
} | ||
} | ||
|
||
// Move the original standalone and copy the custom one | ||
def xmlFile = new File(ORIGINAL_STANDALONE_XML_LOC) | ||
def xmlBackupFile = new File("${JBOSS_CFG_DIR}/standalone.xml.original") | ||
def customXmlFile = new File(CUSTOM_STANDALONE_XML_LOC) | ||
|
||
// If the installer has already been ran | ||
def modifyStandaloneXml = true | ||
if(xmlBackupFile.exists()) { | ||
modifyStandaloneXml = askYesNoQuestion("It looks like you have already run this installer. " + | ||
"If you continue, your current standalone.xml file will be backed up and modified. " + | ||
"Do you wish to continue? (y/N)") | ||
} | ||
|
||
if(modifyStandaloneXml) { | ||
println "Please provide the following information:" | ||
println "(If blank, the default value will apply)" | ||
println "" | ||
|
||
def reader = new BufferedReader(new InputStreamReader(System.in)) | ||
|
||
println "Database Host (default: 'localhost'):" | ||
dbHost = reader.readLine() | ||
if(dbHost.isEmpty()) dbHost = 'localhost' | ||
|
||
println "Database port (default: '3306'):" | ||
dbPort = reader.readLine() | ||
if(dbPort.isEmpty()) dbPort = '3306' | ||
|
||
println "Database schema (default: 'zanata'):" | ||
dbSchema = reader.readLine() | ||
if(dbSchema.isEmpty()) dbSchema = 'zanata' | ||
|
||
println "Database Username (default: ''):" | ||
dbUsername = reader.readLine() | ||
|
||
println "Database Password (default: ''):" | ||
dbPassword = reader.readLine() | ||
|
||
xmlFile.renameTo(xmlBackupFile) // backup original file | ||
Files.copy(customXmlFile.toPath(), xmlFile.toPath()) // standalone-zanata.xml -> standalone.xml | ||
|
||
// Update zanata datasource | ||
def dsXml = new XmlParser().parse(CUSTOM_STANDALONE_XML_LOC) | ||
|
||
def zanataDs = | ||
dsXml.profile.subsystem. | ||
find { s -> s.datasources }.datasources.datasource | ||
.find { | ||
it.@'jndi-name' == "java:jboss/datasources/zanataDatasource" | ||
} | ||
|
||
zanataDs.'connection-url'.replaceNode { | ||
'connection-url'( | ||
"jdbc:mysql://${dbHost}:${dbPort}/${dbSchema}?characterEncoding=UTF-8") | ||
} | ||
zanataDs.security.replaceNode { node -> | ||
security { | ||
'user-name'(dbUsername) | ||
password(dbPassword) | ||
} | ||
} | ||
|
||
XmlUtil.serialize(dsXml, new FileOutputStream(CUSTOM_STANDALONE_XML_LOC)) | ||
println "Configured zanata in $CUSTOM_STANDALONE_XML_LOC" | ||
} | ||
println "Done!" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
java -cp .;groovy-all-2.1.5.jar groovy.lang.GroovyShell InstallZanata.groovy |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
#!/bin/sh | ||
exec java -cp '.:groovy-all-2.1.5.jar' groovy.lang.GroovyShell InstallZanata.groovy |
Oops, something went wrong.