Instalar OpenERP en Ubuntu Parte II

Aunque ya tengo días sin escribir por diversos motivos, pero en esta parte, trataré de terminar lo que hace falta de esta seria de artículos sobre como instalar OpenERP.

En el caso de openerp-web, el archivo en /etc/init.d/ debe de contener lo siguiente:

#!/bin/sh

### BEGIN INIT INFO
# Provides:             openerp-web
# Required-Start:       $syslog
# Required-Stop:        $syslog
# Should-Start:         $network
# Should-Stop:          $network
# Default-Start:        2 3 4 5
# Default-Stop:         0 1 6
# Short-Description:    OpenERP Web - the Web Client of the OpenERP
# Description:          OpenERP is a complete ERP and CRM software.
### END INIT INFO

PATH=/sbin:/bin:/usr/sbin:/usr/bin
DAEMON=/usr/local/bin/openerp-web
NAME=openerp-web
DESC=openerp-web

# Specify the user name (Default: openerp).
USER="openerp"

# Specify an alternate config file (Default: /etc/openerp-web.cfg).
CONFIGFILE="/etc/openerp-web.cfg"

# pidfile
PIDFILE=/var/run/$NAME.pid

# Additional options that are passed to the Daemon.
DAEMON_OPTS="-c $CONFIGFILE"

[ -x $DAEMON ] || exit 0
[ -f $CONFIGFILE ] || exit 0

checkpid() {
    [ -f $PIDFILE ] || return 1
    pid=`cat $PIDFILE`
    [ -d /proc/$pid ] && return 0
    return 1
}

if [ -f /lib/lsb/init-functions ] || [ -f /etc/gentoo-release ] ; then

    do_start() {
        start-stop-daemon --start --quiet --pidfile $PIDFILE \
            --chuid $USER  --background --make-pidfile \
            --exec $DAEMON -- $DAEMON_OPTS

        RETVAL=$?
        sleep 5         # wait for few seconds

        return $RETVAL
    }

    do_stop() {
        start-stop-daemon --stop --quiet --pidfile $PIDFILE --oknodo

        RETVAL=$?
        sleep 2         # wait for few seconds
        rm -f $PIDFILE  # remove pidfile

        return $RETVAL
    }

    do_restart() {
        start-stop-daemon --stop --quiet --pidfile $PIDFILE --oknodo

        sleep 2         # wait for few seconds
        rm -f $PIDFILE  # remove pidfile

        start-stop-daemon --start --quiet --pidfile $PIDFILE \
            --chuid $USER --background --make-pidfile \
            --exec $DAEMON -- $DAEMON_OPTS

        RETVAL=$?
        sleep 5         # wait for few seconds

        return $RETVAL
    }

else

    do_start() {
        $DAEMON $DAEMON_OPTS > /dev/null 2>&1 &

        RETVAL=$?
        sleep 5         # wait for few seconds

        echo $! > $PIDFILE  # create pidfile

        return $RETVAL
    }

    do_stop() {

        pid=`cat $PIDFILE`
        kill -15 $pid

        RETVAL=$?
        sleep 2         # wait for few seconds
        rm -f $PIDFILE  # remove pidfile

        return $RETVAL
    }

    do_restart() {

        if [ -f $PIDFILE ]; then
            do_stop
        fi

        do_start

        return $?
    }

fi

start_daemon() {

    if [ -f $PIDFILE ]; then
        echo "pidfile already exists: $PIDFILE"
        exit 1
    fi

    echo -n "Starting $DESC: "

    do_start

    checkpid

    if [ $? -eq 1 ]; then                
        rm -f $PIDFILE
        echo "failed."
        exit 1
    fi

    echo "done."
}

stop_daemon() {

    checkpid

    if [ $? -eq 1 ]; then
        exit 0
    fi

    echo -n "Stopping $DESC: "

    do_stop

    if [ $? -eq 1 ]; then
        echo "failed."
        exit 1
    fi

    echo "done."
}

restart_daemon() {

    echo -n "Reloading $DESC: "

    do_restart

    checkpid

    if [ $? -eq 1 ]; then                
        rm -f $PIDFILE
        echo "failed."
        exit 1
    fi

    echo "done."
}

status_daemon() {

    echo -n "Checking $DESC: "

    checkpid

    if [ $? -eq 1 ]; then
        echo "stopped."
    else
        echo "running."
    fi
}

