From 01596a3eb24ac2eb68d05d6c2ee8d75a83f14d50 Mon Sep 17 00:00:00 2001 From: Kelvin Sarink Date: Tue, 10 Jan 2023 16:16:23 +0100 Subject: [PATCH] allow setting path to where spm is mounted --- .../java/de/wwu/trap/SpmLauncher/App.java | 20 +------------------ .../de/wwu/trap/SpmLauncher/OSHandler.java | 19 +++++++++++++----- 2 files changed, 15 insertions(+), 24 deletions(-) diff --git a/src/main/java/de/wwu/trap/SpmLauncher/App.java b/src/main/java/de/wwu/trap/SpmLauncher/App.java index d08fc96..98b78dc 100644 --- a/src/main/java/de/wwu/trap/SpmLauncher/App.java +++ b/src/main/java/de/wwu/trap/SpmLauncher/App.java @@ -43,14 +43,10 @@ public static String getManagedSoftwareDir() { * the tmp-mount script! */ public static String getMountDir() { - if (App.mountDir != null) - return App.mountDir; - else - return App.mountDirDefault; + return App.mountDir; } private static String mountDir = null; - private static final String mountDirDefault = "/tmp/SPMLauncher"; /** * The mount script which can be called with sudo without having to enter a @@ -111,8 +107,6 @@ public static void main(String[] args) { Option optionMountdir = new Option("md", "mount-dir", true, "Path to the directory where the temporary spm dirs are mounted"); options.addOption(optionMountdir); - Option optionMountscript = new Option("ms", "mount-script", true, "Path to the mount script tmp-mount"); - options.addOption(optionMountscript); // parsing CommandLineParser parser = new DefaultParser(); @@ -134,18 +128,6 @@ public static void main(String[] args) { */ App.managedSoftwareDir = line.getOptionValue(optionMansofdir); App.mountDir = line.getOptionValue(optionMountdir); - App.mountScript = line.getOptionValue(optionMountscript); - - /* - * Create mount dir with correct permissions for multiuser environments - */ - File mountDir = new File(App.getMountDir()); - if (!mountDir.exists()) { - mountDir.mkdirs(); - mountDir.setReadable(true, false); - mountDir.setWritable(true, false); - mountDir.setExecutable(true, false); - } if (line != null && line.hasOption(optionNc)) { try { diff --git a/src/main/java/de/wwu/trap/SpmLauncher/OSHandler.java b/src/main/java/de/wwu/trap/SpmLauncher/OSHandler.java index 0c033b0..85cfa4f 100644 --- a/src/main/java/de/wwu/trap/SpmLauncher/OSHandler.java +++ b/src/main/java/de/wwu/trap/SpmLauncher/OSHandler.java @@ -251,7 +251,13 @@ public static void buildLaunchCmdStartAndWait(File matlabDir, File spmDir, List< System.out.println(matlabDir.getAbsolutePath()); System.out.println("Starting " + spmDir.getName()); - HashMap toolboxBinds = generateToolboxBinds(spmDir, activatedToolboxes); + String tmpSpmDirStr = App.getMountDir(); + File tmpSpmDir = spmDir; + if (tmpSpmDirStr != null) + tmpSpmDir = new File(tmpSpmDirStr); + + + HashMap toolboxBinds = generateToolboxBinds(tmpSpmDir, activatedToolboxes); LinkedList toolboxBindParameters = generateToolboxBindsParameters(toolboxBinds); LinkedList launchCommand = new LinkedList<>(); @@ -265,13 +271,16 @@ public static void buildLaunchCmdStartAndWait(File matlabDir, File spmDir, List< launchCommand.add("--dev-bind"); launchCommand.add("/dev"); launchCommand.add("/dev"); -// launchCommand.add("--bind"); -// launchCommand.add(spmDir.getAbsolutePath()); -// launchCommand.add(tmpSpmDir.getAbsolutePath()); + if (tmpSpmDir != spmDir) { + launchCommand.add("--bind"); + launchCommand.add(spmDir.getAbsolutePath()); + launchCommand.add(tmpSpmDir.getAbsolutePath()); + } launchCommand.addAll(toolboxBindParameters); launchCommand.add(matlabDir.getAbsolutePath() + "/bin/matlab"); // absolute path to matlab binary launchCommand.add("-r"); - String matlabCommands = generateMatlabPathCommand(spmDir, activatedToolboxes, toolboxBinds) + "cd('/spm-data');" + String matlabCommands = generateMatlabPathCommand(tmpSpmDir, activatedToolboxes, toolboxBinds) + + "cd('/spm-data');" + "spm fmri;" // + "quit" ;