Exemplo n.º 1
0
        /// <summary>
        /// Main program
        /// </summary>
        public async Task <int> Start()
        {
            // Show informational message and start-up diagnostics
            await ShowBanner().ConfigureAwait(false);

            // Version display (handled by ShowBanner in constructor)
            if (_args.Version)
            {
                await CloseDefault();

                if (_args.CloseOnFinish)
                {
                    return(0);
                }
            }

            // Help function
            if (_args.Help)
            {
                _arguments.ShowHelp();
                await CloseDefault();

                if (_args.CloseOnFinish)
                {
                    return(0);
                }
            }

            // Main loop
            do
            {
                try
                {
                    if (_args.Import)
                    {
                        await Import(RunLevel.Unattended);
                        await CloseDefault();
                    }
                    else if (_args.List)
                    {
                        await _renewalManager.ShowRenewalsUnattended();
                        await CloseDefault();
                    }
                    else if (_args.Cancel)
                    {
                        await _renewalManager.CancelRenewalsUnattended();
                        await CloseDefault();
                    }
                    else if (_args.Revoke)
                    {
                        await _renewalManager.RevokeCertificatesUnattended();
                        await CloseDefault();
                    }
                    else if (_args.Renew)
                    {
                        var runLevel = RunLevel.Unattended;
                        if (_args.Force)
                        {
                            runLevel |= RunLevel.ForceRenew | RunLevel.IgnoreCache;
                        }
                        await _renewalManager.CheckRenewals(runLevel);
                        await CloseDefault();
                    }
                    else if (!string.IsNullOrEmpty(_args.Target))
                    {
                        await _renewalCreator.SetupRenewal(RunLevel.Unattended);
                        await CloseDefault();
                    }
                    else if (_args.Encrypt)
                    {
                        await Encrypt(RunLevel.Unattended);
                        await CloseDefault();
                    }
                    else if (_args.SetupTaskScheduler)
                    {
                        await _taskScheduler.CreateTaskScheduler(RunLevel.Unattended);
                        await CloseDefault();
                    }
                    else
                    {
                        await MainMenu();
                    }
                }
                catch (Exception ex)
                {
                    _exceptionHandler.HandleException(ex);
                    await CloseDefault();
                }
                if (!_args.CloseOnFinish)
                {
                    _args.Clear();
                    _exceptionHandler.ClearError();
                    _container.Resolve <IIISClient>().Refresh();
                }
            }while (!_args.CloseOnFinish);

            // Return control to the caller
            _log.Verbose("Exiting with status code {code}", _exceptionHandler.ExitCode);
            return(_exceptionHandler.ExitCode);
        }
Exemplo n.º 2
0
        /// <summary>
        /// Main loop
        /// </summary>
        public async Task Start()
        {
            // Version display (handled by ShowBanner in constructor)
            if (_args.Version)
            {
                await CloseDefault();

                if (_args.CloseOnFinish)
                {
                    return;
                }
            }

            // Help function
            if (_args.Help)
            {
                _arguments.ShowHelp();
                await CloseDefault();

                if (_args.CloseOnFinish)
                {
                    return;
                }
            }

            // Main loop
            do
            {
                try
                {
                    if (_args.Import)
                    {
                        await Import(RunLevel.Unattended);
                        await CloseDefault();
                    }
                    else if (_args.List)
                    {
                        await _renewalManager.ShowRenewals();
                        await CloseDefault();
                    }
                    else if (_args.Cancel)
                    {
                        await _renewalManager.CancelRenewal(RunLevel.Unattended);
                        await CloseDefault();
                    }
                    else if (_args.Renew)
                    {
                        var runLevel = RunLevel.Unattended;
                        if (_args.Force)
                        {
                            runLevel |= RunLevel.ForceRenew | RunLevel.IgnoreCache;
                        }
                        await _renewalManager.CheckRenewals(runLevel);
                        await CloseDefault();
                    }
                    else if (!string.IsNullOrEmpty(_args.Target))
                    {
                        await _renewalManager.SetupRenewal(RunLevel.Unattended);
                        await CloseDefault();
                    }
                    else if (_args.Encrypt)
                    {
                        await Encrypt(RunLevel.Unattended);
                        await CloseDefault();
                    }
                    else
                    {
                        await MainMenu();
                    }
                }
                catch (Exception ex)
                {
                    _exceptionHandler.HandleException(ex);
                    await CloseDefault();
                }
                if (!_args.CloseOnFinish)
                {
                    _args.Clear();
                    Environment.ExitCode = 0;
                    _container.Resolve <IIISClient>().Refresh();
                }
                else
                {
                    _log.Verbose("Exiting with status code {code}", Environment.ExitCode);
                }
            }while (!_args.CloseOnFinish);
        }
