English Version

domingo, 26 de diciembre de 2010

Instalación de OpenERP III - Ejecución como un servicio en OpenSuse de 64 bits

Vamos a continuar hoy con otro post más en la instalación y configuración de OpenERP en OpenSuse. Para los que quieran ver la primera parte pueden hacerlo aquí, y la segunda parte aquí.

En concreto veremos hoy la ejecución del servidor y del cliente web de OpenERP como un servicio.

Aquellos que estéis instalando OpenERP en OpenSuse habréis visto que casi todos los ejemplos que existen para levantar el servidor de OpenERP como un servicio son para Ubuntu. Como diría mi amigo Benito de Papel Tank en señal de protesta “Ñe”. Pero bueno, aunque la comunidad de OpenSuse es menor, ya existe un proyecto para crear una instalación de OpenERP a través de repositorios, podéis visitar su dirección aquí

Desgraciadamente en el momento en que he intentado probar la instalación desde este proyecto no me ha funcionado todo lo bien que hubiera deseado. En concreto no resuelve todas las dependencias de librerías python, al menos por el momento, e incluso en la instalación, el script que usa para levantar OpenERP como un servicio usa el comando start-stop-daemon de Debian - Ubuntu, aunque proporcionan uno para OpenSuse como veremos más adelante.

Si habéis intentado utilizar alguno de los script con start-stop-daemon en OpenSuse habréis visto que no acepta muchas de las opciones aunque tengáis instalado el comando. Parece ser que la versión instalada en OpenSuse es muy antigua, de hecho si ejecutais start-stop-daemon con la opción “--version” podréis ver de qué año es. En mi caso es del año 96. Esto es porque la utilización del comando start-stop-daemon para levantar un servicio es una filosofía Debian, y OpenSuse utiliza el comando startproc para levantar sus servicios.

Afortunadamente en este mismo proyecto que os comento podéis ver en la siguiente dirección un ejemplo de script que usa startproc para levantar el servicio en OpenSuse del servidor de OpenERP. Este ejemplo es para OpenSuse en su versión de 32 bits, yo pondré aquí en un recuadro más abajo mi script con las modificaciones que he realizado para mi sistema de 64 bits ya que el script mostrado no me ha funcionado correctamente por diversos motivos que comentaré más adelante.

Antes describiré los pasos que he realizado:

CONFIGURACIÓN DEL SERVIDOR DE OPENERP COMO UN SERVICIO

1.- Copiar el archivo de configuración del servidor “~/.openerp_serverrc” que habíamos creado con el comando “openerp-server -s” a la carpeta /etc con el nombre “openerp-server.conf” .

#> sudo cp .openerp_serverrc /etc/openerp-server.conf
#> sudo chmod 644 /etc/openerp-server.conf

2.- Para que sea compatible con el script crearemos en nuestro sistema el usuario openerp con la contraseña que queramos, en mi ejemplo para simplificar openerp.

#> sudo useradd openerp
#> sudo passwd openerp

3.- Añadimos también un grupo openerp:

#> sudo groupadd openerp

Podemos ver que se ha asignado el grupo con el siguiente comando:

#> sudo cat /etc/group

4.- Asignamos nuestro usuario openerp a nustro grupo openerp.

#> sudo usermod -g openerp openerp

Ahora si nos identificamos con el usuario openerp (su - openerp) y ejecutamos el comando groups podremos ver como nuestro usuario openerp tiene como grupo principal el grupo openerp.

5.- Creamos el archivo openerp-server en “/etc/init.d”  y lo editamos para que figure como en el siguiente recuadro y le damos permisos para su ejecución "chmod 755 openerp-server":


#!/bin/sh
#
# /etc/init.d/openerp-server
#
### BEGIN INIT INFO
# Provides:          openerp-server
# Required-Start:    $syslog $remote_fs postgresql
# Should-Start:      $network postgresql
# Required-Stop:     $syslog $remote_fs postgresql
# Should-Stop:       $network postgresql
# Default-Start:     2 3 5
# Default-Stop:      0 1 6
# Short-Description: OpenERP Server daemon
# Description:       Start the OpenERP Server daemon
### END INIT INFO
#
# Check for missing binaries (stale symlinks should not happen)
# Note: Special treatment of stop for LSB conformance
PYTHON_BIN="/usr/bin/python"
OPENERP_BIN="/usr/local/lib64/python2.6/site-packages/openerp-server/openerp-server.py"
OPENERP_EXEC="$PYTHON_BIN $OPENERP_BIN"
OPENERP_CONFIGFILE=/etc/openerp-server.conf
OPENERP_PID=/var/run/openerp/openerp-server.pid
OPENERP_LOG=/var/log/openerp-server/openerp-server.log
# Test for python binary
test -x $PYTHON_BIN || { echo "$PYTHON_BIN not installed";
       if [ "$1" = "stop" ]; then exit 0;
       else exit 5; fi; }
