It seems that many init.d scripts return 0 on failure, in spite of these recommendations. For example, in nginx, running directly:

/usr/sbin/nginx -t        # returns 1 (with a bad config)

and running via init.d:

service nginx configtest  # returns 0 (with a bad config)

What's the best way of managing the missing status code? It seems there are a few options:

  • Parse the output looking for 'fail' whenever you call the command.
  • Update the init.d scripts to honour the expected codes described here.
  • Update log_end_msg in /lib/lsb/init-functions so that it does the usual logging and then exits with the exit code it is given initially.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.