propage $server HASH and $server_ip all over config
authorDobrica Pavlinusic <dpavlin@rot13.org>
Mon, 4 Jan 2010 23:19:31 +0000 (23:19 +0000)
committerDobrica Pavlinusic <dpavlin@rot13.org>
Mon, 4 Jan 2010 23:19:31 +0000 (23:19 +0000)
lib/PXElator/config.pm

index a9e44e2..8c898da 100644 (file)
@@ -14,6 +14,9 @@ use File::Slurp;
 
 our $mounted;
 
+our $server;
+our $server_ip;
+
 sub available { qw/katalog debian_live webconverger debirf tinycore nfsroot openvz printer wrt/ };
 
 sub debian_live {
@@ -33,7 +36,7 @@ sub debian_live {
 default debian_live
 label debian_live
        kernel vmlinuz1
-       append initrd=initrd1.img fetch=http://${server::ip}:7777/debian_live/debian-live-501-i386-standard.squashfs boot=live nopersistent hostname=$hostname union=aufs noprompt
+       append initrd=initrd1.img fetch=http://$server_ip:7777/debian_live/debian-live-501-i386-standard.squashfs boot=live nopersistent hostname=$hostname union=aufs noprompt
        });
 
 }
@@ -56,9 +59,9 @@ sub webconverger {
        my $hostname = client::conf( $ip => 'hostname' ) || 'webconverger';
 
        my $homepage = client::conf( $ip => 'webconverger/homepage'
-               , default => "http://${server::ip}:7777/client" );
+               , default => "http://$server_ip:7777/client" );
        my $fetch    = client::conf( $ip => 'webconverger/fetch'
-               , default => "http://${server::ip}:7777/webconverger/iso/live/filesystem.squashfs" );
+               , default => "http://$server_ip:7777/webconverger/iso/live/filesystem.squashfs" );
 
        pxelinux::config_for_ip( $ip, qq{
 
@@ -76,7 +79,7 @@ sub katalog {
        $mounted->{"webconverger/$ip"} ||= upstream::iso( 'http://download.webconverger.com/webc-5.5.iso' );
        my $hostname = client::conf( $ip => 'hostname' ) || 'katalog';
        my $homepage = client::conf( $ip => 'webconverger/homepage' => "http://koha.ffzg.hr" );
-       my $fetch    = client::conf( $ip => 'webconverger/fetch' => "http://${server::ip}:7777/webconverger/custom.squashfs" );
+       my $fetch    = client::conf( $ip => 'webconverger/fetch' => "http://$server_ip:7777/webconverger/custom.squashfs" );
 
        pxelinux::config_for_ip( $ip, qq{
 
@@ -182,7 +185,6 @@ sub nfsroot {
        
        }
 
-       my $server = server::as_hash_for $ip;
 
        my $hostname = client::conf( $ip => 'hostname' ) || 'nfsroot';
        file::replace "$export/etc/hostname", $hostname;
@@ -218,9 +220,10 @@ sub wrt         {}
 
 sub for_ip {
        my $ip = shift || return;
+       $server = server::as_hash_for $ip;
+       $server_ip = $server->{ip} || die "no server ip";
        my $config = client::conf( $ip => 'config' ) || return;
-       eval $config . '($ip)';
-#      $tftp::dir = "$server::base_dir/tftp/$pxelinux::path_prefix";
+       eval $config . '($ip)'; # must be last
 }
 
 warn 'loaded';