From owner-freebsd-ports@FreeBSD.ORG Fri Jan 8 06:51:14 2010 Return-Path: Delivered-To: ports@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id A000A1065672 for ; Fri, 8 Jan 2010 06:51:14 +0000 (UTC) (envelope-from dougb@FreeBSD.org) Received: from mail2.fluidhosting.com (mx21.fluidhosting.com [204.14.89.4]) by mx1.freebsd.org (Postfix) with ESMTP id 482EA8FC12 for ; Fri, 8 Jan 2010 06:51:14 +0000 (UTC) Received: (qmail 23774 invoked by uid 399); 8 Jan 2010 06:51:13 -0000 Received: from localhost (HELO foreign.dougb.net) (dougb@dougbarton.us@127.0.0.1) by localhost with ESMTPAM; 8 Jan 2010 06:51:13 -0000 X-Originating-IP: 127.0.0.1 X-Sender: dougb@dougbarton.us Message-ID: <4B46D5E0.5080102@FreeBSD.org> Date: Thu, 07 Jan 2010 22:51:12 -0800 From: Doug Barton Organization: http://SupersetSolutions.com/ User-Agent: Thunderbird 2.0.0.23 (X11/20091206) MIME-Version: 1.0 To: Jean-Yves Boisiaud - Osiell References: <4B45AAF5.50905@osiell.com> In-Reply-To: <4B45AAF5.50905@osiell.com> X-Enigmail-Version: 0.96.0 OpenPGP: id=D5B2F0FB Content-Type: multipart/mixed; boundary="------------020309050504060302010304" Cc: wen@FreeBSD.org, ports@FreeBSD.org Subject: Re: FreeBSD Port: openerp-server-5.0.6_1 X-BeenThere: freebsd-ports@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Porting software to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 08 Jan 2010 06:51:14 -0000 This is a multi-part message in MIME format. --------------020309050504060302010304 Content-Type: text/plain; charset=ISO-8859-15 Content-Transfer-Encoding: 7bit Jean-Yves Boisiaud - Osiell wrote: > Hello, > > Here is a rc.d script to start/stop/restart the OpenERP server. Overall this is very nice work. :) I've attached a version with some changes that I will detail below. > openerp-server default configuration file (-c option) should give the > same PID file that the rc script : > > pidfile = /var/run/openerp/server.pid > > The installation script should create a user with no password used to > run the OpenERP server. Here, I used terp. > > <<<<<<<<<<<<<<<<<<<<< > #!/bin/sh I added a $FreeBSD$ > # > # PROVIDE: openerp_server > # REQUIRE: postgresql Since this is running as a user other than root it also has to REQUIRE: LOGIN > # KEYWORD: shutdown > # > # Add the following line to /etc/rc.conf to enable OpenERP server: > # > # openerp_server_enable="YES" > # # optional > # openerp_server_flags="-c /usr/local/etc/openerp-server.conf" > # openerp_server_user="terp" > # > # Do not forget to define the same PID file in the OpenERP configuration > # file (see the variable $pidfile defined below). > # > # This scripts takes one of the following commands: > # > # start stop restart status > # > > : ${openerp_server_enable="NO"} > : ${openerp_server_flags="-c /usr/local/etc/openerp-server.conf"} > : ${openerp_server_user="terp"} Default variable assignments should happen after load_rc_config. > . /etc/rc.subr I added a little whitespace below to ease readability. > name="openerp_server" > rcvar=${name}_enable > command_args=" >/dev/null 2>&1 &" > pidfile="/var/run/openerp/server.pid" > start_precmd="${name}_prestart" > command=/usr/local/bin/openerp-server > procname=/usr/local/bin/python2.6 You probably want to use command_interpreter here instead of procname, but I didn't test it. > openerp_server_prestart() { > # PID file should be not empty. > [ x"$pidfile" = x ] && err 1 "variable pidfile should not be empty" This isn't needed, you define pidfile in the script. > # Check PID directory exists. > d=$(dirname "$pidfile") Also not needed. You are hard-coding pidfile (which is fine) so no need for pointless indirection. > if [ ! -d "$d" ]; then No need to do this, mkdir -p will not fail if the directory exists, and even if it exists you want to be sure that the permissions are correct. For example, the user could change the value of openerp_server_user then run the script again and it should still work. > # Create PID directory. > mkdir -p "$d" || return 1 If it's necessary to do this, then if it fails it should be an error. hth, Doug -- Improve the effectiveness of your Internet presence with a domain name makeover! http://SupersetSolutions.com/ Computers are useless. They can only give you answers. -- Pablo Picasso --------------020309050504060302010304 Content-Type: text/plain; name="openerp-rcd" Content-Transfer-Encoding: 7bit Content-Disposition: inline; filename="openerp-rcd" #!/bin/sh # $FreeBSD$ # # PROVIDE: openerp_server # REQUIRE: postgresql LOGIN # KEYWORD: shutdown # # Add the following line to /etc/rc.conf to enable OpenERP server: # # openerp_server_enable="YES" # # optional # openerp_server_flags="-c /usr/local/etc/openerp-server.conf" # openerp_server_user="terp" # # Do not forget to define the same PID file in the OpenERP configuration # file (see the variable $pidfile defined below). # # This scripts takes one of the following commands: # # start stop restart status # . /etc/rc.subr name="openerp_server" rcvar=${name}_enable command=/usr/local/bin/openerp-server command_args=" >/dev/null 2>&1 &" command_interpreter=/usr/local/bin/python2.6 pidfile="/var/run/openerp/server.pid" start_precmd="${name}_prestart" openerp_server_prestart() { # Create PID directory. mkdir -p /var/run/openerp || err 1 "Cannot mkdir /var/run/openerp" chmod 750 /var/run/openerp || err 1 "Cannot chmod /var/run/openerp" chown "${openerp_server_user}:wheel" /var/run/openerp || err 1 "Cannot chown /var/run/openerp" } load_rc_config $name : ${openerp_server_enable="NO"} : ${openerp_server_flags="-c /usr/local/etc/openerp-server.conf"} : ${openerp_server_user="terp"} run_rc_command "$1" --------------020309050504060302010304--