execute a script if provided one
This commit is contained in:
@@ -109,9 +109,25 @@ class Core {
|
|||||||
ConnectionEstablisher connector = new ConnectionEstablisher(eventBus, i2pConnector, props, connectionManager, hostCache)
|
ConnectionEstablisher connector = new ConnectionEstablisher(eventBus, i2pConnector, props, connectionManager, hostCache)
|
||||||
connector.start()
|
connector.start()
|
||||||
|
|
||||||
// ... at the end, sleep
|
// ... at the end, sleep or execute script
|
||||||
log.info("initialized everything, sleeping")
|
if (args.length == 0) {
|
||||||
Thread.sleep(Integer.MAX_VALUE)
|
log.info("initialized everything, sleeping")
|
||||||
|
Thread.sleep(Integer.MAX_VALUE)
|
||||||
|
} else {
|
||||||
|
log.info("executing script ${args[0]}")
|
||||||
|
File f = new File(args[0])
|
||||||
|
if (!f.exists()) {
|
||||||
|
log.warning("Script file doesn't exist")
|
||||||
|
System.exit(1)
|
||||||
|
}
|
||||||
|
|
||||||
|
def binding = new Binding()
|
||||||
|
binding.setProperty("eventBus", eventBus)
|
||||||
|
// TOOD: other bindings?
|
||||||
|
def shell = new GroovyShell(binding)
|
||||||
|
def script = shell.parse(f)
|
||||||
|
script.run()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user