Added files
This commit is contained in:
commit
4bfd948989
9 changed files with 557 additions and 0 deletions
108
.gitignore
vendored
Normal file
108
.gitignore
vendored
Normal file
|
|
@ -0,0 +1,108 @@
|
||||||
|
# Byte-compiled / optimized / DLL files
|
||||||
|
__pycache__/
|
||||||
|
*.py[cod]
|
||||||
|
*$py.class
|
||||||
|
|
||||||
|
# C extensions
|
||||||
|
*.so
|
||||||
|
|
||||||
|
# Distribution / packaging
|
||||||
|
.Python
|
||||||
|
build/
|
||||||
|
develop-eggs/
|
||||||
|
dist/
|
||||||
|
downloads/
|
||||||
|
eggs/
|
||||||
|
.eggs/
|
||||||
|
lib/
|
||||||
|
lib64/
|
||||||
|
parts/
|
||||||
|
sdist/
|
||||||
|
var/
|
||||||
|
wheels/
|
||||||
|
*.egg-info/
|
||||||
|
.installed.cfg
|
||||||
|
*.egg
|
||||||
|
MANIFEST
|
||||||
|
|
||||||
|
# PyInstaller
|
||||||
|
# Usually these files are written by a python script from a template
|
||||||
|
# before PyInstaller builds the exe, so as to inject date/other infos into it.
|
||||||
|
*.manifest
|
||||||
|
*.spec
|
||||||
|
|
||||||
|
# Installer logs
|
||||||
|
pip-log.txt
|
||||||
|
pip-delete-this-directory.txt
|
||||||
|
|
||||||
|
# Unit test / coverage reports
|
||||||
|
htmlcov/
|
||||||
|
.tox/
|
||||||
|
.coverage
|
||||||
|
.coverage.*
|
||||||
|
.cache
|
||||||
|
nosetests.xml
|
||||||
|
coverage.xml
|
||||||
|
*.cover
|
||||||
|
.hypothesis/
|
||||||
|
|
||||||
|
# Translations
|
||||||
|
*.mo
|
||||||
|
*.pot
|
||||||
|
|
||||||
|
# Django stuff:
|
||||||
|
*.log
|
||||||
|
.static_storage/
|
||||||
|
.media/
|
||||||
|
local_settings.py
|
||||||
|
|
||||||
|
# Flask stuff:
|
||||||
|
instance/
|
||||||
|
.webassets-cache
|
||||||
|
|
||||||
|
# Scrapy stuff:
|
||||||
|
.scrapy
|
||||||
|
|
||||||
|
# Sphinx documentation
|
||||||
|
docs/_build/
|
||||||
|
|
||||||
|
# PyBuilder
|
||||||
|
target/
|
||||||
|
|
||||||
|
# Jupyter Notebook
|
||||||
|
.ipynb_checkpoints
|
||||||
|
|
||||||
|
# pyenv
|
||||||
|
.python-version
|
||||||
|
|
||||||
|
# celery beat schedule file
|
||||||
|
celerybeat-schedule
|
||||||
|
|
||||||
|
# SageMath parsed files
|
||||||
|
*.sage.py
|
||||||
|
|
||||||
|
# Environments
|
||||||
|
.env
|
||||||
|
.venv
|
||||||
|
env/
|
||||||
|
venv/
|
||||||
|
ENV/
|
||||||
|
env.bak/
|
||||||
|
venv.bak/
|
||||||
|
|
||||||
|
# Spyder project settings
|
||||||
|
.spyderproject
|
||||||
|
.spyproject
|
||||||
|
|
||||||
|
# Rope project settings
|
||||||
|
.ropeproject
|
||||||
|
|
||||||
|
# mkdocs documentation
|
||||||
|
/site
|
||||||
|
|
||||||
|
# mypy
|
||||||
|
.mypy_cache/
|
||||||
|
|
||||||
|
/backups
|
||||||
|
/settings/config.py
|
||||||
|
/media/js/jsutils
|
||||||
17
__init__.py
Normal file
17
__init__.py
Normal file
|
|
@ -0,0 +1,17 @@
|
||||||
|
from flask import Blueprint, g
|
||||||
|
from paramecio2.modules.admin.libraries.admin_auth import admin_prepare, admin_finished
|
||||||
|
|
||||||
|
php_app=Blueprint('php_app', __name__)
|
||||||
|
|
||||||
|
#@admin_app.before_request
|
||||||
|
#def admin_prepare():
|
||||||
|
|
||||||
|
@php_app.before_request
|
||||||
|
def admin_prepare_php():
|
||||||
|
|
||||||
|
return admin_prepare()
|
||||||
|
|
||||||
|
@php_app.after_request
|
||||||
|
def admin_finished_php(response):
|
||||||
|
|
||||||
|
return admin_finished(response)
|
||||||
85
dashboard.py
Normal file
85
dashboard.py
Normal file
|
|
@ -0,0 +1,85 @@
|
||||||
|
from modules.phpserver import php_app
|
||||||
|
from settings import config
|
||||||
|
from flask import g, url_for, request, session, make_response
|
||||||
|
from paramecio2.libraries.generate_admin_class import GenerateAdminClass
|
||||||
|
from paramecio2.libraries.lists import SimpleList
|
||||||
|
from paramecio2.libraries.i18n import I18n, PGetText
|
||||||
|
from paramecio2.modules.admin import admin_app, t as admin_t
|
||||||
|
from paramecio2.libraries.db.webmodel import WebModel
|
||||||
|
from paramecio2.libraries.lists import AjaxList
|
||||||
|
from modules.pastafari2.models.pastafari2 import ServerGroup, ServerDbTask, UpdateServerScripts
|
||||||
|
from modules.pastafari2.models.tasks import Task as SSHTask
|
||||||
|
from modules.mariadb.models.mariadb import DbServerMariaDb
|
||||||
|
from paramecio2.libraries.mtemplates import PTemplate, env_theme
|
||||||
|
from paramecio2.libraries.formsutils import show_form
|
||||||
|
from paramecio2.libraries.db.coreforms import HiddenForm, SelectForm, TextForm
|
||||||
|
from paramecio2.libraries.slugify import slugify
|
||||||
|
from modules.pastafari2.libraries.configtask import config_task
|
||||||
|
from modules.pastafari2.libraries.progress import load_progress
|
||||||
|
from modules.pastafari2.models.tasks import Task as SSHTask
|
||||||
|
from modules.pastafari2.libraries.configtask import config_task
|
||||||
|
import os
|
||||||
|
|
||||||
|
try:
|
||||||
|
import ujson as json
|
||||||
|
except:
|
||||||
|
import json
|
||||||
|
|
||||||
|
pgettext=PGetText(__file__+'/../')
|
||||||
|
|
||||||
|
_=pgettext.gettext
|
||||||
|
|
||||||
|
env=env_theme(__file__)
|
||||||
|
|
||||||
|
t=PTemplate(env)
|
||||||
|
|
||||||
|
t.env.directories=admin_t.env.directories
|
||||||
|
|
||||||
|
t.env.directories.insert(1, os.path.dirname(__file__).replace('/admin', '')+'/templates/admin')
|
||||||
|
t.env.directories.insert(2, '../pastafari2/templates/admin')
|
||||||
|
|
||||||
|
@php_app.route('/pastafari2/php/servers')
|
||||||
|
def php_dashboard():
|
||||||
|
|
||||||
|
return t.load_template('phpservers.phtml', title=_('PHP Servers'), path_module='php_app.php_dashboard')
|
||||||
|
|
||||||
|
@php_app.route('/get_phpservers', methods=['POST'])
|
||||||
|
def get_phpservers():
|
||||||
|
|
||||||
|
|
||||||
|
db=g.connection
|
||||||
|
|
||||||
|
group_sql=''
|
||||||
|
|
||||||
|
count_data=[]
|
||||||
|
sql_data=[]
|
||||||
|
|
||||||
|
fields=[[_('Version'), True], [_('Hostname'), True], ['IP', True], [_('Options'), False]]
|
||||||
|
arr_order_fields=['version', 'hostname', 'ip']
|
||||||
|
|
||||||
|
count_query=['select count(phpserver.id) as num_elements from phpserver', count_data]
|
||||||
|
|
||||||
|
str_query=['select phpserver.version, serverdbtask.hostname, serverdbtask.ip, phpserver.id as id from serverdbtask, phpserver WHERE serverdbtask.id=phpserver.server_id', sql_data]
|
||||||
|
|
||||||
|
ajax=AjaxList(db, fields, arr_order_fields, count_query, str_query)
|
||||||
|
|
||||||
|
#ajax.func_fields['id']=options_server
|
||||||
|
#ajax.func_fields['ip']=options_ip
|
||||||
|
#ajax.func_fields['select_id']=options_selected
|
||||||
|
ajax.func_fields['id']=options_options
|
||||||
|
ajax.limit=0
|
||||||
|
|
||||||
|
return ajax.show()
|
||||||
|
|
||||||
|
def options_options(row_id, row):
|
||||||
|
|
||||||
|
arr_options=[]
|
||||||
|
|
||||||
|
#arr_options=['<a href="{}">{}</a>'.format(url_for('admin_app.virtualhost', server_id=row_id), I18n.lang('dbservermariadb', 'server_users', 'Server users'))]
|
||||||
|
#arr_options=['<a href="{}">{}</a>'.format(url_for('admin_app.virtualhost', dbservermariadb_id=row_id), _('Websites'))]
|
||||||
|
#
|
||||||
|
#arr_options.append('<a href="{}">{}</a>'.format(url_for('admin_app.ports', dbservermariadb_id=row_id), I18n.lang('dbservermariadb', 'http_ports', 'HTTP Ports')))
|
||||||
|
arr_options.append('<a href="{}">{}</a>'.format("", _('Edit')))
|
||||||
|
arr_options.append('<a href="{}">{}</a>'.format("", _('Delete')))
|
||||||
|
|
||||||
|
return '<br />'.join(arr_options)
|
||||||
29
models/php.py
Normal file
29
models/php.py
Normal file
|
|
@ -0,0 +1,29 @@
|
||||||
|
from paramecio2.libraries.db.webmodel import WebModel
|
||||||
|
from paramecio2.libraries.db import corefields
|
||||||
|
from paramecio2.libraries.db.extrafields.dictfield import DictField
|
||||||
|
from paramecio2.libraries.db.extrafields.datefield import DateField
|
||||||
|
from paramecio2.libraries.db.extrafields.datetimefield import DateTimeField
|
||||||
|
from paramecio2.libraries.db.extrafields.ipfield import IpField
|
||||||
|
from paramecio2.libraries.db.extrafields.urlfield import UrlField
|
||||||
|
from paramecio2.libraries.db.extrafields.urlfield import DomainField
|
||||||
|
from paramecio2.libraries.db.extrafields.dictfield import DictField
|
||||||
|
from paramecio2.libraries.db.extrafields.jsonfield import JsonValueField
|
||||||
|
from paramecio2.libraries.db.extrafields.parentfield import ParentField
|
||||||
|
from paramecio2.libraries.db.extrafields.filefield import FileField
|
||||||
|
from paramecio2.libraries.urls import make_media_url
|
||||||
|
from paramecio2.libraries import datetime
|
||||||
|
from paramecio2.modules.admin.models.admin import UserAdmin
|
||||||
|
from modules.pastafari2.models.tasks import LonelyIpField
|
||||||
|
from modules.pastafari2.models.pastafari2 import ServerDbTask
|
||||||
|
|
||||||
|
#languages={'php': ['8.2', '8.3', '8.4']}
|
||||||
|
|
||||||
|
class PHPServer(WebModel):
|
||||||
|
|
||||||
|
def __init__(self, connection):
|
||||||
|
|
||||||
|
super().__init__(connection)
|
||||||
|
self.register(corefields.CharField('version'), True)
|
||||||
|
self.register(corefields.ForeignKeyField('server_id', ServerDbTask(connection), 11, False, 'id', 'hostname', select_fields=[]))
|
||||||
|
self.register(IpField('access_ip'))
|
||||||
|
|
||||||
70
scripts/install_php.py
Normal file
70
scripts/install_php.py
Normal file
|
|
@ -0,0 +1,70 @@
|
||||||
|
|
||||||
|
from pastafariutils import linux
|
||||||
|
import distro
|
||||||
|
import argparse
|
||||||
|
import os
|
||||||
|
|
||||||
|
php_versions=['8.2', '8.3', '8.4']
|
||||||
|
|
||||||
|
linux_distro=distro.id()
|
||||||
|
|
||||||
|
parser=argparse.ArgumentParser(prog='install_php.py', description='Script for install php')
|
||||||
|
|
||||||
|
parser.add_argument('--version', help='The version of php', required=True)
|
||||||
|
|
||||||
|
parser.add_argument('--ip', help='The IP where php-fpm receive orders')
|
||||||
|
|
||||||
|
args=parser.parse_args()
|
||||||
|
|
||||||
|
ip=None
|
||||||
|
|
||||||
|
if args.ip:
|
||||||
|
ip=args.ip
|
||||||
|
|
||||||
|
|
||||||
|
version=args.version
|
||||||
|
|
||||||
|
if not version in php_versions:
|
||||||
|
linux.json_log('Error: php version not supported', error=1, status=1, progress=100, no_progress=0);
|
||||||
|
exit(1)
|
||||||
|
|
||||||
|
|
||||||
|
linux.json_log('Installing repos...', error=0, status=0, progress=0, no_progress=0);
|
||||||
|
|
||||||
|
if linux_distro=='debian':
|
||||||
|
|
||||||
|
if not os.path.isfile('/etc/apt/sources.list.d/php.list'):
|
||||||
|
|
||||||
|
# Add sury repos
|
||||||
|
add_repos={'debian': "sudo apt-get update & sudo apt-get -y install lsb-release ca-certificates curl & sudo curl -sSLo /usr/share/keyrings/deb.sury.org-php.gpg https://packages.sury.org/php/apt.gpg &sudo ln -s /usr/share/keyrings/deb.sury.org-php.gpg /etc/apt/trusted.gpg.d/deb.sury.org-php.gpg & sudo sh -c 'echo \"deb [signed-by=/usr/share/keyrings/deb.sury.org-php.gpg] https://packages.sury.org/php/ $(lsb_release -sc) main\" > /etc/apt/sources.list.d/php.list'"}
|
||||||
|
|
||||||
|
linux.exec(add_repos)
|
||||||
|
|
||||||
|
linux.exec({'debian': 'sudo apt-get update'})
|
||||||
|
|
||||||
|
if linux_distro=='almalinux' or linux_distro=='rocky' or linux_distro=='fedora':
|
||||||
|
|
||||||
|
pass
|
||||||
|
|
||||||
|
linux.json_log('Repos installed...', error=0, status=0, progress=100, no_progress=0);
|
||||||
|
|
||||||
|
# Install php-fpm version
|
||||||
|
|
||||||
|
install_php={'debian': 'sudo DEBIAN_FRONTEND="noninteractive" apt-get install -y php{version}-fpm php{version}-gd php{version}-mysql php{version}-curl php{version}-mbstring php{version}-intl php{version}-imagick php{version}-xml php{version}-zip php{version}-redis unzip'.format(version=version)}
|
||||||
|
|
||||||
|
linux.json_log('Install php {}...'.format(version), error=0, status=0, progress=0, no_progress=1);
|
||||||
|
|
||||||
|
linux.exec(install_php)
|
||||||
|
|
||||||
|
#sed_php={'debian' : ['ServerTokens OS', "ServerTokens Prod", '\/etc\/apache2\/conf-enabled\/security.conf']}
|
||||||
|
|
||||||
|
"""
|
||||||
|
debian_package='apache2 logrotate socat curl'
|
||||||
|
|
||||||
|
redhat_package='httpd mod_ssl mod_md openssl tar socat policycoreutils-python-utils wget'
|
||||||
|
|
||||||
|
linux_package={'debian' : debian_package, 'ubuntu' : debian_package, 'fedora' : redhat_package, 'almalinux' : redhat_package, 'rocky' : redhat_package, 'arch' : 'apache'}
|
||||||
|
|
||||||
|
linux.install_package(linux_package);
|
||||||
|
|
||||||
|
"""
|
||||||
15
settings/config_admin.py
Normal file
15
settings/config_admin.py
Normal file
|
|
@ -0,0 +1,15 @@
|
||||||
|
from paramecio2.libraries.config_admin import config_admin
|
||||||
|
from paramecio2.libraries.i18n import I18n, PGetText
|
||||||
|
from settings import config
|
||||||
|
import os
|
||||||
|
|
||||||
|
pgettext=PGetText(__file__+'/../')
|
||||||
|
_=pgettext.gettext
|
||||||
|
|
||||||
|
def php():
|
||||||
|
|
||||||
|
return _('PHP servers')
|
||||||
|
|
||||||
|
config_admin.append(['PHP'])
|
||||||
|
|
||||||
|
config_admin.append([php(), 'modules.phpserver.dashboard', 'php_app.php_dashboard', '<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 640 512" width="24" style="fill: currentColor;display: inline-block;vertical-align: -.130em;position:relative;left:-6px;"><!--!Font Awesome Free 6.7.2 by @fontawesome - https://fontawesome.com License - https://fontawesome.com/license/free Copyright 2025 Fonticons, Inc.--><path d="M320 104.5c171.4 0 303.2 72.2 303.2 151.5S491.3 407.5 320 407.5c-171.4 0-303.2-72.2-303.2-151.5S148.7 104.5 320 104.5m0-16.8C143.3 87.7 0 163 0 256s143.3 168.3 320 168.3S640 349 640 256 496.7 87.7 320 87.7zM218.2 242.5c-7.9 40.5-35.8 36.3-70.1 36.3l13.7-70.6c38 0 63.8-4.1 56.4 34.3zM97.4 350.3h36.7l8.7-44.8c41.1 0 66.6 3 90.2-19.1 26.1-24 32.9-66.7 14.3-88.1-9.7-11.2-25.3-16.7-46.5-16.7h-70.7L97.4 350.3zm185.7-213.6h36.5l-8.7 44.8c31.5 0 60.7-2.3 74.8 10.7 14.8 13.6 7.7 31-8.3 113.1h-37c15.4-79.4 18.3-86 12.7-92-5.4-5.8-17.7-4.6-47.4-4.6l-18.8 96.6h-36.5l32.7-168.6zM505 242.5c-8 41.1-36.7 36.3-70.1 36.3l13.7-70.6c38.2 0 63.8-4.1 56.4 34.3zM384.2 350.3H421l8.7-44.8c43.2 0 67.1 2.5 90.2-19.1 26.1-24 32.9-66.7 14.3-88.1-9.7-11.2-25.3-16.7-46.5-16.7H417l-32.8 168.7z"/></svg>'])
|
||||||
9
tasks/php/info.cfg
Normal file
9
tasks/php/info.cfg
Normal file
|
|
@ -0,0 +1,9 @@
|
||||||
|
[info]
|
||||||
|
name=PHP FPM
|
||||||
|
description=Install php-fpm in a server
|
||||||
|
|
||||||
|
[modules]
|
||||||
|
php/install_php=Install php-fpm in a server.
|
||||||
|
|
||||||
|
[form]
|
||||||
|
php/install_php=1
|
||||||
207
tasks/php/php/install_php.py
Normal file
207
tasks/php/php/install_php.py
Normal file
|
|
@ -0,0 +1,207 @@
|
||||||
|
#/usr/bin/env python3
|
||||||
|
|
||||||
|
from modules.pastafari2.libraries.task import Task
|
||||||
|
#from modules.pastafari.models.tasks import TaskModel
|
||||||
|
from paramecio2.libraries.db import coreforms
|
||||||
|
from paramecio2.libraries.db.extrafields.ipfield import IpField
|
||||||
|
from paramecio2.libraries.formsutils import show_form
|
||||||
|
from collections import OrderedDict
|
||||||
|
from paramecio2.libraries.urls import make_media_url, make_url
|
||||||
|
from modules.pastafari2.models.pastafari2 import ServerDbTask
|
||||||
|
from modules.pastafari2.libraries.configtask import config_task
|
||||||
|
import json
|
||||||
|
try:
|
||||||
|
from modules.phpserver.models.php import PHPServer
|
||||||
|
server_db=True
|
||||||
|
except:
|
||||||
|
server_db=False
|
||||||
|
|
||||||
|
php_version=['8.2', '8.3', '8.4']
|
||||||
|
|
||||||
|
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='PHP-FPM installation'
|
||||||
|
|
||||||
|
self.description_task='Installation of a standalone php-fpm server'
|
||||||
|
|
||||||
|
self.codename_task='php-fpm'
|
||||||
|
|
||||||
|
self.files=[['modules/php/scripts/install_php.py', 0o700]]
|
||||||
|
|
||||||
|
# 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/php/scripts/']
|
||||||
|
|
||||||
|
#self.task=Task(conn)
|
||||||
|
|
||||||
|
#self.one_time=True
|
||||||
|
|
||||||
|
self.version='1.0'
|
||||||
|
|
||||||
|
self.links='<p><a href="{}">{}</a></p>'.format(make_url('pastafari2/php/servers'), _('PHP-FPM servers list'))
|
||||||
|
|
||||||
|
self.arr_form=OrderedDict()
|
||||||
|
|
||||||
|
self.arr_form['version']=coreforms.SelectForm('version', '8.2', {'8.2': '8.2', '8.3': '8.3', '8.4': '8.4'})
|
||||||
|
|
||||||
|
self.arr_form['version'].required=True
|
||||||
|
|
||||||
|
self.arr_form['version'].label=_('Version')
|
||||||
|
|
||||||
|
"""
|
||||||
|
self.arr_form['mysql_password']=coreforms.PasswordForm('mysql_password', '')
|
||||||
|
|
||||||
|
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:
|
||||||
|
dbserver=PHPServer(self.connection)
|
||||||
|
|
||||||
|
dbserver.safe_query()
|
||||||
|
|
||||||
|
serverdb=ServerDbTask(self.connection)
|
||||||
|
|
||||||
|
arr_server=serverdb.set_conditions('WHERE ip=%s', [self.server]).select_a_row_where()
|
||||||
|
|
||||||
|
if arr_server:
|
||||||
|
dbserver.insert({'version': self.data['version'], 'server_id': arr_server['id']})
|
||||||
|
|
||||||
|
return True
|
||||||
|
|
||||||
|
|
||||||
|
def pre_task(self):
|
||||||
|
|
||||||
|
ip_option=''
|
||||||
|
|
||||||
|
#if 'ip' in self.data:
|
||||||
|
# ip_option='--ip='+self.data['ip']
|
||||||
|
|
||||||
|
version='8.2'
|
||||||
|
|
||||||
|
if 'version' in self.data:
|
||||||
|
version=self.data['version']
|
||||||
|
|
||||||
|
self.commands_to_execute=[['/home/{}/pythonenv/bin/python3 -u modules/php/scripts/install_php.py'.format(config_task.remote_user), '--version={}'.format(version)]]
|
||||||
|
#self.commands_to_execute=[['/home/{}/pythonenv/bin/python3 -u modules/apache/scripts/install_apache.py'.format(config_task.remote_user), '']]
|
||||||
|
|
||||||
|
return True
|
||||||
|
|
||||||
|
def form(self, t, yes_error=False, pass_values=False, values={}):
|
||||||
|
|
||||||
|
#Here load the form for it task
|
||||||
|
|
||||||
|
return '<h2>PHP-FPM configuration</h2>'+show_form(values, self.arr_form, t, yes_error, pass_values)
|
||||||
|
|
||||||
|
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'])
|
||||||
|
if not self.data['version'] in php_version:
|
||||||
|
|
||||||
|
self.arr_form['version'].error=True
|
||||||
|
self.arr_form['version'].txt_error='Incorrect version'
|
||||||
|
|
||||||
|
error=1
|
||||||
|
|
||||||
|
dbserver=PHPServer(self.connection)
|
||||||
|
|
||||||
|
dbserver.safe_query()
|
||||||
|
|
||||||
|
serverdb=ServerDbTask(self.connection)
|
||||||
|
|
||||||
|
server_id=json.loads(post['ids'])[0]
|
||||||
|
print(server_id)
|
||||||
|
arr_server=serverdb.select_a_row(server_id)
|
||||||
|
|
||||||
|
if arr_server:
|
||||||
|
#dbserver.insert({'version': self.data['version'], 'server_id': arr_server['id']})
|
||||||
|
|
||||||
|
c=dbserver.set_conditions('WHERE server_id=%s and version=%s', [arr_server['id'], self.data['version']]).select_count()
|
||||||
|
|
||||||
|
if c>0:
|
||||||
|
self.arr_form['version'].error=True
|
||||||
|
self.arr_form['version'].txt_error='Error: version installed'
|
||||||
|
|
||||||
|
error=1
|
||||||
|
|
||||||
|
else:
|
||||||
|
self.arr_form['version'].error=True
|
||||||
|
self.arr_form['version'].txt_error='Server incorrect'
|
||||||
|
|
||||||
|
error=1
|
||||||
|
|
||||||
|
if error:
|
||||||
|
return False
|
||||||
|
else:
|
||||||
|
return True
|
||||||
|
|
||||||
|
|
||||||
17
templates/admin/phpservers.phtml
Normal file
17
templates/admin/phpservers.phtml
Normal file
|
|
@ -0,0 +1,17 @@
|
||||||
|
<%inherit file="dashboard.phtml"/>
|
||||||
|
<%block name="content">
|
||||||
|
<p><a href="${url_for('admin_app.pastafari2_dashboard', task_path='modules/phpserver/tasks/php/php/install_php.py')}">${_('Add PHP server')}</a>
|
||||||
|
<div id="table_servers">
|
||||||
|
</div>
|
||||||
|
<%block name="jscript_block">
|
||||||
|
<script language="Javascript" src="${make_media_url('js/jsutils/posting2.js', 'pastafari2')}"></script>
|
||||||
|
<script language="Javascript" src="${make_media_url('js/jsutils/ajax_list.js', 'pastafari2')}"></script>
|
||||||
|
<script>
|
||||||
|
|
||||||
|
options={'url': "${url_for('php_app.get_phpservers')}", extra_data: {}};
|
||||||
|
|
||||||
|
alist=$('#table_servers').ajaxList('table_list', options);
|
||||||
|
|
||||||
|
</script>
|
||||||
|
</%block>
|
||||||
|
</%block>
|
||||||
Loading…
Add table
Add a link
Reference in a new issue