# Test for openerp-server.py
test -r $OPENERP_BIN || { echo "$OPENERP_BIN not installed";
       if [ "$1" = "stop" ]; then exit 0;
       else exit 5; fi; }

# Test for config file. Manual configuration required
test -r $OPENERP_CONFIGFILE || { echo "OpenERP not configured. Do manual copy from
/usr/share/doc/packages/openerp-server/openerp-server.conf to /etc. Edit to set your preferencies and set ownership to openerp user
and group and permissions to read-only user.";
   if [ "$1" = "stop" ]; then exit 0;
   else exit 6; fi; }

# Check for existence of needed config file and read it
# OPENERP_CONFIGFILE=/etc/sysconfig/openerp-server
# test -r $OPENERP_CONFIG || { echo "$OPENERP_CONFIG not existing";
#       if [ "$1" = "stop" ]; then exit 0;
#       else exit 6; fi; }
#
# Read config
# . $OPENERP_CONFIG

# Source LSB init functions
# providing start_daemon, killproc, pidofproc,
# log_success_msg, log_failure_msg and log_warning_msg.
# This is currently not used by UnitedLinux based distributions and
# not needed for init scripts for UnitedLinux only. If it is used,
# the functions from rc.status should not be sourced or used.
#. /lib/lsb/init-functions

# Shell functions sourced from /etc/rc.status:
#      rc_check         check and set local and overall rc status
#      rc_status        check and set local and overall rc status
#      rc_status -v     be verbose in local rc status and clear it afterwards
#      rc_status -v -r  ditto and clear both the local and overall rc status
#      rc_status -s     display "skipped" and exit with status 3
#      rc_status -u     display "unused" and exit with status 3
#      rc_failed        set local and overall rc status to failed
#      rc_failed <num>  set local and overall rc status to <num>
#      rc_reset         clear both the local and overall rc status
#      rc_exit          exit appropriate to overall rc status
#      rc_active        checks whether a service is activated by symlinks
. /etc/rc.status

# Reset status of this service
rc_reset

# Return values acc. to LSB for all commands but status:
# 0       - success
# 1       - generic or unspecified error
# 2       - invalid or excess argument(s)
# 3       - unimplemented feature (e.g. "reload")
# 4       - user had insufficient privileges
# 5       - program is not installed
# 6       - program is not configured
# 7       - program is not running
# 8--199  - reserved (8--99 LSB, 100--149 distrib, 150--199 appl)
#
# Note that starting an already running service, stopping
# or restarting a not-running service as well as the restart
# with force-reload (in case signaling is not supported) are
# considered a success.

