diff --git a/TeslaLogger/Program.cs b/TeslaLogger/Program.cs index cb39d244a..72e6f702e 100644 --- a/TeslaLogger/Program.cs +++ b/TeslaLogger/Program.cs @@ -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 { @@ -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(() => diff --git a/TeslaLogger/Tools.cs b/TeslaLogger/Tools.cs index 80fdc4c36..6a95cc194 100644 --- a/TeslaLogger/Tools.cs +++ b/TeslaLogger/Tools.cs @@ -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"); } diff --git a/TeslaLogger/UpdateTeslalogger.cs b/TeslaLogger/UpdateTeslalogger.cs index 3c08da737..a68277252 100644 --- a/TeslaLogger/UpdateTeslalogger.cs +++ b/TeslaLogger/UpdateTeslalogger.cs @@ -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 @@ -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() {