Init.d script for Rails managing a Rails app via Unicorn
Quoting command line arguments

This is not safe:


[ -f $PID_FILE ] &amp;&amp; ...



Variables and the result of $(...) should be double-quoted to protect from parameter expansion and globbing:

[ -f "$PID_FILE" ] &amp;&amp; ...


A longer example (fixed version, compare with your original):

if [ -f "$PID_FILE" -a -n "${KPID}" -a -d "/proc/${KPID}" ]; then
      logger -sit "$TAG" "Process ${KPID} in PID file $PID_FILE exists. Service '${PROJ_NAME}' should be running"


The lack of quoting is the most common violation in the posted code,
review carefully.
Copy-paste to https://www.shellcheck.net/, it should help.

Use $(...) instead of `...`

The backtick format is obsolete, and harder to read. Always use $(...).

Usability

The stop function waits for 2 seconds after sending the TERM signal to the process to check if the PID file still exists.
That seems a bit arbitrary, and possibly fragile.
It would be better to sleep for 1 second 5 times in a loop.
This is also pretty arbitrary, but a bit more flexible.

Pointless [ -f $PID_FILE ] &amp;&amp; KPID=`cat $PID_FILE`

This is executed always, regardless of the sub-command.
And then most sub-commands reload the value in $PID_FILE.
It would be better to create a function for getting the PID,
and calling that function when you need it.

Signal to PID that might not exist

Some of the functions signal to $(cat "$PID_FILE"),
without making sure that PID actually exists,
or even that $PID_FILE actually exists.
It would be better to validate the state more accurately,
and raise errors as appropriate.

Recursive execution

The restart function calls $0 start to restart the script.
It would be more natural to simply call the start function directly.