server_environment

Package: WA2L/edrc 1.5.57
Section: Library Commands (3)
Updated: 15 November 2008
Index Return to Main Contents

 

NAME

server_environment - print server environment

 

SYNOPSIS

edrc/lib/server_environment [ -h | -l ]

server_environment

server_environment [ -d | -C | -R ][ -s servername ]

 

AVAILABILITY

WA2L/edrc

 

DESCRIPTION

Return a name for the environment of the server where running the command.

In the configuration file edrc/etc/server_environment.cfg it can be defined which server relates to what environment. The server_environment command can be used to develop scripts which act specific on different environments without hardcoding hostnames into the scripts.

When the server environment cannot be resolved, unknown is returned.

 

OPTIONS

return the name of the server environment where logged on.

-h
usage message.

-d
print the description of the server environment.

-C
print customer name of the server environment.

-R
print the whole info record in a SERVER_ENVIRONMENT_<FIELD>='Value' syntax that can be used to set variables in a script.

-l
list all configured server environments.

-s servername
server to be resolved. For common usage it is not needed to specify the servername on the command line. This option can be used to verify configuration file definitions.

 

ENVIRONMENT

-

 

EXIT STATUS

0
no error.

1
information could not be resolved. In this case unknown is returned.

2
Operating system not supported. See osid (3) if you get this error.

4
usage printed.

6
configuration file edrc/etc/server_environment.cfg does not exist.

 

FILES

edrc/etc/server_environment.cfg
configuration file of server_environment. This file contains all server environment definitions.

edrc/var/cache/server_environment/
resolution cache of the server_environment command.

edrc/var/cache/server_environment/meta
meta data for the resolution cache. This file is used to check if the cache data is still valid.

edrc/var/cache/server_environment/data
this file contains the cache data, the resolved CUSTOMER, NAME and DESCRIPTION settings for the system where server_environment has been executed.

edrc/var/samples/hostlist/
configuration examples for hostlist(3) and server_environment(3).

 

EXAMPLES

1) script cut out

In this script server environment dependent variable initialization is implemented using the server_environment command:

#!/bin/sh
:
:

  case `server_environment` in
    TEST)
          Max_load=100
          Mail_to=fred.developer@acme.com
          ;;
    PREPRODUCTION)
          Max_load=200
          Mail_to=barney.verifier@acme.com
          ;;
    PRODUCTION)
          Max_load=250
          Mail_to=wilma.production@acme.com
          ;;
    unknown)
          echo "server environment unknown, aborting."
          exit 1
          ;;
  esac

:
:

2) use of server_environment -R

In this example server_environment -R is used to efficiently query the whole information record and to print it.

#!/bin/sh
:
:

        eval `server_environment -R`

        cat <<EOM
        Customer:    $SERVER_ENVIRONMENT_CUSTOMER
        Environment: $SERVER_ENVIRONMENT_NAME
        Description: $SERVER_ENVIRONMENT_DESCRIPTION
EOM

:
:

 

SEE ALSO

edrcintro(1), server_environment.cfg(4), hostlist(3), edrc/var/samples/hostlist/

 

NOTES

The server_environment command uses the hostname(1) command internally to resolve the hostname.

 

BUGS

-

 

AUTHOR

server_environment was developed by Christian Walther. Send suggestions and bug reports to wa2l@users.sourceforge.net .

 

COPYRIGHT

Copyright © 2008 Christian Walther

This is free software; see edrc/doc/COPYING for copying conditions. There is ABSOLUTELY NO WARRANTY; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.


 

Index

NAME
SYNOPSIS
AVAILABILITY
DESCRIPTION
OPTIONS
ENVIRONMENT
EXIT STATUS
FILES
EXAMPLES
SEE ALSO
NOTES
BUGS
AUTHOR
COPYRIGHT

This document was created by man2html using the manual pages.
Time: 00:14:23 GMT, March 08, 2025