allow instances to be marked unavailable

Add in middleware to check if an instance has been marked as unavailable
and a script to change the setting

Fixes #516