Added modify php.ini from phpserver module
This commit is contained in:
parent
56157e4adb
commit
ffdf81ec07
6 changed files with 295 additions and 37 deletions
|
|
@ -34,7 +34,7 @@ if linux_distro=='debian':
|
|||
|
||||
if not os.path.isfile(path_php_ini):
|
||||
|
||||
linux.json_log('Error: php.ini not found in {}'.path_php_ini(), error=1, status=1, progress=100, no_progress=0);
|
||||
linux.json_log('Error: php.ini not found in {}'+path_php_ini, error=1, status=1, progress=100, no_progress=0);
|
||||
exit(1)
|
||||
|
||||
php_ini_file=''
|
||||
|
|
|
|||
|
|
@ -36,7 +36,7 @@ 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'"}
|
||||
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)
|
||||
|
||||
|
|
@ -54,7 +54,7 @@ linux.json_log('Repos installed...', error=0, status=0, progress=100, no_progres
|
|||
|
||||
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['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']
|
||||
|
|
|
|||
91
scripts/save_php_ini.py
Normal file
91
scripts/save_php_ini.py
Normal file
|
|
@ -0,0 +1,91 @@
|
|||
|
||||
from pastafariutils import linux
|
||||
import distro
|
||||
import argparse
|
||||
import os
|
||||
import json
|
||||
|
||||
php_versions=['8.2', '8.3', '8.4']
|
||||
|
||||
linux_distro=distro.id()
|
||||
|
||||
parser=argparse.ArgumentParser(prog='save_php_ini.py', description='Script for save php.ini')
|
||||
|
||||
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()
|
||||
|
||||
version=args.version
|
||||
|
||||
linux.json_log('Saving php.ini from server', error=0, status=0, progress=0, no_progress=1);
|
||||
|
||||
path_php_ini='/etc/php/php.ini'
|
||||
|
||||
if linux_distro=='debian':
|
||||
path_php_ini='/etc/php/{}/fpm/php.ini'.format(version)
|
||||
|
||||
move_php_ini={'debian': 'sudo cp {} {}'.format(path_php_ini, path_php_ini+'.bak')}
|
||||
|
||||
move_php_ini['ubuntu']=move_php_ini['debian']
|
||||
|
||||
cp_php_ini={'debian': 'sudo cp ./tmp/php.ini {}'.format(path_php_ini)}
|
||||
|
||||
cp_php_ini['ubuntu']=cp_php_ini['debian']
|
||||
|
||||
linux.exec(move_php_ini)
|
||||
|
||||
linux.exec(cp_php_ini)
|
||||
|
||||
service_php={'debian': 'php{}-fpm.service'.format(version)}
|
||||
|
||||
service_php['ubuntu']=service_php['debian']
|
||||
|
||||
error=0
|
||||
|
||||
if not linux.systemd_service('restart', service_php):
|
||||
|
||||
restore_php_ini={'debian': 'sudo cp {} {}'.format(path_php_ini+'.bak', path_php_ini)}
|
||||
|
||||
restore_php_ini['ubuntu']=restore_php_ini['debian']
|
||||
|
||||
linux.json_log('Error: cannot save the new php.ini', error=1, status=1, progress=0, no_progress=1)
|
||||
else:
|
||||
|
||||
linux.json_log('php.ini modified successfully', error=0, status=1, progress=100, no_progress=0)
|
||||
|
||||
# sudo systemctl restart php8.4-fpm
|
||||
|
||||
#linux.json_log('Getting php.ini from server', error=0, status=0, progress=0, no_progress=1);
|
||||
|
||||
|
||||
|
||||
"""
|
||||
linux.json_log('Getting php.ini from server', error=0, status=0, progress=0, no_progress=1);
|
||||
|
||||
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)
|
||||
|
||||
path_php_ini='/etc/php/php.ini'
|
||||
|
||||
if linux_distro=='debian':
|
||||
path_php_ini='/etc/php/{}/fpm/php.ini'.format(version)
|
||||
|
||||
#print(path_php_ini)
|
||||
|
||||
if not os.path.isfile(path_php_ini):
|
||||
|
||||
linux.json_log('Error: php.ini not found in {}'.path_php_ini(), error=1, status=1, progress=100, no_progress=0);
|
||||
exit(1)
|
||||
|
||||
php_ini_file=''
|
||||
|
||||
with open(path_php_ini) as f:
|
||||
php_ini_file=f.read()
|
||||
|
||||
#print(json.dumps({'error': 0, 'status': 1, 'progress': 100, 'no_progress':0, 'message': '{"distro": "'+distro.id()+'"}', 'result': 1}))
|
||||
|
||||
linux.json_log(json.dumps({'file':php_ini_file}), error=0, status=1, progress=100, no_progress=0, result=1)
|
||||
"""
|
||||
Loading…
Add table
Add a link
Reference in a new issue