/// <summary> /// Filters for unattended mode /// </summary> /// <param name="command"></param> /// <returns></returns> private async Task <IEnumerable <Renewal> > FilterRenewalsByCommandLine(string command) { if (_args.HasFilter) { var targets = _renewalStore.FindByArguments( _args.Id, _args.FriendlyName); if (!targets.Any()) { _log.Error("No renewals matched."); } return(targets); } else { _log.Error($"Specify which renewal to {command} using the parameter --id or --friendlyname."); } return(new List <Renewal>()); }
/// <summary> /// If renewal is already Scheduled, replace it with the new options /// </summary> /// <param name="target"></param> /// <returns></returns> private async Task <Renewal> CreateRenewal(Renewal temp, RunLevel runLevel) { // First check by id var existing = _renewalStore.FindByArguments(temp.Id, null).FirstOrDefault(); // If Id has been specified, we don't consider the Friendlyname anymore // So specifying --id becomes a way to create duplicate certificates // with the same --friendlyname in unattended mode. if (existing == null && string.IsNullOrEmpty(_args.Id)) { existing = _renewalStore.FindByArguments(null, temp.LastFriendlyName?.EscapePattern()).FirstOrDefault(); } // This will be a completely new renewal, no further processing needed if (existing == null) { return(temp); } // Match found with existing certificate, determine if we want to overwrite // it or create it side by side with the current one. if (runLevel.HasFlag(RunLevel.Interactive) && (temp.Id != existing.Id) && temp.New) { _input.CreateSpace(); _input.Show("Existing renewal", existing.ToString(_dueDate, _input)); if (!await _input.PromptYesNo($"Overwrite settings?", true)) { return(temp); } } // Move settings from temporary renewal over to // the pre-existing one that we are overwriting _log.Warning("Overwriting previously created renewal"); existing.Updated = true; existing.TargetPluginOptions = temp.TargetPluginOptions; existing.OrderPluginOptions = temp.OrderPluginOptions; existing.CsrPluginOptions = temp.CsrPluginOptions; existing.StorePluginOptions = temp.StorePluginOptions; existing.ValidationPluginOptions = temp.ValidationPluginOptions; existing.InstallationPluginOptions = temp.InstallationPluginOptions; return(existing); }