@@ -297,12 +297,6 @@ cobbzilla-utils is available under the Apache License, version 2: http://www.apa | |||||
<version>${args4j.version}</version> | <version>${args4j.version}</version> | ||||
</dependency> | </dependency> | ||||
<dependency> | |||||
<groupId>net.java.dev.jna</groupId> | |||||
<artifactId>jna</artifactId> | |||||
<version>4.1.0</version> | |||||
</dependency> | |||||
<!-- web/html screenshots --> | <!-- web/html screenshots --> | ||||
<dependency> | <dependency> | ||||
<groupId>com.codeborne</groupId> | <groupId>com.codeborne</groupId> | ||||
@@ -377,7 +371,7 @@ cobbzilla-utils is available under the Apache License, version 2: http://www.apa | |||||
<dependency> | <dependency> | ||||
<groupId>com.github.oshi</groupId> | <groupId>com.github.oshi</groupId> | ||||
<artifactId>oshi-core</artifactId> | <artifactId>oshi-core</artifactId> | ||||
<version>5.2.4</version> | |||||
<version>5.3.4</version> | |||||
</dependency> | </dependency> | ||||
</dependencies> | </dependencies> | ||||
@@ -35,6 +35,7 @@ import static java.util.concurrent.TimeUnit.SECONDS; | |||||
import static java.util.stream.LongStream.range; | import static java.util.stream.LongStream.range; | ||||
import static org.apache.commons.collections.CollectionUtils.collect; | import static org.apache.commons.collections.CollectionUtils.collect; | ||||
import static org.apache.commons.lang3.RandomStringUtils.randomAlphanumeric; | import static org.apache.commons.lang3.RandomStringUtils.randomAlphanumeric; | ||||
import static org.apache.commons.lang3.SystemUtils.IS_OS_MAC; | |||||
import static org.apache.commons.lang3.exception.ExceptionUtils.getStackTrace; | import static org.apache.commons.lang3.exception.ExceptionUtils.getStackTrace; | ||||
import static org.cobbzilla.util.error.ExceptionHandler.DEFAULT_EX_RUNNABLE; | import static org.cobbzilla.util.error.ExceptionHandler.DEFAULT_EX_RUNNABLE; | ||||
import static org.cobbzilla.util.io.FileUtil.abs; | import static org.cobbzilla.util.io.FileUtil.abs; | ||||
@@ -443,8 +444,8 @@ public class ZillaRuntime { | |||||
return collect(range(start.longValue(), end.longValue()).boxed().iterator(), ToStringTransformer.instance); | return collect(range(start.longValue(), end.longValue()).boxed().iterator(), ToStringTransformer.instance); | ||||
} | } | ||||
public static String zcat() { return SystemUtils.IS_OS_MAC ? "gzcat" : "zcat"; } | |||||
public static String zcat(File f) { return (SystemUtils.IS_OS_MAC ? "gzcat" : "zcat") + " " + abs(f); } | |||||
public static String zcat() { return IS_OS_MAC ? "gzcat" : "zcat"; } | |||||
public static String zcat(File f) { return (IS_OS_MAC ? "gzcat" : "zcat") + " " + abs(f); } | |||||
public static final String[] JAVA_DEBUG_OPTIONS = {"-Xdebug", "-agentlib", "-Xrunjdwp"}; | public static final String[] JAVA_DEBUG_OPTIONS = {"-Xdebug", "-agentlib", "-Xrunjdwp"}; | ||||
@@ -17,6 +17,7 @@ import java.security.DigestException; | |||||
import java.security.MessageDigest; | import java.security.MessageDigest; | ||||
import java.security.NoSuchAlgorithmException; | import java.security.NoSuchAlgorithmException; | ||||
import static org.apache.commons.lang3.SystemUtils.IS_OS_MAC; | |||||
import static org.cobbzilla.util.daemon.ZillaRuntime.die; | import static org.cobbzilla.util.daemon.ZillaRuntime.die; | ||||
import static org.cobbzilla.util.io.FileUtil.abs; | import static org.cobbzilla.util.io.FileUtil.abs; | ||||
import static org.cobbzilla.util.string.StringUtil.UTF8cs; | import static org.cobbzilla.util.string.StringUtil.UTF8cs; | ||||
@@ -69,7 +70,7 @@ public class ShaUtil { | |||||
final CommandResult result; | final CommandResult result; | ||||
try { | try { | ||||
if (file.length() < SHA256_FILE_USE_SHELL_THRESHHOLD) return sha256_file_java(file); | if (file.length() < SHA256_FILE_USE_SHELL_THRESHHOLD) return sha256_file_java(file); | ||||
result = exec(new CommandLine("sha256sum").addArgument(abs(file), false)); | |||||
result = exec(shaCommand().addArgument(abs(file), false)); | |||||
if (result.isZeroExitStatus()) return split(result.getStdout(), " ").get(0); | if (result.isZeroExitStatus()) return split(result.getStdout(), " ").get(0); | ||||
} catch (Exception e) { | } catch (Exception e) { | ||||
@@ -80,6 +81,14 @@ public class ShaUtil { | |||||
return die("sha256sum_file: sha256sum "+abs(file)+" exited with status "+result.getExitStatus()+", stderr="+result.getStderr()+", exception="+result.getExceptionString()); | return die("sha256sum_file: sha256sum "+abs(file)+" exited with status "+result.getExitStatus()+", stderr="+result.getStderr()+", exception="+result.getExceptionString()); | ||||
} | } | ||||
private static CommandLine shaCommand() { | |||||
if (IS_OS_MAC) { | |||||
return new CommandLine("shasum").addArgument("-a").addArgument("256"); | |||||
} else { | |||||
return new CommandLine("sha256sum"); | |||||
} | |||||
} | |||||
public static String sha256_file_java(File file) { | public static String sha256_file_java(File file) { | ||||
try { | try { | ||||
@Cleanup final InputStream input = new FileInputStream(file); | @Cleanup final InputStream input = new FileInputStream(file); | ||||
@@ -258,7 +258,7 @@ public class CommandShell { | |||||
} | } | ||||
} | } | ||||
public static final long totalSystemMemory() { return HARDWARE.getMemory().getTotal(); } | |||||
public static long totalSystemMemory() { return HARDWARE.getMemory().getTotal(); } | |||||
public static String hostname () { return toString("hostname"); } | public static String hostname () { return toString("hostname"); } | ||||
public static String domainname() { return toString("hostname -d"); } | public static String domainname() { return toString("hostname -d"); } | ||||