Skip to content

Commit

Permalink
allow setting path to where spm is mounted
Browse files Browse the repository at this point in the history
  • Loading branch information
ksarink committed Jan 10, 2023
1 parent 85ae91a commit 01596a3
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 24 deletions.
20 changes: 1 addition & 19 deletions src/main/java/de/wwu/trap/SpmLauncher/App.java
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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();
Expand All @@ -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 {
Expand Down
19 changes: 14 additions & 5 deletions src/main/java/de/wwu/trap/SpmLauncher/OSHandler.java
Original file line number Diff line number Diff line change
Expand Up @@ -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<String, String> toolboxBinds = generateToolboxBinds(spmDir, activatedToolboxes);
String tmpSpmDirStr = App.getMountDir();
File tmpSpmDir = spmDir;
if (tmpSpmDirStr != null)
tmpSpmDir = new File(tmpSpmDirStr);


HashMap<String, String> toolboxBinds = generateToolboxBinds(tmpSpmDir, activatedToolboxes);
LinkedList<String> toolboxBindParameters = generateToolboxBindsParameters(toolboxBinds);

LinkedList<String> launchCommand = new LinkedList<>();
Expand All @@ -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"
;
Expand Down

0 comments on commit 01596a3

Please sign in to comment.