summaryrefslogtreecommitdiffstats
path: root/src/main/java/org/openslx/taskmanager/tasks/LinkConfigTgz.java
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/java/org/openslx/taskmanager/tasks/LinkConfigTgz.java')
-rw-r--r--src/main/java/org/openslx/taskmanager/tasks/LinkConfigTgz.java73
1 files changed, 0 insertions, 73 deletions
diff --git a/src/main/java/org/openslx/taskmanager/tasks/LinkConfigTgz.java b/src/main/java/org/openslx/taskmanager/tasks/LinkConfigTgz.java
deleted file mode 100644
index 7816247..0000000
--- a/src/main/java/org/openslx/taskmanager/tasks/LinkConfigTgz.java
+++ /dev/null
@@ -1,73 +0,0 @@
-package org.openslx.taskmanager.tasks;
-
-import java.io.File;
-import java.io.IOException;
-import java.nio.file.Files;
-import java.nio.file.Paths;
-
-import org.apache.commons.io.FileUtils;
-import org.apache.commons.io.FilenameUtils;
-import org.openslx.satserver.util.Util;
-import org.openslx.taskmanager.api.AbstractTask;
-
-import com.google.gson.annotations.Expose;
-
-public class LinkConfigTgz extends AbstractTask
-{
-
- protected static final String[] ALLOWED_DIRS =
- { "/tmp/", "/opt/openslx/configs/" };
-
- @Expose
- private String destination = null;
-
- private Output status = new Output();
-
- @Override
- protected boolean initTask()
- {
- this.setStatusObject( status );
- if ( this.destination != null && !this.destination.isEmpty() ) {
- this.destination = FilenameUtils.normalize( this.destination );
- if ( !Util.startsWith( this.destination, ALLOWED_DIRS ) ) {
- status.error = "File not in allowed directory";
- return false;
- }
- } else {
- this.destination = null;
- }
- return true;
- }
-
- @Override
- protected boolean execute()
- {
- try {
- Files.createDirectory( Paths.get( "/srv/openslx/www/boot/default" ) );
- } catch ( Exception e ) {
- }
- try {
- FileUtils.deleteQuietly( new File( "/srv/openslx/www/boot/default/config.tgz" ) );
- } catch ( Exception e ) {
- }
- if ( this.destination != null ) {
- try {
- Files.createSymbolicLink( Paths.get( "/srv/openslx/www/boot/default/config.tgz" ), Paths.get( this.destination ) );
- } catch ( IOException e ) {
- status.error = e.toString();
- return false;
- }
- }
- return true;
- }
-
- /**
- * Output - contains additional status data of this task
- */
- @SuppressWarnings( "unused" )
- private static class Output
- {
- protected String error = null;
- }
-
-}