mirror of
https://github.com/usmannasir/cyberpanel.git
synced 2026-02-15 02:56:49 +01:00
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:
@@ -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)
|
||||
|
||||
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user