21 sub available { qw/katalog debian_live webconverger debirf tinycore nfsroot openvz printer wrt clonezilla ubuntu memdisk vyatta android/ };
26 my $from = 'http://cdimage.debian.org/cdimage/release/current-live/i386/web/';
27 $from = 'http://cdimage.debian.org/cdimage/squeeze_live_alpha2/i386/web/';
28 my $variant = 'standard';
30 my $dir = upstream::files $from => 'MD5SUMS';
32 my ( $vmlinuz, $initrd, $squashfs );
34 my @md5sum = read_file "$dir/MD5SUMS";
37 $vmlinuz = $1 if m/\s+(\S*vmlinuz\S*)/;
38 $initrd = $1 if m/\s+(\S*$variant\S*initrd\S*)/;
39 $squashfs = $1 if m/\s+(\S*$variant\S*\.squashfs)$/;
40 warn "# MD5SUM: $_\n";
43 upstream::files $from => $vmlinuz, $initrd, $squashfs;
45 my $hostname = client::conf( $ip => 'hostname' ) || 'debian-live';
47 # FIXME drop in shell because users doesn't work in current image
48 my $custom_init = 'init=/bin/hash';
50 if ( my $custom_squashfs = client::conf( $ip => 'squashfs' ) ) {
51 $squashfs = $custom_squashfs;
55 pxelinux::config_for_ip( $ip, qq{
60 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
67 Webconverger - the opensource Web Kiosk
69 L<http://webconverger.org/>
76 $mounted->{"webconverger/$ip"} ||= upstream::iso( 'http://download.webconverger.com/webc-5.5.iso' );
78 my $hostname = client::conf( $ip => 'hostname' ) || 'webconverger';
80 my $homepage = client::conf( $ip => 'webconverger/homepage'
81 , default => "http://$server_ip:7777/client" );
82 my $fetch = client::conf( $ip => 'webconverger/fetch'
83 , default => "http://$server_ip:7777/webconverger/iso/live/filesystem.squashfs" );
85 pxelinux::config_for_ip( $ip, qq{
89 kernel iso/live/vmlinuz-2.6.30-backports.1-486
90 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
98 $mounted->{"webconverger/$ip"} ||= upstream::iso( 'http://download.webconverger.com/webc-5.5.iso' );
99 my $hostname = client::conf( $ip => 'hostname' ) || 'katalog';
100 my $homepage = client::conf( $ip => 'webconverger/homepage' => "http://koha.ffzg.hr" );
101 my $fetch = client::conf( $ip => 'webconverger/fetch' => "http://$server_ip:7777/webconverger/custom.squashfs" );
103 pxelinux::config_for_ip( $ip, qq{
107 kernel iso/live/vmlinuz-2.6.30-backports.1-486
108 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
115 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.
117 L<http://cmrg.fifthhorseman.net/wiki/debirf>
124 upstream::iso( 'http://cmrg.mayfirst.org/debirf/debirf-rescue_lenny_2.6.26-1-686.iso' );
126 pxelinux::config_for_ip( $ip, qq{
130 kernel iso/vmlinuz-2.6.26-1-686
131 append initrd=iso//debirf-rescue_lenny_2.6.26-1-686.cgz
138 upstream::iso( 'http://distro.ibiblio.org/pub/linux/distributions/tinycorelinux/3.x/release/tinycore-current.iso' );
139 pxelinux::config_for_ip( $ip, qq{
143 kernel iso/boot/bzImage
144 append initrd=iso/boot/tinycore.gz
151 upstream::iso( 'http://sourceforge.net/projects/clonezilla/files/clonezilla_live_alternative_testing/clonezilla-live-20100503-lucid.iso/download' );
152 pxelinux::config_for_ip( $ip, qq{
156 kernel iso/live/vmlinuz
157 append initrd=iso/live/initrd.img boot=live union=aufs noswap noprompt vga=788 fetch=http://$server_ip:7777/clonezilla/iso/live/filesystem.squashfs
164 upstream::iso( 'http://mirrors.us.kernel.org/ubuntu-releases/lucid/ubuntu-10.04-desktop-i386.iso' );
166 my $export = "$server::base_dir/tftp/ubuntu/iso";
167 my $exported = `exportfs | grep $export`;
168 if ( $exported ne $export ) {
169 warn "exportfs $exported\n";
170 system "sudo exportfs -i -o rw,async,no_root_squash,no_subtree_check,fsid=999 $ip:$export";
172 pxelinux::config_for_ip( $ip, qq{
176 kernel iso/casper/vmlinuz
177 append initrd=iso/casper/initrd.lz boot=casper netboot=nfs nfsroot=$server_ip:$export --
185 my $dir = "$server::base_dir/tftp/memdisk";
186 mkdir $dir unless -e $dir;
188 symlink '/usr/lib/syslinux/memdisk', "$dir/memdisk" unless -e "$dir/memdisk";
190 my $image = client::conf( $ip => 'memdisk.image' );
193 $image = 'freedos.gz';
194 upstream::mirror_file 'http://www.ibiblio.org/pub/micro/pc-stuff/freedos/files/distributions/unofficial/balder/balder10.imz' => "$dir/$image";
195 warn "using $image [default FreeDOS]\n";
196 symlink "$dir/$image", client::ip_path $ip . '/memdisk.image';
198 $image =~ s{^.+/tftp/memdisk/}{} && warn "using $image\n";
201 if ( my $kvm = client::conf $ip => 'kvm' ) {
202 client::conf $ip => 'kvm.bin', 'qemu-system-i386'; # FIXME kvm doesn't seem to work
205 pxelinux::config_for_ip( $ip, qq{
217 upstream::iso( 'http://www.vyatta.com/downloads/vc6.1/vyatta-livecd_VC6.1-2010.08.20_i386.iso' );
219 my $dir = "$server::base_dir/tftp/vyatta";
220 symlink '/usr/lib/syslinux/memdisk', "$dir/memdisk" unless -e "$dir/memdisk";
222 pxelinux::config_for_ip( $ip, qq{
227 kernel iso/live/vmlinuz1
228 append initrd=iso/live/initrd1.img boot=live nopersistent noautologin nonetworking nouser hostname=vyatta fetch=http://$server_ip:7777/vyatta/iso/live/filesystem.squashfs
235 my $path = upstream::iso( 'http://android-x86.googlecode.com/files/android-x86-1.6-r2.iso' );
237 my $dir = "$server::base_dir/tftp/android";
238 symlink '/usr/lib/syslinux/memdisk', "$dir/memdisk" unless -e "$dir/memdisk";
240 client::conf $ip => 'kvm.boot' => "n -cdrom $path";
242 pxelinux::config_for_ip( $ip, qq{
244 default android-1.6-donut
245 label android-1.6-donut
248 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
254 my ( $dir, $command ) = @_;
255 write_file "$dir/tmp/inside.sh", $command;
256 system "sudo chroot $dir sh -x /tmp/inside.sh";
260 my $ip = shift || die "no ip?";
265 my $nfsroot = "$server::base_dir/tftp/nfsroot";
266 my $debian_mirror = server::conf_default( 'debian_mirror', 'http://ftp.debian.org/debian' );
268 if ( ! -e $nfsroot ) {
269 system "sudo apt-get install nfs-kernel-server debootstrap aufs-modules-`uname -r` aufs-tools";
273 my $debootstrap = "$nfsroot/debootstrap";
275 if ( ! -e $debootstrap ) {
277 system "sudo debootstrap --arch i386 $dist $debootstrap $debian_mirror";
279 file::append "$debootstrap/etc/apt/sources.list.d/non-free.list", "deb $debian_mirror $dist non-free\n";
280 in_chroot $debootstrap => 'apt-get update';
282 file::append "$debootstrap/etc/kernel-img.conf", "do_initrd = Yes\n";
283 in_chroot $debootstrap => 'apt-get -f install -y --force-yes locales linux-image-2.6-686 firmware-bnx2';
285 # this can fails on some distros, so we run it alone
286 in_chroot $debootstrap => 'apt-get install -y --force-yes atl2-modules-2.6-686';
287 file::append "$debootstrap/etc/initramfs-tools/modules", "atl2\n";
289 file::change "$debootstrap/etc/initramfs-tools/initramfs.conf", 'BOOT=local' => 'BOOT=nfs';
290 in_chroot $debootstrap => 'update-initramfs -u';
294 my $export = "$nfsroot/$ip";
295 my $br = "$nfsroot/br/$ip";
297 $mounted->{"nfsroot/$ip"} ||= `mount | grep $export`;
299 if ( ! $mounted->{"nfsroot/$ip"} ) {
300 warn "mounting $export";
302 mkdir "$nfsroot/br" unless -e "$nfsroot/br";
303 mkdir $br unless -e $br;
304 mkdir $export unless -e $export;
306 system "sudo mount -t aufs -o br:$br:$debootstrap none $export";
307 system "sudo exportfs -i -o rw,async,no_root_squash,no_subtree_check,fsid=999 $ip:$export";
311 my $exported = `exportfs | grep $export`;
312 if ( $exported ne $export ) {
313 warn "exportfs $exported\n";
314 system "sudo exportfs -i -o rw,async,no_root_squash,no_subtree_check,fsid=999 $ip:$export";
317 my $hostname = client::conf( $ip => 'hostname' ) || 'nfsroot';
318 file::replace "$export/etc/hostname", $hostname;
319 file::replace "$export/etc/hosts", "127.0.0.1\tlocalhost $hostname\n";
320 file::replace "$export/etc/resolv.conf", "domain $server->{domain}\nnameserver $server->{ip}\n";
321 file::replace "$export/etc/rsyslog.d/pxelator.conf", "*.*\t\@$server->{ip}\n";
323 file::append "$debootstrap/etc/network/interfaces", qq{
326 iface lo inet loopback
334 file::copy_once $_ => "$export/$_";
335 file::append "$export/etc/rc.local", $_;
336 } ( '/srv/sysadmin-cookbook/recepies/amt/serial-console.sh' );
338 pxelinux::config_ip_boot( $ip, "$export/boot", "root=/dev/nfs nfsroot=$server->{ip}:$export ro ip=dhcp" );
344 ssh::shell( $ip, 'cat /proc/vz/veinfo', 'vzlist -a', 'uptime', 'free', 'df', 'zfs list' );
350 my $ip = shift || return;
351 $server = server::as_hash_for $ip;
352 $server_ip = $server->{ip} || die "no server ip";
353 my $config = client::conf( $ip => 'config' ) || return;
354 my $ret = eval $config . '($ip)'; # must be last
356 warn "ERROR in executing $config($ip): $@\n";
357 $ret .= qq{<pre style="color:red">$@</pre>};