How does a shell script know that it works in a Solaris zone?

In the shell script, some services and applications are installed and configured on a Solaris instance. One of these services is NTP, but NTP cannot work in a non-global zone (well, maybe, but xntpd fails when it tries to set the clock, and the zone inherits time from the global zone).

How does the shell script report that it really works in the non-global Solaris zone, so that it can skip the NTP configuration step in these cases?

+5
source share
3 answers

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

NAME
   zonename - print name of current zone

SYNOPSIS
   zonename

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

...
+5
source

zoneadm list -cv, , :

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

,

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

Well, if you use the inner zone of the script and want to make sure that it is running in the zone, run the following command

arp -a |grep SP

You can see your global zone in 1 line at the output of the above command. It might be useful to apply validation in your script based on this output.

+1
source

All Articles