mirror of
https://github.com/certbot/certbot.git
synced 2026-06-05 14:54:24 -04:00
Fixes #7713. As discussed in #7713, providing a Powershell script as hook for Certbot is not working currently. This is because hooks are run in a `cmd` environment, that recognizes only `.bat` files as valid scripts that can be run from their bare name on command line. On the other hand, the Powershell both `.bat` and `.ps1` scripts as valid scripts. This PR makes hooks command be executed by Powershell, instead of `cmd` as `Popen` does by default when `shell=true` is used. It also modifies the tests to handle this new environment, in particular in term of encoding (UTF-16-LE is the default one in Powershell). * Run hooks in powershell on Windows * Fix hook test * Fallback to unittest.mock * In fact, shell_cmd as a list of str could not work. Declare only str as acceptable input for shell_cmd. * Added changelog
11 lines
369 B
Python
Executable file
11 lines
369 B
Python
Executable file
#!/usr/bin/env python
|
|
from __future__ import print_function
|
|
import os
|
|
import sys
|
|
|
|
hook_script_type = os.path.basename(os.path.dirname(sys.argv[1]))
|
|
if hook_script_type == 'deploy' and ('RENEWED_DOMAINS' not in os.environ or 'RENEWED_LINEAGE' not in os.environ):
|
|
sys.stderr.write('Environment variables not properly set!\n')
|
|
sys.exit(1)
|
|
|
|
print(hook_script_type)
|