Beispiel #1
0
 public override void DoJob()
 {
     if (Application.CurrentConfiguration.TimeDate.SyncLocalClock)
     {
         Timedatectl.SyncClock();
     }
 }
Beispiel #2
0
 private static void Time()
 {
     Scheduler.ExecuteJob <SyncLocalClockJob>();
     Timedatectl.Apply();
     Ntp.Prepare();
     ConsoleLogger.Log("[time] ready");
 }
 public override void DoJob()
 {
     if (Application.CurrentConfiguration.TimeDate.SyncFromRemoteServer &&
         Application.CurrentConfiguration.TimeDate.RemoteNtpServer != string.Empty)
     {
         Timedatectl.SetNtpdate(Application.CurrentConfiguration.TimeDate.RemoteNtpServer);
     }
 }
Beispiel #4
0
        public TimeDateModule() : base("/timedate")
        {
            Get["/"] = x => {
                return(JsonConvert.SerializeObject(Application.CurrentConfiguration.TimeDate));
            };

            Get["/running"] = x => {
                return(JsonConvert.SerializeObject(Application.RunningConfiguration.TimeDate));
            };

            Post["/save"] = x => {
                string data    = Request.Form.Data;
                var    objects = JsonConvert.DeserializeObject <TimeDate>(data);
                Application.CurrentConfiguration.TimeDate = objects;
                ConfigRepo.Save();
                return(HttpStatusCode.OK);
            };

            Post["/apply"] = x => {
                Timedatectl.Apply();
                return(HttpStatusCode.OK);
            };
        }
Beispiel #5
0
        /// <summary>
        /// Ottiene un Master valorizzato coi valori ottenuti direttamente dal sistema operativo
        /// Potrebbe non corrispondere al Master salvato
        /// Viene utilizzato per ottenere le differenze tra i parametri salvati e quelli effettivamente applicati
        /// </summary>
        /// <returns></returns>
        public static MachineStatus GetRunning()
        {
            //var STOPWATCH = new System.Diagnostics.Stopwatch();
            //STOPWATCH.Start();
            var master = new MachineStatus();

            master.Info.Uptime    = Uptime.Get();
            master.Info.CpuInfo   = CpuInfo.Get();
            master.Info.MemInfo   = MemInfo.Get();
            master.Info.Free      = Free.Get();
            master.Info.Losetup   = Losetup.Get();
            master.Info.DiskUsage = DiskUsage.Get();
            master.Info.Versions  = Versioning.Get();

            master.Host     = Hostnamectl.Get();
            master.TimeDate = new TimeDate()
            {
                Timezone = Timedatectl.Get().Timezone
            };
            master.Boot = new Boot();
            var modules     = Mod.Get();
            var bootModules = new SystemModule[modules.Length];

            for (var i = 0; i < modules.Length; i++)
            {
                bootModules[i] = new SystemModule()
                {
                    Module = modules[i].Module, Active = true
                };
            }
            master.Boot.Modules           = bootModules;
            master.Boot.Services          = cmds.Systemctl.GetAll();
            master.Boot.Parameters        = Sysctl.Get();
            master.Users.SystemUsers      = Passwd.Get();
            master.Users.ApplicativeUsers = new ApplicativeUser[] { new ApplicativeUser()
                                                                    {
                                                                        Active = true, Type = AuthenticationType.simple, Id = "master", Claims = new[] { SHA.Generate("master") }
                                                                    } };

            master.Network.KnownDns          = Dns.GetResolv();
            master.Network.KnownHosts        = Dns.GetHosts();
            master.Network.KnownNetworks     = Dns.GetNetworks();
            master.Network.Bridges           = Brctl.Get();
            master.Network.Bonds             = Bond.Get();
            master.Network.NetworkInterfaces = cmds.Network.Get();
            master.Network.RoutingTables     = Route.GetRoutingTable();
            master.Network.Routing           = Route.Get();

            master.NsSwitch = NS.Switch.Get();

            master.Storage.Mounts       = Mount.Get();
            master.Storage.Zpools       = Zpool.GetPools();
            master.Storage.ZfsDatasets  = Zfs.GetDatasets();
            master.Storage.ZfsSnapshots = Zfs.GetSnapshots();

            master.Services.Ssh.PublicKey     = Ssh.GetRootPublicKey();
            master.Services.Ssh.PrivateKey    = Ssh.GetRootPrivateKey();
            master.Services.Ssh.AuthorizedKey = Ssh.GetAuthorizedKey();

            master.Services.Virsh.Domains = Virsh.GetDomains();

            //ConsoleLogger.Log($"[conf] loaded running conf ({STOPWATCH.ElapsedMilliseconds})");
            return(master);
        }