|,
+ 'hostname' => qq||,
+ );
+
+ my $deploy;
+
+ if ( my $mac = client::mac( $ip ) ) {
+ $deploy = client::conf( $ip, 'deploy' => $param->{deploy} );
+ push @table, (
+ 'mac' => $mac,
+ 'deploy' => html::select( 'deploy', $deploy, config::available )
+ );
+ $deploy = qq|PXElinux
| . html::pre( config::for_ip( $ip ) );
+ }
+
+ print $client ok
, qq||
- , qq|PXElinux $deploy
|
- , config::for_ip( $ip )
- , qq|
|
+ , $deploy
;
+
+ if ( my $amt = client::conf( $ip, 'amt' ) ) {
+ print $client qq|AMT
|, amt::info( $amt );
+ }
} else {
- print $client $ok
+
+ my $arp = {
+ map {
+ my @c = split(/\s+/,$_);
+ if ( $#c == 5 ) {
+ ( uc $c[3] => [ $c[0] , $c[5] ] )
+ } else {
+ }
+ } read_file('/proc/net/arp')
+ };
+
+ warn "# arp ",dump( $arp );
+
+ print $client ok
, qq|Clients on $server::ip
|
- , qq||
- , join("\n",
+ , html::table( -5,
+ 'ip', 'hostname', 'mac', 'deploy', 'arp',
map {
my $ip = $_;
$ip =~ s{^.+/ip/}{};
- qq|- $ip |, client::mac($ip), ' ', client::conf( $ip, 'hostname' ), qq|
|;
+ my $arp = $arp->{ client::mac $ip, 'clean' };
+ $arp = $arp ? $arp->[1] : '';
+ $arp =~ s{$ip}{};
+ (
+ qq|$ip|
+ , client::conf( $ip, 'hostname' )
+ , client::mac( $ip )
+ , html::tt( client::conf( $ip, 'deploy' ) )
+ , $arp
+ );
}
glob("$server::conf/ip/*")
)
- , qq|
|
+ , qq|ARP
|
+ , html::table( -3, 'mac', 'dev', 'ip',
+ map {
+ my $c = $arp->{$_};
+ ( html::tt( $_ ), $c->[1], $c->[0] )
+ } sort keys %$arp
+ )
;
}
} elsif ( $path =~ m{^/our/(\w+)/(\S+)} ) {
eval 'our $' . $1 . ' = ' . $2;
warn $@ if $@;
- print $client $redirect, qq|$1 = $2
Location: $url|;
+ print $client redirect($url), qq|$1 = $2
Location: $url|;
server::debug( $debug ) if $1 eq 'debug';
} elsif ( $path =~ m{^/start_stop/(\S+)} ) {
- print $client $redirect, start_stop($1);
+ print $client redirect, daemons::start_stop($1);
} elsif ( $path =~ m{^/action/([^/]+)/(.+)} ) {
$1->$2();
- print $client $redirect;
+ print $client redirect;
} elsif ( $path =~ m{^/kill/static/(\d+)} ) {
- print $client $redirect;
+ print $client redirect;
kill 1, $1 || kill 9, $2 && warn "killed $1";
} else {
print $client "HTTP/1.0 404 $path\r\nConnection: close\r\nContent-type: text/html\r\n\r\n404 $path";
@@ -280,15 +288,17 @@
}
-use browser;
-use network;
-
sub start {
warn 'tap ', network::tap();
+ daemons::start_stop 'browser', $url;
+ daemons::start_stop $_ foreach ( qw/dhcpd tftpd dnsd/ );
+ daemons::start_stop 'kvm' unless $ENV{DEV}; # skip kvm statup when running on real device
+
my $server = IO::Socket::INET->new(
Proto => 'tcp',
+ LocalAddr => $server::ip,
LocalPort => $httpd::port,
Listen => SOMAXCONN,
Reuse => 1
@@ -296,12 +306,6 @@
print "url $url\n";
- start_stop 'browser', $url;
- start_stop 'dhcpd';
- start_stop 'tftpd';
- start_stop 'dnsd';
- start_stop 'kvm';
-
while (1) {
my $client = $server->accept() || next; # ALARM trickle us
my $request = <$client>;