Exemplo n.º 3
0
        /// <summary>
        /// Main loop
        /// </summary>
        public void Start()
        {
            // Version display (handled by ShowBanner in constructor)
            if (_args.Version)
            {
                CloseDefault();
                if (_args.CloseOnFinish)
                {
                    return;
                }
            }

            // Help function
            if (_args.Help)
            {
                _arguments.ShowHelp();
                CloseDefault();
                if (_args.CloseOnFinish)
                {
                    return;
                }
            }

            // Main loop
            do
            {
                try
                {
                    if (_args.Import)
                    {
                        Import(RunLevel.Unattended);
                        CloseDefault();
                    }
                    else if (_args.List)
                    {
                        ShowRenewals();
                        CloseDefault();
                    }
                    else if (_args.Cancel)
                    {
                        CancelRenewal(RunLevel.Unattended);
                        CloseDefault();
                    }
                    else if (_args.Renew)
                    {
                        var runLevel = RunLevel.Unattended;
                        if (_args.Force)
                        {
                            runLevel |= (RunLevel.ForceRenew | RunLevel.IgnoreCache);
                        }
                        CheckRenewals(runLevel);
                        CloseDefault();
                    }
                    else if (!string.IsNullOrEmpty(_args.Target))
                    {
                        SetupRenewal(RunLevel.Unattended);
                        CloseDefault();
                    }
                    else if (_args.Encrypt)
                    {
                        Encrypt(RunLevel.Unattended);
                        CloseDefault();
                    }
                    else
                    {
                        MainMenu();
                    }
                }
                catch (Exception ex)
                {
                    HandleException(ex);
                    CloseDefault();
                }
                if (!_args.CloseOnFinish)
                {
                    _args.Clear();
                    Environment.ExitCode = 0;
                }
                _container.Resolve <IIISClient>().Refresh();
            }while (!_args.CloseOnFinish);
        }
Exemplo n.º 4
0
        /// <summary>
        /// Main loop
        /// </summary>
        public void Start()
        {
            // Validation failure
            if (_arguments == null)
            {
                Environment.Exit(1);
            }

            // Version display (handled by ShowBanner in constructor)
            if (_arguments.Version)
            {
                CloseDefault();
                if (_arguments.CloseOnFinish)
                {
                    return;
                }
            }

            // Help function
            if (_arguments.Help)
            {
                _optionsService.ShowHelp();
                CloseDefault();
                if (_arguments.CloseOnFinish)
                {
                    return;
                }
            }

            // Verbose logging
            if (_arguments.Verbose)
            {
                _log.SetVerbose();
            }

            // Main loop
            do
            {
                try
                {
                    if (_arguments.Import)
                    {
                        Import(RunLevel.Unattended);
                        CloseDefault();
                    }
                    else if (_arguments.List)
                    {
                        ShowRenewals();
                        CloseDefault();
                    }
                    else if (_arguments.Renew)
                    {
                        CheckRenewals(_arguments.Force);
                        CloseDefault();
                    }
                    else if (!string.IsNullOrEmpty(_arguments.Target))
                    {
                        if (_arguments.Cancel)
                        {
                            CancelRenewal(RunLevel.Unattended);
                        }
                        else
                        {
                            CreateNewCertificate(RunLevel.Unattended);
                        }
                        CloseDefault();
                    }
                    else
                    {
                        MainMenu();
                    }
                }
                catch (Exception ex)
                {
                    HandleException(ex);
                }
                if (!_arguments.CloseOnFinish)
                {
                    _arguments.Clear();
                    Environment.ExitCode = 0;
                }
            } while (!_arguments.CloseOnFinish);
        }