Scripts/Nexus: rewritten instance script

(cherry picked from commit f743fb3e43036bdfd4e6b96dff1a82c19e3faa59)