Solaris Zone Creation Script


 
Thread Tools Search this Thread
Operating Systems Solaris Solaris Zone Creation Script
# 1  
Old 12-30-2008
Solaris Zone Creation Script

I am a new UNIX SA and am in need of help writing a script. We are getting into using ZONES and LDOMS and i wanted to script the process of creating a Solaris ZONE. I have all the commands and they work on the command line but i am sick doing each command over and over. We are turning out quite a few zones and would love to script it. The problem I am running into is that the zones need to be created on each of the Global Zones, and in some of the steps i need to scp the information to the other Global Zones, but when i script it, how do i change the scp command to go to the Global that i am not on? In my code below it works great on the first Global Zone (svanyc702), but when i run it on the other Global Zone (svanyc703) the scp command in step 2 isn't needed, since there are only svanyc702 and svanyc703 in the cluster. This is not Production; in our Production environment we have 3 Global Zone hosts, so my step 2 is even more complicated. How do I get around step two when I don't need it? This also applies in step 11... Any help would be great, thanks in advance.

This is what i have so far:
Code:
#!/bin/sh
## Created on 12-18-2008 ##
NAME=$1
echo "Do you wish to proceed with the creation of UAT ZONE zone-${NAME} <y or n> ? \c"
read WISH
echo
if [ $WISH = "n" ] ; then
echo "You chose no, good bye"
exit
fi

if [ ! $WISH = "y" ] ; then
echo in vaild optin g - exiting
exit
fi
#
mkdir /local/zone-roots/zone-${NAME}
chmod 700 /local/zone-roots/zone-${NAME}
ls -ld /local/zone-roots/zone-${NAME}
echo "Step 1 Completed"
echo " "
#
vi /local/zone.cfg
scp /local/zone.cfg svvnyc703:/local/zone.cfg
echo "Step 2 Completed"
echo " "
#
zonecfg -z zone-${NAME} -f /local/zone.cfg
echo "Step 3 Completed"
echo " "
#
zoneadm -z zone-${NAME} clone zone-template
echo "Step 4 Completed"
echo " "
#
zoneadm -z zone-${NAME} boot
echo "Step 5 Completed"
echo " "
#
zlogin -C zone-${NAME}
echo "Step 6 Completed"
echo " "
#
zoneadm -z zone-${NAME} halt
echo "Step 7 Completed"
echo " "
#
zoneadm -z zone-${NAME} detach
echo "Step 8 Completed"
echo " "
#
cd /opt/IFSvcs/etc
echo "Step 9 Completed"
cp generic.include zone-${NAME}.include
cp generic.exclude zone-${NAME}.exclude
echo " "
#
vi /opt/IFSvcs/etc/zone-sync.conf
echo "Step 10 Completed"
echo " "
#
rsync -av -e ssh --delete /local/zone-roots/zone-${NAME}/ svvnyc703:/local/zone-roots/zone-${NAME}
echo "Step 11 Completed"
echo " "
#
echo "Step 12"
zoneadm -z zone-${NAME} attach
zoneadm list -vi
echo "Step 12 Completed"
echo " "
#
echo "Step 13"
echo "You will now need to configure disk space within VEA."
echo " "
#
echo "Step 14"
echo "You will now need to boot your zone by using zoneadm -z zone-${NAME} boot and then configure within VCS."
echo " "
#
echo "Step 15"
echo "Please run zone creation script on the other GLOBAL ZONE hosts for zone-${NAME}"
echo "Please add the finishing script to your zone on each global zone, make sure your zone is running on the GLOBAL that you are running the finishing script on."
echo "scp /usr/local/adm/scripts/ZONE_setup.sh svvnyc702:/usr/local/adm/scripts/"
echo "scp /usr/local/adm/scripts/ZONE_setup.sh svvnyc703:/usr/local/adm/scripts/"
echo "/usr/local/adm/scripts/ZONE_setup.sh zone-${NAME}
echo " "


Last edited by DukeNuke2; 12-30-2008 at 10:08 AM.. Reason: added CODE tags for better reading
# 2  
Old 12-30-2008
two ways i see this happening:
1. prompt the user to supply the host to scp to
2. or
Code:
machine=`uname -n`
if [ $machine = "svvnyc703" ]
then
   scp svvnyc702 ...
else
   scp svvnyc03 ...
fi

Login or Register to Ask a Question

Previous Thread | Next Thread

9 More Discussions You Might Find Interesting

1. Solaris

Solaris 11 zone has no external network access (except to Global Zone)

Hi, hoping someone can help, its been a while since I used Solaris. After creating a NGZ (non global zone), the NGZ can access the GZ (Global Zone) and the GZ can access the NGZ (using ssh, zlogin) However, the NGZ cannot access any other netwqork devices, it can't even see the default router ... (2 Replies)
Discussion started by: GazinLincoln
2 Replies

2. Solaris

Solaris 11 Global zone patching having Solaris 10 branded zone

I am planning to do solaris 11 global zone patching having solaris 10 branded zone. I have a doubts on step 8 specially Can someone clear my step 8 doubts or if anything wrong between step 1 to step 9 please correct that also as I have pretty good idea about Step 10 mean patching in solaris 10... (2 Replies)
Discussion started by: amity
2 Replies

3. UNIX for Advanced & Expert Users

Solaris 10: I forgot to detach a zone before zpool export. Uninstall zone?

Dear all, recently, I migrated a solaris zone from one host to another. The zone was inside of a zpool. The zpool cotains two volumes. I did the following: host1: $ zlogin zone1 shutdown -y -g0 -i0 #Zone status changes from running to installed $ zpool export zone1 host2: $ zpool... (2 Replies)
Discussion started by: custos
2 Replies

4. Solaris

Host file to dns zone creation solution?

We are currently using the famous script H2N to create our DNS zone files from a host file. However, we are moving to IPV6 soon and this script doesnt support IPV6. Is there another script/solution to creating DNS zones via a host file input? Is there another solution or way to do things that I may... (0 Replies)
Discussion started by: jpolachak
0 Replies

5. UNIX for Dummies Questions & Answers

Host file to DNS zone creation

We are currently using the famous script H2N to create our DNS zone files from a host file. However, we are moving to IPV6 soon and this script doesnt support IPV6. Is there another script/solution to creating DNS zones via a host file input? (0 Replies)
Discussion started by: jpolachak
0 Replies

6. Solaris

Solaris 10 local zone on Solaris 11 global zone

Hi, A quick question: Can Solaris 10 local zones be moved to a Solaris 11 global zone and work well? Thank you in advance! (5 Replies)
Discussion started by: aixlover
5 Replies

7. Solaris

Zone Creation

Is it possible to install a solaris 10 flar image into a sparse zone? (6 Replies)
Discussion started by: mr_crosby
6 Replies

8. Solaris

Solaris 10 11/06 Zone creation issue

Hi, I am new to zone creations in solaris 10. When I try to create a zone with "set ip-type=exclusive" it gives the usage. OS == Solaris 10 11/06 s10s_u3wos_10 SPARC Copyright 2006 Sun Microsystems, Inc. All Rights Reserved. Use is subject to license... (17 Replies)
Discussion started by: niman
17 Replies

9. Solaris

Solaris Zone : Non global Zone check failed

Hi All , I try to install some packages in my global zone... On the execution of the installion of the script it quits by saying the error "Non global zone check failed" Kindly help me in this regard Thanks in advance, jeganr (7 Replies)
Discussion started by: jegaraman
7 Replies
Login or Register to Ask a Question