public virtual void Install(string serviceName) { _logger.Info("Installing service '{0}'", serviceName); var args = $"create {serviceName} " + $"DisplayName= \"{serviceName}\" " + $"binpath= \"{Process.GetCurrentProcess().MainModule.FileName}\" " + "start= auto " + "depend= EventLog/Tcpip/http " + "obj= \"NT AUTHORITY\\LocalService\""; _logger.Info(args); var installOutput = _processProvider.StartAndCapture("sc.exe", args); if (installOutput.ExitCode != 0) { _logger.Error($"Failed to install service: {installOutput.Lines.Select(x => x.Content).ConcatToString("\n")}"); throw new ApplicationException("Failed to install service"); } _logger.Info(installOutput.Lines.Select(x => x.Content).ConcatToString("\n")); var descOutput = _processProvider.StartAndCapture("sc.exe", $"description {serviceName} \"Radarr Application Server\""); if (descOutput.ExitCode != 0) { _logger.Error($"Failed to install service: {descOutput.Lines.Select(x => x.Content).ConcatToString("\n")}"); throw new ApplicationException("Failed to install service"); } _logger.Info(descOutput.Lines.Select(x => x.Content).ConcatToString("\n")); _logger.Info("Service Has installed successfully."); }
public override HealthCheck Check() { if (!OsInfo.IsMono) { return(new HealthCheck(GetType())); } var output = _processProvider.StartAndCapture("mono", "--version"); foreach (var line in output.Standard) { var versionMatch = VersionRegex.Match(line); if (versionMatch.Success) { var version = new Version(versionMatch.Groups["version"].Value); if (version >= new Version(3, 2)) { _logger.Debug("mono version is 3.2 or better: {0}", version.ToString()); return(new HealthCheck(GetType())); } } } return(new HealthCheck(GetType(), HealthCheckResult.Warning, "mono version is less than 3.2, upgrade for improved stability")); }
public override HealthCheck Check() { if (!PlatformInfo.IsMono) { return(new HealthCheck(GetType())); } // Don't warn on arm based synology - could be arm5 or something else rubbish if (_osInfo.Name == "DSM" && RuntimeInformation.ProcessArchitecture == Architecture.Arm) { return(new HealthCheck(GetType())); } // Don't warn on linux x86 - we don't build x86 net core if (OsInfo.IsLinux && RuntimeInformation.ProcessArchitecture == Architecture.X86) { return(new HealthCheck(GetType())); } // Check for BSD var output = _processProvider.StartAndCapture("uname"); if (output?.ExitCode == 0 && MonoUnames.Contains(output?.Lines.First().Content)) { return(new HealthCheck(GetType())); } return(new HealthCheck(GetType(), HealthCheckResult.Warning, "Please upgrade to the .NET Core version of Lidarr", "#update_to_net_core_version")); }
public override HealthCheck Check() { if (!PlatformInfo.IsMono) { return(new HealthCheck(GetType())); } // Don't warn on linux x86 - we don't build x86 net core if (OsInfo.IsLinux && RuntimeInformation.ProcessArchitecture == Architecture.X86) { return(new HealthCheck(GetType(), HealthCheckResult.Error, _localizationService.GetLocalizedString("Monox86SupportCheckMessage"), "mono_support_end_of_life")); } // Check for BSD var output = _processProvider.StartAndCapture("uname"); if (output?.ExitCode == 0 && MonoUnames.Contains(output?.Lines.First().Content)) { return(new HealthCheck(GetType(), HealthCheckResult.Error, string.Format(_localizationService.GetLocalizedString("MonoBSDSupportCheckMessage"), OsInfo.Os), "mono_support_end_of_life")); } return(new HealthCheck(GetType(), HealthCheckResult.Error, _localizationService.GetLocalizedString("MonoNotNetCoreCheckMessage"), "#update_to_net_core_version")); }
public override HealthCheck Check() { if (!PlatformInfo.IsMono) { return(new HealthCheck(GetType())); } // Don't warn on arm based synology - could be arm5 or something else rubbish if (_osInfo.Name == "DSM" && RuntimeInformation.ProcessArchitecture == Architecture.Arm) { return(new HealthCheck(GetType())); } // Check for BSD var output = _processProvider.StartAndCapture("uname"); if (output?.ExitCode == 0 && MonoUnames.Contains(output?.Lines.First().Content)) { return(new HealthCheck(GetType())); } return(new HealthCheck(GetType(), HealthCheckResult.Warning, _localizationService.GetLocalizedString("MonoNotNetCoreCheckMessage"), "#update-to-net-core-version")); }
public OsVersionModel Read() { var output = _processProvider.StartAndCapture("freebsd-version"); var version = output.Standard.First().Content; return(new OsVersionModel("FreeBSD", version, $"FreeBSD {version}")); }
private void ExecuteScript(StringDictionary environmentVariables) { _logger.Debug("Executing external script: {0}", Settings.Path); var process = _processProvider.StartAndCapture(Settings.Path, Settings.Arguments, environmentVariables); _logger.Debug("Executed external script: {0} - Status: {1}", Settings.Path, process.ExitCode); _logger.Debug("Script Output: \r\n{0}", string.Join("\r\n", process.Lines)); }
private ProcessOutput ExecuteScript(StringDictionary environmentVariables) { _logger.Debug("Executing external script: {0}", Settings.Path); var processOutput = _processProvider.StartAndCapture(Settings.Path, Settings.Arguments, environmentVariables); _logger.Debug("Executed external script: {0} - Status: {1}", Settings.Path, processOutput.ExitCode); _logger.Debug($"Script Output: {System.Environment.NewLine}{string.Join(System.Environment.NewLine, processOutput.Lines)}"); return(processOutput); }
private string GetServiceDacls(string serviceName) { var output = _processProvider.StartAndCapture("sc.exe", $"sdshow {serviceName}"); var dacls = output.Standard.Select(s => s.Content).Where(s => s.IsNotNullOrWhiteSpace()).ToList(); if (dacls.Count == 1) { return(dacls[0]); } throw new ArgumentException("Invalid DACL output"); }
private void ExecuteCommand(string args, bool throwOnStdOut = true) { var output = _processProvider.StartAndCapture(SynoIndexPath, args); if (output.Standard.Count != 0 && throwOnStdOut) { throw new SynologyException("synoindex returned an error: {0}", string.Join("\n", output.Standard)); } if (output.Error.Count != 0) { throw new SynologyException("synoindex returned an error: {0}", string.Join("\n", output.Error)); } }
public ProcessOutput Run(string arguments) { try { var output = _processProvider.StartAndCapture("netsh.exe", arguments); return(output); } catch (Exception ex) { _logger.Warn(ex, "Error executing netsh with arguments: " + arguments); } return(null); }
public List <ProcessInfo> FindNzbDroneProcesses() { var monoProcesses = _processProvider.FindProcessByName("mono"); return(monoProcesses.Where(c => { try { var processArgs = _processProvider.StartAndCapture("ps", String.Format("-p {0} -o args=", c.Id)); return processArgs.Standard.Any(p => p.Contains(ProcessProvider.NZB_DRONE_PROCESS_NAME + ".exe") || p.Contains(ProcessProvider.NZB_DRONE_CONSOLE_PROCESS_NAME + ".exe")); } catch (InvalidOperationException ex) { _logger.WarnException("Error getting process arguments", ex); return false; } }).ToList()); }