mirror of
https://github.com/PhotonVision/photonvision
synced 2026-06-20 00:51:41 +00:00
Continued rework of networking, added root check
This commit is contained in:
@@ -1,10 +1,14 @@
|
||||
package com.chameleonvision.settings;
|
||||
|
||||
import com.chameleonvision.util.ShellExec;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
public enum Platform {
|
||||
WINDOWS_64("Windows x64"),
|
||||
LINUX_64("Linux x64"),
|
||||
LINUX_RASPBIAN("Linux Raspbian"),
|
||||
LINUX_AARCH64("Linux ARM 64bit"),
|
||||
LINUX_AARCH64("Linux For Tegra"),
|
||||
MACOS_64("Mac OS x64"),
|
||||
UNSUPPORTED("Unsupported Platform");
|
||||
|
||||
@@ -26,6 +30,29 @@ public enum Platform {
|
||||
return this == MACOS_64;
|
||||
}
|
||||
|
||||
private static ShellExec shell = new ShellExec(true, false);
|
||||
|
||||
public boolean isRoot() {
|
||||
if (isLinux() || isMac()) {
|
||||
try {
|
||||
shell.execute("id", null, true, "-u");
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
while (!shell.isOutputCompleted()) {}
|
||||
if (shell.getExitCode() == 0) {
|
||||
var out = shell.getOutput();
|
||||
out = out.split("\n")[0];
|
||||
return out.equals("0");
|
||||
}
|
||||
} else if (isWindows()) {
|
||||
return true;
|
||||
} else {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public static Platform getCurrentPlatform() {
|
||||
var osName = System.getProperty("os.name");
|
||||
var osArch = System.getProperty("os.arch");
|
||||
|
||||
Reference in New Issue
Block a user