The following script will install Alfresco Labs 3.0 on Ubuntu 8.10 JeOS. Just call it something.sh and execute it as root. You’ll have to attend to it a bit (MySQL password) but it will take a while. Make sure you are connected to the internet.

#!/bin/bash
#
# A script to install Alfresco Labs 3.0 Stable on Intrepid Ibex
#
# Gregory Buchenberger
# 2009/04/10

apt-get install mysql-server \
openoffice.org-headless \
openoffice.org-writer \
openoffice.org-calc \
openoffice.org-impress \
imagemagick \
openoffice.org-java-common \
openjdk-6-jdk
#pdf2swf dependencies
apt-get install libfreetype6-dev \
build-essential \
linux-headers-$(uname -r) \
zlib1g-dev \
libjpeg62-dev
wget http://www.swftools.org/swftools-2009-02-16-1757.tar.gz
tar -zvxf swftools-2009-02-16-1757.tar.gz
cd swftools-2009-02-16-1757
./configure
make
make install
#Configure MySQL
echo " * Creating Alfresco database ..."
echo " * Waiting for  MySQL root password from user..."
mysql -u root -p -e 'create database alfresco;
grant all on alfresco.* to "alfresco"@"localhost" identified by "alfresco" with grant option;
grant all on alfresco.* to "alfresco"@"localhost.localdomain" identified by "alfresco" with grant option;'
echo " * Installing Alfresco ..."
mkdir /opt/alfresco
cd /opt/alfresco
wget http://downloads.sourceforge.net/alfresco/alfresco-labs-tomcat-3Stable.tar.gz
tar -xvf alfresco-labs-tomcat-3Stable.tar.gz
rm ./alfresco-labs-tomcat-3Stable.tar.gz
#MySQL java connector
echo " * Installing MySQL Java Connector ..."
cd /opt/alfresco/tomcat/lib/
wget http://dev.mysql.com/get/Downloads/Connector-J/mysql-connector-java-5.1.7.tar.gz/from/http://mirror.sourceshare.org/mysql/
tar -xvf mysql-connector-java-5.1.7.tar.gz
cp ./mysql-connector-java-5.1.7/mysql-connector-java-5.1.7-bin.jar ./
rm -rf ./mysql-connector-java-5.1.7/
rm ./mysql-connector-java-5.1.7.tar.gz
mkdir /var/alfresco
mkdir /var/alfresco/alf_data
#Init.d Script
echo " * Creating init scripts ..."
echo '#!/bin/bash
#
# alfresco      This shell script takes care of starting and stopping alfresco
#
# chkconfig: - 80 20
#
### BEGIN INIT INFO
# Provides: alfresco
# Required-Start: $network $syslog
# Required-Stop: $network $syslog
# Default-Start:
# Default-Stop:
# Description: Alfresco Enterprise Content Management 2.1.1
# Short-Description: start and stop alfresco
### END INIT INFO
#
NAME="$(basename $0)"
unset ISBOOT
if [ "${NAME:0:1}" = "S" -o "${NAME:0:1}" = "K" ]; then
    NAME="${NAME:3}"
    ISBOOT="1"
