14 |
|
|
15 |
our $mounted; |
our $mounted; |
16 |
|
|
17 |
|
our $server; |
18 |
|
our $server_ip; |
19 |
|
|
20 |
sub available { qw/katalog debian_live webconverger debirf tinycore nfsroot openvz printer wrt/ }; |
sub available { qw/katalog debian_live webconverger debirf tinycore nfsroot openvz printer wrt/ }; |
21 |
|
|
22 |
sub debian_live { |
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 noprompt |
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 |
} |
} |
59 |
my $hostname = client::conf( $ip => 'hostname' ) || 'webconverger'; |
my $hostname = client::conf( $ip => 'hostname' ) || 'webconverger'; |
60 |
|
|
61 |
my $homepage = client::conf( $ip => 'webconverger/homepage' |
my $homepage = client::conf( $ip => 'webconverger/homepage' |
62 |
, default => "http://${server::ip}:7777/client" ); |
, default => "http://$server_ip:7777/client" ); |
63 |
my $fetch = client::conf( $ip => 'webconverger/fetch' |
my $fetch = client::conf( $ip => 'webconverger/fetch' |
64 |
, default => "http://${server::ip}:7777/webconverger/iso/live/filesystem.squashfs" ); |
, 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 |
|
|
79 |
$mounted->{"webconverger/$ip"} ||= upstream::iso( 'http://download.webconverger.com/webc-5.5.iso' ); |
$mounted->{"webconverger/$ip"} ||= upstream::iso( 'http://download.webconverger.com/webc-5.5.iso' ); |
80 |
my $hostname = client::conf( $ip => 'hostname' ) || 'katalog'; |
my $hostname = client::conf( $ip => 'hostname' ) || 'katalog'; |
81 |
my $homepage = client::conf( $ip => 'webconverger/homepage' => "http://koha.ffzg.hr" ); |
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" ); |
my $fetch = client::conf( $ip => 'webconverger/fetch' => "http://$server_ip:7777/webconverger/custom.squashfs" ); |
83 |
|
|
84 |
pxelinux::config_for_ip( $ip, qq{ |
pxelinux::config_for_ip( $ip, qq{ |
85 |
|
|
136 |
sub nfsroot { |
sub nfsroot { |
137 |
my $ip = shift || die "no ip?"; |
my $ip = shift || die "no ip?"; |
138 |
|
|
139 |
|
my $dist = 'lenny'; |
140 |
|
$dist = 'squeeze'; |
141 |
|
|
142 |
my $nfsroot = "$server::base_dir/tftp/nfsroot"; |
my $nfsroot = "$server::base_dir/tftp/nfsroot"; |
143 |
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' ); |
144 |
|
|
151 |
|
|
152 |
if ( ! -e $debootstrap ) { |
if ( ! -e $debootstrap ) { |
153 |
|
|
154 |
system "sudo debootstrap --arch i386 lenny $debootstrap $debian_mirror"; |
system "sudo debootstrap --arch i386 $dist $debootstrap $debian_mirror"; |
155 |
|
|
156 |
file::append "$debootstrap/etc/apt/sources.list.d/non-free.list", "deb $debian_mirror lenny non-free\n"; |
file::append "$debootstrap/etc/apt/sources.list.d/non-free.list", "deb $debian_mirror $dist non-free\n"; |
157 |
in_chroot $debootstrap => 'apt-get update'; |
in_chroot $debootstrap => 'apt-get update'; |
158 |
|
|
159 |
file::append "$debootstrap/etc/kernel-img.conf", "do_initrd = Yes\n"; |
file::append "$debootstrap/etc/kernel-img.conf", "do_initrd = Yes\n"; |
160 |
in_chroot $debootstrap => 'apt-get install -y --force-yes atl2-modules-2.6-686 firmware-bnx2'; |
in_chroot $debootstrap => 'apt-get -f install -y --force-yes locales linux-image-2.6-686 firmware-bnx2'; |
|
in_chroot $debootstrap => 'apt-get -f install -y --force-yes locales'; # linux-image-2.6-686 |
|
161 |
|
|
162 |
|
# this can fails on some distros, so we run it alone |
163 |
|
in_chroot $debootstrap => 'apt-get install -y --force-yes atl2-modules-2.6-686'; |
164 |
file::append "$debootstrap/etc/initramfs-tools/modules", "atl2\n"; |
file::append "$debootstrap/etc/initramfs-tools/modules", "atl2\n"; |
165 |
file::change("$debootstrap/etc/initramfs-tools/initramfs.conf", 'BOOT=local' => 'BOOT=nfs' ) && |
|
166 |
|
file::change "$debootstrap/etc/initramfs-tools/initramfs.conf", 'BOOT=local' => 'BOOT=nfs'; |
167 |
in_chroot $debootstrap => 'update-initramfs -u'; |
in_chroot $debootstrap => 'update-initramfs -u'; |
168 |
|
|
169 |
} |
} |
185 |
|
|
186 |
} |
} |
187 |
|
|
|
my $server = server::as_hash_for $ip; |
|
188 |
|
|
189 |
my $hostname = client::conf( $ip => 'hostname' ) || 'nfsroot'; |
my $hostname = client::conf( $ip => 'hostname' ) || 'nfsroot'; |
190 |
file::replace "$export/etc/hostname", $hostname; |
file::replace "$export/etc/hostname", $hostname; |
207 |
file::append "$export/etc/rc.local", $_; |
file::append "$export/etc/rc.local", $_; |
208 |
} ( '/srv/sysadmin-cookbook/recepies/amt/serial-console.sh' ); |
} ( '/srv/sysadmin-cookbook/recepies/amt/serial-console.sh' ); |
209 |
|
|
210 |
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 |
|
211 |
|
|
|
}); |
|
212 |
} |
} |
213 |
|
|
214 |
sub openvz { |
sub openvz { |
220 |
|
|
221 |
sub for_ip { |
sub for_ip { |
222 |
my $ip = shift || return; |
my $ip = shift || return; |
223 |
|
$server = server::as_hash_for $ip; |
224 |
|
$server_ip = $server->{ip} || die "no server ip"; |
225 |
my $config = client::conf( $ip => 'config' ) || return; |
my $config = client::conf( $ip => 'config' ) || return; |
226 |
eval $config . '($ip)'; |
eval $config . '($ip)'; # must be last |
|
# $tftp::dir = "$server::base_dir/tftp/$pxelinux::path_prefix"; |
|
227 |
} |
} |
228 |
|
|
229 |
warn 'loaded'; |
warn 'loaded'; |