[jboss-user] [JBoss Portal] - Re: IPC and 2.4GA

PeterJ do-not-reply at jboss.com
Mon Sep 18 14:15:29 EDT 2006


Here is the script, and its supporting files.  Before running it:

1) Modify the build.properties file to reflect your environment.
2) Load the MySQL and PostgreSQL JDBC jar files into your Maven2 repository (or change the script to reference them from elsewhere).
3) Use a clean install of JBoss AS, one where the 'default' configuration has never been run, because the script makes a copy of it and thus assumes it has never been used.

Then run ant (no targets necessary).

build.xml
<?xml version="1.0"?>
  | <!--
  |   Destroys the current JBoss Portal installation and reinitializes it.
  |   Does the following:
  |   1) Removes existing portal server configuration (does not remove the
  |      entire JBoss AS installation, only the one configuration)
  |   2) Wipes out and recreates the database (the portal works off of this data
  |      so initializing it is key to trying out different things)
  |   3) Creates the portal server configuration based on the "default" server
  |      configuration.
  |   4) Copies the *-ds.xml and jdbc jar file for the desired database to the
  |      portal server configuration.
  |   5) Copies the portal sar directory to the portal server configuration's deploy
  |      directory.
  | -->
  | <project name="reset" default="reset" basedir=".">
  | 
  |   <!-- Pick up environment variables to locate the local Maven 2 repository -->
  |   <property environment="env" />
  | 
  |   <!-- Contains properties that change often. -->
  |   <property file="build.properties" />
  | 
  |   <!-- Full directory name of the desired server configuration -->
  |   <property name="dir.server"
  |             location="${home.jboss}/server/${config.server}"
  |   />
  |   <property name="dir.deploy" location="${dir.server}/deploy" />
  | 
  |   <!-- Locations of the JDBC jar files within the local Maven 2 repository -->
  |   <condition property="jar.jdbc"
  |              value="${env.M2_REPO}/mysql/mysql-connector-java/${jdbc.mysql.version}/mysql-connector-java-${jdbc.mysql.version}.jar"
  |   >
  |     <equals arg1="mysql" arg2="${database}" />
  |   </condition>
  |   <condition property="jar.jdbc"
  |              value="${env.M2_REPO}/postgresql/postgresql/${jdbc.postgresql.version}/postgresql-${jdbc.postgresql.version}.jar"
  |   >
  |     <equals arg1="postgresql" arg2="${database}" />
  |   </condition>
  | 
  |   <!-- JDBC drivers for the databases -->
  |   <condition property="db.driver" value="com.mysql.jdbc.Driver">
  |     <equals arg1="mysql" arg2="${database}" />
  |   </condition>
  |   <condition property="db.driver" value="org.postgresql.Driver">
  |     <equals arg1="postgresql" arg2="${database}" />
  |   </condition>
  | 
  |   <!--
  |     JDBC URLs for the databases (not the portal database, rather a global
  |     database from which we can create the portal databasae)
  |   -->
  |   <condition property="db.url"
  |              value="jdbc:mysql://localhost:3306/mysql?useServerPrepStmts=false&jdbcCompliantTruncation=false"
  |   >
  |     <equals arg1="mysql" arg2="${database}" />
  |   </condition>
  |   <condition property="db.url" value="jdbc:postgresql:postgres">
  |     <equals arg1="postgresql" arg2="${database}" />
  |   </condition>
  | 
  |   <!-- Administrator login id for the databases -->
  |   <condition property="db.user" value="${db.mysql.user}">
  |     <equals arg1="mysql" arg2="${database}" />
  |   </condition>
  |   <condition property="db.user" value="${db.postgresql.user}">
  |     <equals arg1="postgresql" arg2="${database}" />
  |   </condition>
  | 
  |   <!-- Administrator password for the databases -->
  |   <condition property="db.password" value="${db.mysql.password}">
  |     <equals arg1="mysql" arg2="${database}" />
  |   </condition>
  |   <condition property="db.password" value="${db.postgresql.password}">
  |     <equals arg1="postgresql" arg2="${database}" />
  |   </condition>
  | 
  | 
  |   <!-- =================================================================== -->
  |   <target description="Removes current portal and creates a new one."
  |           name="reset"
  |           depends="clean-jboss, init-db, create-config, copy-jdbc, copy-portal, copy-extras, copy-forums"
  |   />
  | 
  |   <!-- =================================================================== -->
  |   <target description="Removes the server configuration" name="clean-jboss">
  |     <delete dir="${dir.server}" />
  |   </target>
  | 
  | 
  |   <!-- =================================================================== -->
  |   <target description="Initializes the database, removing old one if needed"
  |           name="init-db"
  |   >
  |     <sql driver="${db.driver}"
  |          url="${db.url}"
  |          userid="${db.user}"
  |          password="${db.password}"
  |          onerror="continue"
  |          src="${database}.sql"
  |          print="true"
  |          autocommit="true"
  |     >
  |       <classpath location="${jar.jdbc}" />
  |     </sql>
  |   </target>
  | 
  | 
  |   <!-- =================================================================== -->
  |   <target description="Creates the desired server configuration"
  |           name="create-config"
  |   >
  |     <copy todir="${dir.server}">
  |       <fileset dir="${home.jboss}/server/default" />
  |     </copy>
  | 
  |     <!-- Modified log4j config suppresses Hibernate debug logging -->
  |     <copy todir="${dir.server}/conf" file="log4j.xml" overwrite="true" />
  |   </target>
  | 
  | 
  |   <!-- =================================================================== -->
  |   <target description="Copies the database-related files to the server"
  |           name="copy-jdbc"
  |   >
  |     <copy file="${jar.jdbc}" todir="${dir.server}/lib" verbose="true" />
  |     <copy file="portal-${database}-ds.xml" todir="${dir.deploy}" verbose="true">
  |       <filterset>
  |         <filter token="SERVER" value="${config.server}" />
  |       </filterset>
  |     </copy>
  |   </target>
  | 
  |   <!-- =================================================================== -->
  |   <target description="Deploys the portal sar directory to the server"
  |           name="copy-portal"
  |   >
  |     <copy todir="${dir.deploy}/jboss-portal.sar">
  |       <fileset dir="${home.portal}/jboss-portal.sar" />
  |     </copy>
  |   </target>
  | 
  | 
  |   <!-- =================================================================== -->
  |   <target description="Copies various extras to the portal"
  |           name="copy-extras"
  |           if="portal.extras"
  |   >
  |     <!-- Replace the login page with a better one -->
  |     <copy todir="${dir.deploy}/jboss-portal.sar/portal-server.war"
  |           file="login.jsp"
  |           overwrite="true"
  |     />
  | 
  |     <!-- Add another theme -->
  |     <copy todir="${dir.deploy}/havana_affair.war">
  |       <fileset dir="havana_affair.war" />
  |     </copy>
  |   </target>
  | 
  |   <!-- =================================================================== -->
  |   <target description="Copies the forums portlet to the portal"
  |           name="copy-forums"
  |           if="portal.forums"
  |   >
  |     <copy todir="${dir.deploy}" file="${portal.forums}" overwrite="true" />
  |   </target>
  | 
  | </project>