fi
# Path to alfresco root dir
_ALFRESCO="/opt/alfresco"
# Path to the alfresco launch script
_SCRIPT="${_ALFRESCO}/alfresco.sh"
# Alfresco program name
_PROG="$NAME"
export JAVA_HOME=/usr/lib/jvm/java-6-openjdk
export PATH=$PATH:/usr/bin
echo $PATH
SHUTDOWN_WAIT=30
RETVAL="0"
function checkpid() {
    local i
    for i in $* ; do
        if [ -d "/proc/${i}" ]; then
            return 0
        fi
    done
    return 1
}
function echo_failure() {
    echo -en "\33[60G"
    echo -n "[  "
    echo -n $"FAILED"
    echo -n "  ]"
    echo -ne "\r"
    return 1
}
function echo_success() {
    echo -en "\33[60G"
    echo -n "[  "
    echo -n $"OK"
    echo -n "  ]"
    echo -ne "\r"
    return 0
}
function getIP() {
    ipaddr=""
    inet=$(ip addr show dev eth0 | grep "inet")
    if [ "$inet" != "" ]; then
            set -- $inet
            shift

        echo ${1%%/*} | grep -E \([0-9]\{1,3\}.\{3\}\)[0-9]\{1,3\} > /dev/null
        if [ $? -ne 1 ]; then
                ipaddr=$(echo ${1%%/*} | sed -e s/[.]/-/g)
        fi
    fi
    if [ $ipaddr = "" ]; then
        return -1
    fi
}
function updateVirtDomain() {
    virt_server=${_ALFRESCO}/virtual-tomcat/conf/alfresco-virtserver.properties
    virt_server_property=alfresco.virtserver.domain

    if [ -e $virt_server ]; then
        grep -E ^alfresco\.virtserver\.domain=\([0-9]\{1,3\}-\)\{3\}[0-9]\{1,3\} $virt_server
        if [ $? -eq 0 ]; then
            sed -i -r -e s/^${virt_server_property}=\([0-9]\{1,3\}-\)\{3\}[0-9]\{1,3\}/${virt_server_property}=${ipaddr}/ \
            $virt_server
        else
            sed -i -r -e s/^${virt_server_property}=/${virt_server_property}=${ipaddr}/ \
            $virt_server
        fi
    fi
}
# See how we were called.
function start() {
    echo -n "Starting ${_PROG}: "
        if [ -f "/var/run/${NAME}.pid" ]; then
            read kpid < /var/run/${NAME}.pid
                if checkpid $kpid 2>&1; then
                    echo "$NAME process already running"
                        return -1
                    else
                        echo "lock file found but no process running for"
                        echo "pid $kpid, continuing"
                fi
        fi

    ###Insert start script here###
    getIP
    if [ $? -ne -1 ]; then
        updateVirtDomain
    else
        echo_failure
        exit
    fi    
    $_SCRIPT start
    RETVAL="$?"
    if [ "$RETVAL" -eq 0 ]; then
    sleep 3
    pidof -s java > /var/run/${NAME}.pid
        echo_success
    else
        echo_failure
    fi
    echo
    return $RETVAL
}
function status() {
    RETVAL="1"
    if [ -f "/var/run/${NAME}.pid" ]; then
        read kpid < /var/run/${NAME}.pid
        if checkpid $kpid 2>&1; then
            echo "$0 is already running (${kpid})"
            RETVAL="0"
        else
            echo "lock file found but no process running for pid $kpid"
        fi
    else
        pid="$(pgrep -u root java)"
        if [ -n "$pid" ]; then
            echo "$0 running (${pid}) but no PID file exists"
            RETVAL="0"
        else
            echo "$0 is stopped"
        fi
    fi
    return $RETVAL
}
function stop() {
    local STOP_VERBOSE="false"
    echo -n "Stopping $_PROG: "

    ###Insert Stop script here###
    $_SCRIPT stop
    RETVAL="$?"
        if [ "$RETVAL" -eq "0" ]; then
            count="0"
            if [ -f "/var/run/${NAME}.pid" ]; then
                read kpid < /var/run/${NAME}.pid
                until [ "$(ps --pid $kpid | grep -c $kpid)" -eq "0" ] || \
                      [ "$count" -gt "$SHUTDOWN_WAIT" ]; do
                    if [ "$STOP_VERBOSE" = "true" ]; then
                        echo -n -e "\nwaiting for processes $kpid to exit"
                    fi
                    sleep 1
                    let count="${count}+1"
                done
                if [ "$count" -gt "$SHUTDOWN_WAIT" ]; then
                    if [ "$STOP_VERBOSE" = "true" ]; then
                        echo -n -e "\nkilling processes which did not stop"
                        echo -n -e "after "
                        echo -n "$SHUTDOWN_WAIT seconds"
                    fi
                    kill -9 $kpid
                fi
                echo_success
                if [ "$count" -gt "0" ]; then
                    echo -n -e "\n"
                fi
            fi
        rm -f /var/run/${NAME}.pid
    else
        echo_failure
    fi    
}
# See how we were called.
case "$1" in
    start)
        start
        ;;
    stop)
        stop
        ;;
    restart)
        stop
        sleep 2    
        start
        ;;
    status)
        status
        ;;
    *)
        echo "Usage: $_PROG {start|stop|restart|status}"
        exit 1
esac
exit $RETVAL' > /etc/init.d/alfresco
chmod +x /etc/init.d/alfresco
#update-rc.d alfresco defaults
update-rc.d -f alfresco start 99 2 3 4 5 .
update-rc.d -f alfresco stop 90 0 6 .
#Alfresco launch script
echo " * Creating launch scripts ..."
echo '#!/bin/sh
# Start or stop Alfresco server
# Set the following to where Tomcat is installed
ALF_HOME=/opt/alfresco
APPSERVER="${ALF_HOME}/tomcat"
# Set any default JVM values
export JAVA_OPTS="-Xms128m -Xmx512m -XX:MaxPermSize=128m -server"
if [ "$1" = "start" ]; then
  "${APPSERVER}/bin/startup.sh"
elif [ "$1" = "stop" ]; then
  "${APPSERVER}/bin/shutdown.sh"
fi' > /opt/alfresco/alfresco.sh
chmod +x /opt/alfresco/alfresco.sh
#Alfresco extention config
echo " * Configuring extentions ..."
echo 'swf.exe=/usr/local/bin/pdf2swf
ooo.exe=/usr/lib/openoffice/program/soffice
img.root=/usr
dir.root=/var/alfresco/alf_data
db.driver=org.gjt.mm.mysql.Driver
db.url=jdbc:mysql://localhost/alfresco' > /opt/alfresco/tomcat/shared/classes/alfresco/extension/custom-repository.properties
echo 'hibernate.dialect=org.hibernate.dialect.MySQLInnoDBDialect' > /opt/alfresco/tomcat/shared/classes/alfresco/extension/custom-hibernate-dialect.properties
echo " * Finis!"
Advertisements