diff options
author | Simon Rettberg | 2019-12-11 18:13:59 +0100 |
---|---|---|
committer | Simon Rettberg | 2019-12-11 18:13:59 +0100 |
commit | 1efe9cbbdade4257b382891367b7b0fe86608590 (patch) | |
tree | aca91559877f2461547cdc25d0b2815e8764742b /src/main/java/org/openslx/taskmanager/tasks/LinkConfigTgz.java | |
parent | Simplify some code, remove unused stuff (diff) | |
download | tmlite-bwlp-1efe9cbbdade4257b382891367b7b0fe86608590.tar.gz tmlite-bwlp-1efe9cbbdade4257b382891367b7b0fe86608590.tar.xz tmlite-bwlp-1efe9cbbdade4257b382891367b7b0fe86608590.zip |
[Symlink] Rename and refit from LinkConfigTgz
Diffstat (limited to 'src/main/java/org/openslx/taskmanager/tasks/LinkConfigTgz.java')
-rw-r--r-- | src/main/java/org/openslx/taskmanager/tasks/LinkConfigTgz.java | 73 |
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; - } - -} |