/[pxelator]/lib/PXElator/config.pm
This is repository of my old source code which isn't updated any more. Go to git.rot13.org for current projects!
ViewVC logotype

Diff of /lib/PXElator/config.pm

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 519 by dpavlin, Tue Aug 24 11:44:06 2010 UTC revision 550 by dpavlin, Fri Oct 29 15:45:04 2010 UTC
# Line 9  use pxelinux; Line 9  use pxelinux;
9  use client;  use client;
10  use file;  use file;
11  use ssh;  use ssh;
12    use upstream;
13    
14  use File::Slurp;  use File::Slurp;
15    
# Line 17  our $mounted; Line 18  our $mounted;
18  our $server;  our $server;
19  our $server_ip;  our $server_ip;
20    
21  sub available { qw/katalog debian_live webconverger debirf tinycore nfsroot openvz printer wrt clonezilla ubuntu memdisk vyatta/ };  sub available { qw/
22            katalog debian_live webconverger
23            debirf tinycore nfsroot
24            openvz printer wrt
25            clonezilla ubuntu memdisk vyatta android
26            systemrescue
27            memtest
28    / };
29    
30  sub debian_live {  sub debian_live {
31          my ($ip) = @_;          my ($ip) = @_;
32    
33          upstream::files( qw{          my $from = 'http://cdimage.debian.org/cdimage/release/current-live/i386/web/';
34                  http://cdimage.debian.org/cdimage/release/current-live/i386/web/          $from = 'http://cdimage.debian.org/cdimage/squeeze_live_alpha2/i386/web/';
35                  vmlinuz1          my $variant = 'standard';
36                  initrd1.img  
37                  debian-live-501-i386-standard.squashfs          my $dir = upstream::files $from => 'MD5SUMS';
38          });  
39            my ( $vmlinuz, $initrd, $squashfs );
40            
41            my @md5sum = read_file "$dir/MD5SUMS";
42    
43            foreach ( @md5sum ) {
44                    $vmlinuz = $1 if m/\s+(\S*vmlinuz\S*)/;
45                    $initrd = $1 if m/\s+(\S*$variant\S*initrd\S*)/;
46                    $squashfs = $1 if m/\s+(\S*$variant\S*\.squashfs)$/;
47                    warn "# MD5SUM: $_\n";
48            }
49    
50            upstream::files $from => $vmlinuz, $initrd, $squashfs;
51    
52          my $hostname = client::conf( $ip => 'hostname' ) || 'debian-live';          my $hostname = client::conf( $ip => 'hostname' ) || 'debian-live';
53    
54            # FIXME drop in shell because users doesn't work in current image
55            my $custom_init = 'init=/bin/hash';
56    
57            if ( my $custom_squashfs = client::conf( $ip => 'squashfs' ) ) {
58                    $squashfs = $custom_squashfs;
59                    $custom_init = '';
60            }
61    
62          pxelinux::config_for_ip( $ip, qq{          pxelinux::config_for_ip( $ip, qq{
63    
64  default debian_live  default debian_live
65  label debian_live  label debian_live
66          kernel vmlinuz1          kernel $vmlinuz
67          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=$initrd fetch=http://$server_ip:7777/debian_live/$squashfs boot=live nopersistent hostname=$hostname union=aufs noprompt autologin username=user debug $custom_init
68          });          });
69    
70  }  }
71    
 use upstream;  
   
