Thanks for all the input on this one - in the end I gave up and just added a line in my script that changes the link from the apache 'sites-enabled' file to point to a 'sites-available' file that loads up a maintenance html page I made myself.
General help
Moodle maintenance mode cli in a script
This discussion has been locked so you can no longer reply to it.