/[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 434 by dpavlin, Wed Sep 16 00:47:47 2009 UTC revision 511 by dpavlin, Wed Jul 21 16:50:27 2010 UTC
# Line 14  use File::Slurp; Line 14  use File::Slurp;
14    
15  our $mounted;  our $mounted;
16    
17  sub available { qw/debian_live webconverger debirf tinycore nfsroot openvz printer wrt/ };  our $server;
18    our $server_ip;
19    
20    sub available { qw/katalog debian_live webconverger debirf tinycore nfsroot openvz printer wrt clonezilla ubuntu freedos/ };
21    
22  sub debian_live {  sub debian_live {
23          my ($ip) = @_;          my ($ip) = @_;
# Line 33  sub debian_live { Line 36  sub debian_live {
36  default debian_live  default debian_live
37  label debian_live  label debian_live
38          kernel vmlinuz1          kernel vmlinuz1
39          append initrd=initrd1.img fetch=http://${server::ip}:7777/debian_live/debian-live-501-i386-standard.squashfs boot=live nopersistent hostname=$hostname union=aufs          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
40          });          });
41    
42  }  }
# Line 51  L<http://webconverger.org/> Line 54  L<http://webconverger.org/>
54  sub webconverger {  sub webconverger {
55          my ($ip) = @_;          my ($ip) = @_;
56    
57          $mounted->{"webconverger/$ip"} ||= upstream::iso( 'http://download.webconverger.com/webc-5.2.iso' );          $mounted->{"webconverger/$ip"} ||= upstream::iso( 'http://download.webconverger.com/webc-5.5.iso' );
58    
         my $homepage = client::conf( $ip => 'homepage', default => "http://${server::ip}:7777/client" );  
59          my $hostname = client::conf( $ip => 'hostname' ) || 'webconverger';          my $hostname = client::conf( $ip => 'hostname' ) || 'webconverger';
60    
61            my $homepage = client::conf( $ip => 'webconverger/homepage'
62                    , default => "http://$server_ip:7777/client" );
63            my $fetch    = client::conf( $ip => 'webconverger/fetch'
64                    , default => "http://$server_ip:7777/webconverger/iso/live/filesystem.squashfs" );
65    
66          pxelinux::config_for_ip( $ip, qq{          pxelinux::config_for_ip( $ip, qq{
67    
68  default webconverger  default webconverger
69  label webconverger  label webconverger
70          kernel iso/live/vmlinuz-2.6.30-backports.1-486          kernel iso/live/vmlinuz-2.6.30-backports.1-486
71          append initrd=iso/live/initrd.img-2.6.30-backports.1-486 fetch=http://${server::ip}:7777/webconverger/iso/live/filesystem.squashfs boot=live quiet nosudo splash video=vesa:ywrap,mtrr vga=788 nopersistent username=webc hostname=$hostname union=aufs homepage=$homepage locale=hr          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
72    
73          });          });
74    
75  }  }
76    
77    sub katalog {
78            my ($ip) = @_;
79            $mounted->{"webconverger/$ip"} ||= upstream::iso( 'http://download.webconverger.com/webc-5.5.iso' );
80            my $hostname = client::conf( $ip => 'hostname' ) || 'katalog';
81            my $homepage = client::conf( $ip => 'webconverger/homepage' => "http://koha.ffzg.hr" );
82            my $fetch    = client::conf( $ip => 'webconverger/fetch' => "http://$server_ip:7777/webconverger/custom.squashfs" );
83    
84            pxelinux::config_for_ip( $ip, qq{
85    
86    default katalog
87    label katalog
88            kernel iso/live/vmlinuz-2.6.30-backports.1-486
89            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
90    
91            });
92    
93    }
94  =head1 debirf  =head1 debirf
95    
96  debirf is a system that will create diskless, all-in-ram images (kernel and initramfs) that boot entirely into ram and leave the user in a fully functional Debian system.  debirf is a system that will create diskless, all-in-ram images (kernel and initramfs) that boot entirely into ram and leave the user in a fully functional Debian system.
# Line 103  label linux Line 127  label linux
127          });          });
128  }  }
129    
130    sub clonezilla {
131            my $ip = shift;
132            upstream::iso( 'http://sourceforge.net/projects/clonezilla/files/clonezilla_live_alternative_testing/clonezilla-live-20100503-lucid.iso/download' );
133            pxelinux::config_for_ip( $ip, qq{
134    
135    default linux
136    label linux
137            kernel iso/live/vmlinuz
138            append initrd=iso/live/initrd.img boot=live union=aufs noswap noprompt vga=788 fetch=http://$server_ip:7777/clonezilla/iso/live/filesystem.squashfs
139    
140            });
141    }
142    
143    sub ubuntu {
144            my $ip = shift;
145            upstream::iso( 'http://mirrors.us.kernel.org/ubuntu-releases/lucid/ubuntu-10.04-desktop-i386.iso' );
146    
147            my $export = "$server::base_dir/tftp/ubuntu/iso";
148            my $exported = `exportfs | grep $export`;
149            if ( $exported ne $export ) {
150                    warn "exportfs $exported\n";
151                    system "sudo exportfs -i -o rw,async,no_root_squash,no_subtree_check,fsid=999 $ip:$export";
152            }
153            pxelinux::config_for_ip( $ip, qq{
154    
155    default linux
156    label linux
157            kernel iso/casper/vmlinuz
158            append initrd=iso/casper/initrd.lz boot=casper netboot=nfs nfsroot=$server_ip:$export --
159    
160            });
161    }
162    
163    sub freedos {
164            my $ip = shift;
165    
166            my $dir = "$server::base_dir/tftp/freedos";
167            mkdir $dir unless -e $dir;
168    
169            symlink '/usr/lib/syslinux/memdisk', "$dir/memdisk" unless -e "$dir/memdisk";
170    
171            my $image = client::conf( $ip => 'memdisk.image' );
172    
173            if ( ! $image ) {
174                    $image = 'freedos.gz';
175                    upstream::mirror_file 'http://www.ibiblio.org/pub/micro/pc-stuff/freedos/files/distributions/unofficial/balder/balder10.imz' => "$dir/$image";
176            } else {
177                    $image =~ s{^.+/tftp/freedos/}{} && warn "using $image\n";
178            }
179    
180            pxelinux::config_for_ip( $ip, qq{
181    
182    default freedos
183    label freedos
184            kernel memdisk
185            append initrd=$image
186    
187            });
188    }
189    
190  sub in_chroot {  sub in_chroot {
191          my ( $dir, $command ) = @_;          my ( $dir, $command ) = @_;
192          write_file "$dir/tmp/inside.sh", $command;          write_file "$dir/tmp/inside.sh", $command;
# Line 112  sub in_chroot { Line 196  sub in_chroot {
196  sub nfsroot {  sub nfsroot {
197          my $ip = shift || die "no ip?";          my $ip = shift || die "no ip?";
198    
199            my $dist = 'lenny';
200            $dist = 'squeeze';
201    
202          my $nfsroot = "$server::base_dir/tftp/nfsroot";          my $nfsroot = "$server::base_dir/tftp/nfsroot";
203          my $debian_mirror = server::conf_default( 'debian_mirror', 'http://ftp.debian.org/debian' );          my $debian_mirror = server::conf_default( 'debian_mirror', 'http://ftp.debian.org/debian' );
204    
# Line 124  sub nfsroot { Line 211  sub nfsroot {
211    
212          if ( ! -e $debootstrap ) {          if ( ! -e $debootstrap ) {
213    
214                  system "sudo debootstrap --arch i386 lenny $debootstrap $debian_mirror";                  system "sudo debootstrap --arch i386 $dist $debootstrap $debian_mirror";
215    
216                  file::append "$debootstrap/etc/kernel-img.conf", "do_initrd = Yes\n" &&                  file::append "$debootstrap/etc/apt/sources.list.d/non-free.list", "deb $debian_mirror $dist non-free\n";
217                  in_chroot     $debootstrap => 'apt-get install -y --force-yes atl2-modules-2.6-686';                  in_chroot     $debootstrap => 'apt-get update';
218                  in_chroot     $debootstrap => 'apt-get -f install -y --force-yes locales';      # linux-image-2.6-686  
219                    file::append "$debootstrap/etc/kernel-img.conf", "do_initrd = Yes\n";
220                    in_chroot     $debootstrap => 'apt-get -f install -y --force-yes locales linux-image-2.6-686 firmware-bnx2';
221    
222                    # this can fails on some distros, so we run it alone
223                    in_chroot     $debootstrap => 'apt-get install -y --force-yes atl2-modules-2.6-686';
224                  file::append "$debootstrap/etc/initramfs-tools/modules", "atl2\n";                  file::append "$debootstrap/etc/initramfs-tools/modules", "atl2\n";
225                  file::change("$debootstrap/etc/initramfs-tools/initramfs.conf",  'BOOT=local' => 'BOOT=nfs' ) &&  
226                    file::change "$debootstrap/etc/initramfs-tools/initramfs.conf",  'BOOT=local' => 'BOOT=nfs';
227                  in_chroot     $debootstrap => 'update-initramfs -u';                  in_chroot     $debootstrap => 'update-initramfs -u';
228    
229          }          }
# Line 153  sub nfsroot { Line 245  sub nfsroot {
245                    
246          }          }
247    
248            my $exported = `exportfs | grep $export`;
249            if ( $exported ne $export ) {
250                    warn "exportfs $exported\n";
251                    system "sudo exportfs -i -o rw,async,no_root_squash,no_subtree_check,fsid=999 $ip:$export";
252            }
253    
254          my $hostname = client::conf( $ip => 'hostname' ) || 'nfsroot';          my $hostname = client::conf( $ip => 'hostname' ) || 'nfsroot';
255          file::replace "$export/etc/hostname", $hostname;          file::replace "$export/etc/hostname", $hostname;
256          file::replace "$export/etc/hosts", "127.0.0.1\tlocalhost $hostname\n";          file::replace "$export/etc/hosts", "127.0.0.1\tlocalhost $hostname\n";
257          file::replace "$export/etc/resolv.conf", "domain $server::domain_name\nnameserver $server::ip\n";          file::replace "$export/etc/resolv.conf", "domain $server->{domain}\nnameserver $server->{ip}\n";
258          file::replace "$export/etc/rsyslog.d/pxelator.conf", "*.*\t\@$server::ip\n";          file::replace "$export/etc/rsyslog.d/pxelator.conf", "*.*\t\@$server->{ip}\n";
259    
260          file::append "$debootstrap/etc/network/interfaces", qq{          file::append "$debootstrap/etc/network/interfaces", qq{
261    
# Line 174  iface eth0 inet dhcp Line 272  iface eth0 inet dhcp
272                  file::append "$export/etc/rc.local", $_;                  file::append "$export/etc/rc.local", $_;
273          } ( '/srv/sysadmin-cookbook/recepies/amt/serial-console.sh' );          } ( '/srv/sysadmin-cookbook/recepies/amt/serial-console.sh' );
274    
275          pxelinux::config_for_ip( $ip, qq{          pxelinux::config_ip_boot( $ip, "$export/boot", "root=/dev/nfs nfsroot=$server->{ip}:$export ro ip=dhcp" );
   
 default nfsroot  
 label nfsroot  
         kernel debootstrap/vmlinuz  
         append initrd=debootstrap/initrd.img root=/dev/nfs nfsroot=$server::ip:$export ro ip=dhcp  
276    
         });  
277  }  }
278    
279  sub openvz {  sub openvz {
# Line 193  sub wrt         {} Line 285  sub wrt         {}
285    
286  sub for_ip {  sub for_ip {
287          my $ip = shift || return;          my $ip = shift || return;
288            $server = server::as_hash_for $ip;
289            $server_ip = $server->{ip} || die "no server ip";
290          my $config = client::conf( $ip => 'config' ) || return;          my $config = client::conf( $ip => 'config' ) || return;
291          eval $config . '($ip)';          eval $config . '($ip)'; # must be last
 #       $tftp::dir = "$server::base_dir/tftp/$pxelinux::path_prefix";  
292  }  }
293    
294  warn 'loaded';  warn 'loaded';

Legend:
Removed from v.434  
changed lines
  Added in v.511

  ViewVC Help
Powered by ViewVC 1.1.26