Print this page
XXX Remove nawk(1)


  13 #
  14 # When distributing Covered Code, include this CDDL HEADER in each
  15 # file and include the License file at usr/src/OPENSOLARIS.LICENSE.
  16 # If applicable, add the following below this CDDL HEADER, with the
  17 # fields enclosed by brackets "[]" replaced with your own identifying
  18 # information: Portions Copyright [yyyy] [name of copyright owner]
  19 #
  20 # CDDL HEADER END
  21 #
  22 #
  23 # Copyright (c) 2004, 2010, Oracle and/or its affiliates. All rights reserved.
  24 
  25 . /lib/svc/share/smf_include.sh
  26 
  27 #
  28 # Return a list of running, non-global zones for which a shutdown via
  29 # "/sbin/init 0" may work (typically only Solaris zones.)
  30 #
  31 shutdown_zones()
  32 {
  33         zoneadm list -p | nawk -F: '{
  34                 if ($2 != "global") {
  35                         print $2
  36                 }
  37         }'
  38 }
  39 
  40 [ ! -x /usr/sbin/zoneadm ] && exit 0    # SUNWzoneu not installed
  41 
  42 if [ -z "$SMF_FMRI" ]; then
  43         echo "this script can only be invoked by smf(5)"        
  44         exit $SMF_EXIT_ERR_NOSMF
  45 fi
  46 
  47 # Make sure working directory is / to prevent unmounting problems.
  48 cd /
  49 PATH=/usr/sbin:/usr/bin; export PATH
  50 
  51 case "$1" in
  52 'start')
  53         egrep -vs '^#|^global:' /etc/zones/index || exit 0  # no local zones
  54 
  55         #
  56         # Boot the installed zones for which the "autoboot" zone property is
  57         # set and invoke the sysboot hook for all other installed zones.
  58         #
  59         ZONES=""
  60         for zone in `zoneadm list -pi | nawk -F: '{
  61                         if ($3 == "installed") {
  62                                 print $2
  63                         }
  64                 }'`; do
  65                 zonecfg -z $zone info autoboot | grep "true" >/dev/null 2>&1
  66                 if [ $? -eq 0 ]; then
  67                         [ -z "$ZONES" ] && echo "Booting zones:\c"
  68                         ZONES=yes
  69                         echo " $zone\c"
  70                         #
  71                         # zoneadmd puts itself into its own contract so
  72                         # this service will lose sight of it.  We don't
  73                         # support restart so it is OK for zoneadmd to
  74                         # to be in an orphaned contract.
  75                         #
  76                         zoneadm -z $zone boot &
  77                 else
  78                         zoneadm -z $zone sysboot &
  79                 fi
  80         done




  13 #
  14 # When distributing Covered Code, include this CDDL HEADER in each
  15 # file and include the License file at usr/src/OPENSOLARIS.LICENSE.
  16 # If applicable, add the following below this CDDL HEADER, with the
  17 # fields enclosed by brackets "[]" replaced with your own identifying
  18 # information: Portions Copyright [yyyy] [name of copyright owner]
  19 #
  20 # CDDL HEADER END
  21 #
  22 #
  23 # Copyright (c) 2004, 2010, Oracle and/or its affiliates. All rights reserved.
  24 
  25 . /lib/svc/share/smf_include.sh
  26 
  27 #
  28 # Return a list of running, non-global zones for which a shutdown via
  29 # "/sbin/init 0" may work (typically only Solaris zones.)
  30 #
  31 shutdown_zones()
  32 {
  33         zoneadm list -p | /usr/xpg4/bin/awk -F: '{
  34                 if ($2 != "global") {
  35                         print $2
  36                 }
  37         }'
  38 }
  39 
  40 [ ! -x /usr/sbin/zoneadm ] && exit 0    # SUNWzoneu not installed
  41 
  42 if [ -z "$SMF_FMRI" ]; then
  43         echo "this script can only be invoked by smf(5)"        
  44         exit $SMF_EXIT_ERR_NOSMF
  45 fi
  46 
  47 # Make sure working directory is / to prevent unmounting problems.
  48 cd /
  49 PATH=/usr/sbin:/usr/bin; export PATH
  50 
  51 case "$1" in
  52 'start')
  53         egrep -vs '^#|^global:' /etc/zones/index || exit 0  # no local zones
  54 
  55         #
  56         # Boot the installed zones for which the "autoboot" zone property is
  57         # set and invoke the sysboot hook for all other installed zones.
  58         #
  59         ZONES=""
  60         for zone in `zoneadm list -pi | /usr/xpg4/bin/awk -F: '{
  61                         if ($3 == "installed") {
  62                                 print $2
  63                         }
  64                 }'`; do
  65                 zonecfg -z $zone info autoboot | grep "true" >/dev/null 2>&1
  66                 if [ $? -eq 0 ]; then
  67                         [ -z "$ZONES" ] && echo "Booting zones:\c"
  68                         ZONES=yes
  69                         echo " $zone\c"
  70                         #
  71                         # zoneadmd puts itself into its own contract so
  72                         # this service will lose sight of it.  We don't
  73                         # support restart so it is OK for zoneadmd to
  74                         # to be in an orphaned contract.
  75                         #
  76                         zoneadm -z $zone boot &
  77                 else
  78                         zoneadm -z $zone sysboot &
  79                 fi
  80         done