Russ Petruzzelli 写道:
Is there a way to make a zone installation totally silent?

I use zonemgr to install, but at the end it says:


Copy completed.
Booting zone for the first time.
Waiting for first boot tasks to complete.


Then I "zlogin -C" into the zone and have to do the system
identification;  hostname, nameserver, kerberos, NIS, etc.

Is there an equivalent to the "sysinfo" file for zones to make it
'jumpstart' silent?

I haven't used the "zonemgr" script before (can you give me a link?), so I don't know what it does after zone installation and before zone booting, but to my experience, the point is to populate the /etc/sysidcfg file for the zone before booting it.

You can see the attached script that I'm using to see what's put in this file. I believe there are many other simliar scripts floating around on the web.




Thanks,
Russ

zonemgr script:

$ZONEMGR -a add -n $MYZONENAME -t w -z "$ZONEBASEDIR" \
             -P "xxx" -R / \
             -D "red.iplanet.com" \
             -d "mf-usca19-12" \
             -R "/|/bin/bash" \
             -s enable \
             -I "192.18.77.190|hme0|24|ps-eng8-zone1" \
             -C /etc/ssh/sshd_config -C /etc/resolv.conf \
             -C /etc/nsswitch.conf

END


_______________________________________________
zones-discuss mailing list
zones-discuss@opensolaris.org

#!/bin/ksh
#
# Copyright 2005 Sun Microsystems, Inc.  All rights reserved.
# Use is subject to license terms.
#
#ident  "@(#)create_zone.bash   1.5     05/09/16 SMI"
#

zone_base=/export/home/zones
zone_add_cfg=
bar=\
"------------------------------------------------------------------------------"

usage () {
        echo "Usage: create_zone [options]"

        echo "create_zone -z <zone name> \\"
        echo "            -t <type> \\"
        echo "            -i <intf>/<addr> \\"
        echo "            -g <default_gw>"
        echo ""

        echo "Required switches:"
        echo "  -z <name>         *REQUIRED* Name of the zone to create"
        echo "  -t <type>         *REQUIRED* Type of the zone: shared, or 
exclusive"
        echo "  -i <intf>/<addr>  *REQUIRED* Ethernet Network Interface"
        echo ""
        echo ""

        echo "Optional switches:"
        echo "  -c <config> Add a line to the zone configuration"
        echo "  -n          Exit if a network cannot be configured"
        echo "  -p <path>   Base path for zones, default=$zone_base"
        echo "  -w          Create the zone with a whole root"
        echo "  -h          Print this helpful usage"
        echo ""

        echo "Example usage:"
        echo "create_zone -z zoe02 \\"
        echo "            -t shared \\"
        echo "            -i e1000g0/10.8.57.145 \\"
        echo "            -i e1000g3/2000::192:168:57:204"
        echo ""
        echo "create_zone -z zoe04 \\"
        echo "            -t exclusive \\"
        echo "            -g 10.8.57.254 \\"
        echo "            -i e1000g0/10.8.57.145 \\"
        echo "            -i e1000g3/2000::192:168:57:204"
        echo ""

}

zone_ip_raw=
while getopts "c:g:hi:np:t:wz:" opt; do
        case $opt in
        c)
                zone_add_cfg="$zone_add_cfg
$OPTARG"
                ;;
        i)
                zone_ip_raw="$zone_ip_raw $OPTARG"
                ;;
        g)
                zone_gw=$OPTARG
                ;;
        h)
                usage
                exit 1
                ;;
        n)
                need_network=1
                ;;
        p)
                zone_base=$OPTARG
                ;;
        t)
                zone_type=$OPTARG
                ;;
        w)
                WHOLE="remove inherit-pkg-dir dir=/lib
remove inherit-pkg-dir dir=/platform
remove inherit-pkg-dir dir=/sbin
remove inherit-pkg-dir dir=/usr"
                ;;
        z)
                zone_name=$OPTARG
                ;;
        ?)
                usage
                exit 1
                ;;
        esac
done

if [[ -z $zone_name ]]; then
        echo "Missing *REQUIRED* field:"
        echo "  -z <name>   *REQUIRED* Name of the zone to create"
        echo ""
        usage
        exit 1
fi

if [[ $zone_type != shared && $zone_type != exclusive ]]; then
        echo "Zone type not correct."
        echo "Please specify 'shared' or 'exclusive'"
        usage
        exit 1
fi

zone_dir=${zone_base}/${zone_name}/root

#
# netowrking configuration
#
zone_ip=
zeif=
[[ $zone_type == exclusive ]] && zone_ip="set ip-type=exclusive"
for zr in $zone_ip_raw; do
        echo $zr | sed 's/\// /' | read intf addr
        if [[ $zone_type == exclusive ]]; then
                echo $zeif | grep -w $intf >/dev/null 2>&1 && continue
                zeif="$zeif $intf"
                zr_addr=
        else
                netmask=64
                echo $addr | grep '\.' >/dev/null 2>&1 && netmask=24
                zr_addr="set address=${addr}/$netmask"
        fi
        zone_ip="$zone_ip
