Skip to content

Commit d047a88

Browse files
committed
cont.
1 parent 05aa593 commit d047a88

File tree

1 file changed

+91
-93
lines changed

1 file changed

+91
-93
lines changed

custom-domain/dstack-ingress/scripts/certman.py

Lines changed: 91 additions & 93 deletions
Original file line numberDiff line numberDiff line change
@@ -78,106 +78,104 @@ def install_plugin(self) -> bool:
7878
if not success:
7979
print(f"All installation methods failed", file=sys.stderr)
8080
return False
81-
print(f"Successfully installed {self.provider.CERTBOT_PACKAGE}")
81+
82+
print(f"Successfully installed {self.provider.CERTBOT_PACKAGE}")
83+
84+
# Add diagnostic information
85+
try:
86+
print("=== Diagnostic Information ===")
87+
# Check which Python executable is being used
88+
import sys
89+
print(f"Python executable: {sys.executable}")
90+
print(f"Python version: {sys.version}")
8291

83-
# Add diagnostic information
92+
# Check where the package was installed
93+
import pkg_resources
8494
try:
85-
print("=== Diagnostic Information ===")
86-
# Check which Python executable is being used
87-
import sys
88-
print(f"Python executable: {sys.executable}")
89-
print(f"Python version: {sys.version}")
95+
dist = pkg_resources.get_distribution("certbot-dns-namecheap")
96+
print(f"Package location: {dist.location}")
97+
print(f"Package version: {dist.version}")
98+
except pkg_resources.DistributionNotFound:
99+
print("Package not found in current environment")
100+
101+
# Check sys.path
102+
print(f"Python path: {sys.path[:3]}...")
103+
print("=== End Diagnostic Information ===")
104+
except Exception as diag_error:
105+
print(f"Diagnostic error: {diag_error}")
106+
107+
# For Docker environments, we need to check if the plugin is actually usable
108+
# Try a direct test of the plugin functionality
109+
try:
110+
if self.provider.CERTBOT_PLUGIN == "dns-namecheap":
111+
import certbot_dns_namecheap.dns_namecheap
112+
print(f"Plugin {self.provider.CERTBOT_PLUGIN} successfully imported")
90113

91-
# Check where the package was installed
92-
import pkg_resources
93-
try:
94-
dist = pkg_resources.get_distribution("certbot-dns-namecheap")
95-
print(f"Package location: {dist.location}")
96-
print(f"Package version: {dist.version}")
97-
except pkg_resources.DistributionNotFound:
98-
print("Package not found in current environment")
114+
# Try to create a simple test to see if the plugin works
115+
print(f"Testing if plugin {self.provider.CERTBOT_PLUGIN} is available...")
116+
test_cmd = ["certbot", "plugins"]
117+
test_result = subprocess.run(test_cmd, capture_output=True, text=True, timeout=10)
99118