case "$1" in
   start)
       echo -n "Starting openerp-server "
       ## Start daemon with startproc(8). If this fails
       ## the return value is set appropriately by startproc.
       /sbin/startproc -u openerp -g openerp -l $OPENERP_LOG -p $OPENERP_PID \
       $OPENERP_EXEC --config=$OPENERP_CONFIGFILE
       # Remember status and be verbose
       rc_status -v
       ;;
   stop)
       echo -n "Shutting down openerp-server "
       ## Stop daemon with killproc(8) and if this fails
       ## killproc sets the return value according to LSB.

       /sbin/killproc -t 1 -QUIT -p $OPENERP_PID $OPENERP_EXEC
       /sbin/killproc -t 1 -TERM -p $OPENERP_PID $OPENERP_EXEC

       # Remember status and be verbose
       rc_status -v
       ;;
   try-restart|condrestart)
       ## Do a restart only if the service was active before.
       ## Note: try-restart is now part of LSB (as of 1.9).
       ## RH has a similar command named condrestart.
       if test "$1" = "condrestart"; then
               echo "${attn} Use try-restart ${done}(LSB)${attn} rather than condrestart ${warn}(RH)${norm}"
       fi
       $0 status
       if test $? = 0; then
               $0 restart
       else
               rc_reset        # Not running is not a failure.
       fi
       # Remember status and be quiet
       rc_status
       ;;
   restart)
       ## Stop the service and regardless of whether it was
       ## running or not, start it again.
       $0 stop
       $0 start

       # Remember status and be quiet
       rc_status
       ;;
   force-reload)
       ## Signal the daemon to reload its config. Most daemons
       ## do this on signal 1 (SIGHUP).
       ## If it does not support it, restart the service if it
       ## is running.

       echo -n "Reload service openerp-server "
       ## if it supports it:
       /sbin/killproc -HUP -p $OPENERP_PID $OPENERP_EXEC
       rc_status -v

       ## Otherwise:
       #$0 try-restart
       #rc_status
       ;;
   reload)
       ## Like force-reload, but if daemon does not support
       ## signaling, do nothing (!)

       # If it supports signaling:
       echo -n "Reload service openerp-server "
       /sbin/killproc -HUP -p $OPENERP_PID $OPENERP_EXEC
       rc_status -v

       ## Otherwise if it does not support reload:
       #rc_failed 3
       #rc_status -v
       ;;
  status)
       echo -n "Checking for service openerp-server "
       ## Check status with checkproc(8), if process is running
       ## checkproc will return with exit status 0.

       # Return value is slightly different for the status command:
       # 0 - service up and running
       # 1 - service dead, but /var/run/  pid  file exists
       # 2 - service dead, but /var/lock/ lock file exists
       # 3 - service not running (unused)
       # 4 - service status unknown :-(
       # 5--199 reserved (5--99 LSB, 100--149 distro, 150--199 appl.)

       # NOTE: checkproc returns LSB compliant status values.
       /sbin/checkproc -p $OPENERP_PID $OPENERP_EXEC
       # NOTE: rc_status knows that we called this init script with
       # "status" option and adapts its messages accordingly.
       rc_status -v
       ;;
   probe)
       ## Optional: Probe for the necessity of a reload, print out the
       ## argument to this init script which is required for a reload.
       ## Note: probe is not (yet) part of LSB (as of 1.9)

       test /etc/openerp-server.conf -nt /var/run/openerp-server.pid && echo reload
       ;;
   *)
       echo "Usage: $0 {start|stop|status|try-restart|restart|force-reload|reload|probe}"
       exit 1
       ;;
esac
rc_exit



En teoría con el script de este recuadro podremos levantar nuestro servicio en OpenSuse de 64 bits en base a la instalación realizada en los anteriores post. Digo en teoría porque yo he tenido problemas para hacerlo funcionar. Comentaré a partir del punto 7 los problemas que he tenido y cómo los he solucionado. Si a ti te funciona bien levantando el servicio como indica el punto 6, y confirmas que está levantado el servicio, no leas desde el punto 7 en adelante.

6.- Tan sólo nos queda probar nuestro servicio:

#> sudo /etc/init.d/openerp-server start

Starting openerp-server    done 
    
7.- Aunque en el punto anterior nos muestre el mensaje de que el servicio se ha levantado correctamente, si observamos con profundidad y ejecutamos por ejemplo el comando netstat -a | grep “8070” o el comando ps -x veremos que en realidad el servidor no se ha levantado, ya que ni el puerto está a la escucha ni existe el proceso levantado, ni ha creado el archivo del log en /var/log/openerp-server/openerp-server.log. ¿Cuál es entonces el problema? pues bien, después de mucho probar he podido ver que startproc y el interprete de python tienen el siguiente problema:

La forma de ejecución del comando startproc es la siguiente


startproc /path/to/executable [arguments for executable]


En nuestro script sería de la siguiente forma:


startproc /usr/bin/python /path/to/openerp-server.py


Por algún motivo startproc con el intérprete de python no reconoce como argumento nuestro path al archivo openerp-server.py. Para solucionarlo haremos lo siguiente:


a) Cambiaremos los permisos de ejecución de nuestro archivo openerp-server.py para hacerlo ejecutable


#> sudo chmod 744 /usr/local/lib64/python2.6/site-packages/openerp-server/openerp-server.py


#> chown openerp:openerp /usr/local/lib64/python2.6/site-packages/openerp-server/openerp-server.py  
                              
Cambiaremos en nuestro script la siguiente linea:



