Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Deploy and execute something with Java on UNIX

I have a Java process (daemon) which is running. This process is used like a service. With that service I can download a signed zip archive from a trusted server. After I unpack the ZIP archive I want to execute a binary in the "unpacked" folder.

The problem is that this binary is not executable (no 'x' in its file mode) ... I know it's possible to set it with Java but I want a generic way.

Do you have any ideas how to do the deployment in a nice way?

(Yes, it needs to be Java)

Basically I want to restore the Unix file mode bits after I unpacked the ZIP archive. Is there a Java Lib which can do this?

like image 535
alexvetter Avatar asked Oct 24 '22 07:10

alexvetter


1 Answers

You could easily call the chmod command from your Java application to add that missing x bit. chmod is as standard on Unix as the executable (x) bit itself.

Or you could do it straight from Java.

If you want the executable bit to remain set at decompression, though, you should probably not use the Java decompression libraries. Try using the Unix unzip command to decompress your archive - it has supported storing and restoring the Unix file mode bits for quite some time. If your Unix vendor does not have it, you can get it from the source.

like image 150
thkala Avatar answered Oct 30 '22 04:10

thkala