Run post-hooks if defined. This function also registers any executables found in config.renewal_post_hooks_dir to be run when Certbot is used with the renew subcommand. If the verb is renew, we delay executing any post-hooks until :func:`run_saved_post_hooks` is called. In this
(
config: configuration.NamespaceConfig,
renewed_sans: list[san.SAN]
)
| 99 | |
| 100 | |
| 101 | def post_hook( |
| 102 | config: configuration.NamespaceConfig, |
| 103 | renewed_sans: list[san.SAN] |
| 104 | ) -> None: |
| 105 | |
| 106 | """Run post-hooks if defined. |
| 107 | |
| 108 | This function also registers any executables found in |
| 109 | config.renewal_post_hooks_dir to be run when Certbot is used with |
| 110 | the renew subcommand. |
| 111 | |
| 112 | If the verb is renew, we delay executing any post-hooks until |
| 113 | :func:`run_saved_post_hooks` is called. In this case, this function |
| 114 | registers all hooks found in config.renewal_post_hooks_dir to be |
| 115 | called followed by any post-hook in the config. If the post-hook in |
| 116 | the config is a path to an executable in the post-hook directory, it |
| 117 | is not scheduled to be run twice. |
| 118 | |
| 119 | :param configuration.NamespaceConfig config: Certbot settings |
| 120 | |
| 121 | """ |
| 122 | |
| 123 | all_hooks: list[str] = (list_hooks(config.renewal_post_hooks_dir) if config.directory_hooks |
| 124 | else []) |
| 125 | all_hooks += [config.post_hook] if config.post_hook else [] |
| 126 | # In the "renew" case, we save these up to run at the end |
| 127 | if config.verb == "renew": |
| 128 | for hook in all_hooks: |
| 129 | _run_eventually(hook) |
| 130 | # certonly / run |
| 131 | else: |
| 132 | renewed_sans_str = ' '.join(map(str, renewed_sans)) |
| 133 | # 32k is reasonable on Windows and likely quite conservative on other platforms |
| 134 | if len(renewed_sans_str) > 32_000: |
| 135 | logger.warning("Limiting RENEWED_DOMAINS environment variable to 32k characters") |
| 136 | renewed_sans_str = renewed_sans_str[:32_000] |
| 137 | for hook in all_hooks: |
| 138 | _run_hook( |
| 139 | "post-hook", |
| 140 | hook, |
| 141 | { |
| 142 | 'RENEWED_DOMAINS': renewed_sans_str, |
| 143 | # Since other commands stop certbot execution on failure, |
| 144 | # it doesn't make sense to have a FAILED_DOMAINS variable |
| 145 | 'FAILED_DOMAINS': "" |
| 146 | } |
| 147 | ) |
| 148 | |
| 149 | |
| 150 | post_hooks: list[str] = [] |