First files to the project

This commit is contained in:
Antonio de la Rosa 2022-02-07 00:35:21 +01:00
commit cda8eb1232
26 changed files with 2657 additions and 0 deletions

14
tasks/system/ping.py Normal file
View file

@ -0,0 +1,14 @@
from modules.pastafari2.libraries.task import Task
from modules.pastafari2.models.pastafari2 import ServerDbTask
class ServerTask(Task):
def __init__(self, server, conn, remote_user='root', remote_password='', private_key='./ssh/id_rsa', password_key='', remote_path='leviathan', task_id=0, data={}):
super().__init__(server, conn, remote_user, remote_password, private_key, password_key, remote_path, task_id, data)
self.files=[['modules/pastafari2/scripts/system/alive.sh', 0o755]]
self.commands_to_execute=[]
self.commands_to_execute.append(['modules/pastafari2/scripts/system/alive.sh', ''])

38
tasks/system/task.py Normal file
View file

@ -0,0 +1,38 @@
from modules.pastafari2.libraries.task import Task
from modules.pastafari2.models.pastafari2 import ServerDbTask
class ServerTask(Task):
def __init__(self, server, conn, remote_user='root', remote_password='', private_key='./ssh/id_rsa', password_key='', remote_path='leviathan', task_id=0, data={}):
super().__init__(server, conn, remote_user, remote_password, private_key, password_key, remote_path, task_id, data)
#self.files=[['modules/pastafari2/scripts/system/alive.sh', 0o755]]
self.files=[['modules/pastafari2/scripts/system/install_pzoo_stats.py', 0o755]]
self.files.append(['modules/pastafari2/scripts/system/install_python.sh', 0o755])
self.files.append(['modules/pastafari2/scripts/system/install_psutil.sh', 0o755])
self.files.append(['modules/pastafari2/scripts/system/install_git.sh', 0o755])
self.files.append(['modules/pastafari2/scripts/system/sudoers.d/spanel', 0o640])
self.files.append([self.data['pub_key'], 0o600])
self.commands_to_execute=[]
#self.commands_to_execute.append(['modules/pastafari2/scripts/system/alive.sh', ''])
self.commands_to_execute.append(['modules/pastafari2/scripts/system/install_git.sh', ''])
self.commands_to_execute.append(['modules/pastafari2/scripts/system/install_python.sh', ''])
self.commands_to_execute.append(['modules/pastafari2/scripts/system/install_psutil.sh', ''])
self.commands_to_execute.append(['modules/pastafari2/scripts/system/install_pzoo_stats.py', '--user='+self.data['ssh_user']+' --pub_key='+self.data['pub_key']+' --url_stats='+self.data['url_stats']+' --group='+self.data['group_name']])
def post_task(self):
server=ServerDbTask(self.connection)
server.safe_query()
#'subdomain_id': self.data['subdomain_id']
server.insert({'hostname': self.data['hostname'], 'ip': self.data['ip'], 'group_id': self.data['group_id']})
return True