Sorry about that, it was like 2:00AM.
Thanks everyone for the assistance. Some of the issues I highlighted above are still not clear to me, but it does seem the issue has gone away with the removal of the last line of the .bashrc file.
To answer my own question: How is the discourse-setup
script getting created, and can I manually delete it?
The discourse-setup script should exist in /var/discourse. It ships as part of the base code.
The 502 for a minute, I’ll live with it unless I hear otherwise.