add net
set physical=$intf
$zr_addr
end"
done

#
# Determine the domain name for the system
#
zone_domainname=`domainname`

#
# Determine the root password to use
#
# Could get the root PW from /etc/shadow but lets make it easy
# by hardcoding it:
# zone_rootpasswd=`cat /etc/shadow | grep root | cut -f2 -d:`
zone_rootpasswd="rJSJNt0RfvMy6"

#
# Make sure this zone isn't already configured.
#
zoneadm -z $zone_name list -c > /dev/null 2>&1
if [[ $? -ne 1 ]]; then
        echo "Configuration for zone $zone_name already exists!"
        exit 1
fi

#
# Create the zone configuration
#
cat <<-EOF | zonecfg -z $zone_name > /tmp/${zone_name}-config.log 2>&1
create
set zonepath=${zone_base}/$zone_name
set autoboot=true
$zone_ip
$WHOLE
$zone_add_cfg
commit
exit
EOF

if [[ $? -ne 0 ]]; then
        echo "Failed to configure zone: $zone_name"
        echo "Configuration output logged in /tmp/${zone_name}-config.log"
        exit 1
fi

echo "Configuration created for zone $zone_name:"
echo $bar
zonecfg -z $zone_name info
echo $bar
echo "Configuration output logged in /tmp/${zone_name}-config.log"

zoneadm -z $zone_name install

#
# Populate /etc/sysidcfg for the zone
#

nis_server=`ypwhich`
nis_server_ip=`getent ipnodes $nis_server | cut -f 1`

if [[ $zone_type == shared ]]; then
        #
        # shared zone
        #
        sysidcfg_net="network_interface=primary {
  hostname=$zone_name
}"
else
        #
        # exclusive zone
        #
        # XXXTBD need writing !!!!!!!!!!!!
        #
        for zir in $zone_ip_raw; do
                echo $zir | sed 's/\// /g' | read intf addr
                #
                # skip ipv6 address for now
                #
                echo $addr | grep ':' >/dev/null 2>&1 && continue
                #
                # Now only supprot 1 interface, so it's primary anyway
                #
                sysidcfg_net="network_interface=primary {
  hostname=$zone_name
  default_route=$zone_gw
  ip_address=$addr
  netmask=255.255.255.0
  protocol_ipv6=yes
}"
        done

#
# for non-primary interfaces: "primary", "hostname" skipped
#
#       if [[ -n $zone_ip_2_intf ]]; then
#               sysidcfg_net="$sysidcfg_net
# network_interface=$zone_ip_2_intf {
#   ip_address=$zone_ip_2_addr
#   netmask=255.255.255.0
#   default_route=$default_route2
#   protocol_ipv6=yes
# }"
#       fi

fi

sysidcfg_net="$sysidcfg_net
name_service=NIS {
  domain_name=$zone_domainname
  name_server=$nis_server($nis_server_ip)
}
nfs4_domain=dynamic
"

# cat > /tmp/sysidcfg.x <<-EOF
cat > $zone_dir/etc/sysidcfg <<-EOF
system_locale=C
timezone=US/Eastern
terminal=xterm
security_policy=NONE
root_password=$zone_rootpasswd
$sysidcfg_net
EOF

echo "/etc/sysidcfg created for zone $zone_name:"
echo $bar
cat $zone_dir/etc/sysidcfg
# cat /tmp/sysidcfg
echo $bar

# if [[ $zone_type == exclusive ]]; then
#       echo $zone_ipv6_addr/64 > $zone_dir/etc/hostname6.$zone_ip_intf
#       echo $zone_ipv6_2_addr/64 > $zone_dir/etc/hostname6.$zone_ip_2_intf
# fi

#
# Setup NFSv4 mapid domain in the zone
#
echo "NFSMAPID_DOMAIN=`sharectl get -p nfsmapid_domain nfs | cut -d= -f2`"
    >> $zone_dir/etc/default/nfs
echo $bar
touch $zone_dir/etc/.NFS4inst_state.domain

#
# Copy the hopefully more reasonable nsswitch.conf and resolve.conf from the
# global zone to the new zone.
#
echo "+" > $zone_dir/.rhosts
mkdir -p $zone_dir/.ssh 
for f in \
    /etc/nsswitch.conf \
    /etc/resolv.conf \
    /etc/inet/hosts \
    /etc/default/login \
    /etc/ssh/sshd_config \
    /.ssh/authorized_keys; do
        cp $f $zone_dir/$f || echo >/dev/null 2>&1
done

#
# Boot the zone
#
echo "Please booting zone $zone_name"
# zoneadm -z $zone_name boot
echo "Script create_zone.bash complete!"
echo "Log into the zone with the following command to finish zone creation:"
# echo "zlogin -C $zone_name"
_______________________________________________
zones-discuss mailing list
zones-discuss@opensolaris.org

Reply via email to