| Current File : /home/mmdealscpanel/yummmdeals.com/alt-php-config.zip |
PK ���Ze<�5$ $ alt-php.cfgnu �[��� [MultiPHP Manager]
alt-php44 = yes
alt-php51 = yes
alt-php52 = yes
alt-php53 = yes
alt-php54 = yes
alt-php55 = yes
alt-php56 = yes
alt-php70 = yes
alt-php71 = yes
alt-php72 = yes
alt-php73 = yes
alt-php74 = yes
alt-php80 = yes
alt-php81 = yes
alt-php82 = yes
alt-php83 = yes
alt-php84 = yes
PK ���ZT�!d d # __pycache__/detectcp.cpython-36.pycnu �[��� 3
!hh� � @ s d dl Z dd� ZdS )� Nc C s` t jjd�rdS t jjd�s(t jjd�r,dS t jjd�r<dS t jjd�rLd S t jjd
�r\dS dS )
Nz/usr/local/cpanel/cpanelZcPanelz"/usr/local/directadmin/directadminz(/usr/local/directadmin/custombuild/buildZDirectAdminz/usr/local/interworx/iworx.iniZ InterWorxz/usr/local/ispmgr/bin/ispmgrZ
ISPManagerz/usr/local/psa/version�PleskZUnknown)�os�path�isfile� r r �#/opt/alt/alt-php-config/detectcp.py� getCPName s r )r r r r r r �<module> s PK ���Z�ph� � detectcp.pynu ȯ�� #!/usr/libexec/platform-python
# -*- mode:python; coding:utf-8; -*-
import os
def getCPName():
# cPanel
if os.path.isfile('/usr/local/cpanel/cpanel'):
return "cPanel"
# DirectAdmin
if os.path.isfile('/usr/local/directadmin/directadmin') or \
os.path.isfile('/usr/local/directadmin/custombuild/build'):
return "DirectAdmin"
# InterWorx
if os.path.isfile('/usr/local/interworx/iworx.ini'):
return "InterWorx"
# ISPManager
if os.path.isfile('/usr/local/ispmgr/bin/ispmgr'):
return "ISPManager"
# Plesk
if os.path.isfile('/usr/local/psa/version'):
return "Plesk"
# Unknown panel / No panel
return "Unknown"PK ���Z�Y�� � multiphp_reconfigure.pynu ȯ�� #!/usr/libexec/platform-python
# -*- mode:python; coding:utf-8; -*-
# author: Dmitriy Kasyanov <dkasyanov@cloudlinux.com>
import getopt
import glob
import logging
import os
import sys
import traceback
try:
import configparser
except ImportError:
import ConfigParser as configparser
try:
import rpm
except:
class rpm:
@staticmethod
def labelCompare(version1, version2):
def index_exists(_list, i):
return (0 <= i < len(_list)) or (-len(_list) <= i < 0)
res = 0
ver1 = version1[1].split('.')
ver2 = version2[1].split('.')
max_num = len(ver1)
if len(ver2) > max_num:
max_num = len(ver2)
i = 0
while i < max_num:
if index_exists(ver1,i) and index_exists(ver2,i):
if ver1[i] == ver2[i]:
res=0
else:
return int(ver1[i]) - int(ver2[i])
elif index_exists(ver1,i) and not index_exists(ver2,i):
return 1
elif index_exists(ver2,i) and not index_exists(ver1,i):
return -1
i += 1
return 0
# Minimal version with MultiPHP support for alt-php
MIN_CPANEL_VERSION = '11.66.0.11'
SCL_PREFIX_PATH = '/etc/scl/prefixes'
CONFIG_PATH = '/opt/alt/alt-php-config/alt-php.cfg'
def configure_logging(verbose):
"""
Logging configuration function.
@type verbose: bool
@param verbose: Enable additional debug output if True, display only errors
otherwise.
"""
if verbose:
level = logging.DEBUG
else:
level = logging.ERROR
handler = logging.StreamHandler()
handler.setLevel(level)
log_format = "%(levelname)-8s: %(message)s"
formatter = logging.Formatter(log_format, "%H:%M:%S %d.%m.%y")
handler.setFormatter(formatter)
logger = logging.getLogger()
logger.addHandler(handler)
logger.setLevel(level)
return logger
def get_cpanel_version():
"""
Returns cPanel version if cPanel installed or None othervise.
@rtype: str or None
@return: String with cPanel version or None if cPanel not installed.
"""
if os.path.exists('/usr/local/cpanel/version'):
with open('/usr/local/cpanel/version', 'r') as fd:
version = fd.read()
return version
return None
def find_interpreter_versions():
"""
Returns list of installed alt-php versions and their base directories.
@rtype: list
@return: List of version (e.g. 44, 55) and base directory tuples.
"""
int_versions = []
base_path_regex = "/opt/alt/php[0-9][0-9]"
for int_dir in glob.glob(base_path_regex):
if os.path.exists(os.path.join(int_dir, "usr/bin/php")):
int_versions.append((int_dir[-2:], int_dir))
int_versions.sort()
return int_versions
def delete_prefix(prefix_path):
"""
Remove prefix file
@type prefix_path: str
@param prefix_path: Path to the prefix file, e.g. /etc/scl/prefix/alt-php70
@rtype: bool
@return: True if file was removed sucessfully, False otherwise
"""
try:
if os.path.exists(prefix_path):
os.unlink(prefix_path)
return True
except OSError as e:
logging.error(u"Couldn't remove prefix %s:\n%s" % (prefix_path, e))
return False
def create_prefix(prefix_path, prefix_content):
"""
Creates prefix with path to alt-php
@type prefix_path: str
@param prefix_path: Path to the prefix file, e.g. /etc/scl/prefix/alt-php70
@type prefix_content: str
@param prefix_content: SCL path, e.g. /opt/cloudlinux
@rtype: bool
@return: True if file was created sucessfully, False otherwise
"""
try:
with open(prefix_path, 'w') as fd:
fd.write(prefix_content)
except IOError as e:
logging.error(u"Couldn't open file %s:\n%s" % (prefix_path, e))
return False
return True
def reconfigure(config, int_version):
"""
@type config:
@param config:
@type int_version: str
@param int_version: Interpreter version (44, 55, 72, etc.)
@type int_path: str
@param int_path: Interpreter directory on the disk (/opt/alt/php51, etc.)
@rtype: bool
@return: True if reconfiguration was successful, False otherwise
"""
cp_version = get_cpanel_version()
prefix_name = "alt-php%s" % int_version
prefix_path = os.path.join(SCL_PREFIX_PATH, prefix_name)
prefix_content = "/opt/cloudlinux\n"
alt_php_enable_file = "/opt/cloudlinux/alt-php%s/enable" % int_version
if cp_version and rpm.labelCompare(
('1', cp_version, '0'), ('1', MIN_CPANEL_VERSION, '0')) < 0:
status = delete_prefix(prefix_path)
else:
try:
int_enabled = config.getboolean("MultiPHP Manager", prefix_name)
except configparser.NoOptionError as e:
int_enabled = True
logging.warning("Prefix %s doesn't exist in %s:\n" % (prefix_name,
CONFIG_PATH))
config.set("MultiPHP Manager", prefix_name, "yes")
with open(CONFIG_PATH, 'w') as configfile:
config.write(configfile)
except configparser.NoSectionError as e:
int_enabled = True
config.add_section('MultiPHP Manager')
config.set("MultiPHP Manager", prefix_name, "yes")
with open(CONFIG_PATH, 'w') as configfile:
config.write(configfile)
print("Config %s is broken:\nCreated it.\n" % (CONFIG_PATH))
if int_enabled and os.path.exists(alt_php_enable_file):
status = create_prefix(prefix_path, prefix_content)
elif not int_enabled and os.path.exists(prefix_path):
status = delete_prefix(prefix_path)
else:
return True
return status
def check_alt_path_exists(int_path, int_name, int_ver):
"""
Check if alt-php path exist
----------
@type int_path: str or unicode
@param int_path: Interpreter directory on the disk (/opt/alt/php51, etc.)
@type int_name: str or unicode
@param int_name: Interpreter name (php, python)
@type int_ver: str or unicode
@apram int_ver: Interpreter version (44, 55, 72, etc.)
@rtype: bool
@return: True if interpreter path exists, False otherwise
"""
if not os.path.isdir(int_path):
sys.stderr.write("unknown {0} version {1}".format(int_name, int_ver))
return False
return True
def main(sys_args):
try:
opts, args = getopt.getopt(sys_args, "p:v", ["php=", "verbose"])
except getopt.GetoptError as e:
sys.stderr.write("cannot parse command line arguments: {0}".format(e))
return 1
verbose = False
int_versions = []
int_name = "php"
for opt, arg in opts:
if opt in ("-p", "--php"):
int_name = "php"
int_path = "/opt/alt/php%s" % arg
if check_alt_path_exists(int_path, int_name, arg):
int_versions.append((arg, int_path))
else:
return 1
if opt in ("-v", "--verbose"):
verbose = True
log = configure_logging(verbose)
config = configparser.ConfigParser()
config.read(CONFIG_PATH)
try:
if not int_versions:
int_versions = find_interpreter_versions()
for int_ver, int_dir in int_versions:
reconfigure(config, int_ver)
return 0
except Exception as e:
log.error(u"cannot reconfigure alt-%s for SCL: %s. "
u"Traceback:\n%s" % (int_name, e,
traceback.format_exc()))
return 1
if __name__ == "__main__":
sys.exit(main(sys.argv[1:]))
PK ���ZI�� install_odbcnu ȯ�� #!/bin/sh
#dist_ver=$(cat /etc/redhat-release | sed -e 's#[^0-9]*##g' | cut -b1)
# add repo conf
#curl https://packages.microsoft.com/config/rhel/${dist_ver}/prod.repo > /etc/yum.repos.d/mssql-release.repo
cat << EOF > /etc/yum.repos.d/mssql-release.repo
[packages-microsoft-com-prod]
name=packages-microsoft-com-prod
baseurl=https://packages.microsoft.com/rhel/\$releasever/prod/
enabled=1
gpgcheck=1
gpgkey=https://packages.microsoft.com/keys/microsoft.asc
EOF
# install packages
ACCEPT_EULA=Y yum -y install msodbcsql17
PK ���Z /Z�7 7 alt-php-panel-configuration.pynu ȯ�� #!/usr/libexec/platform-python
# -*- mode:python; coding:utf-8; -*-
import getopt
import glob
import logging
import os
import subprocess
import sys
from shutil import copy2
try:
import db.clcommon.cpapi as cpapi
except ImportError:
import detectcp as cpapi
MODES = ("check", "install", "uninstall")
def configure_logging(verbose):
"""
Logging configuration function
:type verbose: bool
:param verbose: Enable additional debug output if True, display only errors
othervise
:return: configured logger object
"""
if verbose:
level = logging.DEBUG
else:
level = logging.ERROR
handler = logging.StreamHandler()
handler.setLevel(level)
log_format = "%(levelname)-8s: %(message)s"
formatter = logging.Formatter(log_format, "%H:%M:%S %d.%m.%y")
handler.setFormatter(formatter)
logger = logging.getLogger()
logger.addHandler(handler)
logger.setLevel(level)
return logger
def find_alt_php_versions():
"""
Returns list of installed alt-php versions and their base directories
:rtype: list
:return: List of version (e.g. 44, 55) and base directory tuples
"""
php_versions = []
for php_dir in glob.glob("/opt/alt/php[0-9][0-9]"):
php_versions.append((php_dir[-2:], php_dir))
php_versions.sort()
return php_versions
def plesk_check_php_handler(cgi_type, php_ver):
"""
:param php_ver: alt-php version (e.g. 44, 55, 70)
:return: If handler exist returns True, otherwise False
"""
proc = subprocess.Popen(["/usr/local/psa/bin/php_handler", "--list"],
stdout=subprocess.PIPE, stderr=subprocess.STDOUT,
universal_newlines=True)
out, _ = proc.communicate()
for line in out.split("\n"):
if 'alt-php%s-%s' % (php_ver, cgi_type) in line.strip().split(" ")[0]:
logging.info("Handler for alt-php%s-%s exist." % (php_ver, cgi_type))
return True
logging.info("Handler for alt-php%s-%s not exist." % (php_ver, cgi_type))
return False
def plesk_add_php_handler(cgi_type, php_ver, php_path):
if plesk_check_php_handler(cgi_type, php_ver):
logging.info("Handler for alt-php%s-%s exist." % (php_ver, cgi_type))
return False
logging.info("Plesk: Installing alt-php%s-%s handler." % (php_ver, cgi_type))
sys.stdout.write("Plesk: Installing alt-php{0}-{1} handler.".format(php_ver, cgi_type))
# run /usr/local/psa/bin/php_handler --add -displayname alt-php-7.0.0 -path /opt/alt/php70/usr/bin/php-cgi
# -phpini /opt/alt/php70/etc/php.ini -type fastcgi -id 666 -clipath /opt/alt/php70/usr/bin/php
command = "/usr/local/psa/bin/php_handler"
add_command = [
command, '--add',
'-displayname', 'alt-php%s-%s' % (php_ver, cgi_type),
'-clipath', os.path.join(php_path, 'usr/bin/php'),
'-phpini', os.path.join(php_path, 'etc/php.ini'),
'-type', cgi_type,
'-id', 'alt-php%s-%s' % (php_ver, cgi_type), ]
if cgi_type == "fpm":
add_command.extend([
'-service', 'alt-php%s-fpm' % php_ver,
'-path', os.path.join(php_path, 'usr/sbin/php-fpm'),
'-poold', os.path.join(php_path, 'etc/php-fpm.d'),])
if not os.path.exists("/opt/alt/php%s/etc/php-fpm.conf" % php_ver):
copy2(os.path.join(php_path, 'etc/php-fpm.conf.plesk'), os.path.join(php_path, 'etc/php-fpm.conf'))
else:
add_command.extend([
'-path', os.path.join(php_path, 'usr/bin/php-cgi'),])
proc = subprocess.Popen(add_command, stdout=subprocess.PIPE,
stderr=subprocess.STDOUT, universal_newlines=True)
out, _ = proc.communicate()
if proc.returncode != 0:
raise Exception(u"cannot execute \"%s\": %s" % (' '.join(add_command), out))
proc = subprocess.Popen([command, "--reread"], stdout=subprocess.PIPE,
stderr=subprocess.STDOUT, universal_newlines=True)
out, _ = proc.communicate()
if proc.returncode != 0:
raise Exception(u"cannot execute \"" + command + " --reread\": %s" % out)
logging.info("Handler for alt-php%s was successfully added." % php_ver)
return True
def plesk_remove_php_handler(cgi_type, php_ver):
if plesk_check_php_handler(cgi_type, php_ver):
logging.info("Plesk: Removing alt-php%s-%s handler." % (php_ver, cgi_type))
sys.stdout.write("Plesk: Removing alt-php{0}-{1} handler.".format(php_ver, cgi_type))
command = ["/usr/local/psa/bin/php_handler", "--remove",
"-id", "alt-php%s-%s" % (php_ver, cgi_type)]
proc = subprocess.Popen(command, stdout=subprocess.PIPE, stderr=subprocess.STDOUT,
universal_newlines=True)
out, _ = proc.communicate()
if proc.returncode != 0:
raise Exception(u"cannot execute \"%s\": %s" % (' '.join(command), out))
logging.info("Handler for alt-php%s-%s was successfully removed." % (php_ver, cgi_type))
return True
else:
logging.info("Handler for alt-php%s-%s not exist." % (php_ver, cgi_type))
return False
def configure_alt_php(mode, php_ver, php_path):
"""
:rtype: bool
:return: If success returns True, otherwise False
"""
try:
cp_name = cpapi.getCPName()
if cp_name == "Plesk":
if not os.path.exists("/usr/local/psa/bin/php_handler"):
raise Exception("/usr/local/psa/bin/php_handler not exist.")
if mode == "install":
plesk_add_php_handler('fastcgi', php_ver, php_path)
plesk_add_php_handler('cgi', php_ver, php_path)
if os.path.exists("/etc/init.d/alt-php%s-fpm" % php_ver) or os.path.exists("/usr/lib/systemd/system/alt-php%s-fpm.service" % php_ver):
plesk_add_php_handler('fpm', php_ver, php_path)
elif mode == "uninstall":
plesk_remove_php_handler('fastcgi', php_ver)
plesk_remove_php_handler('cgi', php_ver)
if os.path.exists("/etc/init.d/alt-php%s-fpm" % php_ver) or os.path.exists("/usr/lib/systemd/system/alt-php%s-fpm.service" % php_ver):
plesk_remove_php_handler('fpm', php_ver)
else:
return plesk_check_php_handler('fastcgi', php_ver) and plesk_check_php_handler('cgi', php_ver) and plesk_check_php_handler('fpm', php_ver)
except Exception as e:
logging.info(e)
return False
def main(sys_args):
try:
opts, args = getopt.getopt(sys_args, "m:p:v", ["mode=", "php=", "verbose"])
except getopt.GetoptError as e:
sys.stderr.write("cannot parse command line arguments: {0}".format(e))
return 1
verbose = False
mode = "check"
php_versions = []
for opt, arg in opts:
if opt in ("-m", "--mode"):
if arg not in MODES:
# use check mode
mode = "check"
else:
mode = arg
if opt in ("-p", "--php"):
if not os.path.isdir("/opt/alt/php%s" % arg):
sys.stderr.write("unknown PHP version {0}".format(arg))
return 1
php_versions.append((arg, "/opt/alt/php%s" % arg))
if opt in ("-v", "--verbose"):
verbose = True
log = configure_logging(verbose)
if not php_versions:
php_versions = find_alt_php_versions()
log.info(u"installed alt-php versions are\n%s" %
"\n".join(["\t alt-php%s: %s" % i for i in php_versions]))
for ver, path in php_versions:
configure_alt_php(mode, ver, path)
if __name__ == "__main__":
sys.exit(main(sys.argv[1:]))
PK ���Ze<�5$ $ alt-php.cfgnu �[��� PK ���ZT�!d d # _ __pycache__/detectcp.cpython-36.pycnu �[��� PK ���Z�ph� � detectcp.pynu ȯ�� PK ���Z�Y�� � multiphp_reconfigure.pynu ȯ�� PK ���ZI�� '&