#!/usr/bin/perl # This will be the base zone dir used with zonedir below $bzd="/zones"; system(clear); print "\nSolaris 10 Zone Maker\n"; print "---------------------\n\n"; print "What is the name of the new zone to be created? "; $newzone = ; chomp($newzone); print "\nWhat is the name of the directory to be used for this zone? [$newzone] "; $zonedir = ; chomp($zonedir); if (!$zonedir) { $zonedir = $newzone; } print "\nWhat is the IP address to use? "; $newip = ; chomp($newip); print "\nWhat is name of the ethernet interface to bind the IP address to? (ex: bge0) "; $ethint = ; chomp($ethint); print "\nDo you want to inherit standard directories (lib,platform,sbin,usr) from the global zone? [yN] "; $inh = ; chomp($inh); if (!$inh) { $inh = "n"; } if (($inh eq "y") || ($inh eq "Y")) { $isw = "1"; } else { $isw = "0"; } print "\n\nPlease verify the following information:\n\n"; print " Zone Name: $newzone\n"; print " Zone Directory: $zonedir\n"; print " Zone IP Address: $newip\n"; print " Ethernet Interface: $ethint\n"; print " Inherit Directories: $inh\n"; print "\nAre these entries correct? [Yn] "; $yn = ; chomp($yn); if (!$yn) { $yn = "y"; } if (($yn == "y") || ($yn == "Y")) { $of = "/tmp/zccfs10.tmp"; # Create the zonecfg command file `echo "create -b" > $of`; `echo "set zonepath=$bzd/$zonedir" >> $of`; `echo "set autoboot=true" >> $of`; if ($isw == "1") { `echo "add inherit-pkg-dir" >> $of`; `echo "set dir=/lib" >> $of`; `echo "end" >> $of`; `echo "add inherit-pkg-dir" >> $of`; `echo "set dir=/platform" >> $of`; `echo "end" >> $of`; `echo "add inherit-pkg-dir" >> $of`; `echo "set dir=/sbin" >> $of`; `echo "end" >> $of`; `echo "add inherit-pkg-dir" >> $of`; `echo "set dir=/usr" >> $of`; `echo "end" >> $of`; } `echo "add net" >> $of`; `echo "set address=$newip" >> $of`; `echo "set physical=$ethint" >> $of`; `echo "end" >> $of`; # Make the dir that the zone will live in `mkdir $bzd/$zonedir`; `chmod 700 $bzd/$zonedir`; # Now, create the zone dude! print "\nCreating the zone ... \n"; `zonecfg -z $newzone -f $of`; print "Done!\n"; # Install the zone print "Installing the zone, this will take awhile ... \n"; `zoneadm -z $newzone install`; print "Done!\n"; # Boot the zone print "Now booting the zone ... \n"; `zoneadm -z $newzone boot`; print "Done!\n"; # Remove the config file `rm $of`; print "\nZone setup complete, connect to the virtual console with the following command: \n"; print " -> zlogin -C -e\\@ $newzone <- *Exit by typing @.\n\n"; } else { die("Script execution halted.\n"); }