build.properties
# Where JBoss Application Server is installed
  | home.jboss=/jboss/portal/jboss-4.0.4.GA
  | 
  | # Where JBoss Portal is installed
  | #home.portal=/jboss/portal/source/jboss-portal-2.4/core/output/resources
  | #home.portal=/jboss/portal/jboss-portal-2.4.0-CR3-src/core/output/resources
  | home.portal=/jboss/portal/jboss-portal-2.4.0
  | 
  | # The name of the server configuration.  Also used as the database name.
  | config.server=portal24
  | 
  | # Uncomment to copy various extras:
  | #  * improved login page
  | #  * havana affair theme
  | #portal.extras=
  | portal.forums=/jboss/portal/source/jboss-portal-2.4/forums/output/lib/portal-forums.ear
  | 
  | # Identify the database to use (mysql, postgresql)
  | database=mysql
  | #database=postgresql
  | 
  | # The database JDBC versions
  | jdbc.mysql.version=5.0.3
  | jdbc.postgresql.version=8.1-407.jdbc3
  | 
  | # Database login information
  | db.mysql.user=root
  | db.mysql.password=XXXXXX
  | db.postgresql.user=postgres
  | db.postgresql.password=XXXXXXX


mysql.sql
DROP DATABASE ${config.server};
  | CREATE DATABASE ${config.server};
  | GRANT ALL PRIVILEGES ON ${config.server}.* TO 'portal'@'localhost' IDENTIFIED BY 'portalpassword' WITH GRANT OPTION;

postgresql.sql
DROP DATABASE ${config.server};
  | CREATE USER portal WITH PASSWORD 'portalpassword';
  | CREATE DATABASE ${config.server} WITH OWNER = portal ENCODING = 'UTF8';

portal-mysql-ds.xml
<?xml version="1.0" encoding="UTF-8"?>
  | <datasources>
  |   <local-tx-datasource>
  |     <jndi-name>PortalDS</jndi-name>
  |     <connection-url>jdbc:mysql://localhost:3306/@SERVER@?useServerPrepStmts=false&jdbcCompliantTruncation=false</connection-url>
  |     <driver-class>com.mysql.jdbc.Driver</driver-class>
  |     <user-name>portal</user-name>
  |     <password>portalpassword</password>
  |   </local-tx-datasource>
  | </datasources>

portal-postgresql-ds.xml
<?xml version="1.0" encoding="UTF-8"?>
  | <datasources>
  |   <local-tx-datasource>
  |     <jndi-name>PortalDS</jndi-name>
  |     <connection-url>jdbc:postgresql:@SERVER@</connection-url>
  |     <driver-class>org.postgresql.Driver</driver-class>
  |     <user-name>portal</user-name>
  |     <password>portalpassword</password>
  |   </local-tx-datasource>
  | </datasources>


View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=3972392#3972392

Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=3972392



More information about the jboss-user mailing list