CreateZone.sh


#!/bin/sh
#
# ----------------------------------------- */
# CreateZone.sh
#
version="0.9";
# Author: Paul M. Johnson (pjohnson@bosconet.org)
# Language: shell
# Inputs:
# ARG1: name of zone to be created
# [ARG2] primary IP address
# [ARG3] secondary IP address
#
# Output: a functional zone
#
# —————————————– */
# */
# Customization Instructions */
# */
# —————————————– */
#
# things you must do:
#
# things you might have to do:
# —————————————– */

# —- modifications and fixes ———— */

# —————————————– */
# —————————————– */

# —————————————– */
# CONFIGURABLE VARIABLES */
# —————————————– */
INT1=”dmfe0″ # primary ethernet interface
INT2=”dmfe1″ # secondary ethernet interface
PATH=”/export” # path where ZONE will be created

# ———– MAIN PROCESSING ————- */

# test to ensure a ZONE name was passed as the
# first argument

if [ -z "$1" ]
then
echo “ERROR:”
echo “”
echo “name for ZONE to be created required”
echo “”
echo “correct syntax: CreateZone.sh [primary IP] [secondary IP]”
exit -1;
fi
if [ -z "$2" ]
then echo “Creating ZONE without an IP address”
fi

# cat < < END_SCRIPT > $1.zone
echo “create ” > $1.zone
echo “set autoboot=true” >> $1.zone
echo “set zonepath=\”/$PATH/$1\”" >> $1.zone
echo “add net” >> $1.zone
echo “set physical=$INT1″ >> $1.zone
echo “set address=$2″ >> $1.zone
echo “end ” >> $1.zone
echo “add net” >> $1.zone
echo “set physical=$INT2″ >> $1.zone
echo “set address=$3″ >> $1.zone
echo “end” >> $1.zone
echo “add inherit-pkg-dir” >> $1.zone
echo “set dir=/usr/local” >> $1.zone
echo “end” >> $1.zone

exit 0

mkdir /export/$1
chmod 700 /export/$1
zonecfg -z $1 -f $1.zone
zoneadm -z $1 verify
zoneadm -z $1 install

exit 0;