/sbin/startproc -u openerp -g openerp -l $OPENERP_LOG -p $OPENERP_PID \
       $OPENERP_EXEC --config=$OPENERP_CONFIGFILE

Por esta otra:




/sbin/startproc -u openerp -g openerp -l $OPENERP_LOG -p $OPENERP_PID \
       $OPENERP_BIN --config=$OPENERP_CONFIGFILE




b) Si ahora intentamos ejecutar el servicio es posible que nos muestre el siguiente mensaje:






#> sudo /etc/init.d/openerp-server start
Starting openerp-server    failed



Sin embargo ahora si ejecutamos el comando netstat -a | grep “8070” y el comando ps -x y miramos si ha creado el archivo de log /var/log/openerp-server/openerp-server.log y vemos que se está ejecutando el servicio, y está el puerto 8070 a la escucha, y además existe el archivo de log, ¿Por qué nos dice que el arranque del servicio ha fallado? Pues bien, nos indica que el arranque ha fallado porque si observamos no se ha creado el archivo de PID en /var/run/openerp/openerp-server.pid ya que por algún motivo el intérprete de python no lo devuelve bien al comando startproc


c) Para solucionar el problema con el archivo PID introduciremos la siguiente línea justo después de la línea del apartado a)


echo $(ps ax | grep openerp-server.py) | cut --fields=1 -d" " > $OPENERP_PID


Si ahora guardamos y salimos y probamos a levantar otra vez nuestro servicio deberíamos poder levantarlo y pararlo sin problemas. Además mientras esté levantado podremos comprobar que se ha creado el archivo openerp-server.pid con el pid de nuestro server de OpenERP. Es posible que necesitemos crear las rutas a nuestros archivos openerp-server.pid y openerp-server.log.


De esta forma mi archivo final para levantar el servidor de OpenERP quedaría de la siguiente forma:






#!/bin/sh
#
# /etc/init.d/openerp-server
#
### BEGIN INIT INFO
# Provides:          openerp-server
# Required-Start:    $syslog $remote_fs postgresql
# Should-Start:      $network postgresql
# Required-Stop:     $syslog $remote_fs postgresql
# Should-Stop:       $network postgresql
# Default-Start:     2 3 5
# Default-Stop:      0 1 6
# Short-Description: OpenERP Server daemon
# Description:       Start the OpenERP Server daemon
### END INIT INFO
#
# Check for missing binaries (stale symlinks should not happen)
# Note: Special treatment of stop for LSB conformance
PYTHON_BIN="/usr/bin/python"
OPENERP_BIN="/usr/local/lib64/python2.6/site-packages/openerp-server/openerp-server.py"
OPENERP_EXEC="$PYTHON_BIN $OPENERP_BIN"
OPENERP_CONFIGFILE="/etc/openerp-server.conf"
OPENERP_PID="/var/run/openerp/openerp-server.pid"
OPENERP_LOG="/var/log/openerp-server/openerp-server.log"
# Test for python binary
test -x $PYTHON_BIN || { echo "$PYTHON_BIN not installed";
       if [ "$1" = "stop" ]; then exit 0;
       else exit 5; fi; }
# Test for openerp-server.py
test -r $OPENERP_BIN || { echo "$OPENERP_BIN not installed";
       if [ "$1" = "stop" ]; then exit 0;
       else exit 5; fi; }

# Test for config file. Manual configuration required
test -r $OPENERP_CONFIGFILE || { echo "OpenERP not configured. Do manual copy from
/usr/share/doc/packages/openerp-server/openerp-server.conf to /etc. Edit to set your preferencies and set ownership to openerp user
and group and permissions to read-only user.";
   if [ "$1" = "stop" ]; then exit 0;
   else exit 6; fi; }

# Check for existence of needed config file and read it
# OPENERP_CONFIGFILE=/etc/sysconfig/openerp-server
# test -r $OPENERP_CONFIG || { echo "$OPENERP_CONFIG not existing";
#       if [ "$1" = "stop" ]; then exit 0;
#       else exit 6; fi; }
#
# Read config
# . $OPENERP_CONFIG

# Source LSB init functions
# providing start_daemon, killproc, pidofproc,
# log_success_msg, log_failure_msg and log_warning_msg.
# This is currently not used by UnitedLinux based distributions and
# not needed for init scripts for UnitedLinux only. If it is used,
# the functions from rc.status should not be sourced or used.
#. /lib/lsb/init-functions

