Update
This commit is contained in:
@@ -3,6 +3,8 @@
|
||||
import os
|
||||
import xml.etree.ElementTree as etree
|
||||
from sys import stdin
|
||||
import subprocess
|
||||
import datetime
|
||||
|
||||
|
||||
def CheckModuleExists():
|
||||
@@ -11,8 +13,49 @@ def CheckModuleExists():
|
||||
return 'mod_rewrite already installed'
|
||||
return None
|
||||
|
||||
def BuildModule():
|
||||
"""
|
||||
Build and install the nginx mod_rewrite module by calling the utility script.
|
||||
|
||||
Returns:
|
||||
str: Error message if the utility failed, None on success
|
||||
"""
|
||||
utils_dir = '/usr/local/ispmanager-mod_rewrite/utils'
|
||||
build_script = os.path.join(utils_dir, 'build_mod_rewrite.py')
|
||||
log_path = '/usr/local/mgr5/var/nginx-mod-rewrite-plugin.log'
|
||||
|
||||
try:
|
||||
with open(log_path, 'a') as log_file:
|
||||
log_file.write(f'=== Starting module build via utility: {datetime.datetime.now()} ===\n')
|
||||
log_file.write(f'Executing: python3 {build_script}\n')
|
||||
|
||||
result = subprocess.run(
|
||||
['python3', build_script],
|
||||
stdout=subprocess.PIPE,
|
||||
stderr=subprocess.STDOUT,
|
||||
text=True
|
||||
)
|
||||
|
||||
# Log the result
|
||||
log_file.write(f'Build script exit code: {result.returncode}\n')
|
||||
if result.stdout:
|
||||
log_file.write(f'Stdout:\n{result.stdout}')
|
||||
|
||||
if result.returncode != 0:
|
||||
# Extract error message from stderr (already captured in stdout due to redirect)
|
||||
return f'Build utility failed with exit code {result.returncode}'
|
||||
except Exception as exc:
|
||||
log_path_error = os.path.join(os.path.dirname(log_path), 'error.log')
|
||||
with open(log_path_error, 'a') as error_file:
|
||||
error_file.write(f'Unexpected error calling build utility: {exc}\n')
|
||||
return f'Unexpected error: {exc}'
|
||||
|
||||
return None
|
||||
|
||||
def InstallModule():
|
||||
#Todo func
|
||||
result = BuildModule()
|
||||
if result is not None:
|
||||
return result
|
||||
return None
|
||||
|
||||
# Обработка нажатия на кнопку "Сохранить"
|
||||
|
||||
Reference in New Issue
Block a user