-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path_Main.cs
63 lines (53 loc) · 1.78 KB
/
_Main.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
using BSS.Logging;
using Renci.SshNet;
using System;
namespace CertBotHelper
{
internal static partial class Program
{
private static void Main(String[] args)
{
String assemblyPath = Log.Initialize();
if (!LoadConfig(assemblyPath, out Configuration configuration))
{
Environment.Exit(-1);
}
//
if (!ConnectSftp(ref configuration, out SftpClient sftpClient))
{
Environment.Exit(-1);
}
if (!PerformCertificateRenewal(sftpClient, ref configuration))
{
sftpClient.Dispose();
Environment.Exit(-1);
}
if (!DownloadCertificates(sftpClient, ref configuration))
{
sftpClient.Dispose();
Environment.Exit(-1);
}
if (!RemoveDownloadedCertificatesFromRemoteLocation(sftpClient, ref configuration))
{
sftpClient.Dispose();
Environment.Exit(-1);
}
try
{
sftpClient.Disconnect();
sftpClient.Dispose();
Log.FastLog("Disconnected from server", LogSeverity.Info, "SftpClient");
}
catch (Exception exception)
{
Log.FastLog($"An error occurred disconnecting from the server\n{exception.Message}", LogSeverity.Warning, "SftpClient");
sftpClient.Dispose();
}
if (!SignalNginxReload(ref configuration))
{
Environment.Exit(-1);
}
Log.FastLog($"All done", LogSeverity.Info, "Main");
}
}
}