Fixes bug that causes init scripts to fail silently

See #5218 and #5231

This pull request is for the 6-1-stable branch
5218 is the pull request for master branch