Fixes in php delete
This commit is contained in:
parent
e403599bf5
commit
50204461ee
6 changed files with 197 additions and 71 deletions
65
tasks/php/php/delete_php.py
Normal file
65
tasks/php/php/delete_php.py
Normal file
|
|
@ -0,0 +1,65 @@
|
|||
#/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='Remove php version in server'
|
||||
|
||||
self.description_task='Delete php version in server'
|
||||
|
||||
self.codename_task='del_php'
|
||||
|
||||
self.files=[]
|
||||
|
||||
self.files=[['modules/phpserver/scripts/delete_php.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/delete_php.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/delete_php.py'.format(config_task.remote_user), '--version={}'.format(self.data['version'])]]
|
||||
|
||||
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():
|
||||
if not self.connection.query('delete from phpserver where id=%s', [self.data['php_server_id']]):
|
||||
return False
|
||||
|
||||
return True
|
||||
|
|
@ -35,17 +35,12 @@ class ServerTask(Task):
|
|||
# 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/pastafari/scripts/servers/databases/mysql/install_mariadb.py', '']];
|
||||
|
||||
#THe files to delete
|
||||
|
||||
self.delete_files=[]
|
||||
|
||||
self.delete_directories=['modules/phpserver/scripts/']
|
||||
|
||||
#self.task=Task(conn)
|
||||
|
||||
#self.one_time=True
|
||||
|
||||
|
||||
self.version='1.0'
|
||||
|
||||
|
|
@ -59,31 +54,8 @@ class ServerTask(Task):
|
|||
|
||||
self.arr_form['version'].label=_('Version')
|
||||
|
||||
"""
|
||||
self.arr_form['mysql_password']=coreforms.PasswordForm('mysql_password', '')
|
||||
self.path_module='php_app.php_dashboard'
|
||||
|
||||
self.arr_form['mysql_password'].required=True
|
||||
|
||||
self.arr_form['mysql_password'].label='The MySQL password used by all servers'
|
||||
|
||||
self.arr_form['repeat_mysql_password']=coreforms.PasswordForm('repeat_mysql_password', '')
|
||||
|
||||
self.arr_form['repeat_mysql_password'].required=True
|
||||
|
||||
self.arr_form['repeat_mysql_password'].label='Repeat MySQL password'
|
||||
|
||||
self.arr_form['access_localhost']=coreforms.SimpleTextForm('access_localhost', '')
|
||||
|
||||
self.arr_form['access_localhost'].required=True
|
||||
|
||||
#self.arr_form['access_localhost'].default_value='1'
|
||||
|
||||
self.arr_form['access_localhost'].label='IP for access to mariadb server'
|
||||
self.arr_form['access_localhost'].help='Empty if you want only localhost access. If you want all ips, use 0.0.0.0 or if you want other ip, put it'
|
||||
"""
|
||||
|
||||
#self.commands_to_execute=[['modules/pastafari/scripts/servers/databases/mariadb/install_mariadb.py', '--password=%s' % self.data['mysql_password']]]
|
||||
|
||||
def post_task(self):
|
||||
|
||||
if server_db:
|
||||
|
|
@ -127,41 +99,6 @@ class ServerTask(Task):
|
|||
def check_form(self, post):
|
||||
|
||||
error=False
|
||||
"""
|
||||
if 'mysql_password' in post and 'repeat_mysql_password' in post:
|
||||
|
||||
if post['mysql_password'].strip()!='' and post['mysql_password']==post['repeat_mysql_password']:
|
||||
|
||||
self.data['mysql_password']=post['mysql_password'].strip()
|
||||
|
||||
else:
|
||||
|
||||
self.arr_form['mysql_password'].error=True
|
||||
self.arr_form['mysql_password'].txt_error='Passwords doesn\'t match'
|
||||
error=True
|
||||
|
||||
if 'access_localhost' in post:
|
||||
|
||||
self.data['ip']=''
|
||||
|
||||
ip_check=IpField('ip')
|
||||
|
||||
ip_host=post['access_localhost'].strip()
|
||||
|
||||
if ip_host!='':
|
||||
|
||||
ip_host=ip_check.check(ip_host)
|
||||
|
||||
if ip_host!='':
|
||||
self.data['ip']=ip_host
|
||||
|
||||
if ip_check.error:
|
||||
|
||||
self.arr_form['access_localhost'].error=True
|
||||
self.arr_form['access_localhost'].txt_error='Wrong ip format'
|
||||
error=True
|
||||
|
||||
"""
|
||||
|
||||
self.data['version']=post['version'].strip()
|
||||
#print(self.data['version'])
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue