From 4dd7e4531f95c934e678ffe97d78bb4e9983897c Mon Sep 17 00:00:00 2001 From: absurdo Date: Fri, 1 Dec 2023 23:53:14 +0100 Subject: [PATCH] Fixes in scripts for fedora derivatives --- scripts/install_apache.php | 6 ++++-- scripts/webapps/wordpress/install_wordpress_site.py | 10 +++++----- scripts/webapps/wordpress/install_wp.php | 10 +++++----- tasks/apache/scripts/wordpress.py | 4 ++-- 4 files changed, 16 insertions(+), 14 deletions(-) diff --git a/scripts/install_apache.php b/scripts/install_apache.php index 273972a..8d1b2df 100644 --- a/scripts/install_apache.php +++ b/scripts/install_apache.php @@ -10,9 +10,11 @@ $conf_vhosts="IncludeOptional vhosts.d/*.conf"; Linux::json_log('Installing Apache server', $error=0, $status=0, $progress=0, $no_progress=1); -$redhat_package='mod_ssl openssl tar socat policycoreutils-python-utils wget'; +$debian_package='apache2 logrotate socat curl'; -$linux_package=['debian' => 'apache2 logrotate socat curl', 'ubuntu' => 'apache2 logrotate socat curl', 'fedora' => $redhat_package, 'almalinux' => $redhat_package, 'rocky' => $redhat_package, 'arch' => 'apache']; +$redhat_package='httpd mod_ssl 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); diff --git a/scripts/webapps/wordpress/install_wordpress_site.py b/scripts/webapps/wordpress/install_wordpress_site.py index 24dc7b3..a119ce6 100644 --- a/scripts/webapps/wordpress/install_wordpress_site.py +++ b/scripts/webapps/wordpress/install_wordpress_site.py @@ -52,10 +52,10 @@ if linux_distro=='arch': php_command='/usr/bin/php-legacy' -if linux_distro=='fedora' or linux_distro=='rocky': +if linux_distro=='fedora' or linux_distro=='rocky' or linux_distro=='almalinux': php_command='/usr/bin/php'+args.php_version.replace('.', '') - + if linux_distro=='debian' or linux_distro=='ubuntu': php_command='/usr/bin/php'+args.php_version @@ -117,7 +117,7 @@ if os.path.isfile(home_user+'/index.php'): print('Installing Wordpress...') if subprocess.call("sudo su %s -s /bin/bash -c '%s %s core download'" % (user, php_command, wp_command), shell=True) > 0: - print('Error') + print("Error: %s %s core download\n" % (php_command, wp_command)) sys.exit(1) mysql_user=args.user_mysql @@ -128,7 +128,7 @@ host_db=args.server_mysql if args.port_mysql!=3306: host_db=host_db+':'+str(args.port_mysql) -if subprocess.call("sudo su %s -s /bin/bash -c '%s %s config create --dbname=%s --dbuser=%s --dbpass=%s --dbhost=%s'" % (user, php_command, wp_command, args.db_mysql, mysql_user, mysql_password, host_db), shell=True) > 0: +if subprocess.call("sudo su %s -s /bin/bash -c '%s %s config create --dbname=%s --dbuser=%s --dbpass=\"%s\" --dbhost=%s'" % (user, php_command, wp_command, args.db_mysql, mysql_user, mysql_password, host_db), shell=True) > 0: print('Error') sys.exit(1) @@ -136,7 +136,7 @@ print('Created basic config...') # Add cronjob for wordpress -if subprocess.call("sudo su %s -s /bin/bash -c '%s %s core install --url=%s --title=\"%s\" --admin_user=%s --admin_password=%s --admin_email=%s'" % (user, php_command, wp_command, args.domain+args.path, args.title, args.user, args.password, args.email), shell=True) > 0: +if subprocess.call("sudo su %s -s /bin/bash -c '%s %s core install --url=%s --title=\"%s\" --admin_user=%s --admin_password=\"%s\" --admin_email=%s'" % (user, php_command, wp_command, args.domain+args.path, args.title, args.user, args.password, args.email), shell=True) > 0: print('Error: cannot install wordpress') sys.exit(1) else: diff --git a/scripts/webapps/wordpress/install_wp.php b/scripts/webapps/wordpress/install_wp.php index 386d2a6..9258a25 100644 --- a/scripts/webapps/wordpress/install_wp.php +++ b/scripts/webapps/wordpress/install_wp.php @@ -6,7 +6,7 @@ include('leviathanutils/vendor/autoload.php'); $user=get_current_user(); -$file_wp='./bin/wp'; +$file_wp='/usr/local/bin/wp'; Linux::json_log('Installing WP Wordpress utility...', $error=0, $status=0, $progress=0, $no_progress=1); @@ -14,20 +14,20 @@ if(is_file($file_wp)) { Linux::json_log('Installed, updating wp...', $error=0, $status=0, $progress=0, $no_progress=1); - Linux::shell_command(['./bin/wp cli update --yes']); + Linux::shell_command(["sudo ${file_wp} cli update --yes"]); } else { - + /* if(!is_dir('./bin')) { mkdir('./bin'); - } + }*/ Linux::shell_command(['curl -O https://raw.githubusercontent.com/wp-cli/builds/gh-pages/phar/wp-cli.phar']); Linux::shell_command(['chmod +x wp-cli.phar']); - Linux::shell_command(["mv wp-cli.phar ./bin/wp && sudo ln -s /home/${user}/bin/wp /usr/local/bin/wp"]); + Linux::shell_command(["sudo mv wp-cli.phar /usr/local/bin/wp"]); } diff --git a/tasks/apache/scripts/wordpress.py b/tasks/apache/scripts/wordpress.py index fc4b982..f100333 100644 --- a/tasks/apache/scripts/wordpress.py +++ b/tasks/apache/scripts/wordpress.py @@ -154,9 +154,9 @@ class ServerTask(WebAppTask): #self.commands_to_execute.append(['modules/webservers/scripts/add_php_vhost.py', '--user=%s --php_version=8.2 --domain=%s' % (self.data['username'], self.data['domain_wp']), 'sudo']) - 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']) + 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])