Skip to content

Commit

Permalink
Cert Update
Browse files Browse the repository at this point in the history
  • Loading branch information
bassmaster187 committed Jan 31, 2024
1 parent 5f96609 commit a2c61d9
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 1 deletion.
3 changes: 3 additions & 0 deletions TeslaLogger/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ internal class Program
public static int SQLTRACELIMIT = 250;
public static int KeepOnlineMinAfterUsage = 5;
public static int SuspendAPIMinutes = 30;
public static DateTime uptime = DateTime.Now;

public enum TLMemCacheKey
{
Expand Down Expand Up @@ -203,6 +204,8 @@ internal static void StartCarThread(DataRow r, Car.TeslaState oldCarState = Car.

private static void InitWebserver()
{
UpdateTeslalogger.CertUpdate();

try
{
Thread threadWebserver = new Thread(() =>
Expand Down
4 changes: 4 additions & 0 deletions TeslaLogger/Tools.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1479,6 +1479,10 @@ private static void CreateBackupForDocker()
if (!IsDocker())
return;

var ts = DateTime.Now - Program.uptime;
if (ts.TotalHours < 24)
return;

Logfile.Log("Start backup for Docker");
Tools.ExecMono("/bin/bash", "/etc/teslalogger/backup.sh");
}
Expand Down
16 changes: 15 additions & 1 deletion TeslaLogger/UpdateTeslalogger.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1066,7 +1066,7 @@ public static async void DownloadUpdateAndInstall()

Tools.ExecMono("rm", "-rf /etc/teslalogger/git");
Tools.ExecMono("mkdir", "/etc/teslalogger/git");
Tools.ExecMono("cert-sync", "/etc/ssl/certs/ca-certificates.crt");
CertUpdate();

// run housekeeping to make sure there is enough free disk space

Expand Down Expand Up @@ -1222,6 +1222,20 @@ public static async void DownloadUpdateAndInstall()
}
}

public static void CertUpdate()
{
try
{
Tools.ExecMono("sed", "-i 's/^mozilla\\/DST_Root_CA_X3.crt$/!mozilla\\/DST_Root_CA_X3.crt/' /etc/ca-certificates.conf");
Tools.ExecMono("update-ca-certificates", "");
Tools.ExecMono("cert-sync", "/etc/ssl/certs/ca-certificates.crt");
}
catch (Exception ex)
{
ex.ToExceptionless().FirstCarUserID().Submit();
Logfile.Log(ex.ToString());
}
}

private static void CheckBackupCrontab()
{
Expand Down

0 comments on commit a2c61d9

Please sign in to comment.