+ return ret.toString();
+ } catch (Exception e) {
+ throw new RuntimeException("Cannot run SLC command line", e);
+ }
+ }
+
+ public static void main(String[] args) {
+ try {
+ // Prepare directories
+ File executionDir = new File(System.getProperty("user.dir"));
+ File slcDir;
+ Boolean isTransient = false;
+ if (isTransient) {
+ File tempDir = new File(System.getProperty("java.io.tmpdir")
+ + "/" + System.getProperty("user.name"));
+ slcDir = new File(tempDir, "slc-"
+ + UUID.randomUUID().toString());
+ slcDir.mkdirs();
+ System.setProperty("argeo.node.repo.configuration",
+ "osgibundle:repository-memory.xml");
+ } else {
+ slcDir = findSlcDir(executionDir);
+ if (slcDir == null) {
+ slcDir = new File(executionDir, slcDirName);
+ slcDir.mkdirs();
+ }
+ }
+
+ File dataDir = new File(slcDir, "data");
+ if (!dataDir.exists())
+ dataDir.mkdirs();
+
+ File confDir = new File(slcDir, "conf");
+ if (!confDir.exists())
+ confDir.mkdirs();
+
+ File modulesDir = new File(slcDir, "modules");
+
+ // JAAS
+ File jaasFile = new File(confDir, "jaas.config");
+ if (!jaasFile.exists())
+ copyResource("/org/argeo/slc/cli/jaas.config", jaasFile);
+ System.setProperty("java.security.auth.login.config",
+ jaasFile.getCanonicalPath());
+
+ // log4j
+ File log4jFile = new File(confDir, "log4j.properties");
+ if (!log4jFile.exists())
+ copyResource("/org/argeo/slc/cli/log4j.properties", log4jFile);
+ System.setProperty("log4j.configuration",
+ "file://" + log4jFile.getCanonicalPath());
+ // Run as a privileged action
+ LoginContext lc = new LoginContext(os);
+ lc.login();
+
+ Subject subject = Subject.getSubject(AccessController.getContext());
+ Subject.doAs(subject, new SlcMain(args, confDir, dataDir,
+ modulesDir));
+
+ if (args.length != 0)
+ System.exit(0);