Fixes in scripts

This commit is contained in:
Antonio de la Rosa 2024-02-09 19:44:08 +01:00
parent ce92428dea
commit c7d3f1b1ad
7 changed files with 53 additions and 31 deletions

View file

@ -667,7 +667,7 @@ def edit_virtualhost(virtualhost_id):
virtual.fields['php'].label=I18n.lang('webservers', 'php_support', 'PHP support')
virtual.fields['php'].name_form=SelectForm
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'}]
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'].help=I18n.lang('webservers', 'add_php_support_to_virtualhost', 'Add support to php to virtualhost. You can choose ophp version that you prefer')
#'port', 'ssl_port',

View file

@ -17,34 +17,24 @@ linux.install_package(linux_package);
linux.json_log('Create directories for Apache manager...', error=0, status=0, progress=0, no_progress=1);
create_dirs={'debian' : {"sudo mkdir -p /etc/apache2/vhosts.d/ && sudo mkdir -p /etc/apache2/vhosts.d/{php,extra/proxyphp,extra/proxy}"}};
create_dirs={'debian' : "sudo mkdir -p /etc/apache2/vhosts.d/ && sudo mkdir -p /etc/apache2/vhosts.d/php && sudo mkdir -p /etc/apache2/vhosts.d/extra/proxyphp && sudo mkdir -p /etc/apache2/vhosts.d/extra/proxy"};
create_dirs['ubuntu']=create_dirs['debian'];
create_dirs['fedora']=["sudo mkdir -p /etc/httpd/vhosts.d/{php,extra/proxyphp,extra/proxy} "];
create_dirs['fedora']="sudo mkdir -p /etc/httpd/vhosts.d/php && sudo mkdir -p /etc/httpd/vhosts.d/extra/proxyphp && sudo mkdir -p /etc/httpd/vhosts.d/extra/proxy";
create_dirs['almalinux']=create_dirs['fedora'];
create_dirs['rocky']=create_dirs['fedora'];
create_dirs['arch']=create_dirs['fedora']
linux.exec(create_dirs);
#if(!file_put_contents('vhosts.conf', conf_vhosts)) {
with open('vhosts.conf', 'w') as f:
f.write(conf_vhosts)
# linux.json_log('Error: cannot create vhosts.conf', error=1, status=1, progress=100, no_progress=0);
# exit(1);
#}
try:
with fopen('vhosts.conf', 'w') as f:
f.write(conf_vhosts)
except:
linux.json_log('Error: cannot create vhosts.conf', error=1, status=1, progress=100, no_progress=0);
exit(1)
create_vhost_file={'debian' : ["sudo mv vhosts.conf /etc/apache2/sites-enabled/ && sudo chown root:root /etc/apache2/sites-enabled/vhosts.conf"]};
create_vhost_file={'debian' : "sudo mv vhosts.conf /etc/apache2/sites-enabled/ && sudo chown root:root /etc/apache2/sites-enabled/vhosts.conf"};
create_vhost_file['ubuntu']=create_vhost_file['debian'];
@ -52,24 +42,28 @@ create_vhost_file['ubuntu']=create_vhost_file['debian'];
#create_vhost_file['fedora']=["sudo mv vhosts.conf /etc/httpd/conf.d/zzz-vhosts.conf && sudo chown root:root /etc/httpd/conf.d/zzz-vhosts.conf && sudo chmod 644 /etc/httpd/conf.d/zzz-vhosts.conf"];
create_vhost_file['fedora']=["echo {conf_vhosts} | sudo tee -a /etc/httpd/conf/httpd.conf"];
create_vhost_file['fedora']="echo {} | sudo tee -a /etc/httpd/conf/httpd.conf".format(conf_vhosts)
create_vhost_file['almalinux']=create_vhost_file['fedora'];
create_vhost_file['rocky']=create_vhost_file['fedora'];
create_vhost_file['arch']=create_vhost_file['fedora'];
linux.exec(create_vhost_file);
#Modifying apache configuration
linux.json_log('Modifying Apache configuration...', error=0, status=0, progress=0, no_progress=1);
if linux_distro=='ubuntu' or linux_distro=='debian':
if linux_distro=='ubuntu' or linux_distro=='debian' or linux_distro=='arch':
sed_apache={'debian' : ['ServerTokens OS', "ServerTokens Prod", '/etc/apache2/conf-enabled/security.conf']}
sed_apache={'debian' : ['ServerTokens OS', "ServerTokens Prod", '\/etc\/apache2\/conf-enabled\/security.conf']}
sed_apache['ubuntu']=sed_apache['debian'];
sed_apache['arch']=['ServerTokens Full', 'ServerTokens Prod', '\/etc\/httpd\/conf\/extra\/httpd-default.conf']
linux.sed(sed_apache)
# In red hat derivatives is different.
@ -79,7 +73,7 @@ if linux_distro=='rocky' or linux_distro=='almalinux' or linux_distro=='fedora':
#echo 'deb blah ... blah' | sudo tee -a /etc/apt/sources.list
add_tokens={}
add_tokens['rocky']=["sudo echo \"ServerTokens Prod\" | sudo tee -a /etc/httpd/conf.d/tokens.conf"]
add_tokens['rocky']="sudo echo \"ServerTokens Prod\" | sudo tee -a /etc/httpd/conf.d/tokens.conf"
add_tokens['almalinux']=add_tokens['rocky']
@ -92,19 +86,40 @@ if linux_distro=='rocky' or linux_distro=='almalinux' or linux_distro=='fedora':
if linux_distro=='ubuntu' or linux_distro=='debian':
activate_modules={'debian' : ["sudo a2enmod ssl rewrite proxy proxy_fcgi headers"]}
activate_modules={'debian' : "sudo a2enmod ssl rewrite proxy proxy_fcgi headers"}
activate_modules['ubuntu']=create_vhost_file['debian'];
linux.exec(activate_modules)
# #LoadModule proxy_module modules/mod_proxy.so
#LoadModule proxy_scgi_module modules/mod_proxy_scgi.so
if linux_distro=='arch':
load_proxy={}
load_proxy['arch']=['#LoadModule proxy_module modules\/mod_proxy.so', "LoadModule proxy_module modules\/mod_proxy.so", '/etc/httpd/conf/httpd.conf']
linux.sed(load_proxy)
load_proxy_fcgi={'arch': ['#LoadModule proxy_fcgi_module modules\/mod_proxy_fcgi.so', "LoadModule proxy_fcgi_module modules\/mod_proxy_fcgi.so", '/etc/httpd/conf/httpd.conf']}
linux.sed(load_proxy_fcgi)
#Options Indexes FollowSymLinks
quit_indexes={'arch': ['Options Indexes FollowSymLinks', 'Options FollowSymLinks', '/etc/httpd/conf/httpd.conf']}
linux.sed(quit_indexes)
if linux_distro=='rocky' or linux_distro=='almalinux' or linux_distro=='fedora':
if linux.shell_command('sudo systemctl status firewalld', 0)==0:
if linux.shell_command('sudo systemctl status firewalld'):
linux.shell_command("sudo firewall-cmd --add-service=http && sudo firewall-cmd --add-service=http --permanent && sudo firewall-cmd --add-service=https && sudo firewall-cmd --add-service=https --permanent")
else:
print('Not firewalld detected...')
#Restart apache

