configure_datastore_add_replicants fixes

Fix some logic and typos in `configure_datastore_add_replicants`:

• Interpret exit code 0 from `mongo` as signifying success rather than error.

• Fix interleaved `while` and `print` statements in the mongo shell code to determine the primary.

• Change `"$(echo foo)"` to `'foo'` or `"foo"` as appropriate in several places.

• Perform string comparison instead of pattern matching when comparing `$replicant` and `$master_out`.

• Fix a typo of `$replicant` as `$repicant` in an error message.

• Reformat some commands and control structures.

Note: This is untested, except by copying and pasting individual commands.