From: Jean-Yves Boisiaud - Osiell on 7 Jan 2010 04:35 Hello, Here is a rc.d script to start/stop/restart the OpenERP server. 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 # # PROVIDE: openerp_server # REQUIRE: postgresql # 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"} .. /etc/rc.subr 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 openerp_server_prestart() { # PID file should be not empty. [ x"$pidfile" = x ] && err 1 "variable pidfile should not be empty" # Check PID directory exists. d=$(dirname "$pidfile") if [ ! -d "$d" ]; then # Create PID directory. mkdir -p "$d" || return 1 chmod 750 "$d" || return 1 chown "${openerp_server_user}:wheel" "$d" || return 1 fi } load_rc_config $name run_rc_command "$1" >>>>>>>>>>>>>>>>>>>>> _______________________________________________ freebsd-ports(a)freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/freebsd-ports To unsubscribe, send any mail to "freebsd-ports-unsubscribe(a)freebsd.org"
From: Doug Barton on 8 Jan 2010 01:51 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
|
Pages: 1 Prev: Fwd: Re: libusb-config missing? Next: freeradius-2.1.6 + perl-5.8.9_3 + perl hook problem |