Use regex for Auto-SSL config injection to handle any adminEmails value

The previous string replace only matched 'adminEmails               root@localhost'
exactly. On fresh OLS installs where adminEmails may have a different value
or different spacing, the replace would silently fail and Auto-SSL config
would never be injected. Use re.sub to match the adminEmails line regardless
of its value.
This commit is contained in:
usmannasir
2026-02-14 00:43:30 +05:00
parent cedbbd27e8
commit 0c07293d1a
2 changed files with 12 additions and 8 deletions

View File

@@ -501,15 +501,17 @@ module cyberpanel_ols {
# Enable Auto-SSL in httpd_config.conf
try:
import re
conf_path = '/usr/local/lsws/conf/httpd_config.conf'
if os.path.exists(conf_path):
with open(conf_path, 'r') as f:
content = f.read()
if 'autoSSL' not in content:
content = content.replace(
'adminEmails root@localhost',
'adminEmails root@localhost\nautoSSL 1\nacmeEmail admin@cyberpanel.net',
1
content = re.sub(
r'(adminEmails\s+\S+)',
r'\1\nautoSSL 1\nacmeEmail admin@cyberpanel.net',
content,
count=1
)
with open(conf_path, 'w') as f:
f.write(content)

View File

@@ -4598,13 +4598,15 @@ pm.max_spare_servers = 3
# Enable Auto-SSL if not already configured
conf_path = '/usr/local/lsws/conf/httpd_config.conf'
try:
import re
with open(conf_path, 'r') as f:
content = f.read()
if 'autoSSL' not in content:
content = content.replace(
'adminEmails root@localhost',
'adminEmails root@localhost\nautoSSL 1\nacmeEmail admin@cyberpanel.net',
1
content = re.sub(
r'(adminEmails\s+\S+)',
r'\1\nautoSSL 1\nacmeEmail admin@cyberpanel.net',
content,
count=1
)
with open(conf_path, 'w') as f:
f.write(content)