Perl – Basic Solaris Zone Config

#!/usr/bin/perl
# — Written by Blane Craft —
# — 11/03/06 —
#
## – Basic Zone Config – ##

print ‘##–Basic Zone Configuration–##’;
print”\n”;
print”\n”;
print ‘Zone Name? ‘;
$name = ; chomp ($name);

print ‘Set Dir? ‘;
$setdir = ; chomp ($setdir);

print ‘Special Dir? ‘;
$spcdir = ; chomp ($spcdir);

print ‘Filesystem Type? ‘;
$fs = ; chomp ($fs);

print ‘Extra Options? ‘;
$extra = ; chomp ($extra);
print”\n”;
print”\n”;
## – Network Config – ##

print ‘##–Network Configuration–##’;
print”\n”;
print”\n”;
print ‘IP Address? ‘;
$ip = ; chomp ($ip);

print ‘Interface? ‘;
$if = ; chomp ($if);
print”\n”;
print”\n”;
## – Resource Control – ##

print ‘##–Resource Control–##’;
print”\n”;
print”\n”;
print ‘Resource Control? ‘;
$rctl = ; chomp ($rctl);

print ‘Resource Control Value? (in parens) ‘;
$rctlv = ; chomp ($rctlv);
print”\n”;
print”\n”;
print ‘##–Attributes–##’;
print”\n”;
print”\n”;
print ‘Name? ‘;
$attrn = ; chomp ($attrn);

print ‘Type? ‘;
$attrt = ; chomp ($attrs);

print ‘Value? ‘;
$attrv = ; chomp ($attrv);
print”\n”;
print”\n”;
print”Creating Zone and adding interfaces\n”;
sleep 1;
system(“zonecfg -z $name ‘create ; set zonepath=/Zones/$name ; set autoboot=true ; add fs ; set dir=$setdir ; set special=$spcdir ; set type=$fs ; add options $extra ; end ; add net; set address=$ip ; set physical=$if ; end'”);
print”Adding resource controls and values\n”;
sleep 1;
system(“zonecfg -z $name ‘add rctl ; set name=$rctl ; set value=$rctlv ; end'”);
print”Adding attributes, verifying, and exiting\n”;
sleep 1;
system(“zonecfg -z $name ‘add attr ; set name=$attrn ; set type=$attrt ; set value=$attrv ; end ; verify ; commit ; exit'”);
print”Listing existing zones\n”;
sleep 1;
system(“zoneadm list -vc”);
print”\n”;
print”\n”;

Leave a Reply

Your email address will not be published. Required fields are marked *