View file

@ -10,7 +10,9 @@ from modules.pastafari2.models.tasks import ResultTask
from modules.pastafari2.models.pastafari2 import ServerDbTask
from modules.apache.models.webservers import WebServer
from settings import config
from modules.pastafari2.libraries.configtask import config_task
import json
from paramecio2.libraries.urls import make_media_url, make_url
class ServerTask(Task):
@ -26,7 +28,7 @@ class ServerTask(Task):
#['modules/webservers/scripts/install_quota_home.py', 0o700],
self.files=[['modules/apache/scripts/install_apache.php', 0o700]]
self.files=[['modules/apache/scripts/install_apache.py', 0o700]]
#self.commands_to_execute=[]
@ -38,7 +40,7 @@ class ServerTask(Task):
#--mysql_server={} --mysql_db={} --mysql_user={} --mysql_pass={}'.format(mysql_server, mysql_db, config.webserver_user_db, config.webserver_user_pass)
self.commands_to_execute=[['php modules/apache/scripts/install_apache.php', '']]
self.commands_to_execute=[['/home/{}/pythonenv/bin/python3 -u modules/apache/scripts/install_apache.py'.format(config_task.remote_user), '']]
#self.commands_to_execute.append(['modules/webservers/scripts/install_quota_home.py', '', 'sudo'])
@ -52,6 +54,9 @@ class ServerTask(Task):
self.version='1.0'
self.path_module='admin_app.webservers'
self.links='<p><a href="{}">{}</a></p>'.format(make_url('webservers/servers'), _('Webservers list'))
def post_task(self):

View file

@ -39,7 +39,7 @@ class ServerTask(WebAppTask):
self.delete_directories=['modules/apache/scripts']
self.path_module='admin_app.webservers'
self.path_module='admin_app.apache'
self.links='<p><a href="{}">{}</a> &gt;&gt; <a href="{}">{}</a> &gt;&gt; <a href="{}">{}</a>'.format(make_url('webservers/servers'), I18n.lang('webservers', 'webservers_list', 'Webservers list'), make_url('webservers/virtualhost/'+str(self.webserver_id)), I18n.lang('webservers', 'websites', 'Websites'), make_url('webapps/'+str(self.data['virtualhost_id'])), I18n.lang('webservers', 'webapps', 'Webapps'))

View file

@ -156,7 +156,7 @@ class ServerTask(WebAppTask):
install_wordpress='--home_user=%s --user=%s --password="%s" --email=%s --domain=%s --title="%s" --db_mysql=%s --user_mysql=%s --password_mysql="%s" --server_mysql="%s" --port_mysql=%i --path=%s --php_version=%s' % (self.data['home'], self.data['user_wp'], self.data['password_wp'], self.data['email_wp'], self.data['domain_wp'], self.data['title_wp'], self.data['mysql_db'], self.data['mysql_user'], self.data['mysql_password'], self.data['mysql_host'], 3306, self.data['path'], arr_virtualhost['php'])
print(install_wordpress)
#print(install_wordpress)
self.commands_to_execute.append(['modules/apache/scripts/webapps/wordpress/install_wordpress_site.py', install_wordpress])

View file

@ -18,8 +18,9 @@ ids=json.dumps([server_id])
<option value="${v[1]}">${v[0]}</option>
% endfor
</select>
<input type="hidden" name="ids" id="ids" value="${ids}"/>
</select></p>
</p>
</div>
<p><input type="submit" value="${lang('webservers', 'add_website', 'Add website')}" />
</form>

View file

@ -1,5 +1,6 @@
<%inherit file="dashboard.phtml"/>
<%block name="content">
<p><a href="${url_for('admin_app.pastafari2_dashboard', task_path='modules/apache/tasks/apache/apache/install_apache.py')}">${_('Add new server')}</a></p>
<div id="table_servers">
</div>
<%block name="jscript_block">