RE: [suse-autoinstall] Antwort: Re: [suse-autoinstall] sles 9 installation Source in autoyast.xml [Virus checked]
Here's a script we use. It works through a template and replaces the values which it finds with values which the use types in. You will obviously need to modify your template of modify this script to match the values in your template, but you shoudl get the general idea. No warranty or support caveat emptor applies: #!/usr/bin/perl use Getopt::Long; $basedir = '/SuSE/tftpdir/suse'; (my $progname = $0) =~ s/.*\///; # basename $0 $useage = qq{ Summary: $progname creates the xml install configuration specifically for a host Example Command: Build XML for t13s1d2 in lab 13 $progname --hostname=t13s1d2 --ip=10.224.34.136 --subnet=255.255.255.192 --network=10.224.34.128 --broadcast=10.224.34.191 --gateway=10.224.34.129 --rel ease=C.08.10.00052 --template=dsp.xml This command will create 10.224.34.136.xml in $basedir for the install to us e once it's started. Options list --ip: IP address for the system to use once it's installed. --hostname: Host name for the system. --broadcast: Network broadcast address. --subnet: Subnet mask. --network: Base network address. --gateway: Default gateway. --release: The release version of the xml template to use. --template: The name of the template to use. --help: Show this help. }; if (not @ARGV) { warn $useage; exit 0; } GetOptions( 'ip=s' => \$ip, 'hostname=s' => \$hostname, 'broadcast=s' => \$broadcast, 'subnet=s' => \$subnet, 'network=s' => \$network, 'gateway=s' => \$gateway, 'release=s' => \$release, 'template=s' => \$template, 'help' => \$help ) or exit 1; # mandatory option check if ($help) { warn $useage; exit 0; } print "[ERROR] must specify --ip\n" unless $ip; print "[ERROR] must specify --hostname\n" unless $hostname; print "[ERROR] must specify --broadcast\n" unless $broadcast; print "[ERROR] must specify --subnet\n" unless $subnet; print "[ERROR] must specify --network\n" unless $network; print "[ERROR] must specify --gateway\n" unless $gateway; print "[ERROR] must specify --release\n" unless $release; print "[ERROR] must specify --template\n" unless $template; exit 0 unless ($ip and $hostname and $broadcast and $subnet and $network and $ga teway and $release and $template); # read the template into memory open(TEMPLATE, "<$basedir/$release/$template.xml") or die "[FATAL] unable to ope n $basedir/$release/$template.xml for reading: $!\n"; @template = <TEMPLATE>; close(TEMPLATE); # process the template and create the output file open(XML, ">$basedir/$ip.xml") or die "[FATAL] unable to open $basedir/$ip.xml f or writing\n"; foreach $line (@template) { if ($line =~ m#<hostname>\S+</hostname>#) { $line = "<hostname>$hostname</hostname>\n"; } if ($line =~ m#<broadcast>192.168.0.255</broadcast>#) { $line = "<broadcast>$broadcast</broadcast>\n"; } if ($line =~ m#<ipaddr>192.168.0.200</ipaddr>#) { $line = "<ipaddr>$ip</ipaddr>\n"; } if ($line =~ m#<netmask>255.255.255.0</netmask>#) { $line = "<netmask>$subnet</netmask>\n"; } if ($line =~ m#<network>192.168.0.0</network>#) { $line = "<network>$network</network>\n"; } if ($line =~ m#<gateway>192.168.0.254</gateway>#) { $line = "<gateway>$gateway</gateway>\n"; } if ($line =~ m#<user_password>shippingpassword</user_password>#) { $line = "<user_password>wackypassword</user_password>\n"; } print XML $line; } close(XML); print "[INFO] $basedir/$ip.xml created\n"; tsduser3:fraserb$ -- To unsubscribe, e-mail: suse-autoinstall-unsubscribe@suse.com For additional commands, e-mail: suse-autoinstall-help@suse.com
<fraser_bailey@agilent.com> schrieb am 02.08.2005 10:36:29:
Here's a script we use. It works through a template and replaces the values which it finds with values which the use types in. You will obviously need to modify your template of modify this script to match the values in your template, but you shoudl get the general idea.
thanks for your script. now I discovered a strange behaviour again. Perhaps someone can help. my interfaces section looks like this: <interfaces config:type="list"> <interface> <bootproto>static</bootproto> <broadcast>BCAST-ADDR</broadcast> <device>eth0</device> <ipaddr>IP-ADDR</ipaddr> <netmask>SN-MASK</netmask> <network>NW-ADDR</network> <startmode>onboot</startmode> </interface> </interfaces> but the ip seems to be assigned to a random interface (I've seen eth2 and eth3). Can this effect be caused by the indention of bcast, ip, netmask and network, or is it estimated behaviour? thanks matthias
participants (2)
-
fraser_bailey@agilent.com
-
Matthias.Eble@kaufland.de