53 |
use client; |
use client; |
54 |
use log; |
use log; |
55 |
use x11; |
use x11; |
56 |
|
use amt; |
57 |
|
|
58 |
sub static { |
sub static { |
59 |
my ($client,$path) = @_; |
my ($client,$path) = @_; |
113 |
|
|
114 |
sub start_stop { |
sub start_stop { |
115 |
my $daemon = shift; |
my $daemon = shift; |
|
my $pid = $pids->{$daemon} || 'not started'; |
|
116 |
|
|
117 |
|
my $pid = $pids->{$daemon}; |
118 |
|
my $pid_path = "$server::conf/$daemon.pid"; |
119 |
|
|
120 |
|
if ( ! $pid && -e $pid_path ) { |
121 |
|
my $p = read_file $pid_path; |
122 |
|
if ( kill 0, $p ) { |
123 |
|
warn "adopted $daemon $p\n"; |
124 |
|
return $pids->{$daemon} = $p; |
125 |
|
} else { |
126 |
|
warn "old $daemon $p not running"; |
127 |
|
unlink $pid_path; |
128 |
|
} |
129 |
|
} |
130 |
|
|
131 |
|
$pid ||= 'not started'; |
132 |
warn "start_stop $daemon $pid\n"; |
warn "start_stop $daemon $pid\n"; |
133 |
|
|
134 |
if ( $pid =~ m{^\d+$} ) { |
if ( $pid =~ m{^\d+$} ) { |
142 |
if ( $pid = fork ) { |
if ( $pid = fork ) { |
143 |
# parent |
# parent |
144 |
$pids->{$daemon} = $pid; |
$pids->{$daemon} = $pid; |
145 |
|
write_file $pid_path, $pid; |
146 |
warn "forked $daemon $pid\n"; |
warn "forked $daemon $pid\n"; |
147 |
return qq|$daemon pid $pid started|; |
return qq|$daemon pid $pid started|; |
148 |
} elsif ( defined $pid ) { |
} elsif ( defined $pid ) { |
264 |
, config::for_ip( $ip ) |
, config::for_ip( $ip ) |
265 |
, qq|</pre>| |
, qq|</pre>| |
266 |
; |
; |
267 |
|
|
268 |
|
if ( my $amt = client::conf( $ip, 'amt' ) ) { |
269 |
|
print $client amt::info( $amt ); |
270 |
|
} |
271 |
} else { |
} else { |
272 |
print $client $ok |
print $client $ok |
273 |
, qq|<h2>Clients on $server::ip</h2>| |
, qq|<h2>Clients on $server::ip</h2>| |
322 |
start_stop 'dhcpd'; |
start_stop 'dhcpd'; |
323 |
start_stop 'tftpd'; |
start_stop 'tftpd'; |
324 |
start_stop 'dnsd'; |
start_stop 'dnsd'; |
325 |
start_stop 'kvm'; |
start_stop 'kvm' unless $ENV{DEV}; # skip kvm statup when running on real device |
326 |
|
|
327 |
while (1) { |
while (1) { |
328 |
my $client = $server->accept() || next; # ALARM trickle us |
my $client = $server->accept() || next; # ALARM trickle us |