/[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 270 by dpavlin, Wed Aug 19 18:10:37 2009 UTC revision 271 by dpavlin, Wed Aug 19 22:48:54 2009 UTC
# Line 7  use autodie; Line 7  use autodie;
7  use server;  use server;
8  use pxelinux;  use pxelinux;
9  use client;  use client;
10    use file;
11    
12  use File::Slurp;  use File::Slurp;
13    
14  sub available { qw/debian_live webconverger debirf tinycore nfsroot/ };  sub available { qw/debian_live webconverger debirf tinycore nfsroot/ };
# Line 98  label linux Line 100  label linux
100          });          });
101  }  }
102    
103    sub in_chroot {
104            my ( $dir, $command ) = @_;
105            write_file "$dir/tmp/inside.sh", $command;
106            system "sudo chroot $dir sh -x /tmp/inside.sh";
107    }
108    
109    our $mounted;
110    
111  sub nfsroot {  sub nfsroot {
112          my $ip = shift;          my $ip = shift;
113    
# Line 105  sub nfsroot { Line 115  sub nfsroot {
115          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' );
116    
117          if ( ! -e $nfsroot ) {          if ( ! -e $nfsroot ) {
118                  system "apt-get install nfs-kernel-server debootstrap";                  system "sudo apt-get install nfs-kernel-server debootstrap aufs-modules-`uname -r` aufs-tools";
119                    mkdir $nfsroot;
120            }
121    
122                  if ( ! -e $nfsroot ) {          my $debootstrap = "$nfsroot/debootstrap";
                         mkdir $nfsroot;  
                         system "debootstrap --arch i386 lenny $nfsroot http://ftp.hr.debian.org/debian";  
                 }  
123    
124                  write_file "$nfsroot/tmp/configure.sh", qq{          if ( ! -e $debootstrap ) {
 echo "do_initrd = Yes" > /etc/kernel-img.conf  
125    
126  # apt-get install kernel-image-686                  system "sudo debootstrap --arch i386 lenny $debootstrap $debian_mirror";
 apt-get install atl2-modules-2.6-686  
 echo atl2 >> /etc/initramfs-tools/modules  
127    
128  cat /etc/initramfs-tools/initramfs.conf | sed 's/BOOT=local/BOOT=nfs/' > /tmp/initramfs.conf \                  file::append "$debootstrap/etc/kernel-img.conf", "do_initrd = Yes\n" &&
129          && mv /tmp/initramfs.conf /etc/initramfs-tools/initramfs.conf                  in_chroot     $debootstrap => 'apt-get install -y --force-yes atl2-modules-2.6-686';
130                    in_chroot     $debootstrap => 'apt-get -f install -y --force-yes locales';      # linux-image-2.6-686
131    
132  update-initramfs -u -v                  file::append "$debootstrap/etc/initramfs-tools/modules", "atl2\n";
133                    file::change("$debootstrap/etc/initramfs-tools/initramfs.conf",  'BOOT=local' => 'BOOT=nfs' ) &&
134                    in_chroot     $debootstrap => 'update-initramfs -u';
135    
136  };                  file::append "$debootstrap/etc/rsyslog.d/pxelator.conf", "*.*\t\@$server::ip\n";
137                    file::append "$debootstrap/etc/network/interfaces", qq{
138    
139                  system "chroot $nfsroot sh -x /tmp/configure.sh";  auto lo
140    iface lo inet loopback
141    
142                  open(my $exports, '>>', '/etc/exports');  allow-hotplug eth0
143                  print $exports "$nfsroot\t$server::ip/$server::netmask(rw,async,no_root_squash,no_subtree_check)\n";  iface eth0 inet dhcp
                 close($exports);  
144    
145                  system "exportfs -rva";                  };
146    
147          }          }
148    
149            my $export = "$nfsroot/$ip";
150            my $br     = "$nfsroot/br/$ip";
151    
152            my $m = $mounted->{$ip} ||= `mount | grep $export`;
153            if ( ! $m ) {
154                    warn "mounting $export";
155    
156                    mkdir "$nfsroot/br"     unless -e "$nfsroot/br";
157                    mkdir $br                       unless -e $br;
158                    mkdir $export           unless -e $export;
159    
160                    system "sudo mount -t aufs -o br:$br:$debootstrap none $export";
161                    system "sudo exportfs -i -o rw,async,no_root_squash,no_subtree_check,fsid=999 $ip:$export";
162            
163                    my $hostname = client::conf( $ip => 'hostname' ) || 'nfsroot';
164                    write_file "$export/etc/hostname", $hostname;
165                    file::append "$export/hosts", '127.0.0.1';
166            }
167    
168    
169          pxelinux::config_for_ip( $ip, qq{          pxelinux::config_for_ip( $ip, qq{
170    
171  default nfsroot  default nfsroot
172  label nfsroot  label nfsroot
173          kernel vmlinuz          kernel debootstrap/vmlinuz
174          append initrd=initrd.img root=/dev/nfs nfsroot=$server::ip:$nfsroot ro ip=dhcp          append initrd=debootstrap/initrd.img root=/dev/nfs nfsroot=$server::ip:$export ro ip=dhcp
175    
176          });          });
177  }  }

Legend:
Removed from v.270  
changed lines
  Added in v.271

  ViewVC Help
Powered by ViewVC 1.1.26