#!/usr/bin/perl # zaza-control # Startup and shutdown Zaza's applications and servers # # 0.24 9/20/2002 # Quick update for mod_perl support # # 0.23 7/19/2002 # Updated reaction startup in Test mode # # 0.22 6/19/2002 # Added explicit host-based access control. # # 0.21 5/9/2002 # Added obstacleServer startup to test mode. # # 0.20 1/25/2002 # Removed Phase I as an option. Added support for CGI::Request. Modified for top-level # control from zazaconsole. Sends CGI requests to zaza1 via LWP::Simple. # use CGI::Request; use LWP::Simple; use Apache::Constants ':common'; # Simple interface: (combines SendHeaders, new and import_names) #my $req = GetRequest($pkg); # Full Interface: my $req = new CGI::Request; # fetch and parse request # List of IPs we allow to use the control interface my @allowedips = ('10.1.5.71', '10.1.5.72', '10.1.5.73', '10.1.5.74', '64.81.244.139', '192.168.69.3', '127.0.0.1' ); my $clientip = $req->cgi->var("REMOTE_ADDR"); my $verified = 0; for $i (0 .. $#allowedips) { if ($allowedips[$i] eq $clientip) { $verified = 1; } } if (!$verified) { print "
Sorry, $clientip is not allowed to use the control interface.
\n"; exit; } if ($req->param('op_mode') eq "ShutDown") { # Send startup request to Zaza1, wait for reply. if (is_error(getprint("http://zaza1.exhibits.thetech.org/cgi-bin/zaza-control-simple?op_mode=ShutDown"))) { print "
";
      print "Error, could not reach zaza1!\n";
      print "
"; } } #if ($req->param('op_mode') eq "Phase1") { # # print "
";
#  # print "Starting Phase1 demo mode...\n";
#   # Send startup request to Zaza1
#   # Send startup request to Zaza1, wait for reply.
#    if (is_success(getprint("http://zaza1.exhibits.thetech.org/cgi-bin/zaza-control-simple?op_mode=Phase1"))) {
#      # Everything is kosher
#    }
#    else {
#      print "
";
#      print "Error, could not reach zaza1!\n";
#      print "
"; # } # # # print "
\n"; # #} if ($req->param('op_mode') eq "Phase2") { # Send startup request to Zaza1, wait for reply. if (is_error(getprint("http://zaza1.exhibits.thetech.org/cgi-bin/zaza-control-simple?op_mode=Phase2"))) { print "
";
      print "Error, could not reach zaza1!\n";
      print "
"; } } if ($req->param('op_mode') eq "Test") { if (is_error(getprint("http://zaza1.exhibits.thetech.org/cgi-bin/zaza-control-simple?op_mode=Test"))) { print "
";
     print "Error, could not reach zaza1!\n";
     print "
"; } else { print "
";
     print "Starting zazaconsole processes...\n";

     system("/home/brudy/posServer/speakit2.pl Starting localizer! >/dev/null 2>&1 &") == 0
         or print "speakit2.pl execution failed: $?";   

     # plan -nodisplay
     # SET_ROBOT -pos 2235 3885 153 -sim
     # LOCALIZE tech-ex.ini
     # poslibtcx -gmap /home/brudy/bee/data/localize/tech-ex/map-ex.map
     # obstacleServer /home/brudy/bee/data/localize/tech-ex/map-ex.planmap

     system("/home/brudy/posServer/reaction-up.pl 2>&1 &") == 0
         or print "reaction startup failed: $?";

     system("export TCXHOST=zaza1; cd /home/brudy/bee/bin; ./plan -nodisplay >/var/www/html/logs/plan.log 2>&1 &") == 0
         or print "plan startup failed: $?";

     system("export TCXHOST=zaza1; cd /home/brudy/bee/bin; ./SET_ROBOT -pos 2235 3885 153 -sim >/var/www/html/logs/SET_ROBOT.log 2>&1 &") == 0
         or print "SET_ROBOT startup failed: $?";
     sleep 1;
     system("export TCXHOST=zaza1; cd /home/brudy/bee/data/localize/tech-ex; /home/brudy/bee/bin/LOCALIZE tech-ex.ini >/var/www/html/logs/LOCALIZE.log 2>&1 &") == 0
         or print "LOCALIZE startup failed: $?";

     system("export TCXHOST=zaza1; cd /home/brudy/bee/bin; ./poslibtcx -gmap /home/brudy/bee/data/localize/tech-ex/map-ex.map >/var/www/html/logs/poslibtcx.log 2>&1 &") == 0
         or print "poslibtcx startup failed: $?";

     system("export TCXHOST=zaza1; cd /home/brudy/bee/bin; ./obstacleServer /home/brudy/bee/data/localize/tech-ex/map-ex.planmap >/var/www/html/logs/obstacleServer.log 2>&1 &") == 0
         or print "obstacleServer startup failed: $?";

     system("/home/brudy/posServer/speakit2.pl Startup Complete! >/dev/null 2>&1 &") == 0
         or print "speakit2.pl execution failed: $?";   

     print "
\n"; } } print<

Mode

eof