summaryrefslogtreecommitdiff
path: root/client
diff options
context:
space:
mode:
authorAndrew Gaffney <agaffney@gentoo.org>2007-12-24 07:18:23 +0000
committerAndrew Gaffney <agaffney@gentoo.org>2007-12-24 07:18:23 +0000
commit53fae43967313c5e025a40b5bfea429d2c76e752 (patch)
tree4e6b652dc9883914655f797a34f0050e228a3ceb /client
parentconfig touchups. (diff)
downloadscire-53fae43967313c5e025a40b5bfea429d2c76e752.tar.gz
scire-53fae43967313c5e025a40b5bfea429d2c76e752.tar.bz2
scire-53fae43967313c5e025a40b5bfea429d2c76e752.zip
rename verbose to debug
split identify and register svn path=/branches/new-fu/; revision=260
Diffstat (limited to 'client')
-rwxr-xr-xclient/scireclient.pl36
1 files changed, 26 insertions, 10 deletions
diff --git a/client/scireclient.pl b/client/scireclient.pl
index d027d59..bf47e43 100755
--- a/client/scireclient.pl
+++ b/client/scireclient.pl
@@ -32,7 +32,7 @@ if (-d ".svn") {
if (! -d $conf{job_dir}) {
print "WARNING! $conf{job_dir} does not exist...creating\n";
- mkdir -p $conf{job_dir}, 0660
+ mkdir $conf{job_dir}, 0660
or die("Couldn't make $conf{job_dir} w/ perms 0660: $!");
}
@@ -44,7 +44,11 @@ sub run_main {
create_connection();
#2. Register with the DB. (only it knows if you're allowed to be active)
- register_client();
+ if(-f "../etc/client_key") {
+ identify_client();
+ } else {
+# register_client();
+ }
#3. Scan the jobs directory. If there are done/failed jobs, report them. Note jobs in running or queue.
#4. Fetch the jobs list
@@ -62,7 +66,7 @@ sub run_test {
sub parse_command_line {
GetOptions(
- 'verbose|D' => \$conf{debug},
+ 'debug|D' => \$conf{debug},
'dry-run' => \$conf{dry_run},
'help|h' => \$conf{help},
'config|c=s' => \$conf{config},
@@ -76,7 +80,7 @@ sub parse_command_line {
'job_dir' => \$conf{job_dir},
);
if ($conf{help}) {
- print "\nusage: scireclient.pl [--verbose or -D]\n\t [--dry-run]"
+ print "\nusage: scireclient.pl [--debug or -D]\n\t [--dry-run]"
."\t [--config=CONF or -c] \n\t [--threads=# or -t] \t [--help or -h] \n"
."\t [[--host=HOST] \t [--port=PORT] \t [--user=USER or -u] \n\t"
." [--server_script=foo.pl] \t [--job_dir=/tmp/jobs] \n";
@@ -109,7 +113,12 @@ sub get_response {
}
sub create_connection {
- # XXX: We need to see what this function returns if the command returns non-zero
+ # XXX: How do we capture this error? $pid has a valid value even if the
+ # process fails to run, since it just returns the PID of the forked perl
+ # process. I tried adding 'or die' after it, but it didn't help since it
+ # doesn't fail in the main process. When it fails, it outputs an error
+ # to STDERR:
+ # open2: exec of ../server/scireserver.pl failed at ./scireclient.pl line 116
my $pid = open2(*SERVER_STDOUT, *SERVER_STDIN, $connection_command);
}
@@ -129,12 +138,19 @@ sub read_config {
}
sub register_client {
- my $fingerprint = "AA:BB:CC:DD:EE:FF:GG:HH... this is a digest.";
- my $cmd = "IDENTIFY $fingerprint";
+ send_command("REGISTER 00:11:22:33:44:55 192.168.2.3 myhostname");
+}
+
+sub identify_client {
+ open FILE, "< ../etc/client_key" or die "Couldn't open client_key: $!";
+ my $client_key = join("", <FILE>);
+ close FILE;
+ my $cmd = "IDENTIFY ${client_key}";
send_command($cmd);
my $response = get_response();
- $response =~ /IDENTIFIED\ CLIENT\ (\d+)/
- or die("Couldn't register client. Response was $response");
- $conf{client_id} = $1;
+ $response =~ /^(OK|ERROR (.+))$/;
+ if($1 eq "ERROR") {
+ print "Could not identify to server: $2\n";
+ }
print "Registered client $conf{client_id}\n" if $conf{debug};
}