58 lines
1.7 KiB
Python
58 lines
1.7 KiB
Python
|
|
#!/usr/bin/env python3
|
|||
|
|
|
|||
|
|
import os
|
|||
|
|
import xml.etree.ElementTree as etree
|
|||
|
|
from sys import stdin
|
|||
|
|
|
|||
|
|
|
|||
|
|
def CheckModuleExists():
|
|||
|
|
module_path = '/usr/share/nginx/modules/ngx_http_apache_rewrite_module.conf'
|
|||
|
|
if os.path.isfile(module_path):
|
|||
|
|
return 'mod_rewrite already installed'
|
|||
|
|
return None
|
|||
|
|
|
|||
|
|
def InstallModule():
|
|||
|
|
#Todo func
|
|||
|
|
return None
|
|||
|
|
|
|||
|
|
# Обработка нажатия на кнопку "Сохранить"
|
|||
|
|
def Handle(root):
|
|||
|
|
result = True
|
|||
|
|
result_error = CheckModuleExists()
|
|||
|
|
if result_error is None:
|
|||
|
|
result_error = InstallModule()
|
|||
|
|
result = result_error is None
|
|||
|
|
|
|||
|
|
if not result:
|
|||
|
|
# Формирование сообщения об ошибке согласно структуре в metadata
|
|||
|
|
error = etree.SubElement(root, "error")
|
|||
|
|
error.set('code', '1')
|
|||
|
|
error.set('type', 'nginx_mod_rewrite_plugin')
|
|||
|
|
error.set('object', 'wrong_value')
|
|||
|
|
param = etree.SubElement(error, 'param')
|
|||
|
|
param.text = 'wrong_value'
|
|||
|
|
param.set('name', 'object')
|
|||
|
|
param.set('type', 'msg')
|
|||
|
|
param = etree.SubElement(error, 'param')
|
|||
|
|
param.set('name', 'value')
|
|||
|
|
param.text = result_error
|
|||
|
|
|
|||
|
|
|
|||
|
|
if __name__ == "__main__":
|
|||
|
|
func = os.getenv("PARAM_func")
|
|||
|
|
correct_function = False
|
|||
|
|
|
|||
|
|
if func == "nginx_mod_rewrite_plugin.settings":
|
|||
|
|
correct_function = True
|
|||
|
|
elif func == "plugin.settings":
|
|||
|
|
if os.getenv("PARAM_plugin_settings") == "nginx_mod_rewrite_plugin":
|
|||
|
|
correct_function = True
|
|||
|
|
root = etree.parse(stdin).getroot()
|
|||
|
|
|
|||
|
|
if correct_function:
|
|||
|
|
if os.getenv("PARAM_clicked_button") == "ok":
|
|||
|
|
Handle(root)
|
|||
|
|
|
|||
|
|
etree.dump(root)
|
|||
|
|
quit(0)
|