use pxelinux;
use File::Slurp;
+sub available { qw/debian_live webconverger debirf tinycore/ };
+
sub debian_live {
$dhcpd::file = "pxelinux.0";
$pxelinux::path_prefix = 'live-helper/tftpboot/';
=cut
sub webconverger {
- my ($ip,$append) = @_;
+ my ($ip) = @_;
upstream::iso( 'http://download.webconverger.com/webc-5.2.iso' );
- $append ||= 'homepage=http://' . $server::ip . ':7777';
+ my $homepage = server::shared( "$ip/homepage" ) || "http://${server::ip}:7777/client";
+ my $hostname = server::shared( "$ip/hostname" ) || 'webconverger';
pxelinux::config_for_ip( $ip, qq{
default webconverger
label webconverger
kernel iso/live/vmlinuz-2.6.30-backports.1-486
- append initrd=iso/live/initrd.img-2.6.30-backports.1-486 fetch=http://172.16.10.1:7777/webconverger/iso/live/filesystem.squashfs boot=live quiet nosudo splash video=vesa:ywrap,mtrr vga=788 nopersistent username=webc hostname=webconverger union=aufs $append
+ append initrd=iso/live/initrd.img-2.6.30-backports.1-486 fetch=http://172.16.10.1: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
});
return $ip;
}
- mkdir $_ foreach grep { ! -e $_ } map { "$conf/$_" } ( 'ip', 'mac' );
-
my $p = Net::Ping->new;
my $prefix = $server::ip;
qq|<tt>| . join(' ', @_) . qq|</tt>|;
}
+sub select {
+ my $name = shift;
+ my $checked_option = shift;
+ return join("\n"
+ , qq|<select type=select name=$name>|
+ , join("\n", map { my $checked = $_ eq $checked_option ? 'checked' : ''; qq|<option name=$_ $checked>$_</option>| } @_ )
+ , qq|</select>|
+ , qq|</form>|
+ );
+}
+
warn "loaded";
1;
<div style="font-size: 80%; color: #888">
<a href=/>home</a>
<a href=/server>server</a>
+<a href=/client>client</a>
</div>
}}
use html;
our $static_pids;
use progress_bar;
+use config;
sub static {
my ($client,$path) = @_;
, menu()
, html::table( 2, map { ( $_, eval '$server::'.$_ ) } ( 'ip', 'netmask', 'ip_from', 'ip_to', 'domain_name', 'base_dir' ) )
;
+ } elsif ( $path =~ m{^/client} ) {
+ my $ip = $client->peerhost;
+ my $hostname = server::shared( "hostname/$ip", $param->{hostname} );
+ my $deploy = server::shared( "deploy/$ip", $param->{deploy} );
+ print $client $ok
+ , menu()
+ , qq|<form method=get>|
+ , html::table( 2,
+ 'ip' => $ip,
+ 'hostname' => qq|<input type=text name=hostname value=$hostname>|,
+ 'deploy' => html::select( 'deploy', $deploy, config::available ),
+ )
+ , qq|<input type=submit value=change></form><pre>|
+ , config::for_ip( $ip )
+ , qq|</pre>|
+ ;
} elsif ( $path =~ m{^/our/(\w+)/(\S+)} ) {
eval 'our $' . $1 . ' = ' . $2;
warn $@ if $@;
warn "# config: $path ", -s $path;
-
+ return $config;
}
1;
use Module::Refresh qw//;
sub refresh { Module::Refresh->refresh };
+mkdir $_ foreach grep { ! -e $_ } map { "$base_dir/conf/$server::ip/$_" } ( 'ip', 'mac', 'hostname', 'deploy' );
+
use File::Slurp;
sub shared {
my ($name, $value) = @_;
my $path ="$base_dir/conf/$server::ip/$name";
if ( defined $value ) {
write_file $path, $value;
+ warn "update $path = $value";
} else {
$value = read_file $path if -e $path;
}
use strict;
use autodie;
-use Test::More tests => 2;
+use Test::More tests => 3;
use_ok 'html';
ok( my $html = html::table( 2, qw/a1 a2 b1 b2 c1 c2/ ), 'table' );
diag $html;
+ok( $html = html::select( 'dropdown', 2, 1, 2, 3 ), 'select' );
+diag $html;