I am trying to write a script for Oracle startup and finding the traditional dbstart/dbshut to be too simple.

Basically need something that will start up a database in the same mode that it was in when it was last shut down.

Not running RAC, so CRS is not an option.

So, the easy one, if the DB is a primary and open, startup normal.

However, if the database is a snapshot standby, it could be previously opened in read-write, read-only or simply mounted.

Is there any OS file that indicates last state? I imagine I could poll the alert log for the last state...

If there isn't, I've thought about writing a script that goes out and polls the current state of the database a few times a day and then record it, but that seems a bit inelegant...

Any ideas?