Added modify php.ini from phpserver module

This commit is contained in:
Antonio de la Rosa 2025-10-24 00:15:45 +02:00
parent 56157e4adb
commit ffdf81ec07
6 changed files with 295 additions and 37 deletions

View file

@ -0,0 +1,68 @@
#/usr/bin/env python3
from collections import OrderedDict
import json
from modules.pastafari2.libraries.task import Task
from modules.pastafari2.models.pastafari2 import ServerDbTask
from modules.pastafari2.libraries.configtask import config_task
#import distro
class ServerTask(Task):
def __init__(self, server, conn, remote_user='root', remote_password='', private_key='./ssh/id_rsa', password_key='', remote_path='pastafari2', task_id=0, data={}, port=22):
super().__init__(server, conn, remote_user, remote_password, private_key, password_key, remote_path, task_id, data, port)
self.name_task='Get php.ini from server'
self.description_task='Get php.ini from server'
self.codename_task='save_php_ini'
self.files=[]
self.files=[['modules/phpserver/scripts/save_php_ini.py', 0o755]]
# Format first array element is command with the interpreter, the task is agnostic, the files in os directory. The commands are setted with 750 permission.
# First element is the file, next elements are the arguments
self.commands_to_execute=[['modules/phpserver/scripts/save_php_ini.py', '']]
#THe files to delete
self.delete_files=[]
#self.delete_directories=['modules/phpserver/scripts']
#self.task=Task(conn)
self.one_time=False
self.version='1.0'
self.path_module='php_app.php_dashboard'
def pre_task(self):
#self.commands_to_execute=[['modules/webservers/scripts/manager/${os_server}/manage_apache.py', '--password=%s' % self.extra_data['mysql_password']]]
# usage: manager.py [-h] --operation OPERATION --domain DOMAIN [--email EMAIL] [--user USER] [--root_dir ROOT_DIR] [--indexes] [--allow_override]
self.commands_to_execute=[['/home/{}/pythonenv/bin/python3 -u modules/phpserver/scripts/save_php_ini.py'.format(config_task.remote_user), '--version={}'.format(self.data['version'])]]
self.files.append(['./tmp/php.ini', 0o755])
#with open('./mo/php.ini', 'w') as f:
# f.write(self.data['file'])
return True
def post_task(self):
#vhost=VirtualHost(self.connection)
#vhost.safe_query()
#vhost.insert({'servers': servers, 'principal_ip': servers[0], 'domain': self.extra_data['domain'], 'email': self.extra_data['email'], 'user': self.extra_data['user'], 'root_dir': self.extra_data['root_dir'], 'indexes': self.extra_data['indexes'], 'allow_override': self.extra_data['allow_override']})
#if not vhost.set_conditions('WHERE domain=%s', [self.data['domain']]).delete():
return True