root/honeyclient/tags/exp/UP1-kindlund-simpler_agent/bin/StartManager.pl

Revision 1008, 2.7 kB (checked in by kindlund, 1 year ago)

Merging kindlund-dynamic_updates branch back into trunk.

  • Property svn:executable set to *
  • Property svn:keywords set to Id "$file"
Line 
1 #!perl -w -Ilib
2
3 # $Id$
4
5 use strict;
6 use warnings;
7 use Carp ();
8
9 # Include Dumper Library
10 use Data::Dumper;
11
12 # Include Hash Serialization Utility Libraries
13 use Storable qw(nfreeze thaw);
14
15 # Include Base64 Libraries
16 use MIME::Base64 qw(encode_base64 decode_base64);
17
18 # Include Getopt Parser
19 use Getopt::Long;
20
21 # Include utility access to global configuration.
22 use HoneyClient::Util::Config qw(getVar);
23
24 # Include Manager Library
25 use HoneyClient::Manager;
26
27 # Include Logging Library
28 use Log::Log4perl qw(:easy);
29
30 # The global logging object.
31 our $LOG = get_logger();
32
33 # We expect that the user will supply a single argument to this script.
34 # Namely, the initial set of URLs that they want the Agent to use.
35
36 # Change to 'HoneyClient::Agent::Driver::Browser::IE' or
37 #           'HoneyClient::Agent::Driver::Browser::FF'
38 my $driver = undef;
39 my $config = undef;
40 my $maxrel = undef;
41 my $nexturl = "";
42 my $urllist= "";
43
44 # TODO: Need --help option, along with sanity checking.
45 # TODO: Also need a decent POD for this code.
46 GetOptions('driver=s'             => \$driver,
47            'master_vm_config=s'   => \$config,
48            'url_list=s'           => \$urllist,
49            'max_relative_links:i' => \$maxrel);
50
51 # Sanity Check.  Make sure $driver is set.
52 unless (defined($driver)) {
53     $driver = getVar(name      => "default_driver",
54                      namespace => "HoneyClient::Agent");
55 }
56
57 # Sanity Check.  Make sure $max_relative_links is set.
58 unless (defined($maxrel)) {
59     $maxrel = getVar(name      => "max_relative_links_to_visit",
60                      namespace => "HoneyClient::Agent::Driver::Browser");
61 }
62
63 # Go through the list of urls to create the array
64 # Anything not associated with an option is a URL
65 # Grab those first and then get the ones from the file specified
66 my @urls;
67 push( @urls, @ARGV );
68 if( -e $urllist ){
69     open URL, $urllist;
70     push(@urls, <URL>);
71 }
72
73 # Get the first url from the list
74 # Create a hashtable in the form: url => 1 for links_to_visit
75 chomp @urls;
76 my $firsturl = shift @urls;
77 my %remaining_urls;
78 foreach(@urls){
79     # We assign our initial list of URLs a priority of 1000, so that
80     # they'll be (likely to be) selected first, before going to any other
81     # external URLs found from subsequent drive operations.
82     $remaining_urls{$_} = 1000;
83 }
84
85 my $agentState = HoneyClient::Manager->run(
86                     driver           => $driver,
87                     master_vm_config => $config,
88                     agent_state      => encode_base64(nfreeze({
89                         $driver => {
90                             next_link_to_visit => $firsturl,
91                             max_relative_links_to_visit => $maxrel,
92                             links_to_visit => \%remaining_urls,
93                          },
94                     })),
95                  );
96
Note: See TracBrowser for help on using the browser.