public static ZpoolModel[] GetPools() { var result = CommonProcess.Execute(zpoolFileLocation, "list").ToArray(); if (result.Length < 1) { return(new ZpoolModel[0]); } if (result[0].Contains(zpoolEmptyMessage)) { return(new ZpoolModel[0]); } var pools = new ZpoolModel[result.Length]; for (var i = 0; i < pools.Length; i++) { var currentData = result[i].Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries); pools[i] = new ZpoolModel { Name = currentData[0], Size = currentData[1], Alloc = currentData[2], Free = currentData[3], Expandsz = currentData[4], Frag = currentData[5], Cap = currentData[6], Dedup = currentData[7], Health = currentData[8], Altroot = currentData[9], Status = Bash.Execute($"zpool status {currentData[0]}") }; } return(pools); }
public void GenerateReport() { DirectoryWithAcl.CreateDirectory(ReportDir, "755", "root", "wheel"); try { var lines = new List <string> { "+================================+", $"| Antd Report @ {DateTime.Now:yyyy-MM-dd} |", "+================================+", "", Bash.Execute("uname -a"), $"uptime: {Bash.Execute("uptime | awk -F ',' '{print $1 $2}'").Trim()}", $"processes: {Bash.Execute("ps -aef | wc | awk -F ' ' '{ print $1 }'").Trim()}", $"users logged: {Bash.Execute("who | awk -F ' ' '{print $1}' |sort -u | wc |awk -F ' ' '{print $1}'").Trim()}", $"sessions open: {Bash.Execute("who | sort -u | wc |awk -F ' ' '{print $1}'").Trim()}", $"load: {Bash.Execute("uptime | awk -F ',' '{print $4 $5 $6}' | awk -F ':' '{print $2}'").Trim()}", "" }; lines.AddRange(GetSecurityReport()); FileWithAcl.WriteAllLines($"{ReportDir}/{Timestamp.Now}-antd-report.txt", lines, "644", "root", "wheel"); } catch (Exception ex) { ConsoleLogger.Error($"unable to create the log report: {ex.Message}"); } }
public static List <string> History() { var obj = Bash.Execute("zpool history"); var list = obj.Split(new[] { Environment.NewLine }, StringSplitOptions.RemoveEmptyEntries); return(list.ToList()); }
private static bool IsTargetActive() { var bash = new Bash(); var result = bash.Execute("systemctl is-active tt.target"); return(result.Trim() == "active"); }
public IEnumerable <string> GetAllLogSinceHour(string hours) { var cmd = $"journalctl --no-pager --quiet --since='{hours}h ago'"; var result = Bash.Execute(cmd); return(result.Split(new[] { Environment.NewLine }, StringSplitOptions.RemoveEmptyEntries)); }
public bool IsActive(string ttName) { var bash = new Bash(); var result = bash.Execute($"systemctl is-active {ttName}.target"); return(result.Trim() == "active"); }
public void Remove(string name) { var bash = new Bash(); bash.Execute($"systemctl stop {name}.target", false); var timerFile = $"{TargetDirectory}/{name}.target"; if (File.Exists(timerFile)) { File.Delete(timerFile); } bash.Execute($"systemctl stop {name}.service", false); var serviceFile = $"{TargetDirectory}/{name}.service"; if (File.Exists(serviceFile)) { File.Delete(serviceFile); } var schedulerConfiguration = new TimerConfiguration(); var tryget = schedulerConfiguration.Get().Timers.FirstOrDefault(_ => _.Alias == name); if (tryget != null) { schedulerConfiguration.RemoveTimer(tryget.Guid); } bash.Execute("systemctl daemon-reload", false); }
public static IEnumerable <SystemComponentModel> GetSystemComponentModels() { var repoSystem = Parameter.RepoSystem; var actives = Directory.EnumerateFileSystemEntries(repoSystem).Where(_ => _.Contains("active-")).ToList(); var repoKernel = Parameter.RepoKernel; actives.AddRange(Directory.EnumerateFileSystemEntries(repoKernel).Where(_ => _.Contains("active-")).ToList()); var components = new List <SystemComponentModel>(); var losetup = GetLosetup().ToList(); foreach (var file in actives) { var alias = file.SplitToList("-").LastOrDefault(); var dir = file.SplitToList("active-").LastOrDefault(); var active = Bash.Execute($"file {file}").SplitToList("symbolic link to ").LastOrDefault(); var recovery = Bash.Execute($"file {file.Replace("active", "recovery")}").SplitToList(":").LastOrDefault()?.Replace("symbolic link to", ""); var hash = File.Exists(dir + "/" + active) ? GetFileHash(dir + "/" + active) : ""; var running = losetup.Any(_ => _.Hash == hash && _.Backfile == dir + "/" + active) ? "1" : "0"; var comp = new SystemComponentModel { Alias = alias, Active = active, Recovery = recovery, Running = running }; components.Add(comp); } return(components); }
protected void AdbRun(string path, System.Action <int> onDoneCallback) { this.FixAppPath(ref CustomBuild.adbPath, "adb"); string adbCmd = "'" + CustomBuild.adbPath + "adb'"; #if UNITY_5_6_OR_NEWER string adbArgs = "shell am start -n '" + PlayerSettings.applicationIdentifier + "/" + CustomBuild.mainActivityPath + "'"; #else string adbArgs = "shell am start -n '" + PlayerSettings.bundleIdentifier + "/" + CustomBuild.mainActivityPath + "'"; #endif string cmdPath = "'" + path + "/" + PlayerSettings.productName + "'"; Terminal terminal = null; if (TERMINAL_CHOSEN == CMD_LOCATION) { terminal = new CMD(); } else { terminal = new Bash(); } terminal.RunCommand(2, adbCmd, adbArgs, cmdPath, false, onDoneCallback); }
public IEnumerable <VirtualMachineInfo> GetVmList() { var vms = new List <VirtualMachineInfo>(); var res = Bash.Execute("virsh list --all | sed '1,2d'"); if (res.Length < 1) { return(vms); } var virshVms = res.Split(new[] { Environment.NewLine }, 3, StringSplitOptions.RemoveEmptyEntries); foreach (var i in virshVms) { var info = i.Split(new[] { " " }, StringSplitOptions.RemoveEmptyEntries); var vm = new VirtualMachineInfo { Id = info[0], Domain = info[1], State = info[2], }; var vnc = GetVmVncAddress(vm.Domain); vm.VncIp = vnc.Key; vm.VncPort = vnc.Value; vms.Add(vm); } return(vms); }
private static string[] GetPhysicalInterfaces() { var ifList = new List <string>(); var bash = new Bash(); var list = bash.Execute("ls -la /sys/class/net").SplitBash().Where(_ => _.Contains("->")); foreach (var f in list) { if (f.Contains("bond")) { } else if (f.Contains("br")) { } else if (f.Contains("virtual/net") || f.Contains("platform")) { } else if (!f.Contains("virtual/net")) { var name = f.Print(9, " "); ifList.Add(name.Trim()); } } return(ifList.ToArray()); }
public static void Aossvc(bool forced, bool unitsOnly) { Console.WriteLine(); _publicRepositoryUrlHttps = GetReferenceServer("https"); Console.WriteLine($"repo = {_publicRepositoryUrlHttps}"); CleanTmp(); _publicRepositoryUrlHttps = GetReferenceServer("https"); var sourceUrl = $"{_publicRepositoryUrlHttps}/aossvc.exe"; const string destinationPath = "/usr/sbin/aossvc.exe"; var download = new FileDownloader(sourceUrl, destinationPath).DownloadFile(); if (download != true) { Console.WriteLine($"An error occurred downloading {sourceUrl}, download process error"); return; } var svcUrl = $"{_publicRepositoryUrlHttps}/aossvc.service"; const string svcBin = "/usr/lib/systemd/system/aossvc.service"; var download2 = new FileDownloader(svcUrl, svcBin).DownloadFile(); if (download2 != true) { Console.WriteLine($"An error occurred downloading {svcUrl}, download process error"); return; } Bash.Execute("systemctl daemon-reload"); Bash.Execute("systemctl start aossvc.service"); CleanTmp(); Console.WriteLine(); }
public string[] ChecCrl() { var bash = new Bash(); var crl = $"{_caIntermediateDirectory}/crl/intermediate.crl.pem"; return(bash.Execute($"openssl crl -in {crl} -noout -text").SplitBash().ToArray()); }
private static void RestartAntdsh() { Target.Setup(); Units.CreateRemountUnits(); Bash.Execute("systemctl restart tt-antdsh-01-remount.timer"); Environment.Exit(0); }
public void Antd(bool forced, bool unitsOnly) { _publicRepositoryUrlHttps = GetRandomServer("http"); Console.WriteLine($"repo = {_publicRepositoryUrlHttps}"); Bash.Execute($"rm -fR {TmpDirectory}; mkdir -p {TmpDirectory}"); Directory.CreateDirectory(AntdDirectory); Directory.CreateDirectory(AntdUiDirectory); if (unitsOnly) { UpdateUnits(UpdateVerbForUnits, UnitsTargetApp, "-AppAntdUi."); UpdateUnits(UpdateVerbForUnits, UnitsTargetApp, "-AppAntd."); RestartAntdUi(); RestartAntd(); return; } UpdateContext(UpdateVerbForAntdUi, AntdUiActive, AntdUiDirectory, forced); UpdateUnits(UpdateVerbForUnits, UnitsTargetApp, "-AppAntdUi."); RestartAntdUi(); UpdateContext(UpdateVerbForAntd, AntdActive, AntdDirectory, forced); UpdateUnits(UpdateVerbForUnits, UnitsTargetApp, "-AppAntd."); RestartAntd(); Bash.Execute("systemctl daemon-reload"); Bash.Execute("systemctl restart antd.target"); Bash.Execute($"rm -fR {TmpDirectory}; mkdir -p {TmpDirectory}"); }
public static void Backup(string dir) { var acls = Bash.Execute($"getfacl -R {dir}").SplitBash(); var destination = SetAclBackupFilePath(dir); FileWithAcl.WriteAllLines(destination, acls, "644", "root", "wheel"); }
public void CreateServerCertificate(string name, string passphrase, string email, string c, string st, string l, string o, string ou) { var bash = new Bash(); var config = $"{_caIntermediateDirectory}/openssl.cnf"; var key = $"{_caIntermediateDirectory}/private/{name}.key.pem"; if (!File.Exists(key)) { bash.Execute($"openssl genrsa -aes256 -out {key} -passout pass:{passphrase} 2048"); bash.Execute($"chmod 400 ${key}"); } var csr = $"{_caIntermediateDirectory}/csr/{name}.csr.pem"; if (!File.Exists(key)) { bash.Execute($"openssl req -config {config} -key {key} -new -sha256 -out {csr} -passin pass:{passphrase} -subj \"/C={c}/ST={st}/L={l}/O={o}/OU={ou}/CN={name}/emailAddress={email}\""); } var cert = $"{_caIntermediateDirectory}/certs/{name}.cert.pem"; if (!File.Exists(cert)) { bash.Execute($"openssl ca -config {config} -extensions server_cert -days 375 -notext -md sha256 -in {csr} -out {cert}"); bash.Execute($"chmod 444 ${cert}"); } }
/// <summary> /// 08 - se ve tutto bene antd si avvia in automatico al riavvio, la prima cosa che fa è create le units di sistema /// </summary> public void CreateUnitsForSystem() { Console.WriteLine("Setting system units"); Console.WriteLine("Reload daemon now..."); Bash.Execute("systemctl daemon-reload"); }
public List <ZfsSnapModel> List() { var bash = new Bash(); var result = bash.Execute("zfs list -t snap"); var list = new List <ZfsSnapModel>(); if (string.IsNullOrEmpty(result)) { return(list); } var lines = result.Split(new[] { Environment.NewLine }, StringSplitOptions.RemoveEmptyEntries).ToList().Skip(1); foreach (var line in lines) { var cells = Regex.Split(line, @"\s+"); var model = new ZfsSnapModel { Guid = Guid.NewGuid().ToString(), Name = cells[0], Used = cells[1], Available = cells[2], Refer = cells[3], Mountpoint = cells[4] }; list.Add(model); } return(list); }
/// <summary> /// 09 - controlla la cartella /mnt/cdrom/DIRS e monta il suo contenuto /// todo: crea file o cartelle se non ci sono /// </summary> public void SetAndMountDirs() { Console.WriteLine("Mounting directories and files: "); var directories = Directory.EnumerateDirectories(Parameter.RepoDirs).Where(d => !d.Contains(".ori")); foreach (var t in directories) { var path = Path.GetFileName(t); if (path == null) { continue; } var newPath = path.Replace("_", "/"); Console.WriteLine($"{t} mounted on {newPath}"); Bash.Execute($"mount --bind {t} {newPath}"); } var files = Directory.EnumerateFiles(Parameter.RepoDirs).Where(f => !f.Contains(".ori")); foreach (var t in files) { var path = Path.GetFileName(t); if (path == null) { continue; } var newPath = path.Replace("_", "/"); Console.WriteLine($"{t} mounted on {newPath}"); Bash.Execute($"mount --bind {t} {newPath}"); } }
public JsonResult Start(AntiVirus av) { #region Демо режим if (Platform.IsDemo) { return(Json(new Text("Операция недоступна в демо-режиме"))); } #endregion #region Проверяем поля if (AntiVirus.IsRun(0)) { return(Json(new Text("Антивирус уже запущен"))); } if (string.IsNullOrWhiteSpace(av.path)) { return(Json(new Text("Укажите каталог для сканирования"))); } if (!System.IO.File.Exists(av.php)) { return(Json(new Text($"Отсутствует исполняемый файл '{av.php}'"))); } #endregion #region Создаем команду StringBuilder comand = new StringBuilder(); comand.Append($"--path={av.path} "); if (!string.IsNullOrWhiteSpace(av.skip)) { comand.Append($"--skip={av.skip} "); } if (!string.IsNullOrWhiteSpace(av.scan)) { comand.Append($"--scan={av.scan} "); } comand.Append($"--mode={(av.mode == 1 ? 1 : 2)} "); comand.Append($"--memory={av.memory}M "); comand.Append($"--size={av.size}K "); comand.Append($"--delay={av.delay} "); #endregion // Имя отчета string report = $"{AntiVirus.name}_{AntiVirus.vers}_{DateTime.Now.ToString("HH-mm_dd-MM-yyy")}{av.path.Replace("/", "_-_")}"; // Trigger.OnStart(("0", report)); // Запускаем процесс bash Bash bash = new Bash(); bash.Run($"{av.php} {Folders.AV}/ai-bolit.php {comand.ToString()} --progress={Folders.AV}/progress_id-0.json --report={Folders.ReportsAV}/{report}.html >/dev/null 2>/dev/null &"); bash.Run("sleep 3"); // Отдаем результат return(Json(new TrueOrFalse(true))); }
public static void CreateSmartCardCertificate(string name, string passphrase, string upn, string email, string c, string st, string l, string o, string ou) { var config = $"{CaIntermediateDirectory}/{name}.openssl.cnf"; if (!File.Exists(config)) { var applicationSetting = new AppConfiguration().Get(); FileWithAcl.WriteAllLines(config, CaConfigurationFiles.IntermediateCaSmartCardOpensslCnf( CaIntermediateDirectory, $"http://{GetThisIp()}:{applicationSetting.AntdPort}/services/ca/crl", upn ), "644", "root", "wheel"); } var key = $"{CaIntermediateDirectory}/private/{name}.key.pem"; if (!File.Exists(key)) { Bash.Execute($"openssl genrsa -aes256 -out {key} -passout pass:{passphrase} 2048"); Bash.Execute($"chmod 400 ${key}"); } var csr = $"{CaIntermediateDirectory}/csr/{name}.csr.pem"; if (!File.Exists(key)) { Bash.Execute($"openssl req -config {config} -key {key} -new -sha256 -out {csr} -passin pass:{passphrase} -subj \"/C={c}/ST={st}/L={l}/O={o}/OU={ou}/CN={name}/emailAddress={email}\""); } var cert = $"{CaIntermediateDirectory}/certs/{name}.cert.pem"; if (!File.Exists(cert)) { Bash.Execute($"openssl ca -config {config} -extensions usr_cert -days 375 -notext -md sha256 -in {csr} -out {cert}"); Bash.Execute($"chmod 444 ${cert}"); } }
/// <summary> /// Lista effettiva degli snapshot da rimuovere /// Viene generata partendo dalla lista completa degli snapshot dopo essere stata filtrata secondo le Regole definite sotto /// </summary> public HashSet <string> GetRemovableSnapshots(IEnumerable <string> t = null) { var snapshots = new List <Model>(); var text = Bash.Execute("zfs list -t snap -o name,used -p"); var lines = t ?? text.Split(new[] { Environment.NewLine }, StringSplitOptions.RemoveEmptyEntries).Skip(1); foreach (var line in lines) { var snap = new Model(); var attr = line.Split(new[] { " " }, StringSplitOptions.RemoveEmptyEntries); try { snap.Name = attr[0]; snap.PoolName = attr[0].Split('@').FirstOrDefault(); snap.Dimension = Convert.ToInt64(attr[1]); snap.Created = GetSnapshotDate(snap.Name); snapshots.Add(snap); } catch (Exception ex) { Console.WriteLine(ex); } } var list = new HashSet <string>(); var snapshotGroups = snapshots.GroupBy(_ => _.PoolName); foreach (var snpgrp in snapshotGroups) { var filter = Filter(snpgrp); foreach (var snp in filter) { list.Add(snp.Name); } } return(list); }
public AuthorizedKeysModule() { Post["/ak/create"] = x => { string remoteUser = Request.Form.RemoteUser; string user = Request.Form.User; string key = Request.Form.Key; var model = new AuthorizedKeyModel { RemoteUser = remoteUser, User = user, KeyValue = key }; var authorizedKeysConfiguration = new AuthorizedKeysConfiguration(); authorizedKeysConfiguration.AddKey(model); var home = user == "root" ? "/root/.ssh" : $"/home/{user}/.ssh"; var authorizedKeysPath = $"{home}/authorized_keys"; if (!File.Exists(authorizedKeysPath)) { File.Create(authorizedKeysPath); } var line = $"{key} {remoteUser}"; File.AppendAllLines(authorizedKeysPath, new List <string> { line }); var bash = new Bash(); bash.Execute($"chmod 600 {authorizedKeysPath}", false); bash.Execute($"chown {user}:{user} {authorizedKeysPath}", false); return(HttpStatusCode.OK); }; Get["/ak/introduce"] = x => { var remoteHost = Request.Query.Host; var remoteUser = $"{Environment.UserName}@{Environment.MachineName}"; Console.WriteLine(remoteUser); string user = Request.Query.User; string key = Request.Query.Key; var dict = new Dictionary <string, string> { { "RemoteUser", remoteUser }, { "User", user }, { "Key", key } }; var r = new ApiConsumer().Post($"http://{remoteHost}/ak/create", dict); return(r); }; Post["/ak/introduce"] = x => { var remoteHost = Request.Form.Host; var remoteUser = $"{Environment.UserName}@{Environment.MachineName}"; Console.WriteLine(remoteUser); string user = Request.Form.User; string key = Request.Form.Key; var dict = new Dictionary <string, string> { { "RemoteUser", remoteUser }, { "User", user }, { "Key", key } }; var r = new ApiConsumer().Post($"http://{remoteHost}/ak/create", dict); return(r); }; }
//private static readonly Dfp _dfp = new Dfp(); //private static void CheckMount(string directory) { // var isMntd = MountHelper.IsAlreadyMounted(directory); // var mntDirectory = MountHelper.SetDirsPath(directory); // var timestampNow = Timestamp.Now; // _dfp.Set(mntDirectory, timestampNow); // _dfp.Set(directory, timestampNow); // var dirsTimestamp = _dfp.GetTimestamp(mntDirectory); // var dirsDfp = dirsTimestamp != null; // var directoryTimestamp = _dfp.GetTimestamp(directory); // var directoryDfp = directoryTimestamp != null; // if(isMntd && directoryTimestamp == "unauthorizedaccessexception" && dirsTimestamp == "unauthorizedaccessexception") { // MountRepository.SetAsMountedReadOnly(directory); // } // else if(isMntd && dirsDfp && directoryDfp) { // if(dirsTimestamp == directoryTimestamp) { // MountRepository.SetAsMounted(directory, mntDirectory); // } // else { // MountRepository.SetAsDifferentMounted(directory); // } // } // else if(isMntd == false && dirsDfp && directoryDfp == false) { // MountRepository.SetAsNotMounted(directory); // } // else if(isMntd && dirsDfp == false && directoryDfp) { // MountRepository.SetAsTmpMounted(directory); // } // else if(isMntd == false && dirsDfp == false && directoryDfp == false) { // MountRepository.SetAsError(directory); // } // else { // MountRepository.SetAsError(directory); // } // _dfp.Delete(mntDirectory); // _dfp.Delete(directory); //} private static void SetBind(string source, string destination) { if (MountHelper.IsAlreadyMounted(source, destination)) { return; } Bash.Execute($"mount -o bind {source} {destination}", false); }
public static bool VerifyRootCertificate() { //openssl x509 -noout -text -in certs/ca.cert.pem var file = $"{CaMainDirectory}/certs/ca.cert.pem"; Bash.Execute($"openssl x509 -noout -text -in {file}"); return(true); }
private static void RestartAntd() { Bash.Execute("systemctl daemon-reload"); Bash.Execute("systemctl stop app-antd-03-launcher.service"); Bash.Execute("systemctl stop framework-antd.mount"); Bash.Execute("systemctl restart app-antd-02-mount.service"); Bash.Execute("systemctl restart app-antd-03-launcher.service"); }
//private static void UmountAll() { // Console.WriteLine("Unmounting Antd"); // while(true) { // if(File.Exists("/proc/mounts")) { // var procMounts = File.ReadAllLines("/proc/mounts"); // if(procMounts.Any(_ => _.Contains("/antd"))) // return; // Bash.Execute($"umount {Parameter.AntdCfg}"); // Bash.Execute($"umount {Parameter.AntdCfgDatabase}"); // Bash.Execute("umount /framework/antd"); // } // } //} private static void StatusFunc(string[] args) { var res = Bash.Execute("ps -aef").Split().Grep("Antd.exe"); Console.WriteLine(res.Any() ? "Antd is running." : "Antd is NOT running"); Console.WriteLine(""); Console.WriteLine(Bash.Execute("systemctl status ")); }
private static void InstallDownloadedFile(string latestTmpFilePath, string newVersionPath, string activeVersionPath) { File.Copy(latestTmpFilePath, newVersionPath, true); File.Delete(activeVersionPath); Bash.Execute($"ln -s {Path.GetFileName(newVersionPath)} {activeVersionPath}"); Bash.Execute($"chown root:wheel {newVersionPath}"); Bash.Execute($"chmod 644 {newVersionPath}"); }
public AntdTimeModule() { Get["/time/info"] = x => { const StringSplitOptions ssoree = StringSplitOptions.RemoveEmptyEntries; var bash = new Bash(); var launcher = new CommandLauncher(); var hostConfiguration = new HostConfiguration(); var timezones = bash.Execute("timedatectl list-timezones --no-pager").SplitBash(); var timedatectl = launcher.Launch("timedatectl").ToList(); var ntpd = launcher.Launch("cat-etc-ntp").ToArray(); var model = new PageTimeModel { Timezones = timezones, LocalTime = timedatectl.First(_ => _.Contains("Local time:")).Split(new[] { ":" }, 2, ssoree)[1], UnivTime = timedatectl.First(_ => _.Contains("Universal time:")).Split(new[] { ":" }, 2, ssoree)[1], RtcTime = timedatectl.First(_ => _.Contains("RTC time:")).Split(new[] { ":" }, 2, ssoree)[1], Timezone = timedatectl.First(_ => _.Contains("Time zone:")).Split(new[] { ":" }, 2, ssoree)[1], Nettimeon = timedatectl.First(_ => _.Contains("Network time on:")).Split(new[] { ":" }, 2, ssoree)[1], Ntpsync = timedatectl.First(_ => _.Contains("NTP synchronized:")).Split(new[] { ":" }, 2, ssoree)[1], Rtcintz = timedatectl.First(_ => _.Contains("RTC in local TZ:")).Split(new[] { ":" }, 2, ssoree)[1], NtpServer = hostConfiguration.Host.NtpdateServer.StoredValues["$server"], Ntpd = ntpd.JoinToString("<br />"), NtpdEdit = ntpd.JoinToString(Environment.NewLine) }; return(JsonConvert.SerializeObject(model)); }; Post["/host/timezone"] = x => { string timezone = Request.Form.Timezone; var hostconfiguration = new HostConfiguration(); hostconfiguration.SetTimezone(timezone); hostconfiguration.ApplyTimezone(); return(HttpStatusCode.OK); }; Post["/host/synctime"] = x => { var hostconfiguration = new HostConfiguration(); hostconfiguration.SyncClock(); return(HttpStatusCode.OK); }; Post["/host/ntpdate"] = x => { string ntpdate = Request.Form.Ntpdate; var hostconfiguration = new HostConfiguration(); hostconfiguration.SetNtpdate(ntpdate); hostconfiguration.ApplyNtpdate(); return(HttpStatusCode.OK); }; Post["/host/ntpd"] = x => { string ntpd = Request.Form.Ntpd; var hostConfiguration = new HostConfiguration(); hostConfiguration.SetNtpd(ntpd.Contains("\n") ? ntpd.SplitToList("\n").ToArray() : ntpd.SplitToList(Environment.NewLine).ToArray()); hostConfiguration.ApplyNtpd(); return(HttpStatusCode.OK); }; }