49 |
our $static_pids; |
our $static_pids; |
50 |
use progress_bar; |
use progress_bar; |
51 |
use config; |
use config; |
52 |
|
use client; |
53 |
|
use log; |
54 |
|
|
55 |
sub static { |
sub static { |
56 |
my ($client,$path) = @_; |
my ($client,$path) = @_; |
104 |
|
|
105 |
use boolean; |
use boolean; |
106 |
|
|
|
use screen; |
|
107 |
use kvm; |
use kvm; |
108 |
|
|
109 |
$SIG{CHLD} = 'IGNORE'; |
$SIG{CHLD} = 'IGNORE'; |
131 |
# child |
# child |
132 |
my $invoke = 'start'; |
my $invoke = 'start'; |
133 |
$invoke = $1 if $daemon =~ s{/(.+)}{}; |
$invoke = $1 if $daemon =~ s{/(.+)}{}; |
134 |
my $eval = $daemon . '::' . $invoke . '(' . ( @_ ? dump(@_) : '' ) . ')'; |
if ( $daemon =~ m{dhcpd|tftpd|dnsd} ) { |
135 |
warn "eval $eval"; |
my $exec = "perl -I$server::base_dir/lib -I$server::base_dir/lib/PXElator -M$daemon -e ${daemon}::${invoke}"; |
136 |
eval $eval; |
warn "exec $exec"; |
137 |
warn "can't start $daemon: $@" if $@; |
exec "xterm -T $daemon -n $daemon -e $exec"; |
138 |
|
} else { |
139 |
|
my $eval = $daemon . '::' . $invoke . '(' . ( @_ ? dump(@_) : '' ) . ')'; |
140 |
|
warn "eval $eval"; |
141 |
|
eval $eval; |
142 |
|
warn "can't start $daemon: $@" if $@; |
143 |
|
} |
144 |
exit; |
exit; |
145 |
} else { |
} else { |
146 |
die "fork error $!"; |
die "fork error $!"; |
162 |
warn "static $found" if $debug; |
warn "static $found" if $debug; |
163 |
} elsif ( $path eq '/' ) { |
} elsif ( $path eq '/' ) { |
164 |
|
|
|
my $screen = $pids->{screen} ? qq|stop <tt>$pids->{screen}</tt>| : 'start'; |
|
|
my $kvm = $pids->{kvm} ? qq|stop <tt>$pids->{kvm}</tt>| : |
|
|
$pids->{screen} ? qq|start| : qq|start screen first|; |
|
|
|
|
165 |
my @rows = ( |
my @rows = ( |
166 |
'debug', qq|<a href=/our/debug/| . boolean::toggle($debug) . qq|>$debug</a>|, |
'debug', qq|<a href=/our/debug/| . boolean::toggle($debug) . qq|>$debug</a>|, |
167 |
); |
); |
229 |
; |
; |
230 |
} elsif ( $path =~ m{^/client} ) { |
} elsif ( $path =~ m{^/client} ) { |
231 |
my $ip = $client->peerhost; |
my $ip = $client->peerhost; |
232 |
my $hostname = server::shared( "hostname/$ip", $param->{hostname} ); |
my $hostname = client::conf( $ip, 'hostname' => $param->{hostname} ); |
233 |
my $deploy = server::shared( "deploy/$ip", $param->{deploy} ); |
my $deploy = client::conf( $ip, 'deploy' => $param->{deploy} ); |
234 |
print $client $ok |
print $client $ok |
235 |
, menu() |
, menu() |
236 |
, qq|<form method=get>| |
, qq|<form method=get>| |
248 |
warn $@ if $@; |
warn $@ if $@; |
249 |
print $client $redirect, qq|<big>$1 = $2</big><br>Location: <a href="$url">$url</a>|; |
print $client $redirect, qq|<big>$1 = $2</big><br>Location: <a href="$url">$url</a>|; |
250 |
server::debug( $debug ) if $1 eq 'debug'; |
server::debug( $debug ) if $1 eq 'debug'; |
251 |
} elsif ( $path =~ m{^/start_stop/((?:screen|kvm).*)} ) { # XXX we don't want to stop all classes |
} elsif ( $path =~ m{^/start_stop/(\S+)} ) { |
252 |
print $client $redirect, start_stop($1); |
print $client $redirect, start_stop($1); |
253 |
} elsif ( $path =~ m{^/action/([^/]+)/(.+)} ) { |
} elsif ( $path =~ m{^/action/([^/]+)/(.+)} ) { |
254 |
$1->$2(); |
$1->$2(); |
291 |
print "url $url\n"; |
print "url $url\n"; |
292 |
|
|
293 |
start_stop 'browser', $url; |
start_stop 'browser', $url; |
294 |
start_stop 'screen'; |
start_stop 'dhcpd'; |
295 |
|
start_stop 'tftpd'; |
296 |
|
start_stop 'dnsd'; |
297 |
start_stop 'kvm'; |
start_stop 'kvm'; |
298 |
|
|
299 |
while (1) { |
while (1) { |