public static bool IsRunningAsRoot() { if (ExternalCommandRunner.RunExternalCommand("whoami", string.Empty, out string username, out string _) == 0) { return(username.Trim().Equals("root")); } return(false); }
public static string GetOsVersion() { if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) { return(Environment.OSVersion.VersionString); } else if (RuntimeInformation.IsOSPlatform(OSPlatform.Linux) || RuntimeInformation.IsOSPlatform(OSPlatform.OSX)) { if (ExternalCommandRunner.RunExternalCommand("uname", "-r", out string StdOut, out string _) == 0) { return(StdOut); } } return(""); }
public static string GetOsName() { if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) { return(AsaHelpers.GetPlatformString()); } else if (RuntimeInformation.IsOSPlatform(OSPlatform.Linux) || RuntimeInformation.IsOSPlatform(OSPlatform.OSX)) { if (ExternalCommandRunner.RunExternalCommand("uname", "-s", out string StdOut, out string _) == 0) { return(StdOut); } } return(""); }