How to evaluate the state of the OS X Server.app from a shell script? I need to evaluate if the OS X Server.app has been installed and if it has been started or not. This I need to do from within a shell script. 
I could check for existing folder names, but I would expect it cannot truly make sure that the Server.app is installed and up and running so that I can run the serveradmin command.
Anyone with a suggestion?

This is a follow-up question to my previous question: Configure the OS X Server from .pkg postinstall script
It can be determined by running the following command:

serverinfo --configured


To evaluate the result of the command within a shell script use the -q option and encapsulate it in an if-statement:

 if serverinfo -q --configured;
 then
    echo configured; 
 else
    echo not_configured;
 fi


The serverinfo gives two options to determine if the Server.app is just installed or configured: 

--software [PATH]
    Returns status 0 if the root volume has a server OS installed
    Use optional argument PATH to specify mountpoint of alternate volume
--configured [PATH]
    Returns status 0 if the server is configured
    Use optional argument PATH to specify mountpoint of alternate volume


So if the serveradmin --configured command "fails", you could check if is installed:

 if serverinfo -q --configured;
 then
    echo configured; 
 else
    if serverinfo -q --software;
    then
       echo installed;
    else
       echo not_installed;
    fi
 fi