20 sub available { qw/katalog debian_live webconverger debirf tinycore nfsroot openvz printer wrt clonezilla ubuntu memdisk vyatta/ };
26 http://cdimage.debian.org/cdimage/release/current-live/i386/web/
29 debian-live-501-i386-standard.squashfs
32 my $hostname = client::conf( $ip => 'hostname' ) || 'debian-live';
34 pxelinux::config_for_ip( $ip, qq{
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 noprompt
48 Webconverger - the opensource Web Kiosk
50 L<http://webconverger.org/>
57 $mounted->{"webconverger/$ip"} ||= upstream::iso( 'http://download.webconverger.com/webc-5.5.iso' );
59 my $hostname = client::conf( $ip => 'hostname' ) || 'webconverger';
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" );
66 pxelinux::config_for_ip( $ip, qq{
70 kernel iso/live/vmlinuz-2.6.30-backports.1-486
71 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
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" );
84 pxelinux::config_for_ip( $ip, qq{
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
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.
98 L<http://cmrg.fifthhorseman.net/wiki/debirf>
105 upstream::iso( 'http://cmrg.mayfirst.org/debirf/debirf-rescue_lenny_2.6.26-1-686.iso' );
107 pxelinux::config_for_ip( $ip, qq{
111 kernel iso/vmlinuz-2.6.26-1-686
112 append initrd=iso//debirf-rescue_lenny_2.6.26-1-686.cgz
119 upstream::iso( 'http://distro.ibiblio.org/pub/linux/distributions/tinycorelinux/2.x/release/tinycore_2.2.iso' );
120 pxelinux::config_for_ip( $ip, qq{
124 kernel iso/boot/bzImage
125 append initrd=iso/boot/tinycore.gz
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{
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
145 upstream::iso( 'http://mirrors.us.kernel.org/ubuntu-releases/lucid/ubuntu-10.04-desktop-i386.iso' );
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";
153 pxelinux::config_for_ip( $ip, qq{
157 kernel iso/casper/vmlinuz
158 append initrd=iso/casper/initrd.lz boot=casper netboot=nfs nfsroot=$server_ip:$export --
166 my $dir = "$server::base_dir/tftp/memdisk";
167 mkdir $dir unless -e $dir;
169 symlink '/usr/lib/syslinux/memdisk', "$dir/memdisk" unless -e "$dir/memdisk";
171 my $image = client::conf( $ip => 'memdisk.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 warn "using $image [default FreeDOS]\n";
177 symlink "$dir/$image", client::ip_path $ip . '/memdisk.image';
179 $image =~ s{^.+/tftp/memdisk/}{} && warn "using $image\n";
182 if ( my $kvm = client::conf $ip => 'kvm' ) {
183 client::conf $ip => 'kvm.bin', 'qemu-system-i386'; # FIXME kvm doesn't seem to work
186 pxelinux::config_for_ip( $ip, qq{
198 upstream::iso( 'http://www.vyatta.com/downloads/vc6.0/vyatta-livecd-virt_VC6.0-2010.06.01_i386.iso' );
200 my $dir = "$server::base_dir/tftp/vyatta";
201 symlink '/usr/lib/syslinux/memdisk', "$dir/memdisk" unless -e "$dir/memdisk";
203 pxelinux::config_for_ip( $ip, qq{
208 kernel iso/live/vmlinuz1
209 append initrd=iso/live/initrd1.img boot=live nopersistent noautologin nonetworking nouser hostname=vyatta fetch=http://$server_ip:7777/vyatta/iso/live/filesystem.squashfs
215 my ( $dir, $command ) = @_;
216 write_file "$dir/tmp/inside.sh", $command;
217 system "sudo chroot $dir sh -x /tmp/inside.sh";
221 my $ip = shift || die "no ip?";
226 my $nfsroot = "$server::base_dir/tftp/nfsroot";
227 my $debian_mirror = server::conf_default( 'debian_mirror', 'http://ftp.debian.org/debian' );
229 if ( ! -e $nfsroot ) {
230 system "sudo apt-get install nfs-kernel-server debootstrap aufs-modules-`uname -r` aufs-tools";
234 my $debootstrap = "$nfsroot/debootstrap";
236 if ( ! -e $debootstrap ) {
238 system "sudo debootstrap --arch i386 $dist $debootstrap $debian_mirror";
240 file::append "$debootstrap/etc/apt/sources.list.d/non-free.list", "deb $debian_mirror $dist non-free\n";
241 in_chroot $debootstrap => 'apt-get update';
243 file::append "$debootstrap/etc/kernel-img.conf", "do_initrd = Yes\n";
244 in_chroot $debootstrap => 'apt-get -f install -y --force-yes locales linux-image-2.6-686 firmware-bnx2';
246 # this can fails on some distros, so we run it alone
247 in_chroot $debootstrap => 'apt-get install -y --force-yes atl2-modules-2.6-686';
248 file::append "$debootstrap/etc/initramfs-tools/modules", "atl2\n";
250 file::change "$debootstrap/etc/initramfs-tools/initramfs.conf", 'BOOT=local' => 'BOOT=nfs';
251 in_chroot $debootstrap => 'update-initramfs -u';
255 my $export = "$nfsroot/$ip";
256 my $br = "$nfsroot/br/$ip";
258 $mounted->{"nfsroot/$ip"} ||= `mount | grep $export`;
260 if ( ! $mounted->{"nfsroot/$ip"} ) {
261 warn "mounting $export";
263 mkdir "$nfsroot/br" unless -e "$nfsroot/br";
264 mkdir $br unless -e $br;
265 mkdir $export unless -e $export;
267 system "sudo mount -t aufs -o br:$br:$debootstrap none $export";
268 system "sudo exportfs -i -o rw,async,no_root_squash,no_subtree_check,fsid=999 $ip:$export";
272 my $exported = `exportfs | grep $export`;
273 if ( $exported ne $export ) {
274 warn "exportfs $exported\n";
275 system "sudo exportfs -i -o rw,async,no_root_squash,no_subtree_check,fsid=999 $ip:$export";
278 my $hostname = client::conf( $ip => 'hostname' ) || 'nfsroot';
279 file::replace "$export/etc/hostname", $hostname;
280 file::replace "$export/etc/hosts", "127.0.0.1\tlocalhost $hostname\n";
281 file::replace "$export/etc/resolv.conf", "domain $server->{domain}\nnameserver $server->{ip}\n";
282 file::replace "$export/etc/rsyslog.d/pxelator.conf", "*.*\t\@$server->{ip}\n";
284 file::append "$debootstrap/etc/network/interfaces", qq{
287 iface lo inet loopback
295 file::copy_once $_ => "$export/$_";
296 file::append "$export/etc/rc.local", $_;
297 } ( '/srv/sysadmin-cookbook/recepies/amt/serial-console.sh' );
299 pxelinux::config_ip_boot( $ip, "$export/boot", "root=/dev/nfs nfsroot=$server->{ip}:$export ro ip=dhcp" );
305 ssh::shell( $ip, 'cat /proc/vz/veinfo', 'vzlist -a', 'uptime', 'free', 'df', 'zfs list' );
311 my $ip = shift || return;
312 $server = server::as_hash_for $ip;
313 $server_ip = $server->{ip} || die "no server ip";
314 my $config = client::conf( $ip => 'config' ) || return;
315 eval $config . '($ip)'; # must be last