72  =head1 webconverger  =head1 webconverger
73    
74  Webconverger - the opensource Web Kiosk  Webconverger - the opensource Web Kiosk
# Line 51  L<http://webconverger.org/> Line 77  L<http://webconverger.org/>
77    
78  =cut  =cut
79    
80    sub _glob_first {
81            my ( $dir, $path ) = @_;
82            my @glob = glob "$dir/$path";
83            my $first = $glob[0] || die "no $dir/$path";
84            $dir   =~ s{iso/*$}{};
85            $first =~ s{^\Q$dir\E}{}g;
86            return $first;
87    }
88    
89  sub webconverger {  sub webconverger {
90          my ($ip) = @_;          my ($ip) = @_;
91    
92          $mounted->{"webconverger/$ip"} ||= upstream::iso( 'http://download.webconverger.com/webc-5.5.iso' );          $mounted->{"webconverger/$ip"} ||= upstream::iso( 'http://download.webconverger.com/webc-6.2.iso' );
93    
94          my $hostname = client::conf( $ip => 'hostname' ) || 'webconverger';          my $hostname = client::conf( $ip => 'hostname' ) || 'webconverger';
95    
# Line 63  sub webconverger { Line 98  sub webconverger {
98          my $fetch    = client::conf( $ip => 'webconverger/fetch'          my $fetch    = client::conf( $ip => 'webconverger/fetch'
99                  , default => "http://$server_ip:7777/webconverger/iso/live/filesystem.squashfs" );                  , default => "http://$server_ip:7777/webconverger/iso/live/filesystem.squashfs" );
100    
101            my $mnt = "$server::base_dir/tftp/webconverger/iso";
102            warn "# mnt: $mnt\n";
103            my $kernel = _glob_first $mnt => 'live/vmlinuz*';
104            my $initrd = _glob_first $mnt => 'live/initrd.img*';
105    
106          pxelinux::config_for_ip( $ip, qq{          pxelinux::config_for_ip( $ip, qq{
107    
108  default webconverger  default webconverger
109  label webconverger  label webconverger
110          kernel iso/live/vmlinuz-2.6.30-backports.1-486          kernel $kernel
111          append initrd=iso/live/initrd.img-2.6.30-backports.1-486 fetch=$fetch boot=live quiet nosudo splash video=vesa:ywrap,mtrr vga=788 nopersistent username=webc hostname=$hostname union=aufs homepage=$homepage locale=hr noprompt kioskresetstation=10          append initrd=$initrd fetch=$fetch boot=live quiet nosudo splash video=vesa:ywrap,mtrr vga=788 nopersistent username=webc hostname=$hostname union=aufs homepage=$homepage locale=hr noprompt kioskresetstation=10
112    
113          });          });
114    
# Line 116  label linux Line 156  label linux
156    
157  sub tinycore {  sub tinycore {
158          my $ip = shift;          my $ip = shift;
159          upstream::iso( 'http://distro.ibiblio.org/pub/linux/distributions/tinycorelinux/2.x/release/tinycore_2.2.iso' );          upstream::iso( 'http://distro.ibiblio.org/pub/linux/distributions/tinycorelinux/3.x/release/tinycore-current.iso' );
160          pxelinux::config_for_ip( $ip, qq{          pxelinux::config_for_ip( $ip, qq{
161    
162  default linux  default linux
# Line 195  label $image Line 235  label $image
235    
236  sub vyatta {  sub vyatta {
237          my $ip = shift;          my $ip = shift;
238          upstream::iso( 'http://www.vyatta.com/downloads/vc6.0/vyatta-livecd-virt_VC6.0-2010.06.01_i386.iso' );          upstream::iso( 'http://www.vyatta.com/downloads/vc6.1/vyatta-livecd_VC6.1-2010.08.20_i386.iso' );
239    
240          my $dir = "$server::base_dir/tftp/vyatta";          my $dir = "$server::base_dir/tftp/vyatta";
241          symlink '/usr/lib/syslinux/memdisk', "$dir/memdisk" unless -e "$dir/memdisk";          symlink '/usr/lib/syslinux/memdisk', "$dir/memdisk" unless -e "$dir/memdisk";
# Line 211  label vyatta Line 251  label vyatta
251          });          });
252  }  }
253    
254    sub android {
255            my $ip = shift;
256            my $path = upstream::iso( 'http://android-x86.googlecode.com/files/android-x86-1.6-r2.iso' );
257    
258            my $dir = "$server::base_dir/tftp/android";
259            symlink '/usr/lib/syslinux/memdisk', "$dir/memdisk" unless -e "$dir/memdisk";
260    
261            client::conf $ip => 'kvm.boot' => "n -cdrom $path";
262    
263            pxelinux::config_for_ip( $ip, qq{
264    
265    default android-1.6-donut
266    label android-1.6-donut
267    
268            kernel iso/kernel
269            append initrd=iso/initrd.img root=/dev/ram0 androidboot_hardware=eeepc acpi_sleep=s3_bios,s3_mode quiet SRC= DATA= SDCARD= vga=788 DEBUG=1
270    
271            });
272    }
273    
274    
275    # http://www.sysresccd.org/Sysresccd-manual-en_PXE_network_booting
276    sub systemrescue {
277            my $ip = shift;
278            my $path = upstream::iso( 'http://sourceforge.net/projects/systemrescuecd/files/sysresccd-x86/1.6.1/systemrescuecd-x86-1.6.1.iso/download' );
279    
280            my $dir = "$server::base_dir/tftp/systemrescue";
281            symlink '/usr/lib/syslinux/memdisk', "$dir/memdisk" unless -e "$dir/memdisk";
282    
283            client::conf $ip => 'kvm.boot' => "n -cdrom $path";
284    
285            pxelinux::config_for_ip( $ip, qq{
286    
287    default systemrescue
288    label systemrescue
289    
290            kernel iso/isolinux/rescuecd
291            append initrd=iso/isolinux/initram.igz dodhcp netboot=http://$server::ip:7777/systemrescue/iso/sysrcd.dat
292    
293            });
294    }
295    
296    # http://www.memtest.org/
297    sub memtest {
298            my $ip = shift;
299    
300            my $dir = "$server::base_dir/tftp/memtest";
301            mkdir $dir unless -e $dir;
302            symlink '/boot/memtest86+.bin', "$dir/memtest.bin" unless -e "$dir/memtest.bin";
303    
304            pxelinux::config_for_ip( $ip, qq{
305    
306    default memtest
307    label memtest
308            linux memtest.bin
309    
310            });
311    }
312    
313  sub in_chroot {  sub in_chroot {
314          my ( $dir, $command ) = @_;          my ( $dir, $command ) = @_;
315          write_file "$dir/tmp/inside.sh", $command;          write_file "$dir/tmp/inside.sh", $command;
# Line 312  sub for_ip { Line 411  sub for_ip {
411          $server = server::as_hash_for $ip;          $server = server::as_hash_for $ip;
412          $server_ip = $server->{ip} || die "no server ip";          $server_ip = $server->{ip} || die "no server ip";
413          my $config = client::conf( $ip => 'config' ) || return;          my $config = client::conf( $ip => 'config' ) || return;
414          eval $config . '($ip)'; # must be last          my $ret = eval $config . '($ip)'; # must be last
415            if ( $@ ) {
416                    warn "ERROR in executing $config($ip): $@\n";
417                    $ret .= qq{<pre style="color:red">$@</pre>};
418            }
419            return $ret;
420  }  }
421    
422  warn 'loaded';  warn 'loaded';

Legend:
Removed from v.519  
changed lines
  Added in v.550

  ViewVC Help
Powered by ViewVC 1.1.26