Skip to content

Commit

Permalink
Utility method for yum package manager detection
Browse files Browse the repository at this point in the history
  • Loading branch information
jjxtra committed Nov 20, 2020
1 parent 155961f commit c7a8c02
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions IPBanCore/Core/Utility/OSUtility.cs
Original file line number Diff line number Diff line change
Expand Up @@ -90,12 +90,18 @@ public class OSUtility
/// </summary>
public static string Description { get; private set; }

/// <summary>
/// Whether the OS uses the yum package manager (Linux only). If false, apt is used, if true yum is used.
/// </summary>
public static bool UsesYumPackageManager { get; private set; }

private static readonly string tempFolder;

private static bool isWindows;
private static bool isLinux;
private static bool isMac;


private static string processVerb;

static OSUtility()
Expand Down Expand Up @@ -196,6 +202,11 @@ private static void LoadVersionFromLinux()
Version = ExtractRegex(versionText, "^Version_Id=(?<value>.+)$", Version);
}
}

UsesYumPackageManager = FriendlyName.Contains("centos", StringComparison.OrdinalIgnoreCase) ||
OSUtility.FriendlyName.Contains("fedora", StringComparison.OrdinalIgnoreCase) ||
OSUtility.FriendlyName.Contains("red hat", StringComparison.OrdinalIgnoreCase) ||
OSUtility.FriendlyName.Contains("redhat", StringComparison.OrdinalIgnoreCase);
}

private static void LoadVersionFromWindows()
Expand Down

0 comments on commit c7a8c02

Please sign in to comment.