56 |
use wireshark; |
use wireshark; |
57 |
use syslogd; |
use syslogd; |
58 |
use nmap; |
use nmap; |
59 |
|
use ping; |
60 |
|
use wol; |
61 |
|
|
62 |
use CouchDB; |
use CouchDB; |
63 |
|
|
241 |
if ( $ip && $ip ne $server::ip ) { |
if ( $ip && $ip ne $server::ip ) { |
242 |
my $hostname = client::conf( $ip, 'hostname' => $param->{hostname} ); |
my $hostname = client::conf( $ip, 'hostname' => $param->{hostname} ); |
243 |
|
|
244 |
|
my $nmap = qq|<a href=/nmap?scan=$ip>nmap</a>|; |
245 |
|
|
246 |
my @table = ( |
my @table = ( |
247 |
'ip' => qq|<input type=text name=change_ip value="$ip" onChange="document.getElementById('old_ip').style.display = '';"><span id=old_ip style="display: none; color: #888;">old: $ip<span>|, |
'ip' => qq|<input type=text name=change_ip value="$ip" onChange="document.getElementById('old_ip').style.display = '';"><span id=old_ip style="display: none; color: #888;">old: $ip<span>|, |
248 |
'hostname' => qq|<input type=text name=hostname value="$hostname">|, |
'hostname' => qq|<input type=text name=hostname value="$hostname">|, |
249 |
|
'ping' => ping::host($ip) ? qq|<span style="color:green">up</span> $nmap| : qq|<a href=/wol/$ip title=wol>down</a> $nmap|, |
250 |
); |
); |
251 |
|
|
252 |
my $deploy; |
my $config; |
253 |
|
|
254 |
if ( my $mac = client::mac_from_ip( $ip ) ) { |
if ( my $mac = client::mac_from_ip( $ip ) ) { |
255 |
$deploy = client::conf( $ip, 'deploy' => $param->{deploy} ); |
my $deploy = client::conf( $ip, 'deploy' => $param->{deploy} ); |
256 |
push @table, ( |
push @table, ( |
257 |
'mac' => format::mac( $mac => 'html' ), |
'mac' => format::mac( $mac => 'html' ), |
258 |
'deploy' => html::select( 'deploy', $deploy, config::available ) |
'deploy' => html::select( 'deploy', $deploy, config::available ) |
259 |
); |
); |
260 |
if ( my $pxelinux = config::for_ip( $ip ) ) { |
if ( $config = config::for_ip( $ip ) ) { |
261 |
$deploy = qq|<h2>PXElinux</h2>| . html::pre( $pxelinux ); |
$config = qq|<h2>config</h2>| . html::pre( $config ); |
262 |
} |
} |
263 |
} |
} |
264 |
|
|
269 |
<input type=submit name=action value=change> |
<input type=submit name=action value=change> |
270 |
<input type=submit name=action value=remove style="color: red"> |
<input type=submit name=action value=remove style="color: red"> |
271 |
</form>| |
</form>| |
272 |
, $deploy |
, $config |
273 |
; |
; |
274 |
|
|
275 |
if ( my $amt = client::conf( $ip, 'amt' ) ) { |
if ( my $amt = client::conf( $ip, 'amt' ) ) { |
290 |
|
|
291 |
print $client ok |
print $client ok |
292 |
, qq|<h2>Clients on $server::ip</h2>| |
, qq|<h2>Clients on $server::ip</h2>| |
293 |
, html::table( -6, |
, html::table( -5, |
294 |
'ip', 'mac', 'dev', 'hostname', 'deploy', 'conf', |
'ip', 'mac', 'dev', 'hostname', 'conf', |
295 |
map { |
map { |
296 |
my $ip = $_; |
my $ip = $_; |
297 |
my $conf = client::all_conf( $ip ); |
my $conf = client::all_conf( $ip ); |
308 |
, format::mac( $mac => 'html' ) |
, format::mac( $mac => 'html' ) |
309 |
, $arp->{$mac} |
, $arp->{$mac} |
310 |
, delete $conf->{hostname} |
, delete $conf->{hostname} |
311 |
, delete $conf->{deploy} |
, join("\n", map { |
312 |
, ( %$conf ? html::pre_dump( $conf ) : qq|<a href=/nmap?scan=$ip>nmap</a>| ) |
my $name = $_; |
313 |
|
my $html = $conf->{$name}; |
314 |
|
if ( $name eq 'amt' ) { |
315 |
|
$html = qq|<a title="$html" href=http://$ip:16992/logon.htm>logon</a>|; |
316 |
|
} |
317 |
|
$html = qq|<pre style="display: inline">$html</pre>| |
318 |
|
unless |
319 |
|
#0 && |
320 |
|
$html =~ s{\b(\S+)\t(\S+)\t(\S+)\b}{<b title="$1/$2">$3</b> }gs; |
321 |
|
qq|<em>$name</em> $html<br>| |
322 |
|
} keys %$conf ) |
323 |
); |
); |
324 |
} client::all_ips |
} client::all_ips |
325 |
) |
) |
359 |
</form> |
</form> |
360 |
|; |
|; |
361 |
} |
} |
362 |
|
} elsif ( $path =~ m{^/wol/(\S+)} ) { |
363 |
|
print $client redirect( "$url/client/$1" ), wol::power_on($1); |
364 |
} elsif ( $path =~ m{^/our/(\w+)/(\S+)} ) { |
} elsif ( $path =~ m{^/our/(\w+)/(\S+)} ) { |
365 |
eval 'our $' . $1 . ' = ' . $2; |
eval 'our $' . $1 . ' = ' . $2; |
366 |
warn $@ if $@; |
warn $@ if $@; |