simplified behavior and removed functions which should be managed manually

This commit is contained in:
root 2019-07-19 05:17:27 +02:00
parent 8d1640aa44
commit ffccea8480
2 changed files with 3 additions and 42 deletions

View File

@ -173,40 +173,5 @@ namespace LetsEncrypt
} }
} }
} }
public static string RestoreCon(string cmd)
{
var escapedArgs = cmd.Replace("\"", "\\\"");
var process = new Process()
{
StartInfo = new ProcessStartInfo
{
FileName = "restorecon",
Arguments = $"-v \"{escapedArgs}\"",
RedirectStandardOutput = true,
UseShellExecute = false,
CreateNoWindow = true,
}
};
process.Start();
string result = process.StandardOutput.ReadToEnd();
process.WaitForExit();
return result;
}
} }
} }

View File

@ -68,6 +68,7 @@ namespace LetsEncrypt
Console.WriteLine("Certificate and Key exists and valid."); Console.WriteLine("Certificate and Key exists and valid.");
} }
else { else {
//check if folder for the site exists
if(!Directory.Exists(Path.Combine(settings.www, site.name))) { if(!Directory.Exists(Path.Combine(settings.www, site.name))) {
throw new DirectoryNotFoundException(string.Format("Site {0} wasn't initialized", site.name)); throw new DirectoryNotFoundException(string.Format("Site {0} wasn't initialized", site.name));
} }
@ -88,10 +89,10 @@ namespace LetsEncrypt
//ensure to enable static file discovery on server in .well-known/acme-challenge //ensure to enable static file discovery on server in .well-known/acme-challenge
//and listen on 80 port //and listen on 80 port
//create acme directory for web site //check acme directory of the web site
string acme = Path.Combine(settings.www, site.name, settings.acme); string acme = Path.Combine(settings.www, site.name, settings.acme);
if(!Directory.Exists(acme)) { if(!Directory.Exists(acme)) {
Directory.CreateDirectory(acme); throw new DirectoryNotFoundException(string.Format("Directory {0} wasn't created", acme));
} }
foreach (FileInfo file in new DirectoryInfo(acme).GetFiles()) foreach (FileInfo file in new DirectoryInfo(acme).GetFiles())
@ -104,13 +105,8 @@ namespace LetsEncrypt
string token = Path.Combine(acme, splitToken[0]); string token = Path.Combine(acme, splitToken[0]);
File.WriteAllText(token, splitToken[1]); File.WriteAllText(token, splitToken[1]);
//for Selinux on centos7
Console.WriteLine(Library.RestoreCon(token));
} }
break; break;
} }