Date: Tue, 29 Jul 2008 10:22:13 -0700 From: Doug Barton <dougb@FreeBSD.org> To: "Rodrigo OSORIO (ros)" <rodrigo@bebik.net> Cc: hackers@freebsd.org Subject: Re: Problem with an rc script Message-ID: <488F51C5.7000002@FreeBSD.org> In-Reply-To: <20080729150018.GB19987@hodja.bebik.net> References: <20080729150018.GB19987@hodja.bebik.net>
next in thread | previous in thread | raw e-mail | index | archive | help
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--
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?488F51C5.7000002>