From owner-freebsd-hackers@FreeBSD.ORG Tue Jul 29 17:48:55 2008 Return-Path: Delivered-To: hackers@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id C4BC21065671 for ; Tue, 29 Jul 2008 17:48:55 +0000 (UTC) (envelope-from dougb@FreeBSD.org) Received: from mail2.fluidhosting.com (mx23.fluidhosting.com [204.14.89.6]) by mx1.freebsd.org (Postfix) with ESMTP id 5ED588FC1B for ; Tue, 29 Jul 2008 17:48:55 +0000 (UTC) (envelope-from dougb@FreeBSD.org) Received: (qmail 3305 invoked by uid 399); 29 Jul 2008 17:22:14 -0000 Received: from localhost (HELO lap.dougb.net) (dougb@dougbarton.us@127.0.0.1) by localhost with ESMTPAM; 29 Jul 2008 17:22:14 -0000 X-Originating-IP: 127.0.0.1 X-Sender: dougb@dougbarton.us Message-ID: <488F51C5.7000002@FreeBSD.org> Date: Tue, 29 Jul 2008 10:22:13 -0700 From: Doug Barton Organization: http://www.FreeBSD.org/ User-Agent: Thunderbird 2.0.0.16 (X11/20080726) MIME-Version: 1.0 To: "Rodrigo OSORIO (ros)" References: <20080729150018.GB19987@hodja.bebik.net> In-Reply-To: <20080729150018.GB19987@hodja.bebik.net> X-Enigmail-Version: 0.95.6 OpenPGP: id=D5B2F0FB Content-Type: multipart/mixed; boundary="------------030006070104090301060305" Cc: hackers@freebsd.org Subject: Re: Problem with an rc script X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 29 Jul 2008 17:48:55 -0000 This is a multi-part message in MIME format. --------------030006070104090301060305 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Rodrigo OSORIO (ros) wrote: > Hi, > > I'm trying to deal with a rc script I'm writing to launch a deamon. > I wrote it based on the hanbook rc script sample. It works pretty > well but I have some (strange to me) warning message. Your script looks pretty good, but it needs a little work. :) I assume that you wrote this based on the handbook examples for the base. You should probably take a look at the one for ports too: http://www.freebsd.org/doc/en_US.ISO8859-1/books/porters-handbook/rc-scripts.html > Fisrt a short explanation about what i'm doing : The application is > a python script deamon started by a shell script located in > /usr/local/sbin/ntlmaps. The shell script launch the application > and write the pid file if require > > So, the rc script (ntlmapsd) The name of the script, the $name value, and the REQUIRE: value should all match. So you should either name them all ntlmapsd, or ntlmaps. There is no conflict between the script name and the binary in /usr/local/sbin/, FYI. > calls the shell script with the right > arguments to start the application, then performs a 'kill -KILL' to > stop it based on the pid file information. > > The thing is stopping the application I receive a message saying: > ./ntlmapsd: WARNING: $command_interpreter -b != /bin/sh This is a tricky one because what you did looks totally reasonable since the script you're calling does use /bin/sh. However the command_interpreter value for rc.d needs to be what the _process_ is running, which in this case is /usr/local/bin/python. I've attached an example script that might work for you. Personally I would not make the pidfile stuff optional, in which case you could simplify things to the one in -v2. Whatever you decide, please test it thoroughly first. In addition to the web pages another good resource is to read through the comments in /etc/rc.subr. hth, Doug -- This .signature sanitized for your protection --------------030006070104090301060305 Content-Type: text/plain; name="ntlmaps" Content-Transfer-Encoding: 7bit Content-Disposition: inline; filename="ntlmaps" #!/bin/sh # # PROVIDE: ntlmaps # REQUIRE: LOGIN # KEYWORD: shutdown # Add the following lines to /etc/rc.conf.local or /etc/rc.conf # to enable this service: # # ntlmaps_enable (bool): Set to NO by default. # Set it to YES to enable ntlmaps. # ntlmaps_nice (string): Set to -5 by default # ntlmaps_pidfile (path): Set to /var/run/ntlmaps.pid by default . /etc/rc.subr name="ntlmaps" rcvar=${name}_enable command="/usr/local/sbin/ntlmaps" command_interpreter="/usr/local/bin/python" load_rc_config $name ntlmaps_enable=${ntlmaps_enable-"NO"} ntlmaps_nice=${ntlmaps_nice-"-5"} ntlmaps_pidfile=${ntlmaps_pidfile-"/var/run/ntlmaps.pid"} if [ -n "$ntlmaps_pidfile" ]; then pidfile=${ntlmaps_pidfile} command_args="-b -p $pidfile" else command_args="-b" fi run_rc_command "$1" --------------030006070104090301060305 Content-Type: text/plain; name="ntlmaps-v2" Content-Transfer-Encoding: 7bit Content-Disposition: inline; filename="ntlmaps-v2" #!/bin/sh # # PROVIDE: ntlmaps # REQUIRE: LOGIN # KEYWORD: shutdown # Add the following lines to /etc/rc.conf.local or /etc/rc.conf # to enable this service: # # ntlmaps_enable (bool): Set to NO by default. # Set it to YES to enable ntlmaps. # ntlmaps_nice (string): Set to -5 by default . /etc/rc.subr name="ntlmaps" rcvar=${name}_enable command="/usr/local/sbin/ntlmaps" command_interpreter="/usr/local/bin/python" pidfile=/var/run/ntlmaps.pid command_args="-b -p $pidfile" load_rc_config $name ntlmaps_enable=${ntlmaps_enable-"NO"} ntlmaps_nice=${ntlmaps_nice-"-5"} run_rc_command "$1" --------------030006070104090301060305--