Added files
This commit is contained in:
commit
4bfd948989
9 changed files with 557 additions and 0 deletions
70
scripts/install_php.py
Normal file
70
scripts/install_php.py
Normal file
|
|
@ -0,0 +1,70 @@
|
|||
|
||||
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 apt-get update & sudo apt-get -y install lsb-release ca-certificates curl & sudo curl -sSLo /usr/share/keyrings/deb.sury.org-php.gpg https://packages.sury.org/php/apt.gpg &sudo ln -s /usr/share/keyrings/deb.sury.org-php.gpg /etc/apt/trusted.gpg.d/deb.sury.org-php.gpg & sudo sh -c 'echo \"deb [signed-by=/usr/share/keyrings/deb.sury.org-php.gpg] https://packages.sury.org/php/ $(lsb_release -sc) main\" > /etc/apt/sources.list.d/php.list'"}
|
||||
|
||||
linux.exec(add_repos)
|
||||
|
||||
linux.exec({'debian': 'sudo apt-get update'})
|
||||
|
||||
if linux_distro=='almalinux' or linux_distro=='rocky' or linux_distro=='fedora':
|
||||
|
||||
pass
|
||||
|
||||
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)}
|
||||
|
||||
linux.json_log('Install php {}...'.format(version), error=0, status=0, progress=0, no_progress=1);
|
||||
|
||||
linux.exec(install_php)
|
||||
|
||||
#sed_php={'debian' : ['ServerTokens OS', "ServerTokens Prod", '\/etc\/apache2\/conf-enabled\/security.conf']}
|
||||
|
||||
"""
|
||||
debian_package='apache2 logrotate socat curl'
|
||||
|
||||
redhat_package='httpd mod_ssl mod_md 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);
|
||||
|
||||
"""
|
||||
Loading…
Add table
Add a link
Reference in a new issue