Refactor the init script and remove the -d option.

Fixes #3666