diff options
Diffstat (limited to 'src/main/java/org')
3 files changed, 16 insertions, 58 deletions
diff --git a/src/main/java/org/openslx/taskmanager/tasks/LdadpLauncher.java b/src/main/java/org/openslx/taskmanager/tasks/LdadpLauncher.java index cb648b9..d1550c5 100644 --- a/src/main/java/org/openslx/taskmanager/tasks/LdadpLauncher.java +++ b/src/main/java/org/openslx/taskmanager/tasks/LdadpLauncher.java @@ -6,6 +6,7 @@ import java.util.List; import java.util.concurrent.atomic.AtomicReference; import org.openslx.satserver.util.Constants; +import org.openslx.satserver.util.Util; import org.openslx.taskmanager.api.SystemCommandTask; import com.google.gson.annotations.Expose; @@ -14,6 +15,9 @@ public class LdadpLauncher extends SystemCommandTask { @Expose private int[] ids = null; + + @Expose + private String command; private Output status = new Output(); @@ -27,13 +31,16 @@ public class LdadpLauncher extends SystemCommandTask status.addMessage( "No ids passed to task." ); return false; } + if ( Util.isEmpty( command ) ) { + command = "start"; + } return true; } @Override protected String[] initCommandLine() { - if ( !isRunning.compareAndSet( null, this ) ) { + if ( !command.equals( "check" ) && !isRunning.compareAndSet( null, this ) ) { LdadpLauncher other = isRunning.get(); if ( other != null && !Arrays.equals( this.ids, other.ids ) ) { status.addMessage( "Another operation is already in progress." ); @@ -44,14 +51,14 @@ public class LdadpLauncher extends SystemCommandTask args.addAll( Arrays.asList( new String[] { "/usr/bin/sudo", "-n", - "-u", "ldadp", Constants.BASEDIR + "/scripts/ldadp-launcher", - "/opt/ldadp", + "-u", "root", Constants.BASEDIR + "/scripts/ldadp-launcher", + "--" + command, "--" } ) ); for ( int i = 0; i < ids.length; ++i ) { args.add( Integer.toString( this.ids[i] ) ); } - this.timeoutSeconds = 8; + this.timeoutSeconds = 16; return args.toArray( new String[ args.size() ] ); } @@ -65,7 +72,7 @@ public class LdadpLauncher extends SystemCommandTask @Override protected void processStdOut( String line ) { - //status.addMessage( line ); + status.addMessage( line ); } @Override diff --git a/src/main/java/org/openslx/taskmanager/tasks/MountVmStore.java b/src/main/java/org/openslx/taskmanager/tasks/MountVmStore.java index e0a998a..2a46a10 100644 --- a/src/main/java/org/openslx/taskmanager/tasks/MountVmStore.java +++ b/src/main/java/org/openslx/taskmanager/tasks/MountVmStore.java @@ -7,7 +7,6 @@ import org.openslx.satserver.util.Constants; import org.openslx.satserver.util.Util; import org.openslx.taskmanager.api.SystemCommandTask; -import com.btr.proxy.util.Logger; import com.google.gson.annotations.Expose; public class MountVmStore extends SystemCommandTask diff --git a/src/main/java/org/openslx/taskmanager/tasks/Systemctl.java b/src/main/java/org/openslx/taskmanager/tasks/Systemctl.java index 7b09a39..bce52c9 100644 --- a/src/main/java/org/openslx/taskmanager/tasks/Systemctl.java +++ b/src/main/java/org/openslx/taskmanager/tasks/Systemctl.java @@ -1,8 +1,5 @@ package org.openslx.taskmanager.tasks; -import java.util.ArrayList; -import java.util.List; - import org.openslx.taskmanager.api.SystemCommandTask; import com.google.gson.annotations.Expose; @@ -23,56 +20,11 @@ public class Systemctl extends SystemCommandTask @Override protected String[] initCommandLine() { - boolean allowAll = false; - boolean asRoot = true; - // Check if operation is allowed - switch ( operation ) { - case "start": - case "stop": - case "enable": - case "disable": - case "restart": - case "status": - break; - case "show": - case "is-active": - allowAll = true; - asRoot = false; - break; - default: - status.addMsg( "Unknown operation: " + operation ); - return null; - } - if ( !allowAll ) { - // Check if service is allowed - switch ( service ) { - case "dmsd": - case "dnbd3-server": - break; - case "taskmanager": - case "lighttpd": - if ( !operation.equals( "restart" ) ) { - status.addMsg( "Error: Service " + service + " can only be restarted." ); - return null; - } - break; - default: - status.addMsg( "Unknown service: " + operation ); - return null; - } - } - List<String> params = new ArrayList<>(); - if ( asRoot ) { - params.add( "/usr/bin/sudo" ); - params.add( "-n" ); - params.add( "-u" ); - params.add( "root" ); - } - params.add( "/bin/systemctl" ); - params.add( operation ); - params.add( service ); this.timeoutSeconds = 15; - return params.toArray( new String[ params.size() ] ); + return new String[] { "/usr/bin/sudo", + "-n", "-u", "root", + "/opt/taskmanager/scripts/systemctl", + operation, service }; } private boolean errorIfNull( String check, String message ) |