JSERVERPORT=5222; # jabber server port
JSERVERLEVEL=3; # can be 1-4, 4 is the highest
JSERVERIP="*"; # can be "*" or a specific local IP address
-ROUTERLOG="$LOGDIR/router.log" # jabber router log
# --------------------------------------------------------------------------
# --------------------------------------------------------------------------
function startRouter {
- "$BINDIR/router" "$ETCDIR/router_config.xml"
+ "$BINDIR/router" "$ETCDIR/opensrf_core.xml"
}
function startOpenSRF {
--- /dev/null
+<?xml version='1.0'?>
+
+<!-- Bootstrap config file for the C opensrf_stack library -->
+<config>
+
+ <!-- The section between <gateway>...</gateway> is a standard OpenSRF C stack config file -->
+ <gateway>
+
+ <!-- the routers's name on the network -->
+ <router_name>router</router_name>
+
+ <!-- jabber domains to connect to (domain1, domain2, ...) -->
+ <domains>
+ <domain1>127.0.0.1</domain1>
+ </domains>
+
+ <!-- jabber login info -->
+ <username>mylogin</username>
+ <passwd>mypassword</passwd>
+
+ <!-- If the port is a positive number,
+ we will connect via TCP port, if not and unixpath is defined,
+ we will connect via UNIX domain socket with the given path -->
+ <port>5222</port>
+ <unixpath>/openils/var/sock/jserver.sock</unixpath>
+
+ <!-- log file location -->
+ <logfile>/openils/var/log/gateway.log</logfile>
+ <!-- 0 None, 1 Error, 2 Warning, 3 Info, 4 debug -->
+ <loglevel>3</loglevel>
+
+ </gateway>
+
+ <rest_gateway>
+ <router_name>router</router_name>
+ <domains>
+ <domain1>127.0.0.1</domain1>
+ </domains>
+ <username>mylogin</username>
+ <passwd>mypassword</passwd>
+ <port>5222</port>
+ <unixpath>/openils/var/sock/jserver.sock</unixpath>
+ <logfile>/openils/var/log/gateway.log</logfile>
+ <loglevel>3</loglevel>
+ </rest_gateway>
+
+
+ <!-- ======================================================================================== -->
+
+ <router>
+ <component>0</component> <!-- leave disabled for now -->
+
+ <trusted_domains>
+ <!-- Trusted servers are allowed to register apps with the router -->
+ <server1>127.0.0.1</server1>
+ <!-- Trusted clients are allowed to send packets through the router -->
+ <client1>127.0.0.1</client1>
+ </trusted_domains>
+
+ <transport>
+ <!-- jabber server are we connecting to -->
+ <server>127.0.0.1</server>
+ <!-- If the port is a positive number,
+ we will connect via TCP port, if not and unixpath is defined,
+ we will connect via UNIX domain socket with the given path -->
+ <port>5222</port>
+ <unixpath>/openils/var/sock/unix_sock</unixpath>
+
+ <!-- router's name on the network -->
+ <username>router</username>
+ <password>mypassword</password>
+ <!-- router's jabber resource -->
+ <resource>router</resource>
+ <connect_timeout>10</connect_timeout>
+ <max_reconnect_attempts>5</max_reconnect_attempts>
+ </transport>
+
+ <logfile>/openils/var/log/router.log</logfile>
+ <loglevel>3</loglevel>
+
+ </router>
+
+ <!-- ======================================================================================== -->
+
+</config>
+
+
+
+
cp ../bin/opensrf_ctl $(BINDIR)
cp ../bin/opensrf_all $(BINDIR)
cp ../examples/opensrf.xml.example $(ETCDIR)
+ cp ../examples/opensrf_core.xml.example $(ETCDIR)
# --------------------------------------------------------------------------------
echo "-> $$(pwd)"
install:
- cp gateway.xml.example $(ETCDIR)
echo installing ils_gateway
$(APXS2) -i -a -n ils_gateway libmod_ils_gateway.so
echo installing ils_rest_gateway
+++ /dev/null
-<!-- Bootstrap config file for the C opensrf_stack library -->
-<config>
- <bootstrap>
- <!-- log level (WARN, INFO, DEBUG) -->
- <debug>INFO</debug>
-
- <!-- best to leave this untouched if possible -->
- <router_name>router</router_name>
-
- <!-- jabber domains to connect to (domain1, domain2, ...) -->
- <domains>
- <domain1>host.example.com</domain1>
- </domains>
-
- <!-- jabber connection information. Note that unix socket connectes are
- not yet implemented with any of the C libraries so port will
- have to be a port number -->
- <username>my_jabber_login</username>
- <passwd>my_jabber_password</passwd>
- <port>5222</port>
- <unixpath>/path/to/unix_sock_file</unixpath>
-
- </bootstrap>
-
- <!-- log file location -->
- <logs>
- <client>/path/to/log/gateway.log</client>
- </logs>
-
-</config>
static void mod_ils_gateway_child_init(apr_pool_t *p, server_rec *s) {
- if( ! osrf_system_bootstrap_client( "/openils/conf/gateway.xml") )
+ char* context = "gateway";
+ #ifdef RESTGATEWAY
+ context = "rest_gateway";
+ #endif
+ if( ! osrf_system_bootstrap_client( "/home/erickson/sandbox/openils/conf/opensrf_core.xml", context) )
fatal_handler("Unable to load gateway config file...");
fprintf(stderr, "Bootstrapping %d\n", getpid() );
fflush(stderr);
char target_buf[512];
memset(target_buf,0,512);
- char* domain = config_value( "opensrf.bootstrap", "//bootstrap/domains/domain1" ); /* just the first for now */
- char* router_name = config_value( "opensrf.bootstrap", "//bootstrap/router_name" );
+ char* domain = config_value( "opensrf.bootstrap", "//%s/domains/domain1", osrf_config_context ); /* just the first for now */
+ char* router_name = config_value( "opensrf.bootstrap", "//%s/router_name", osrf_config_context );
sprintf( target_buf, "%s@%s/%s", router_name, domain, remote_service );
free(domain);
free(router_name);
return global_client;
}
-int osrf_system_bootstrap_client( char* config_file ) {
+int osrf_system_bootstrap_client( char* config_file, char* contextnode ) {
if( config_file == NULL )
fatal_handler("No Config File Specified\n" );
config_reader_init( "opensrf.bootstrap", config_file );
+
+ osrf_config_context = contextnode;
- char* log_file = config_value( "opensrf.bootstrap", "//logs/client" );
- char* log_level = config_value( "opensrf.bootstrap", "//bootstrap/debug" );
- char* domain = config_value( "opensrf.bootstrap", "//bootstrap/domains/domain1" ); /* just the first for now */
- char* username = config_value( "opensrf.bootstrap", "//bootstrap/username" );
- char* password = config_value( "opensrf.bootstrap", "//bootstrap/passwd" );
- char* port = config_value( "opensrf.bootstrap", "//bootstrap/port" );
- char* unixpath = config_value( "opensrf.bootstrap", "//bootstrap/unixpath" );
+ char* log_file = config_value( "opensrf.bootstrap", "//%s/logfile", contextnode );
+ char* log_level = config_value( "opensrf.bootstrap", "//%s/loglevel", contextnode );
+ char* domain = config_value( "opensrf.bootstrap", "//%s/domains/domain1", contextnode ); /* just the first for now */
+ char* username = config_value( "opensrf.bootstrap", "//%s/username", contextnode );
+ char* password = config_value( "opensrf.bootstrap", "//%s/passwd", contextnode );
+ char* port = config_value( "opensrf.bootstrap", "//%s/port", contextnode );
+ char* unixpath = config_value( "opensrf.bootstrap", "//%s/unixpath", contextnode );
int llevel = 0;
int iport = 0;
if(port) iport = atoi(port);
-
- if (!strcmp(log_level, "ERROR")) llevel = LOG_ERROR;
- else if (!strcmp(log_level, "WARN")) llevel = LOG_WARNING;
- else if (!strcmp(log_level, "INFO")) llevel = LOG_INFO;
- else if (!strcmp(log_level, "DEBUG")) llevel = LOG_DEBUG;
+ if(log_level) llevel = atoi(log_level);
log_init( llevel, log_file );
info_handler("Bootstrapping system with domain %s, port %d, and unixpath %s", domain, iport, unixpath );
- // XXX config values
transport_client* client = client_init( domain, iport, unixpath, 0 );
char buf[256];
memset(buf,0,256);
#ifndef OSRF_SYSTEM_H
#define OSRF_SYSTEM_H
-/** Connects to jabber. Returns 1 on success, 0 on failure */
-int osrf_system_bootstrap_client();
+/** Connects to jabber. Returns 1 on success, 0 on failure
+ contextnode is the location in the config file where we collect config info
+*/
+
+char* osrf_config_context;
+
+int osrf_system_bootstrap_client( char* config_file, char* contextnode );
transport_client* osrf_system_get_transport_client();
int osrf_system_shutdown();
+
#endif
install:
echo installing router
cp router $(BINDIR)
- cp router_config.xml.example $(ETCDIR)
router: router.c $(LIB_SOURCES)
echo $@
config_reader_init( "opensrf.router", argv[1] );
if( conf_reader == NULL ) fatal_handler( "main(): Config is NULL" );
- /* laod the config options */
+ /* load the config options */
char* server = config_value("opensrf.router", "//router/transport/server");
char* port = config_value("opensrf.router", "//router/transport/port");
char* unixpath = config_value("opensrf.router", "//router/transport/unixpath");
char* max_retries = config_value("opensrf.router", "//router/transport/max_reconnect_attempts" );
char* component = config_value("opensrf.router", "//router/component" );
+ fprintf(stderr, "Router connecting with uname %s, server %s, port %s, unixpath %s",
+ username, server, port, unixpath );
+
/* set up the logger */
- char* level = config_value("opensrf.router","//log/level");
- char* log_file = config_value("opensrf.router","//log/file");
+ char* level = config_value("opensrf.router","//router/loglevel");
+ char* log_file = config_value("opensrf.router","//router/logfile");
+
int llevel = atoi(level);
fprintf(stderr, "Level %d; file %s\n", llevel, log_file );
+++ /dev/null
-<router>
-
- <component>0</component> <!-- leave disabled for now -->
-
- <trusted_domains>
-
- <!--
- Trusted servers are allowed to register apps with the router
- -->
- <server1>server1.domain.com</server1>
- <server2>server2.domain.com</server2>
-
- <!--
- Trusted clients are allowed to send queries to the router
- -->
- <client1>client1.domain.com</client1>
- <client2>client2.domain.com</client2>
-
- </trusted_domains>
-
-
- <!-- jabber connection information. Note that unix socket connectes are
- not yet implemented with any of the C libraries so port will
- have to be a port number -->
-
- <transport>
- <server>jabber_server.domain.com</server>
- <port>5222</port>
- <unixpath>/path/to/unix_sock</unixpath>
- <username>router</username>
- <password>my_password</password>
- <resource>router</resource>
- <connect_timeout>10</connect_timeout>
- <max_reconnect_attempts>5</max_reconnect_attempts>
- </transport>
-
-
- <log>
- <file>/pines/log/router.log</file>
-
- <!--
- 0 No logging
- 1 Error logging
- 2 Warning
- 3 Info
- 4 debug
- -->
- <level>3</level>
- </log>
-
-
-</router>
sprintf(fbuf,"%s/.srfsh.xml",home);
if(!access(fbuf, R_OK)) {
- if( ! osrf_system_bootstrap_client(fbuf) )
+ if( ! osrf_system_bootstrap_client(fbuf, "srfsh") )
fatal_handler( "Unable to bootstrap client for requests");
} else {