From 9dd4bae072b566b9bfc4917d8a8840a6514b2666 Mon Sep 17 00:00:00 2001 From: erickson Date: Wed, 12 Mar 2008 16:04:21 +0000 Subject: [PATCH] gave oils_requestor the ability to find the IDL from the settings server based on hostname if none is specified in the path. passing hostname from the offline-blocked list generator git-svn-id: svn://svn.open-ils.org/ILS/trunk@8993 dcc99617-32d9-48b4-a31d-7c20da2025e4 --- Open-ILS/src/extras/oils_requestor.c | 28 +++++++++++++--------- .../src/support-scripts/offline-blocked-list.pl | 4 +++- 2 files changed, 20 insertions(+), 12 deletions(-) diff --git a/Open-ILS/src/extras/oils_requestor.c b/Open-ILS/src/extras/oils_requestor.c index bacbf5677f..53effc2632 100644 --- a/Open-ILS/src/extras/oils_requestor.c +++ b/Open-ILS/src/extras/oils_requestor.c @@ -22,9 +22,10 @@ int main( int argc, char* argv[] ) { char* config = NULL; char* context = NULL; char* idl_filename = NULL; + char* hostname = NULL; char* request; - while( (c = getopt( argc, argv, "f:u:p:s:c:i:" )) != -1 ) { + while( (c = getopt( argc, argv, "f:u:p:s:c:i:h:" )) != -1 ) { switch(c) { case '?': return -1; case 'f': config = strdup(optarg); break; @@ -33,19 +34,10 @@ int main( int argc, char* argv[] ) { case 'p': password = strdup(optarg); break; case 's': script = strdup(optarg); break; case 'i': idl_filename = strdup(optarg); break; + case 'h': hostname = strdup(optarg); break; } } - if (!idl_filename) { - fprintf(stderr, "IDL file not provided. Exiting...\n"); - return -1; - } - - if (!oilsInitIDL( idl_filename )) { - fprintf(stderr, "IDL file could not be loaded. Exiting...\n"); - return -1; - } - if(!(config && context)) { fprintf(stderr, "Config or config context not provided. Exiting...\n"); return -1; @@ -56,6 +48,19 @@ int main( int argc, char* argv[] ) { return 1; } + if(!idl_filename) { + if(!hostname) { + fprintf(stderr, "We need an IDL file name or a settings server hostname...\n"); + return 1; + } + osrf_settings_retrieve(hostname); + } + + if (!oilsInitIDL( idl_filename )) { + fprintf(stderr, "IDL file could not be loaded. Exiting...\n"); + return -1; + } + printf("Connected to OpenSRF network...\n"); if( username && password && @@ -76,6 +81,7 @@ int main( int argc, char* argv[] ) { free(script); free(authtoken); free(idl_filename); + osrf_settings_free_host_config(NULL); return 1; } diff --git a/Open-ILS/src/support-scripts/offline-blocked-list.pl b/Open-ILS/src/support-scripts/offline-blocked-list.pl index e2714e3a00..42327d01bf 100755 --- a/Open-ILS/src/support-scripts/offline-blocked-list.pl +++ b/Open-ILS/src/support-scripts/offline-blocked-list.pl @@ -16,11 +16,13 @@ if(1) { # XXX command line param use OpenSRF::Utils::JSON; use IPC::Open2 qw/open2/; + use Net::Domain qw/hostfqdn/; sub runmethod { my $method = shift; my $flag = shift; - my $command = "echo \"open-ils.storage $method\" | $oils_reqr -f $config -c $context"; + my $hostname = hostfqdn(); + my $command = "echo \"open-ils.storage $method\" | $oils_reqr -f $config -c $context -h $hostname"; warn "-> $command\n"; my ($child_stdout, $child_stdin); -- 2.11.0