// System.out.println ("unknown option: ["+args[i]+"]") ;
// System.exit (1) ;
}
}
// Get the properties for this server:
ObservableProperties props = null;
props = new ObservableProperties(System.getProperties()) ;
// Get the root and configuration directories:
File root = ((cmdroot == null)
? new File(props.getProperty("user.dir", null))
: new File(cmdroot));
File config = new File(root, cmdconfig);
// Locate the property file:
if (cmdprop == null) {
// Try to guess it, cause it is really required:
File guess = new File (config, cmdid+".props");
if ( ! guess.exists() )
// A hack for smooth upgrade from 1.0alpha3 to greater:
guess = new File(config, "httpd.props");
cmdprop = guess.getAbsolutePath() ;
}
if ( cmdprop != null ) {
System.out.println ("loading properties from: " + cmdprop) ;
try {
File propfile = new File(cmdprop) ;
props.load(new FileInputStream(propfile)) ;
props.put (PROPS_P, propfile.getAbsolutePath()) ;
} catch (FileNotFoundException ex) {
System.out.println ("Unable to load properties: "+cmdprop);
System.out.println ("\t"+ex.getMessage()) ;
System.exit (1) ;
} catch (IOException ex) {
System.out.println ("Unable to load properties: "+cmdprop);
System.out.println ("\t"+ex.getMessage()) ;
System.exit (1) ;
}
System.setProperties (props) ;
}
// Check for an upgrade:
int configvers = props.getInteger(httpd.VERSCOUNT_P, 1);
if (configvers < httpd.verscount) {
System.err.println("+ Jigsaw needs upgrade from internal version "+
configvers+
" to " + httpd.verscount);
if ( noupgrade ) {
System.err.println("+ Jigsaw cannot run in that version.");
System.exit(1);
}
// upgrade(configvers, httpd.verscount, args);
return;
}
// Override properties with our command line options:
if ( cmdport != null )
props.put (PORT_P, cmdport.toString()) ;
if ( cmdhost != null )
props.put (HOST_P, cmdhost) ;
if ( cmdroot != null )
props.put (ROOT_P, root.getAbsolutePath()) ;
if ( cmdconfig != null )
props.put(CONFIG_P, config.getAbsolutePath());
if ( cmdspace != null )
props.put (SPACE_P, cmdspace) ;
if ( cmdtrace != null ) {
props.put (TRACE_P, "true") ;
props.put (CLIENT_DEBUG_P, "true") ;
}
if (maxstores != null)
props.put (MAX_LOADED_STORE_P, maxstores);
// Install security manager if needed:
if (Boolean.getBoolean(USE_SM_P)) {
SecurityManager sm = new httpdSecurityManager() ;
System.setSecurityManager (sm) ;