#!/bin/sh ### BEGIN INIT INFO # Provides: php-fcgi # Required-Start: $local_fs $remote_fs $network $syslog $named # Required-Stop: $local_fs $remote_fs $network $syslog $named # Default-Start: 2 3 4 5 # Default-Stop: 0 1 6 # Short-Description: starts/stops php over fcgi # Description: starts/stops php over fcgi ### END INIT INFO # Required-Start: $nginx # Required-Stop: $nginx PATH=/bin:/usr/bin:/usr/sbin:/sbin test 0 = $( id -u ) || { echo "You need to have root priviliges." ; exit 1 ; } # This parameter **MUST** be consistent with that defined in nginx.conf SOCKET_DIR=/opt/schplurtz/nginx/fastcgi_temp # This directory must exists and be properly protected BIND=$SOCKET_DIR/php-fcgi.sock USER=www-data PHP_FCGI_CHILDREN=2 PHP_FCGI_MAX_REQUESTS=1000 PHP_CGI=/opt/bin/php-fcgi PHP_CGI_NAME=${PHP_CGI##*/} PHP_CGI_ARGS="- USER=$USER PATH=/usr/bin PHP_FCGI_CHILDREN=$PHP_FCGI_CHILDREN PHP_FCGI_MAX_REQUESTS=$PHP_FCGI_MAX_REQUESTS $PHP_CGI -b $BIND" RETVAL=0 fatal() { warn "$@" exit 1 } warn() { printf %s\\n "$@" >&2 } start() { echo -n "Starting PHP FastCGI: " su -c "test -O '$SOCKET_DIR'" $USER || fatal \ "socket dir >>$SOCKET_DIR<< does not exists" \ "or it does not belong to $USER" start-stop-daemon --quiet --start --background --chuid "$USER" --exec /usr/bin/env -- $PHP_CGI_ARGS RETVAL=$? echo "$PHP_CGI_NAME." } stop() { echo -n "Stopping PHP FastCGI: " #busybox can t handle these options : # killall -q -w -u $USER $PHP_CGI pkill -f $PHP_CGI RETVAL=$? echo "$PHP_CGI_NAME." } case "$1" in (start) start ;; (stop) stop ;; (restart) stop start ;; (*) echo "Usage: php-fastcgi {start|stop|restart}" exit 1 ;; esac exit $RETVAL