/[pxelator]/lib/PXElator/httpd.pm
This is repository of my old source code which isn't updated any more. Go to git.rot13.org for current projects!
ViewVC logotype

Diff of /lib/PXElator/httpd.pm

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 153 by dpavlin, Wed Aug 5 23:22:17 2009 UTC revision 159 by dpavlin, Thu Aug 6 15:40:42 2009 UTC
# Line 49  use html; Line 49  use html;
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) = @_;
# Line 102  sub static { Line 104  sub static {
104    
105  use boolean;  use boolean;
106    
 use screen;  
107  use kvm;  use kvm;
108    
109  $SIG{CHLD} = 'IGNORE';  $SIG{CHLD} = 'IGNORE';
# Line 130  sub start_stop { Line 131  sub start_stop {
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 $!";
# Line 155  sub get_request { Line 162  sub get_request {
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                  );                  );
# Line 226  sub get_request { Line 229  sub get_request {
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>|
# Line 245  sub get_request { Line 248  sub get_request {
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();
# Line 288  sub start { Line 291  sub start {
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) {

Legend:
Removed from v.153  
changed lines
  Added in v.159

  ViewVC Help
Powered by ViewVC 1.1.26