64 lines
2.3 KiB
Python
64 lines
2.3 KiB
Python
|
|
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 curl -sSLo /tmp/debsuryorg-archive-keyring.deb https://packages.sury.org/debsuryorg-archive-keyring.deb && sudo dpkg -i /tmp/debsuryorg-archive-keyring.deb && sudo sh -c 'echo \"deb [signed-by=/usr/share/keyrings/debsuryorg-archive-keyring.gpg] https://packages.sury.org/php/ $(lsb_release -sc) main\" > /etc/apt/sources.list.d/php.list' && sudo apt-get update"}
|
|
|
|
linux.exec(add_repos)
|
|
|
|
repos={'debian': 'sudo apt-get update', 'fedora': 'echo "Remi repos installed by default..."'}
|
|
|
|
repos['rocky']=repos['fedora']
|
|
|
|
repos['almalinux']=repos['fedora']
|
|
|
|
linux.exec(repos)
|
|
|
|
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)}
|
|
|
|
install_php['fedora']='sudo dnf -y install php{version} php{version}-php-gd php{version}-php-mysqlnd php{version}-php-imap php{version}-php-intl php{version}-php-fpm php{version}-php-process composer unzip mariadb php{version}-php-pecl-zip'.format(version=version.replace('.', ''))
|
|
|
|
install_php['almalinux']=install_php['fedora']
|
|
install_php['rocky']=install_php['fedora']
|
|
|
|
linux.json_log('Install php {}...'.format(version), error=0, status=0, progress=0, no_progress=1);
|
|
|
|
linux.exec(install_php)
|