Plaatsingsdatum: Oct 15, 2010 10:41:47 AM
Return 0 if the machine is a global zone with 1 or more local zones
Return 1 if the machine is either a local zone or a global zone with 0 local zones
{{{
#! /bin/bash
#
# When issued with the -g or --global flag, this script will return:
# 0 if the machine is a global zone and has one or more local zones.
# Otherwise, it will return 1
#
# Wen issued with the -l or --local flag, this script will return:
# 0 if if is a local zone and 1 if it is not
#
list=( `/usr/sbin/zoneadm list -civ | awk '{ print $1 }'`)
case "$1" in
-g|--global)
# If the third element in our array is null, set it to 0
if [ "${list[2]}" == "" ]; then
list[2]=0
fi
# This is a global zone only if it has one or more local zones.
if [ ${list[1]} -eq 0 ] && [ ${list[2]} -ge 1 ]; then
# 1 is returned if we have a global and local zone, otherwise, we return 0
exit 0
else
exit 1
fi
;;
-l|--local)
# If the second element in our array is = or > 1, it is a local zone.
if [ ${list[1]} -ge 1 ]; then
# Return 1 if this is a local zone, otherwise return 0.
exit 0
else
exit 1
fi
;;
*)
echo "Usage: /local/adm/zonetype.sh {-l | --local | -g | --global}"
exit 1
esac
}}}