From 68d585a3b7310e111e5727c575338b43431e88a1 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=E9=99=88=E5=9B=BD=E4=BC=9F?= <366193849@qq.com>
Date: Fri, 12 Nov 2021 13:28:12 +0800
Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=AD=A3ReleasName=E5=88=A4=E6=96=AD?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
FastGithub.HttpServer/CaCertInstallerOfLinux.cs | 14 ++++++++------
.../CaCertInstallerOfLinuxCentOS.cs | 2 +-
.../CaCertInstallerOfLinuxDebian.cs | 2 +-
.../CaCertInstallerOfLinuxRedHat.cs | 2 +-
.../CaCertInstallerOfLinuxUbuntu.cs | 2 +-
5 files changed, 12 insertions(+), 10 deletions(-)
diff --git a/FastGithub.HttpServer/CaCertInstallerOfLinux.cs b/FastGithub.HttpServer/CaCertInstallerOfLinux.cs
index 12ceab3..12af24a 100644
--- a/FastGithub.HttpServer/CaCertInstallerOfLinux.cs
+++ b/FastGithub.HttpServer/CaCertInstallerOfLinux.cs
@@ -53,6 +53,7 @@ namespace FastGithub.HttpServer
}
catch (Exception ex)
{
+ File.Delete(destCertFilePath);
logger.LogWarning(ex.Message, "自动安装证书异常");
}
}
@@ -63,21 +64,22 @@ namespace FastGithub.HttpServer
///
///
///
- protected bool IsReleasName(string name)
+ protected static bool IsReleasName(string name)
{
if (File.Exists(OS_RELEASE_FILE) == false)
{
return false;
}
- var releaseLines = File.ReadAllLines(OS_RELEASE_FILE);
- if (releaseLines.Length == 0)
+ foreach (var line in File.ReadAllLines(OS_RELEASE_FILE))
{
- return false;
+ if (line.StartsWith("NAME=") && line.Contains(name))
+ {
+ return true;
+ }
}
- var nameLine = releaseLines[0];
- return nameLine.Contains(name);
+ return false;
}
}
}
\ No newline at end of file
diff --git a/FastGithub.HttpServer/CaCertInstallerOfLinuxCentOS.cs b/FastGithub.HttpServer/CaCertInstallerOfLinuxCentOS.cs
index 1600670..3ed7031 100644
--- a/FastGithub.HttpServer/CaCertInstallerOfLinuxCentOS.cs
+++ b/FastGithub.HttpServer/CaCertInstallerOfLinuxCentOS.cs
@@ -10,7 +10,7 @@ namespace FastGithub.HttpServer
///
public override bool IsSupported()
{
- return OperatingSystem.IsLinux() && base.IsReleasName("CentOS");
+ return OperatingSystem.IsLinux() && IsReleasName("CentOS");
}
}
}
\ No newline at end of file
diff --git a/FastGithub.HttpServer/CaCertInstallerOfLinuxDebian.cs b/FastGithub.HttpServer/CaCertInstallerOfLinuxDebian.cs
index 3a7cf08..802fdf9 100644
--- a/FastGithub.HttpServer/CaCertInstallerOfLinuxDebian.cs
+++ b/FastGithub.HttpServer/CaCertInstallerOfLinuxDebian.cs
@@ -14,7 +14,7 @@ namespace FastGithub.HttpServer
///
public override bool IsSupported()
{
- return OperatingSystem.IsLinux() && base.IsReleasName("Debian");
+ return OperatingSystem.IsLinux() && IsReleasName("Debian");
}
}
}
\ No newline at end of file
diff --git a/FastGithub.HttpServer/CaCertInstallerOfLinuxRedHat.cs b/FastGithub.HttpServer/CaCertInstallerOfLinuxRedHat.cs
index 28f908f..cfa0441 100644
--- a/FastGithub.HttpServer/CaCertInstallerOfLinuxRedHat.cs
+++ b/FastGithub.HttpServer/CaCertInstallerOfLinuxRedHat.cs
@@ -14,7 +14,7 @@ namespace FastGithub.HttpServer
///
public override bool IsSupported()
{
- return OperatingSystem.IsLinux() && base.IsReleasName("Red Hat");
+ return OperatingSystem.IsLinux() && IsReleasName("Red Hat");
}
}
}
\ No newline at end of file
diff --git a/FastGithub.HttpServer/CaCertInstallerOfLinuxUbuntu.cs b/FastGithub.HttpServer/CaCertInstallerOfLinuxUbuntu.cs
index d94b3e1..fa0371a 100644
--- a/FastGithub.HttpServer/CaCertInstallerOfLinuxUbuntu.cs
+++ b/FastGithub.HttpServer/CaCertInstallerOfLinuxUbuntu.cs
@@ -10,7 +10,7 @@ namespace FastGithub.HttpServer
///
public override bool IsSupported()
{
- return OperatingSystem.IsLinux() && base.IsReleasName("Ubuntu");
+ return OperatingSystem.IsLinux() && IsReleasName("Ubuntu");
}
}
}
\ No newline at end of file