# Shell functions sourced from /etc/rc.status:
#      rc_check         check and set local and overall rc status
#      rc_status        check and set local and overall rc status
#      rc_status -v     be verbose in local rc status and clear it afterwards
#      rc_status -v -r  ditto and clear both the local and overall rc status
#      rc_status -s     display "skipped" and exit with status 3
#      rc_status -u     display "unused" and exit with status 3
#      rc_failed        set local and overall rc status to failed
#      rc_failed <num>  set local and overall rc status to <num>
#      rc_reset         clear both the local and overall rc status
#      rc_exit          exit appropriate to overall rc status
#      rc_active        checks whether a service is activated by symlinks
. /etc/rc.status

# Reset status of this service
rc_reset

# Return values acc. to LSB for all commands but status:
# 0       - success
# 1       - generic or unspecified error
# 2       - invalid or excess argument(s)
# 3       - unimplemented feature (e.g. "reload")
# 4       - user had insufficient privileges
# 5       - program is not installed
# 6       - program is not configured
# 7       - program is not running
# 8--199  - reserved (8--99 LSB, 100--149 distrib, 150--199 appl)
#
# Note that starting an already running service, stopping
# or restarting a not-running service as well as the restart
# with force-reload (in case signaling is not supported) are
# considered a success.

case "$1" in
   start)
       echo -n "Starting openerp-server "
       ## Start daemon with startproc(8). If this fails
       ## the return value is set appropriately by startproc.
       /sbin/startproc  -u openerp -g openerp -l $OPENERP_LOG -p $OPENERP_PID \
       $OPENERP_BIN --config=$OPENERP_CONFIGFILE
       echo $(ps ax | grep openerp-server.py) | cut --fields=1 -d" " > $OPENERP_PID
       # Remember status and be verbose
       rc_status -v
       ;;
   stop)
       echo -n "Shutting down openerp-server "
       ## Stop daemon with killproc(8) and if this fails
       ## killproc sets the return value according to LSB.

       /sbin/killproc -t 1 -QUIT -p $OPENERP_PID $OPENERP_EXEC
       /sbin/killproc -t 1 -TERM -p $OPENERP_PID $OPENERP_EXEC

       # Remember status and be verbose
       rc_status -v
       ;;
   try-restart|condrestart)
       ## Do a restart only if the service was active before.
       ## Note: try-restart is now part of LSB (as of 1.9).
       ## RH has a similar command named condrestart.
       if test "$1" = "condrestart"; then
               echo "${attn} Use try-restart ${done}(LSB)${attn} rather than condrestart ${warn}(RH)${norm}"
       fi
       $0 status
       if test $? = 0; then
               $0 restart
       else
               rc_reset        # Not running is not a failure.
       fi
       # Remember status and be quiet
       rc_status
       ;;
   restart)
       ## Stop the service and regardless of whether it was
       ## running or not, start it again.
       $0 stop
       $0 start

       # Remember status and be quiet
       rc_status
       ;;
   force-reload)
       ## Signal the daemon to reload its config. Most daemons
       ## do this on signal 1 (SIGHUP).
       ## If it does not support it, restart the service if it
       ## is running.

       echo -n "Reload service openerp-server "
       ## if it supports it:
       /sbin/killproc -HUP -p $OPENERP_PID $OPENERP_EXEC
       rc_status -v

       ## Otherwise:
       #$0 try-restart
       #rc_status
       ;;
   reload)
       ## Like force-reload, but if daemon does not support
       ## signaling, do nothing (!)

       # If it supports signaling:
       echo -n "Reload service openerp-server "
       /sbin/killproc -HUP -p $OPENERP_PID $OPENERP_EXEC
       rc_status -v

       ## Otherwise if it does not support reload:
       #rc_failed 3
       #rc_status -v
       ;;
  status)
       echo -n "Checking for service openerp-server "
       ## Check status with checkproc(8), if process is running
       ## checkproc will return with exit status 0.

       # Return value is slightly different for the status command:
       # 0 - service up and running
       # 1 - service dead, but /var/run/  pid  file exists
       # 2 - service dead, but /var/lock/ lock file exists
       # 3 - service not running (unused)
       # 4 - service status unknown :-(
       # 5--199 reserved (5--99 LSB, 100--149 distro, 150--199 appl.)

       # NOTE: checkproc returns LSB compliant status values.
       /sbin/checkproc -p $OPENERP_PID $OPENERP_EXEC
       # NOTE: rc_status knows that we called this init script with
       # "status" option and adapts its messages accordingly.
       rc_status -v
       ;;
   probe)
       ## Optional: Probe for the necessity of a reload, print out the
       ## argument to this init script which is required for a reload.
       ## Note: probe is not (yet) part of LSB (as of 1.9)

       test /etc/openerp-server.conf -nt /var/run/openerp-server.pid && echo reload
       ;;
   *)
       echo "Usage: $0 {start|stop|status|try-restart|restart|force-reload|reload|probe}"
       exit 1
       ;;
