2 |
|
|
3 |
use warnings; |
use warnings; |
4 |
use strict; |
use strict; |
5 |
|
use autodie; |
6 |
|
|
7 |
use File::Slurp; |
use File::Slurp; |
8 |
|
|
9 |
use server; |
use httpd; |
10 |
use tftpd; |
use tftpd; |
11 |
|
|
12 |
our $file = 'gpxelinux.0'; |
our $file = 'gpxelinux.0'; |
14 |
symlink '/usr/lib/syslinux/gpxelinux.0', $path unless -l $path; |
symlink '/usr/lib/syslinux/gpxelinux.0', $path unless -l $path; |
15 |
warn "file $path ", -s $path; |
warn "file $path ", -s $path; |
16 |
|
|
17 |
my $url = "http://$server::ip/pxelator/debian-live/"; |
my $url = $httpd::url; |
18 |
my $squash = tftpd::path('debian-live/*squashfs'); |
#$url = "tftp://$server::ip/"; # fallback to tftp |
19 |
|
#$url = "http://$server::ip/pxelator/"; |
20 |
|
|
21 |
|
use LWP::Simple qw/mirror RC_NOT_MODIFIED/; |
22 |
|
foreach my $file ( 'vmlinuz1', 'initrd1.img', 'debian-live-501-i386-standard.squashfs' ) { |
23 |
|
my $path = "$tftpd::dir/debian-live"; |
24 |
|
mkdir $path unless -e $path; |
25 |
|
# next if -e "$path/$file"; |
26 |
|
print STDERR "mirror $file "; |
27 |
|
mirror( "http://cdimage.debian.org/cdimage/release/current-live/i386/web/$file", "$path/$file") |
28 |
|
== RC_NOT_MODIFIED |
29 |
|
&& warn("not modified\n") |
30 |
|
|| warn("mirrored ", -s "$path/$file", "\n") |
31 |
|
; |
32 |
|
} |
33 |
|
|
34 |
|
sub config_for_ip { |
35 |
|
|
36 |
|
my $ip = shift; |
37 |
|
$ip = uc sprintf "%02x%02x%02x%02x", split /\./,$ip; |
38 |
|
|
39 |
|
my $config = "$tftpd::dir/pxelinux.cfg"; |
40 |
|
mkdir $config unless -d $config; |
41 |
|
$config .= '/' . $ip; |
42 |
|
|
43 |
|
my $squash = $url . tftpd::path('debian-live/*squashfs'); |
44 |
|
write_file $config, qq{ |
45 |
|
|
46 |
|
default linux |
47 |
|
label linux |
48 |
|
kernel $url/debian-live/vmlinuz1 |
49 |
|
append initrd=$url/debian-live/initrd1.img boot=live union=aufs noswap noprompt vga=normal fetch=$squash |
50 |
|
|
51 |
|
}; |
52 |
|
|
53 |
my $config = "$ftpd::dir/pxelinux.cfg/default"; |
warn "config $config ", -s $config if $server::debug; |
54 |
|
|
55 |
write_file $config, qq{ |
} |
|
|
|
|
default linux |
|
|
label linux |
|
|
kernel $url/vmlinuz1 |
|
|
append initrd=$url/initrd1.img boot=live union=aufs noswap noprompt vga=normal fetch=$url/$squash |
|
|
|
|
|
}; |
|
|
|
|
|
warn "config $config ", -s $config; |
|
56 |
|
|
57 |
warn "loaded"; |
warn "loaded"; |
58 |
|
|