Custom rc script using /usr/sbin/daemon

Eric Masson emss at free.fr
Tue Oct 5 11:18:49 UTC 2010


Hello,

I'm trying to create a script that would launch php-cgi in fastcgi mode.
So far, I've the following script :

#!/bin/sh
#
# PROVIDE: phpfastcgi
# REQUIRE: DAEMON
# KEYWORD: shutdown
#
# Add the following lines to /etc/rc.conf to enable phpfastcgi :
#
# phpfastcgi_enable (bool):             Set it to "YES" to enable
phpfastcgi
#                                       Default is "NO".
# phpfastcgi_flags (str):               Set the uwsgi command line
arguments
#                                       Default is "-M -L".

. /etc/rc.subr

name="phpfastcgi"
rcvar=`set_rcvar`

[ -z "$phpfastcgi_enable" ]          && phpfastcgi_enable="NO"
[ -z "$phpfastcgi_flags" ]          && phpfastcgi_flags=""

load_rc_config $name

sig_stop="TERM"
pidfile="/var/run/${name}/${name}.pid"
command="/usr/sbin/daemon -f -p ${pidfile} /usr/local/bin/php-cgi"

run_rc_command "$1"

When invoked with start argument, it barfs at me but launches php-cgi as
expected :
emss at srvbsdfenssv:~> sudo /usr/local/etc/rc.d/phpfastcgi start
/usr/local/etc/rc.d/phpfastcgi: WARNING: no shebang line in /usr/sbin/daemon
[: /usr/sbin/daemon: unexpected operator
Starting phpfastcgi.

When invoked with stop argument, it errors and doesn't stop the process
as expected :
emss at srvbsdfenssv:~> sudo /usr/local/etc/rc.d/phpfastcgi stop
/usr/local/etc/rc.d/phpfastcgi: WARNING: no shebang line in /usr/sbin/daemon
phpfastcgi not running? (check /var/run/phpfastcgi/phpfastcgi.pid).

>From a quick peek at /etc/rc.subr, it seems that messages regarding
lack of shebang line in /usr/sbin/daemon indicate something is wrong in
my script but atm, I can't figure it.

Any idea, anyone ?

Kind Regards

Éric Masson

-- 
 RJ> j'ai eu des cookies sur mon HD et j'ai un peu peur des représailles
 Il faut reformater ton disque dur et le jetter depuis le 3e étage de la
 tour Eiffel pour le détruire irrémédiablement sans laisser de traces.
 -+- LP in <http://www.le-gnu.net> : Par ici ou parano c'est pareil -+-


More information about the freebsd-questions mailing list