esac
rc_exit





CONFIGURACIÓN DEL CLIENTE WEB DE OPENERP COMO UN SERVICIO

Al igual que el servidor tenemos un script de ejemplo para levantar el cliente web en OpenSuse de 32 bits en la siguiente dirección.

Yo pondré aquí los pasos seguidos y la configuración para mi sistema de 64 bits.

1.- Copiamos el archivo ~/.openerprc del anterior post a /etc/ con el nombre openerp-web.cfg.

#> sudo cp .openerprc /etc/openerp-web.cfg

2.- Creamos un archivo llamado openerp-web en “/etc/init.d” y lo editamos para que sea similar al del siguiente recuadro y le damos permisos para su ejecución "chmod 755 openerp-web":






#!/bin/sh
#
# /etc/init.d/openerp-web
#
### BEGIN INIT INFO
# Provides:          openerp-web
# Required-Start:    $syslog $remote_fs openerp-server
# Should-Start:      $network openerp-server
# Required-Stop:     $syslog $remote_fs openerp-server
# Should-Stop:       $network openerp-server
# Default-Start:     2 3 5
# Default-Stop:      0 1 6
# Short-Description: OpenERP WEB Client daemon
# Description:       Start the OpenERP WEB Client daemon
### END INIT INFO
#
# Check for missing binaries (stale symlinks should not happen)
# Note: Special treatment of stop for LSB conformance
PYTHON_BIN="/usr/bin/python"
OPENERP_BIN="/usr/local/bin/openerp-web"
OPENERP_EXEC="$PYTHON_BIN $OPENERP_BIN"
OPENERP_CONFIGFILE=/etc/openerp-web.cfg
OPENERP_LOG=/var/log/openerp-web/openerp-web.log
OPENERP_PID=/var/run/openerp/openerp-web.pid
# Test for python binary
test -x $PYTHON_BIN || { echo "$PYTHON_BIN not installed";
       if [ "$1" = "stop" ]; then exit 0;
       else exit 5; fi; }
# Test for openerp-web.py
test -x $OPENERP_BIN || { echo "$OPENERP_BIN not installed";
       if [ "$1" = "stop" ]; then exit 0;
       else exit 5; fi; }

# Check for existence of needed config file and read it
# OPENERP_CONFIG=/etc/sysconfig/openerp-web
# test -r $OPENERP_CONFIG || { echo "$OPENERP_CONFIG not existing";
#       if [ "$1" = "stop" ]; then exit 0;
#       else exit 6; fi; }
#
# Read config
# . $OPENERP_CONFIG

# Source LSB init functions
# providing start_daemon, killproc, pidofproc,
# log_success_msg, log_failure_msg and log_warning_msg.
# This is currently not used by UnitedLinux based distributions and
# not needed for init scripts for UnitedLinux only. If it is used,
# the functions from rc.status should not be sourced or used.
#. /lib/lsb/init-functions

# Shell functions sourced from /etc/rc.status:
#      rc_check         check and set local and overall rc status
#      rc_status        check and set local and overall rc status
#      rc_status -v     be verbose in local rc status and clear it afterwards
#      rc_status -v -r  ditto and clear both the local and overall rc status
#      rc_status -s     display "skipped" and exit with status 3
#      rc_status -u     display "unused" and exit with status 3
#      rc_failed        set local and overall rc status to failed
#      rc_failed <num>  set local and overall rc status to <num>
#      rc_reset         clear both the local and overall rc status
#      rc_exit          exit appropriate to overall rc status
#      rc_active        checks whether a service is activated by symlinks
. /etc/rc.status

# Reset status of this service
rc_reset

