tags:

views:

250

answers:

3

A shell script installs and configures some services and applications in a Solaris instance. One of these services is NTP - but NTP cannot run in a non-global zone (well it can, but xntpd fails when it tries to adjust the clock; instead the zone inherits the time from the global zone).

How can a shell script tell that it is indeed running in a non-global Solaris zone, so that it can skip the NTP configuration step in those cases?

A: 

Test the output of uname?

-- MarkusQ

MarkusQ
A: 

You could also try zoneadm list -cv, in the global zone you will see output like:

# zoneadm list -cv
ID NAME             STATUS         PATH
0 global           running        /
1 zone1            running        /zones/zone1

whereas in any other zone you would only see that particular zone, e.g.

# zoneadm list -cv
ID NAME             STATUS         PATH
1 zone1            running        /zones/zone1
+2  A: 

Use zonename(1). In the global zone (or on a standalone server without any zones), this will return the string global.

NAME
   zonename - print name of current zone

SYNOPSIS
   zonename

DESCRIPTION
   The zonename utility prints the name of the current zone.

...
Martin Carpenter