From cf07859027f1b53ba3dcd55027613e780d2fd7c6 Mon Sep 17 00:00:00 2001 From: absurdo Date: Tue, 28 Mar 2023 18:20:35 +0200 Subject: [PATCH] Fixes in scripts --- scripts/system/install_php.py | 29 +++++++++++++++++++++++++++++ scripts/system/install_psutil.py | 18 ++++++++++++++++++ scripts/system/install_python.sh | 8 ++++---- scripts/system/install_unixutils.sh | 6 ++++++ tasks/system/task.py | 4 ++++ templates/admin/multiprogress.phtml | 4 ++++ templates/admin/progress.phtml | 2 ++ 7 files changed, 67 insertions(+), 4 deletions(-) create mode 100644 scripts/system/install_php.py create mode 100644 scripts/system/install_psutil.py create mode 100644 scripts/system/install_unixutils.sh diff --git a/scripts/system/install_php.py b/scripts/system/install_php.py new file mode 100644 index 0000000..803cd2b --- /dev/null +++ b/scripts/system/install_php.py @@ -0,0 +1,29 @@ +#!/usr/bin/python3 -u + +# A script for install pzoo user + +from subprocess import call +from time import sleep +import distro + +linux_distro=distro.id() + +print('{"error": 0, "status": 0, "progress": 0, "no_progress":0, "message": "Installing php..."}') + +sleep(1) + +if linux_distro=='arch': + + if call("sudo pacman -S --noconfirm php php-gd php-pgsql php-snmp php-sodium php-sqlite", shell=True) > 0: + print('Error, cannot install php...') + exit(1) + +elif linux_distro=='debian' or linux_distro=='ubuntu': + + if call('sudo DEBIAN_FRONTEND="noninteractive" apt-get install -y php-fpm php-gd php-json php-mysql php-curl php-mbstring php-intl php-imagick php-xml php-zip php-redis unzip', shell=True) > 0: + print('Error, cannot install php...') + exit(1) +elif linux_distro=='rocky' or linux_distro=='fedora': + if call("sudo dnf install -y php php-gd php-mysqlnd php-fpm php-zip", shell=True) > 0: + print('Error, cannot install php...') + exit(1) diff --git a/scripts/system/install_psutil.py b/scripts/system/install_psutil.py new file mode 100644 index 0000000..11733bf --- /dev/null +++ b/scripts/system/install_psutil.py @@ -0,0 +1,18 @@ +#!/usr/bin/python3 -u + +# A script for install pzoo user + +import subprocess +import argparse +import re +import os +import shutil +import pwd +from subprocess import call +from pathlib import Path +from time import sleep +import distro + +if call("sudo useradd -m -s /bin/bash %s" % args.user, shell=True) > 0: + print('Error, cannot install psutil...') + exit(1) diff --git a/scripts/system/install_python.sh b/scripts/system/install_python.sh index f29c67b..9114151 100644 --- a/scripts/system/install_python.sh +++ b/scripts/system/install_python.sh @@ -13,15 +13,15 @@ DISTRO=`( lsb_release -ds || cat /etc/*release || uname -om ) 2>/dev/null | head if [[ $DISTRO =~ ^Debian ]] || [[ $DISTRO =~ ^Ubuntu ]]; then sudo apt-get update - sudo apt-get -y install python3 python3-pip + sudo apt-get -y install python3 python3-pip sudo elif [[ $DISTRO =~ ^NAME=\"Arch ]]; then - sudo pacman -Syu --noconfirm python python-pip + sudo pacman -Syu --noconfirm python python-pip sudo elif [[ $DISTRO =~ ^NAME=\"Rocky ]]; then - sudo dnf install -y python python-pip + sudo dnf install -y python python-pip sudo #Install EPEL dnf config-manager --set-enabled crb sudo dnf install -y \ @@ -33,7 +33,7 @@ elif [[ $DISTRO =~ ^Fedora ]]; then sudo dnf upgrade -y - sudo dnf install -y python3 python3-pip + sudo dnf install -y python3 python3-pip sudo else diff --git a/scripts/system/install_unixutils.sh b/scripts/system/install_unixutils.sh new file mode 100644 index 0000000..85a501a --- /dev/null +++ b/scripts/system/install_unixutils.sh @@ -0,0 +1,6 @@ +#!/bin/sh + +# Install unix tools repo. + +sudo pip3 install git+https://bitbucket.org/paramecio/pastafariutils + diff --git a/tasks/system/task.py b/tasks/system/task.py index 59d7c41..6ee8627 100644 --- a/tasks/system/task.py +++ b/tasks/system/task.py @@ -13,6 +13,8 @@ class ServerTask(Task): 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.py', 0o755]) + self.files.append(['modules/pastafari2/scripts/system/install_php.py', 0o755]) + self.files.append(['modules/pastafari2/scripts/system/install_unixutils.sh', 0o755]) self.files.append(['modules/pastafari2/scripts/system/sudoers.d/spanel', 0o640]) self.files.append([self.data['pub_key'], 0o600]) @@ -22,6 +24,8 @@ class ServerTask(Task): #self.commands_to_execute.append(['modules/pastafari2/scripts/system/alive.sh', '']) self.commands_to_execute.append(['modules/pastafari2/scripts/system/install_python.sh', '']) self.commands_to_execute.append(['modules/pastafari2/scripts/system/install_git.py', '']) + self.commands_to_execute.append(['modules/pastafari2/scripts/system/install_php.py', '']) + self.commands_to_execute.append(['modules/pastafari2/scripts/system/install_unixutils.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']+'" --path='+remote_path]) diff --git a/templates/admin/multiprogress.phtml b/templates/admin/multiprogress.phtml index 94ea357..3bd682d 100644 --- a/templates/admin/multiprogress.phtml +++ b/templates/admin/multiprogress.phtml @@ -1,6 +1,8 @@ <%inherit file="dashboard.phtml"/> <%block name="content"> +<%block name="go_back_top">

${lang('pastafari2', 'servers', 'Servers')} >> ${lang('pastafari2', 'task_progress', 'Task progress')}

+

${name_task}

${description_task}


@@ -17,8 +19,10 @@ +<%block name="go_back_bottom">

${lang('pastafari2', 'servers', 'Servers')} >> ${lang('pastafari2', 'task_progress', 'Task progress')}

+ <%block name="jscript_block">