From cc1b8039b1412989e94cbfbfb90badf6a3ee4393 Mon Sep 17 00:00:00 2001 From: "Carlos A. Munoz" Date: Tue, 16 Dec 2014 16:15:53 +1000 Subject: [PATCH] Add a Zanata overlay zip submodule. Pull Request: https://github.com/zanata/zanata-server/pull/637 Squashed commit of the following: commit ac46d8051275c9738db875dd29d7f4c1a43b85b1 Author: Carlos A. Munoz 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 4110de2921804b5e37874b65385986b1b8878790 Author: Carlos A. Munoz 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 fc5daf1bf29b484e5a4e41c7d71f728f4c2c2b6b Author: Carlos A. Munoz 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 482604e2c9d66be67810b3906d3c501c4d46528e Author: Carlos A. Munoz Date: Mon Dec 1 11:11:04 2014 +1000 Remove the need for a custom standalone.xml when installing Zanata. commit 362a2653d51ba402a84e56a22835b0677c558174 Author: Carlos Munoz Date: Fri Nov 28 15:38:48 2014 +1000 Add missing newline characters and change shell scripts. commit a99f9310d418bb560ae6ecadb9c31789d5ab86f1 Author: Carlos A. Munoz 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) --- .gitignore | 3 + zanata-dist/etc/assembly.xml | 46 -- zanata-dist/etc/sql/config_setup.sql | 30 -- zanata-dist/pom.xml | 69 --- zanata-overlay/.gitignore | 1 + zanata-overlay/build.gradle | 103 ++++ .../bin/zanata-installer/InstallZanata.groovy | 131 +++++ .../common/bin/zanata-installer/install.bat | 1 + .../common/bin/zanata-installer/install.sh | 2 + .../bin/zanata-installer/installer.properties | 1 + zanata-overlay/config/remote-deps.groovy | 32 ++ .../configuration/standalone-zanata.xml | 463 +++++++++++++++++ .../configuration/standalone-zanata.xml | 470 ++++++++++++++++++ 13 files changed, 1207 insertions(+), 145 deletions(-) delete mode 100644 zanata-dist/etc/assembly.xml delete mode 100644 zanata-dist/etc/sql/config_setup.sql delete mode 100644 zanata-dist/pom.xml create mode 100644 zanata-overlay/.gitignore create mode 100644 zanata-overlay/build.gradle create mode 100644 zanata-overlay/common/bin/zanata-installer/InstallZanata.groovy create mode 100755 zanata-overlay/common/bin/zanata-installer/install.bat create mode 100755 zanata-overlay/common/bin/zanata-installer/install.sh create mode 100644 zanata-overlay/common/bin/zanata-installer/installer.properties create mode 100644 zanata-overlay/config/remote-deps.groovy create mode 100644 zanata-overlay/distros/eap-6/standalone/configuration/standalone-zanata.xml create mode 100644 zanata-overlay/distros/wildfly-8.1/standalone/configuration/standalone-zanata.xml diff --git a/.gitignore b/.gitignore index f9b58c5b1c..f242e6da8f 100644 --- a/.gitignore +++ b/.gitignore @@ -64,3 +64,6 @@ bin/ *.tmp /tmp* *.bak + +# Gradle files +.gradle/ diff --git a/zanata-dist/etc/assembly.xml b/zanata-dist/etc/assembly.xml deleted file mode 100644 index bf21efd6c4..0000000000 --- a/zanata-dist/etc/assembly.xml +++ /dev/null @@ -1,46 +0,0 @@ - - zanata-dist - - zip - tar.gz - - false - - - etc/sql - - *.sql - - sql - - - - - - org.zanata:zanata-war:war:jaas - - zanata${dashClassifier?}.${artifact.extension} - - - - org.zanata:zanata-war:war:kerberos - - zanata${dashClassifier?}.${artifact.extension} - - - - org.zanata:zanata-war:war:fedora - - zanata${dashClassifier?}.${artifact.extension} - - - - org.zanata:zanata-war:war:internal - - zanata${dashClassifier?}.${artifact.extension} - - - diff --git a/zanata-dist/etc/sql/config_setup.sql b/zanata-dist/etc/sql/config_setup.sql deleted file mode 100644 index b3a6cb2a62..0000000000 --- a/zanata-dist/etc/sql/config_setup.sql +++ /dev/null @@ -1,30 +0,0 @@ -/* - * ==================================================================================================================== - * Zanata Initial Setup Script - * - * Edit these variables for Zanata's initial setup. - * Note: Existing values will get overridden and some elements (e.g. Login Config Xml) will not insert - * a configuration record for null values. - * ==================================================================================================================== - */ -set @LOGIN_CONFIG_URL = null; -set @AUTH_TYPE = ''; /* Valid values: INTERNAL, KERBEROS, FEDORA_OPENID, JAAS */ - -/* - * ==================================================================================================================== - * End of Configurable elements. Do not edit this script beyond this marker. - * ==================================================================================================================== - */ - -/* Change to a custom Login Config Url */ -insert ignore into HApplicationConfiguration(creationDate, lastChanged, versionNum, config_key, config_value) -values(CURRENT_TIMESTAMP(), CURRENT_TIMESTAMP(), 0, 'zanata.login-config.url', @LOGIN_CONFIG_URL) -on duplicate key update config_value = @LOGIN_CONFIG_URL, versionNum=versionNum+1, lastChanged=CURRENT_TIMESTAMP(); - -/* Change the Authentication type. Valid values are: INTERNAL, FEDORA_OPENID, KERBEROS, OTHER */ -insert into HApplicationConfiguration(creationDate, lastChanged, versionNum, config_key, config_value) -values(CURRENT_TIMESTAMP(), CURRENT_TIMESTAMP(), 0, 'zanata.security.authType', @AUTH_TYPE) -on duplicate key update config_value = @AUTH_TYPE, versionNum=versionNum+1, lastChanged=CURRENT_TIMESTAMP(); - -/* Cleanup */ -delete from HApplicationConfiguration where config_key = 'zanata.login-config.url' and config_value = ''; \ No newline at end of file diff --git a/zanata-dist/pom.xml b/zanata-dist/pom.xml deleted file mode 100644 index 45bb56181b..0000000000 --- a/zanata-dist/pom.xml +++ /dev/null @@ -1,69 +0,0 @@ - - 4.0.0 - - server - org.zanata - 1.5-SNAPSHOT - - - zanata-dist - Packages all server artifacts for distribution. - Zanata Server distribution packages. - pom - - - - - maven-assembly-plugin - - - - false - - etc/assembly.xml - - - package - - single - - - - - - - - - - org.zanata - zanata-war - war - jaas - ${project.version} - - - org.zanata - zanata-war - war - kerberos - ${project.version} - - - org.zanata - zanata-war - war - fedora - ${project.version} - - - org.zanata - zanata-war - war - internal - ${project.version} - - - - diff --git a/zanata-overlay/.gitignore b/zanata-overlay/.gitignore new file mode 100644 index 0000000000..08eb0a07a6 --- /dev/null +++ b/zanata-overlay/.gitignore @@ -0,0 +1 @@ +!bin/ \ No newline at end of file diff --git a/zanata-overlay/build.gradle b/zanata-overlay/build.gradle new file mode 100644 index 0000000000..d70150a555 --- /dev/null +++ b/zanata-overlay/build.gradle @@ -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() +} diff --git a/zanata-overlay/common/bin/zanata-installer/InstallZanata.groovy b/zanata-overlay/common/bin/zanata-installer/InstallZanata.groovy new file mode 100644 index 0000000000..1ad25aef7d --- /dev/null +++ b/zanata-overlay/common/bin/zanata-installer/InstallZanata.groovy @@ -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 camunoz@redhat.com + */ +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!" diff --git a/zanata-overlay/common/bin/zanata-installer/install.bat b/zanata-overlay/common/bin/zanata-installer/install.bat new file mode 100755 index 0000000000..920b70b165 --- /dev/null +++ b/zanata-overlay/common/bin/zanata-installer/install.bat @@ -0,0 +1 @@ +java -cp .;groovy-all-2.1.5.jar groovy.lang.GroovyShell InstallZanata.groovy diff --git a/zanata-overlay/common/bin/zanata-installer/install.sh b/zanata-overlay/common/bin/zanata-installer/install.sh new file mode 100755 index 0000000000..dc4b877ff7 --- /dev/null +++ b/zanata-overlay/common/bin/zanata-installer/install.sh @@ -0,0 +1,2 @@ +#!/bin/sh +exec java -cp '.:groovy-all-2.1.5.jar' groovy.lang.GroovyShell InstallZanata.groovy diff --git a/zanata-overlay/common/bin/zanata-installer/installer.properties b/zanata-overlay/common/bin/zanata-installer/installer.properties new file mode 100644 index 0000000000..c02cc31529 --- /dev/null +++ b/zanata-overlay/common/bin/zanata-installer/installer.properties @@ -0,0 +1 @@ +zanata.version=$version diff --git a/zanata-overlay/config/remote-deps.groovy b/zanata-overlay/config/remote-deps.groovy new file mode 100644 index 0000000000..cdddbceb65 --- /dev/null +++ b/zanata-overlay/config/remote-deps.groovy @@ -0,0 +1,32 @@ +/** + * This is where all Remote dependencies are configured for each of the Zanata + * overlay distributions. + * Each distribution under the 'distros' folder may have a configuration entry + * on this file. Each of those entries must have the following structure: + * + * <> { + * <> { + * url = "Url where the dependency is to be downloaded from" + * toFile = "File (on the distro build folder) where the downloaded dependecny should reside" + * extract = true|false // Indicates if the dependency is to be extracted in place. If it is, the original file will be removed after extraction. + * } + * + * ... More dependencies + * } + * + * The dependency name is not relevant, just an identifier. + */ + +'wildfly-8.1' { + hibernatemodule { + url = "http://sourceforge.net/projects/zanata/files/wildfly/wildfly-8.1.0.Final-module-hibernate-main-4.2.15.Final.zip/download" + toFile = "/hibernate-module.zip" + extract = true + } + + jsfmodule { + url = "http://sourceforge.net/projects/zanata/files/wildfly/wildfly-8.1.0.Final-module-mojarra-2.1.28.zip/download" + toFile = "/mojarra-module.zip" + extract = true + } +} \ No newline at end of file diff --git a/zanata-overlay/distros/eap-6/standalone/configuration/standalone-zanata.xml b/zanata-overlay/distros/eap-6/standalone/configuration/standalone-zanata.xml new file mode 100644 index 0000000000..6e0d097b22 --- /dev/null +++ b/zanata-overlay/distros/eap-6/standalone/configuration/standalone-zanata.xml @@ -0,0 +1,463 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + jdbc:h2:mem:test;DB_CLOSE_DELAY=-1;DB_CLOSE_ON_EXIT=FALSE + h2 + + sa + sa + + + + jdbc:mysql://localhost:3306/zanata?characterEncoding=UTF-8 + com.mysql.jdbc.Driver + mysql-connector-java.jar + + 0 + 20 + FailingConnectionOnly + + + root + + + NOWARN + + + + + org.h2.jdbcx.JdbcDataSource + + + + + + + + + false + true + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + true + NIO + 2 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + jms.queue.DLQ + jms.queue.ExpiryQueue + 0 + 10485760 + 2097152 + PAGE + 10 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + true + ${jboss.bind.address:127.0.0.1} + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/zanata-overlay/distros/wildfly-8.1/standalone/configuration/standalone-zanata.xml b/zanata-overlay/distros/wildfly-8.1/standalone/configuration/standalone-zanata.xml new file mode 100644 index 0000000000..da763edee5 --- /dev/null +++ b/zanata-overlay/distros/wildfly-8.1/standalone/configuration/standalone-zanata.xml @@ -0,0 +1,470 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + jdbc:h2:mem:test;DB_CLOSE_DELAY=-1;DB_CLOSE_ON_EXIT=FALSE + h2 + + sa + sa + + + + jdbc:mysql://localhost:3306/zanata?characterEncoding=UTF-8 + com.mysql.jdbc.Driver + mysql-connector-java.jar + + 0 + 20 + FailingConnectionOnly + + + root + + + NOWARN + + + + + org.h2.jdbcx.JdbcDataSource + + + + + + + + + false + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + ${jboss.bind.address:127.0.0.1} + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +