Fixers in manager_apache

This commit is contained in:
Antonio de la Rosa 2025-05-17 18:21:04 +02:00
parent 8231aa715c
commit 592ad67719
5 changed files with 66 additions and 49 deletions

View file

@ -82,6 +82,7 @@ def options_options(row_id, row):
# #
#arr_options.append('<a href="{}">{}</a>'.format(url_for('admin_app.ports', webserver_id=row_id), _('HTTP Ports'))) #arr_options.append('<a href="{}">{}</a>'.format(url_for('admin_app.ports', webserver_id=row_id), _('HTTP Ports')))
#arr_options.append('<a href="{}">{}</a>'.format("", _('Edit'))) #arr_options.append('<a href="{}">{}</a>'.format("", _('Edit')))
arr_options.append('<a href="{}">{}</a>'.format(url_for('admin_app.webservers_edit_languages', webserver_id=row_id), _('Languages')))
arr_options.append('<a href="{}">{}</a>'.format(url_for('admin_app.delete_webserver', webserver_id=row_id), _('Delete'))) arr_options.append('<a href="{}">{}</a>'.format(url_for('admin_app.delete_webserver', webserver_id=row_id), _('Delete')))
return '<br />'.join(arr_options) return '<br />'.join(arr_options)
@ -628,7 +629,7 @@ def edit_virtualhost(virtualhost_id):
virtual=VirtualHost(db) virtual=VirtualHost(db)
#arr_vhost=virtual.select_a_row(virtualhost_id, [], True) #arr_vhost=virtual.select_a_row(virtualhost_id, [], True)
with virtual.query('select virtualhost.*, webserver.id, serverdbtask.distro from virtualhost, webserver, serverdbtask WHERE virtualhost.id=%s AND virtualhost.webserver_id=webserver.id AND webserver.server_id=serverdbtask.id', [virtualhost_id]) as cursor: with virtual.query('select virtualhost.*, webserver.id, serverdbtask.distro, serverdbtask.id from virtualhost, webserver, serverdbtask WHERE virtualhost.id=%s AND virtualhost.webserver_id=webserver.id AND webserver.server_id=serverdbtask.id', [virtualhost_id]) as cursor:
arr_vhost=cursor.fetchone() arr_vhost=cursor.fetchone()
@ -676,10 +677,22 @@ def edit_virtualhost(virtualhost_id):
virtual.fields['php'].label=_('PHP support') virtual.fields['php'].label=_('PHP support')
virtual.fields['php'].name_form=SelectForm virtual.fields['php'].name_form=SelectForm
"""
if arr_vhost['distro']!='arch': if arr_vhost['distro']!='arch':
virtual.fields['php'].extra_parameters=[{'': 'No php support', '7.4': 'PHP 7.4', '8.0': 'PHP 8.0', '8.1': 'PHP 8.1', '8.2': 'PHP 8.2', '8.3': 'PHP 8.3'}] virtual.fields['php'].extra_parameters=[{'': 'No php support', '7.4': 'PHP 7.4', '8.0': 'PHP 8.0', '8.1': 'PHP 8.1', '8.2': 'PHP 8.2', '8.3': 'PHP 8.3'}]
else: else:
virtual.fields['php'].extra_parameters=[{'': 'No php support', '8.1': 'PHP 8.1 (On Arch, php-legacy for maximum compatibility)'}] virtual.fields['php'].extra_parameters=[{'': 'No php support', '8.1': 'PHP 8.1 (On Arch, php-legacy for maximum compatibility)'}]
"""
with db.query('select * from phpserver where server_id=%s', [arr_vhost['serverdbtask.id']]) as cursor:
arr_php=cursor.fetchall()
#print(arr_php)
virtual.fields['php'].extra_parameters=[{'': 'No php support'}]
for p in arr_php:
#print(p['version'])
virtual.fields['php'].extra_parameters[0][p['version']]='PHP '+p['version']
virtual.fields['php'].help=_('Add support to php to virtualhost. You can choose ophp version that you prefer') virtual.fields['php'].help=_('Add support to php to virtualhost. You can choose ophp version that you prefer')
@ -829,7 +842,7 @@ def save_edit_virtualhost():
php=request.form.get('php', '') php=request.form.get('php', '')
if php!='': if php!='':
if php!='7.4' and php!='8.0' and php!='8.1' and php!='8.2' and php!='8.3': if php!='8.2' and php!='8.3' and php!='8.4':
php='' php=''
task_id=0 task_id=0

View file

@ -164,47 +164,6 @@ if [ "$DISTRO" = 'debian' ] || [ "$DISTRO" = 'ubuntu' ]; then
fi fi
if [ -f "/usr/local/bin/composer" ]; then
echo "Updating composer..."
# need sudo for composer autoupdate
sudo /usr/local/bin/composer self-update
else
echo "Installing composer..."
EXPECTED_CHECKSUM="$(php -r 'copy("https://composer.github.io/installer.sig", "php://stdout");')"
php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');"
ACTUAL_CHECKSUM="$(php -r "echo hash_file('sha384', 'composer-setup.php');")"
if [ "$EXPECTED_CHECKSUM" != "$ACTUAL_CHECKSUM" ]
then
>&2 echo 'ERROR: Invalid installer checksum'
rm composer-setup.php
exit 1
fi
php composer-setup.php --quiet
RESULT=$?
rm composer-setup.php
sudo mv composer.phar /usr/local/bin/composer
if [ $RESULT -eq 0 ]; then
echo '{"error": 0, "status": 0, "progress": 100, "no_progress":0, "message": "Composer installed sucessfully..."}'
else
echo '{"error": 1, "status": 1, "progress": 100, "no_progress":0, "message": "Error: cannot install composer!"}'
exit 1
fi
fi
elif [ "$DISTRO" = 'rocky' ] || [ "$DISTRO" = 'almalinux' ] || [ "$DISTRO" = 'fedora' ]; then elif [ "$DISTRO" = 'rocky' ] || [ "$DISTRO" = 'almalinux' ] || [ "$DISTRO" = 'fedora' ]; then
@ -316,3 +275,46 @@ else
fi fi
echo "Installing composer..."
if [ -f "/usr/local/bin/composer" ]; then
echo "Updating composer..."
# need sudo for composer autoupdate
sudo /usr/local/bin/composer self-update
else
echo "Installing composer..."
EXPECTED_CHECKSUM="$(php -r 'copy("https://composer.github.io/installer.sig", "php://stdout");')"
php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');"
ACTUAL_CHECKSUM="$(php -r "echo hash_file('sha384', 'composer-setup.php');")"
if [ "$EXPECTED_CHECKSUM" != "$ACTUAL_CHECKSUM" ]
then
>&2 echo 'ERROR: Invalid installer checksum'
rm composer-setup.php
exit 1
fi
php composer-setup.php --quiet
RESULT=$?
rm composer-setup.php
sudo mv composer.phar /usr/local/bin/composer
if [ $RESULT -eq 0 ]; then
echo '{"error": 0, "status": 0, "progress": 100, "no_progress":0, "message": "Composer installed sucessfully..."}'
else
echo '{"error": 1, "status": 1, "progress": 100, "no_progress":0, "message": "Error: cannot install composer!"}'
exit 1
fi
fi

View file

@ -604,7 +604,7 @@ def manage():
json_return['error']=0 json_return['error']=0
json_return['status']=0 json_return['status']=0
json_return['progress']=100 json_return['progress']=100
json_return['message']='Cleaning certbot ssl certificate for the domain' json_return['message']='Cleaning certbot ssl certificate for the domain...'
print(json.dumps(json_return)) print(json.dumps(json_return))

View file

@ -1,10 +1,12 @@
from paramecio2.libraries.config_admin import config_admin from paramecio2.libraries.config_admin import config_admin
from paramecio2.libraries.i18n import I18n from paramecio2.libraries.i18n import I18n
from modules.apache.admin import install_apps from modules.apache.admin import install_apps
from modules.apache.admin import languages
#modules_admin=[[I18n.lang('admin', 'users_admin', 'User\'s Admin'), 'paramecio.modules.admin.admin.ausers', 'ausers']] #modules_admin=[[I18n.lang('admin', 'users_admin', 'User\'s Admin'), 'paramecio.modules.admin.admin.ausers', 'ausers']]
config_admin.append([I18n.lang('webservers', 'webservers_apache_admin', 'Apache Webservers')]) config_admin.append([I18n.lang('webservers', 'webservers_apache_admin', 'Apache Webservers')])
config_admin.append([I18n.lang('webservers', 'webservers_apache', 'Webservers'), 'modules.apache.admin.app', 'admin_app.webservers', 'fa-globe']) config_admin.append([I18n.lang('webservers', 'webservers_apache', 'Webservers'), 'modules.apache.admin.app', 'admin_app.webservers', 'fa-globe'])
#config_admin.append([I18n.lang('webservers', 'webservers_apache', 'Webservers'), 'modules.apache.admin.languages', 'admin_app.webservers', 'fa-globe'])
#config_admin.append([I18n.lang('webservers', 'webservers', 'Webservers'), 'modules.webservers.admin.install_apps', 'admin_app.install_apps', 'fa-globe']) #config_admin.append([I18n.lang('webservers', 'webservers', 'Webservers'), 'modules.webservers.admin.install_apps', 'admin_app.install_apps', 'fa-globe'])

View file

@ -18,13 +18,13 @@ class ServerTask(Task):
self.name_task='Edit virtualhost in server' self.name_task='Edit virtualhost in server'
self.description_task='Edot a virtual host in a server, or many of them' self.description_task='Edit a virtual host in a server, or many of them'
self.codename_task='edit_virtualhost_apache' self.codename_task='edit_virtualhost_apache'
self.files=[] self.files=[]
self.files=[['modules/apache/scripts/manage_apache.py', 0o755], ['modules/apache/scripts/files/vhost.tpl', 0o644]] self.files=[['modules/apache/scripts/manage_apache.py', 0o755], ['modules/apache/scripts/add_php_vhost.py', 0o755], ['modules/apache/scripts/files/vhost.tpl', 0o644]]
if self.data['ssl']=='2': if self.data['ssl']=='2':
@ -104,10 +104,10 @@ class ServerTask(Task):
if self.data['php']!='': if self.data['php']!='':
php_support='--php_version='+self.data['php'] php_support='--php_version='+self.data['php']
self.files.append(['modules/apache/scripts/check_php.sh', 0o700]) #self.files.append(['modules/apache/scripts/check_php.sh', 0o700])
self.files.append(['modules/apache/scripts/add_php_vhost.py', 0o700]) #self.files.append(['modules/apache/scripts/add_php_vhost.py', 0o700])
self.commands_to_execute.append(['modules/apache/scripts/check_php.sh', self.data['php']]) #self.commands_to_execute.append(['modules/apache/scripts/check_php.sh', self.data['php']])
self.commands_to_execute.append(['modules/apache/scripts/add_php_vhost.py', '--user=%s --php_version=%s --domain=%s' % (self.data['user'], self.data['php'], self.data['domain']), 'sudo']) self.commands_to_execute.append(['modules/apache/scripts/add_php_vhost.py', '--user=%s --php_version=%s --domain=%s' % (self.data['user'], self.data['php'], self.data['domain']), 'sudo'])