100-
# Check sys.path
101-
print(f"Python path: {sys.path[:3]}...")
102-
print("=== End Diagnostic Information ===")
103-
except Exception as diag_error:
104-
print(f"Diagnostic error: {diag_error}")
105-
106-
# For Docker environments, we need to check if the plugin is actually usable
107-
# Try a direct test of the plugin functionality
108-
try:
109-
if self.provider.CERTBOT_PLUGIN == "dns-namecheap":
110-
import certbot_dns_namecheap.dns_namecheap
111-
print(f"Plugin {self.provider.CERTBOT_PLUGIN} successfully imported")
112-
113-
# Try to create a simple test to see if the plugin works
114-
print(f"Testing if plugin {self.provider.CERTBOT_PLUGIN} is available...")
115-
test_cmd = ["certbot", "plugins"]
116-
test_result = subprocess.run(test_cmd, capture_output=True, text=True, timeout=10)
117-
118-
print(f"Certbot plugins command returned: {test_result.returncode}")
119-
if test_result.stdout:
120-
print(f"Available plugins:")
121-
print(test_result.stdout)
122-
123-
if test_result.stderr:
124-
print(f"Plugin test stderr: {test_result.stderr}")
125-
126-
if test_result.returncode == 0 and "dns-namecheap" in test_result.stdout:
127-
print(f"Plugin {self.provider.CERTBOT_PLUGIN} is available and working correctly")
128-
return True
129-
else:
130-
print(f"Plugin {self.provider.CERTBOT_PLUGIN} may not be properly installed")
131-
if "dns-namecheap" not in test_result.stdout:
132-
print(f"Warning: dns-namecheap plugin not found in certbot plugins list")
133-
134-
# Try some additional fixes
135-
print("Attempting additional fixes...")
136-
137-
# Try to reload Python modules
138-
try:
139-
import importlib
140-
import certbot_dns_namecheap
141-
importlib.reload(certbot_dns_namecheap)
142-
print("Reloaded certbot_dns_namecheap module")
143-
except Exception as reload_error:
144-
print(f"Module reload failed: {reload_error}")
145-
146-
# Try installing with --force-reinstall
147-
try:
148-
print("Trying force reinstall...")
149-
import sys
150-
force_cmd = [sys.executable, "-m", "pip", "install", "--force-reinstall", self.provider.CERTBOT_PACKAGE]
151-
print(f"Force reinstall command: {' '.join(force_cmd)}")
152-
force_result = subprocess.run(force_cmd, capture_output=True, text=True)
153-
if force_result.returncode == 0:
154-
print("Force reinstall succeeded")
155-
else:
156-
print(f"Force reinstall failed: {force_result.stderr}")
157-
except Exception as force_error:
158-
print(f"Force reinstall error: {force_error}")
159-
160-
# Test plugins again after fixes
161-
print("Testing plugins again after fixes...")
162-
retest_cmd = ["certbot", "plugins"]
163-
retest_result = subprocess.run(retest_cmd, capture_output=True, text=True, timeout=10)
164-
if retest_result.returncode == 0 and "dns-namecheap" in retest_result.stdout:
165-
print(f"Plugin {self.provider.CERTBOT_PLUGIN} is now available after fixes!")
166-
return True
167-
168-
# In Docker environments, this might still work in practice
169-
print("Continuing anyway - plugin may work in actual certbot execution")
170-
return True
119+
print(f"Certbot plugins command returned: {test_result.returncode}")
120+
if test_result.stdout:
121+
print(f"Available plugins:")
122+
print(test_result.stdout)
171123

172-
except Exception as e:
173-
print(f"Plugin test warning: {e}")
174-
# Continue anyway - the plugin may still work
175-
return True
124+
if test_result.stderr:
125+
print(f"Plugin test stderr: {test_result.stderr}")
126+
127+
if test_result.returncode == 0 and "dns-namecheap" in test_result.stdout:
128+
print(f"Plugin {self.provider.CERTBOT_PLUGIN} is available and working correctly")
129+
return True
130+
else:
131+
print(f"Plugin {self.provider.CERTBOT_PLUGIN} may not be properly installed")
132+
if "dns-namecheap" not in test_result.stdout:
133+
print(f"Warning: dns-namecheap plugin not found in certbot plugins list")
134+
135+
# Try some additional fixes
136+
print("Attempting additional fixes...")
137+
138+
# Try to reload Python modules
139+
try:
140+
import importlib
141+
import certbot_dns_namecheap
142+
importlib.reload(certbot_dns_namecheap)
143+
print("Reloaded certbot_dns_namecheap module")
144+
except Exception as reload_error:
145+
print(f"Module reload failed: {reload_error}")
146+
147+
# Try installing with --force-reinstall
148+
try:
149+
print("Trying force reinstall...")
150+
import sys
151+
force_cmd = [sys.executable, "-m", "pip", "install", "--force-reinstall", self.provider.CERTBOT_PACKAGE]
152+
print(f"Force reinstall command: {' '.join(force_cmd)}")
153+
force_result = subprocess.run(force_cmd, capture_output=True, text=True)
154+
if force_result.returncode == 0:
155+
print("Force reinstall succeeded")
156+
else:
157+
print(f"Force reinstall failed: {force_result.stderr}")
158+
except Exception as force_error:
159+
print(f"Force reinstall error: {force_error}")
160+
161+
# Test plugins again after fixes
162+
print("Testing plugins again after fixes...")
163+
retest_cmd = ["certbot", "plugins"]
164+
retest_result = subprocess.run(retest_cmd, capture_output=True, text=True, timeout=10)
165+
if retest_result.returncode == 0 and "dns-namecheap" in retest_result.stdout:
166+
print(f"Plugin {self.provider.CERTBOT_PLUGIN} is now available after fixes!")
167+
return True
168+
169+
# In Docker environments, this might still work in practice
170+
print("Continuing anyway - plugin may work in actual certbot execution")
171+
return True
176172

177-
return True
178173
except Exception as e:
179-
print(f"Error installing plugin: {e}", file=sys.stderr)
180-
return False
174+
print(f"Plugin test warning: {e}")
175+
# Continue anyway - the plugin may still work
176+
return True
177+
178+
return True
181179

182180
def setup_credentials(self) -> bool:
183181
"""Setup credentials file for certbot using provider implementation."""

0 commit comments

Comments
 (0)