# Return values acc. to LSB for all commands but status:
# 0       - success
# 1       - generic or unspecified error
# 2       - invalid or excess argument(s)
# 3       - unimplemented feature (e.g. "reload")
# 4       - user had insufficient privileges
# 5       - program is not installed
# 6       - program is not configured
# 7       - program is not running
# 8--199  - reserved (8--99 LSB, 100--149 distrib, 150--199 appl)
#
# Note that starting an already running service, stopping
# or restarting a not-running service as well as the restart
# with force-reload (in case signaling is not supported) are
# considered a success.

case "$1" in
   start)
       echo -n "Starting openerp-web "
       ## Start daemon with startproc(8). If this fails
       ## the return value is set appropriately by startproc.
       #/sbin/startproc -l $OPENERP_LOG -p $OPENERP_PID $OPENERP_BIN --config=$OPENERP_CONFIGFILE
       /sbin/startproc -l $OPENERP_LOG -p $OPENERP_PID $OPENERP_BIN
       echo $(ps ax | grep /usr/local/bin/openerp-web) | cut --fields=1 -d" " > $OPENERP_PID
       # Remember status and be verbose
       rc_status -v
       ;;
   stop)
       echo -n "Shutting down openerp-web "
       ## Stop daemon with killproc(8) and if this fails
       ## killproc sets the return value according to LSB.

       /sbin/killproc -t 1 -QUIT -p $OPENERP_PID $OPENERP_EXEC
       /sbin/killproc -t 1 -TERM -p $OPENERP_PID $OPENERP_EXEC

       # Remember status and be verbose
       rc_status -v
       ;;
   try-restart|condrestart)
       ## Do a restart only if the service was active before.
       ## Note: try-restart is now part of LSB (as of 1.9).
       ## RH has a similar command named condrestart.
       if test "$1" = "condrestart"; then
               echo "${attn} Use try-restart ${done}(LSB)${attn} rather than condrestart ${warn}(RH)${norm}"
       fi
       $0 status
       if test $? = 0; then
               $0 restart
       else
               rc_reset        # Not running is not a failure.
       fi
       # Remember status and be quiet
       rc_status
       ;;
   restart)
       ## Stop the service and regardless of whether it was
       ## running or not, start it again.
       $0 stop
       $0 start

       # Remember status and be quiet
       rc_status
       ;;
   force-reload)
       ## Signal the daemon to reload its config. Most daemons
       ## do this on signal 1 (SIGHUP).
       ## If it does not support it, restart the service if it
       ## is running.

       echo -n "Reload service openerp-web "
       ## if it supports it:
       /sbin/killproc -HUP -p $OPENERP_PID $OPENERP_EXEC
       rc_status -v

       ## Otherwise:
       #$0 try-restart
       #rc_status
       ;;
   reload)
       ## Like force-reload, but if daemon does not support
       ## signaling, do nothing (!)

       # If it supports signaling:
       echo -n "Reload service openerp-web "
       /sbin/killproc -HUP -p $OPENERP_PID $OPENERP_EXEC
       rc_status -v

       ## Otherwise if it does not support reload:
       #rc_failed 3
       #rc_status -v
       ;;
   status)
       echo -n "Checking for service openerp-web "
       ## Check status with checkproc(8), if process is running
       ## checkproc will return with exit status 0.

       # Return value is slightly different for the status command:
       # 0 - service up and running
       # 1 - service dead, but /var/run/  pid  file exists
       # 2 - service dead, but /var/lock/ lock file exists
       # 3 - service not running (unused)
       # 4 - service status unknown :-(
       # 5--199 reserved (5--99 LSB, 100--149 distro, 150--199 appl.)

       # NOTE: checkproc returns LSB compliant status values.
       /sbin/checkproc -p $OPENERP_PID $OPENERP_EXEC
       # NOTE: rc_status knows that we called this init script with
       # "status" option and adapts its messages accordingly.
       rc_status -v
       ;;
   *)
       echo "Usage: $0 {start|stop|status|try-restart|restart|force-reload|reload}"
       exit 1
       ;;
esac
rc_exit



3.- Probamos nuestro servicio:

#> sudo /etc/init.d/openerp-web start

Starting openerp-web done


Si todo ha ido bien ya tendremos nuestro servidor OpenERP y nuestro cliente web ejecutándose como servicios en nuestro sistema OpenSuse.

Saludos a todos.