8 |
use pxelinux; |
use pxelinux; |
9 |
use File::Slurp; |
use File::Slurp; |
10 |
|
|
|
sub shared { |
|
|
my ($name, $value) = @_; |
|
|
|
|
|
my $path ="$server::base_dir/conf/$server::ip/$name"; |
|
|
if ( defined $value ) { |
|
|
write_file $path, $value; |
|
|
} else { |
|
|
$value = read_file $path if -e $path; |
|
|
} |
|
|
return $value; |
|
|
} |
|
|
|
|
11 |
sub debian_live { |
sub debian_live { |
12 |
$dhcpd::file = "pxelinux.0"; |
$dhcpd::file = "pxelinux.0"; |
13 |
$pxelinux::path_prefix = 'live-helper/tftpboot/'; |
$pxelinux::path_prefix = 'live-helper/tftpboot/'; |
14 |
$pxelinux::config_file = 'pxelinux.cfg/default'; |
$pxelinux::config_file = 'pxelinux.cfg/default'; |
15 |
} |
} |
16 |
|
|
17 |
use LWP::Simple qw/mirror RC_NOT_MODIFIED/; |
use upstream; |
|
sub webconverger { |
|
|
$dhcpd::file = "pxelinux.0"; |
|
|
$pxelinux::path_prefix = 'webconverger/'; |
|
|
|
|
|
my $dir = "$server::base_dir/tftp/$pxelinux::path_prefix"; |
|
|
|
|
|
mkdir $dir unless -d $dir; |
|
|
|
|
|
my $cfg = "$dir/pxelinux.cfg"; |
|
|
return 1 if -e $cfg; |
|
18 |
|
|
19 |
mkdir $cfg; |
sub webconverger { |
20 |
|
my $ip = shift; |
|
my $iso = '/srv/pxelator/iso/webc-5.2.iso'; |
|
|
my $url = 'http://download.webconverger.com/webc-5.2.iso'; |
|
|
|
|
|
print STDERR "mirror $url"; |
|
|
mirror( $url, $iso) |
|
|
== RC_NOT_MODIFIED |
|
|
&& warn(" not modified\n") |
|
|
|| warn(" done ", -s $iso, " bytes\n") |
|
|
; |
|
|
|
|
|
mkdir "$dir/iso" unless -e "$dir/iso"; |
|
|
|
|
|
system "mount -t iso9660 | grep webc-5.2 || sudo mount $iso $dir/iso/ -o loop -t iso9660 -v"; |
|
21 |
|
|
22 |
symlink "/usr/lib/syslinux/pxelinux.0", "$dir/$dhcpd::file"; |
upstream::iso( 'http://download.webconverger.com/webc-5.2.iso' ); |
23 |
|
|
24 |
$cfg .= '/default'; |
pxelinux::config_for_ip( $ip, qq{ |
25 |
|
|
26 |
write_file $cfg, qq{ |
default webconverger |
27 |
label webconverger |
label webconverger |
28 |
kernel iso/live/vmlinuz-2.6.30-backports.1-486 |
kernel iso/live/vmlinuz-2.6.30-backports.1-486 |
29 |
append initrd=iso/live/initrd.img-2.6.30-backports.1-486 fetch=http://172.16.10.1/pxelator/webconverger/iso/live/filesystem.squashfs boot=live quiet homepage=http://172.16.10.1:7777/ nonetworking nosudo splash video=vesa:ywrap,mtrr vga=788 nopersistent username=webc hostname=webconverger union=aufs |
append initrd=iso/live/initrd.img-2.6.30-backports.1-486 fetch=http://172.16.10.1/pxelator/webconverger/iso/live/filesystem.squashfs boot=live quiet homepage=http://172.16.10.1:7777/ nonetworking nosudo splash video=vesa:ywrap,mtrr vga=788 nopersistent username=webc hostname=webconverger union=aufs |
|
}; |
|
30 |
|
|
31 |
# $pxelinux::config_file = $cfg; |
}); |
32 |
|
|
33 |
} |
} |
34 |
|
|
35 |
sub for_ip { |
sub for_ip { |
36 |
my $ip = shift; |
my $ip = shift; |
37 |
# debian_live(); |
# debian_live(); |
38 |
webconverger(); |
webconverger($ip); |
39 |
# $tftp::dir = "$server::base_dir/tftp/$pxelinux::path_prefix"; |
# $tftp::dir = "$server::base_dir/tftp/$pxelinux::path_prefix"; |
40 |
} |
} |
41 |
|
|