phpserver/scripts/get_php_ini.py

47 lines
1.3 KiB
Python

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='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()
version=args.version
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)