case "$1" in
    start) start_daemon ;;
    stop) stop_daemon ;;
    restart|force-reload) restart_daemon ;;
    status) status_daemon ;;
    *)
        N=/etc/init.d/$NAME
        echo "Usage: $N {start|stop|restart|force-reload|status}" >&2
        exit 1
        ;;
esac

exit 0

Con lo anterior, ya tenemos los archivos de arranque tanto para openerp-server como para openerp-web, ahora continuamos creando los archivos de configuración:

El archivo de configuración de /etc/openerp-server.conf

# /etc/openerp-server.conf(5) - configuration file for openerp-server(1)

[options]
# Enable the debugging mode (default False).
#verbose = True

# The file where the server pid will be stored (default False).
#pidfile = /var/run/openerp.pid

# The file where the server log will be stored (default False).
logfile = /var/log/openerp/openerp.log

# The IP address on which the server will bind.
# If empty, it will bind on all interfaces (default empty).
#interface = localhost
interface = 
# The TCP port on which the server will listen (default 8069).
port = 8069

# Enable debug mode (default False).
#debug_mode = True

# Launch server over https instead of http (default False).
secure = False

# Specify the SMTP server for sending email (default localhost).
smtp_server = localhost

# Specify the SMTP user for sending email (default False).
smtp_user = False

# Specify the SMTP password for sending email (default False).
smtp_password = False

# Specify the database name.
db_name =

# Specify the database user name (default None).
db_user = openerp

# Specify the database password for db_user (default None).
db_password = TU_PASSWORD_AQUI

# Specify the database host (default localhost).
db_host =

# Specify the database port (default None).

db_port = 5432

Y el contenido del archivo openerp-web.cfg es el siguiente:

[global]
server.environment = "development"

# Some server parameters that you may want to tweak
server.socket_host = "0.0.0.0"
server.socket_port = 8080

# Sets the number of threads the server uses
server.thread_pool = 10

tools.sessions.on = True
tools.sessions.persistent = False

# Simple code profiling
server.profile_on = False
server.profile_dir = "profile"

# if this is part of a larger site, you can set the path
# to the TurboGears instance here
#server.webpath = ""

# Set to True if you are deploying your App behind a proxy
# e.g. Apache using mod_proxy
#tools.proxy.on = True

# If your proxy does not add the X-Forwarded-Host header, set
# the following to the *public* host url.
#tools.proxy.base = 'http://mydomain.com'

# logging
log.access_file = "/var/log/openerp-web/access.log"
log.error_file = "/var/log/openerp-web/error.log"
log.access_level = "INFO"
log.error_level = "INFO"

# Set to false to disable CSRF checks
tools.csrf.on = True

# replace builtin traceback tools by cgitb
tools.log_tracebacks.on: False
tools.cgitb.on: True
# a default install can probably avoid logging those via cgitb as they're
# available in the server log
tools.cgitb.ignore=(
    openobject.errors.Concurrency,
    openobject.errors.TinyException)

# OpenERP Server
openerp.server.host = 'localhost'
openerp.server.port = '8070'
openerp.server.protocol = 'socket'
openerp.server.timeout = 450

# Web client settings
[openerp-web]
# filter dblists based on url pattern?
# NONE: No Filter
# EXACT: Exact Hostname
# UNDERSCORE: Hostname_
# BOTH: Exact Hostname or Hostname_

dblist.filter = 'NONE'

# whether to show Databases button on Login screen or not
dbbutton.visible = True

# will be applied on company logo
company.url = ''

Con eso ya tenemos los archivos de configuración tanto para OpenERP web y server. Ahora procedemos a cambiar los permisos de los archivos.

Cambiamos los permisos de los archivos de configuración:

sudo chown root.root /etc/openerp-server.conf 
sudo chmod 644 /etc/openerp-server.conf

sudo chown root.root /etc/openerp-web.cfg 
sudo chmod 644 /etc/openerp-web.cfg

Creamos el archivo /var/log/openerp-web.log para almacenar los logs:

sudo mkdir -p /var/log/openerp-web 
sudo touch /var/log/openerp-web/access.log 
sudo touch /var/log/openerp-web/error.log 
sudo chown -R openerp.root /var/log/openerp-web/

Ahora configuramos openerp para que se inicie en el arranque del sistema:

sudo update-rc.d openerp-server start 21 2 3 4 5 . stop 21 0 1 6 . 
sudo update-rc.d openerp-web start 70 2 3 4 5 . stop 20 0 1 6 .

Espero que les sirve a todos para terminar sus instalaciones y tener OpenERP funcionando.

Pingbacks

Los pingbacks están cerrados.

Comentarios

Los comentarios están deshabilitados.