3

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

2
  • 1
    I don't have OSX Server, but serverinfo might help. And you could test for the existence of serveradmin and assume "no server" if it is missing.
    – nohillside
    Commented Oct 8, 2015 at 8:23
  • Checking on the result of running serverinfo -q --software helped. Thank you for helping @patrix Commented Oct 9, 2015 at 19:32

1 Answer 1

3

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
3
  • Thanks @grgarside Based on this command I will test if this could be a solution in my shell script: OUTPUT=$(serverinfo --software) $if [ $OUTPUT = "This system has server software installed." ]; then cp product.conf /Library/Server/Web/Config/apache2/other/ #stop and start the websites service serveradmin stop web serveradmin start web fi Commented Oct 8, 2015 at 10:19
  • 1
    @JoachimBratteli There's no need to check for string output—you can use the -q option such as if serverinfo -q --software; then echo enabled; else echo disabled; fi
    – grg
    Commented Oct 8, 2015 at 10:21
  • With your remarks my script has been tested and found to be working for both Yosemite without the Server.app installed and El Capitan that has the Server.app installed. Thanks @grgarside Commented Oct 8, 2015 at 14:01

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .