torsdag den 8. november 2012

Distributing Liferay including custom portlets, hook, ext etc

Been working on Liferay (CE 6.1.1) for a couple of months now.
I ended up with a task about creating a script that could automate deployment of Liferay, a database server and all the war archives we created (portlets, ext, hooks, themes etc).

I used PostgreSQL (9.1.6) as the database.

The documentation on this was pretty fragmented so I thought I might as well publish the complete script here:

#!/bin/bash

####################################################
# Install the postgres database                    #
####################################################
tar -zxvf ~/Downloads/postgresql-9.1.6-1-linux-x64-binaries.tar.gz
pgsql/bin/initdb -D pgsql/data
pgsql/bin/pg_ctl start -w -D pgsql/data/ -l postgres.logs
pgsql/bin/createuser --no-createdb --no-createrole --no-superuser schneider
pgsql/bin/createdb lportal -O schneider
####################################################
# Install liferay bundle including tomcat          #
####################################################
unzip ~/Downloads/liferay-portal-tomcat-6.1.1-ce-ga2-20120731132656558.zip
####################################################
# Install portlets, hook, ext...                   #
####################################################
mkdir liferay-portal-6.1.1-ce-ga2/deploy
unzip ~/Downloads/all_the_war_archives.zip -d liferay-portal-6.1.1-ce-ga2/deploy/
####################################################
# Manually deploy ext...                           #
####################################################
unzip liferay-portal-6.1.1-ce-ga2/deploy/project-ext.war WEB-INF/ext-web/docroot/WEB-INF/classes/portal-ext.properties
mv WEB-INF/ext-web/docroot/WEB-INF/classes/portal-ext.properties liferay-portal-6.1.1-ce-ga2/tomcat-7.0.27/webapps/ROOT/WEB-INF/classes/
unzip liferay-portal-6.1.1-ce-ga2/deploy/project-ext.war WEB-INF/ext-impl/classes/*
mv WEB-INF/ext-impl/classes/ liferay-portal-6.1.1-ce-ga2/tomcat-7.0.27/webapps/ROOT/WEB-INF/classes/
rm -rf WEB-INF
####################################################
# Add setup properties file to avoid initial       #
# create user dialog...                            #
#################################################### 
cp portal-setup-wizard.properties liferay-portal-6.1.1-ce-ga2/
####################################################
# Startup liferay                                  #
####################################################
liferay-portal-6.1.1-ce-ga2/tomcat-7.0.27/bin/startup.sh

The auto deployment of the ext war archive didin't work as expected. Because of that I manually extract the parts I needed to have deployed on startup.

To make Liferay automatically create the required database tables the portal-ext.properties have to be deployed prior to the first startup. The required settings in the portal-ext.properties are:

    #
    # Set this to to true to populate with the minimal amount of data. Set this
    # to false to populate with a larger amount of sample data.
    #
    schema.run.minimal=true
  
    #
    # Set this to true to automatically create tables and populate with default
    # data if the database is empty.
    #
    schema.run.enabled=true
   
    jdbc.default.driverClassName=org.postgresql.Driver
    jdbc.default.url=jdbc:postgresql://localhost:5432/lportal
    jdbc.default.username=schneider
    jdbc.default.password=schneider

Ingen kommentarer:

Send en kommentar