Use Python3 Scripts for Newer Operating Systems
This commit is contained in:
parent
9b0f0260d7
commit
2d8fe68344
3 changed files with 125 additions and 85 deletions
|
@ -2729,10 +2729,18 @@ function installPythonPamMysql(){
|
|||
|
||||
# Copy our libpam-python scripts to /etc/security
|
||||
cp -vf /var/www/new/ehcp/etc/pam/pam_dbauth_smtp.conf /etc/security/pam_dbauth_smtp.conf
|
||||
cp -vf /var/www/new/ehcp/etc/pam/pam_dbauth_smtp_ubuntu_20_plus.py /etc/security/pam_dbauth_smtp.py
|
||||
if [[ "$distro" == "ubuntu" && "$yrelease" -ge "23" ]] || [[ "$distro" == "debian" && "$yrelease" -ge "12" ]]; then
|
||||
cp -vf /var/www/new/ehcp/etc/pam/pam_dbauth_smtp_python3.py /etc/security/pam_dbauth_smtp.py
|
||||
else
|
||||
cp -vf /var/www/new/ehcp/etc/pam/pam_dbauth_smtp_ubuntu_20_plus.py /etc/security/pam_dbauth_smtp.py
|
||||
fi
|
||||
|
||||
cp -vf /var/www/new/ehcp/etc/pam/pam_dbauth_vsftpd.conf /etc/security/pam_dbauth_vsftpd.conf
|
||||
cp -vf /var/www/new/ehcp/etc/pam/pam_dbauth_vsftpd_ubuntu_20_plus.py /etc/security/pam_dbauth_vsftpd.py
|
||||
if [[ "$distro" == "ubuntu" && "$yrelease" -ge "23" ]] || [[ "$distro" == "debian" && "$yrelease" -ge "12" ]]; then
|
||||
cp -vf /var/www/new/ehcp/etc/pam/pam_dbauth_vsftpd_python3.py /etc/security/pam_dbauth_vsftpd.py
|
||||
else
|
||||
cp -vf /var/www/new/ehcp/etc/pam/pam_dbauth_vsftpd_ubuntu_20_plus.py /etc/security/pam_dbauth_vsftpd.py
|
||||
fi
|
||||
|
||||
if ([[ "$distro" == "ubuntu" && "$yrelease" -ge "16" ]] || [[ "$distro" == "debian" && "$yrelease" -ge "9" ]]) && [[ -e "/usr/lib/python2.7/lib-dynload/_hashlib.x86_64-linux-gnu.so" ]]; then
|
||||
rm -f /usr/lib/python2.7/lib-dynload/_hashlib.x86_64-linux-gnu.so
|
||||
|
@ -3380,55 +3388,66 @@ function fixSQMailPerms(){
|
|||
}
|
||||
|
||||
function installPipManuallyIfNeeded(){
|
||||
aptgetInstall "python-pip"
|
||||
curDir=$(pwd)
|
||||
|
||||
if [ ! -e "/usr/bin/python2" ]; then
|
||||
# We need python2 still
|
||||
cd "$patchDir"
|
||||
wget -N "https://www.python.org/ftp/python/2.7.18/Python-2.7.18.tgz"
|
||||
tar zxvf "Python-2.7.18.tgz"
|
||||
cd "Python-2.7.18"
|
||||
./configure --prefix=/usr --with-ensurepip=install
|
||||
make
|
||||
make install
|
||||
fi
|
||||
|
||||
# Create a symlink for python if one doesn't exist
|
||||
if [ ! -e "/usr/bin/python" ]; then
|
||||
if [ -e "/usr/bin/python2" ]; then
|
||||
ln -s "/usr/bin/python2" "/usr/bin/python"
|
||||
fi
|
||||
if [[ "$distro" == "ubuntu" && "$yrelease" -ge "23" ]] || [[ "$distro" == "debian" && "$yrelease" -ge "12" ]]; then
|
||||
aptgetInstall "python3"
|
||||
aptgetInstall "python3-pip"
|
||||
aptgetInstall "python3-configargparse"
|
||||
aptgetInstall "python3-passlib"
|
||||
aptgetInstall "python3-mysqldb"
|
||||
aptgetInstall "python3-chardet"
|
||||
aptgetInstall "python3-requests"
|
||||
else
|
||||
currentPythonVersion=$(python --version 2>&1 | grep -o "Python 3")
|
||||
if [ ! -z "$currentPythonVersion" ]; then
|
||||
aptgetInstall "python-pip"
|
||||
|
||||
if [ ! -e "/usr/bin/python2" ]; then
|
||||
# We need python2 still
|
||||
cd "$patchDir"
|
||||
wget -N "https://www.python.org/ftp/python/2.7.18/Python-2.7.18.tgz"
|
||||
tar zxvf "Python-2.7.18.tgz"
|
||||
cd "Python-2.7.18"
|
||||
./configure --prefix=/usr --with-ensurepip=install
|
||||
make
|
||||
make install
|
||||
fi
|
||||
|
||||
# Create a symlink for python if one doesn't exist
|
||||
if [ ! -e "/usr/bin/python" ]; then
|
||||
if [ -e "/usr/bin/python2" ]; then
|
||||
ln -f -s "/usr/bin/python2" "/usr/bin/python"
|
||||
ln -s "/usr/bin/python2" "/usr/bin/python"
|
||||
fi
|
||||
else
|
||||
currentPythonVersion=$(python --version 2>&1 | grep -o "Python 3")
|
||||
if [ ! -z "$currentPythonVersion" ]; then
|
||||
if [ -e "/usr/bin/python2" ]; then
|
||||
ln -f -s "/usr/bin/python2" "/usr/bin/python"
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
|
||||
# Create a symlink for python pip 2 if one doesn't exist
|
||||
if [ ! -e "/usr/bin/pip" ] && [ -e "/usr/bin/pip2" ]; then
|
||||
ln -s "/usr/bin/pip2" "/usr/bin/pip"
|
||||
fi
|
||||
# Create a symlink for python pip 2 if one doesn't exist
|
||||
if [ ! -e "/usr/bin/pip" ] && [ -e "/usr/bin/pip2" ]; then
|
||||
ln -s "/usr/bin/pip2" "/usr/bin/pip"
|
||||
fi
|
||||
|
||||
# Install pip if it's not found on the system manually
|
||||
currentPip=$(which pip)
|
||||
insPip2=0
|
||||
if [ ! -z "$currentPip" ]; then
|
||||
currentPipVersion=$(pip --version 2>&1 | grep -o "python3")
|
||||
if [ ! -z "$currentPipVersion" ]; then
|
||||
# Install pip if it's not found on the system manually
|
||||
currentPip=$(which pip)
|
||||
insPip2=0
|
||||
if [ ! -z "$currentPip" ]; then
|
||||
currentPipVersion=$(pip --version 2>&1 | grep -o "python3")
|
||||
if [ ! -z "$currentPipVersion" ]; then
|
||||
insPip2=1
|
||||
fi
|
||||
else
|
||||
insPip2=1
|
||||
fi
|
||||
else
|
||||
insPip2=1
|
||||
fi
|
||||
|
||||
if [ "$insPip2" == 1 ]; then
|
||||
cd "$patchDir"
|
||||
curl https://bootstrap.pypa.io/pip/2.7/get-pip.py -o get-pip.py
|
||||
python get-pip.py
|
||||
if [ "$insPip2" == 1 ]; then
|
||||
cd "$patchDir"
|
||||
curl https://bootstrap.pypa.io/pip/2.7/get-pip.py -o get-pip.py
|
||||
python get-pip.py
|
||||
fi
|
||||
fi
|
||||
|
||||
cd "$curDir"
|
||||
|
|
|
@ -1226,7 +1226,12 @@ function installPythonPamMysql(){
|
|||
|
||||
// Copy our libpam-python scripts to /etc/security
|
||||
passthru2("cp -vf $ehcpinstalldir/etc/pam/pam_dbauth_smtp.conf /etc/security/pam_dbauth_smtp.conf");
|
||||
passthru2("cp -vf $ehcpinstalldir/etc/pam/pam_dbauth_smtp_ubuntu_20_plus.py /etc/security/pam_dbauth_smtp.py");
|
||||
|
||||
if((getIsUbuntu() && getUbuntuReleaseYear() >= "23") || (getIsDebian() && getUbuntuReleaseYear() >= "12")){
|
||||
passthru2("cp -vf $ehcpinstalldir/etc/pam/pam_dbauth_smtp_python3.py /etc/security/pam_dbauth_smtp.py");
|
||||
}else{
|
||||
passthru2("cp -vf $ehcpinstalldir/etc/pam/pam_dbauth_smtp_ubuntu_20_plus.py /etc/security/pam_dbauth_smtp.py");
|
||||
}
|
||||
|
||||
if((getIsUbuntu() && getUbuntuReleaseYear() >= "16") || (getIsDebian() && getUbuntuReleaseYear() >= "9")){
|
||||
if(file_exists("/usr/lib/python2.7/lib-dynload/_hashlib.x86_64-linux-gnu.so")){
|
||||
|
@ -1235,7 +1240,11 @@ function installPythonPamMysql(){
|
|||
}
|
||||
|
||||
passthru2("cp -vf $ehcpinstalldir/etc/pam/pam_dbauth_vsftpd.conf /etc/security/pam_dbauth_vsftpd.conf");
|
||||
passthru2("cp -vf $ehcpinstalldir/etc/pam/pam_dbauth_vsftpd_ubuntu_20_plus.py /etc/security/pam_dbauth_vsftpd.py");
|
||||
if((getIsUbuntu() && getUbuntuReleaseYear() >= "23") || (getIsDebian() && getUbuntuReleaseYear() >= "12")){
|
||||
passthru2("cp -vf $ehcpinstalldir/etc/pam/pam_dbauth_vsftpd_python3.py /etc/security/pam_dbauth_vsftpd.py");
|
||||
}else{
|
||||
passthru2("cp -vf $ehcpinstalldir/etc/pam/pam_dbauth_vsftpd_ubuntu_20_plus.py /etc/security/pam_dbauth_vsftpd.py");
|
||||
}
|
||||
|
||||
// Replace EHCP mysql password with the correct one
|
||||
replacelineinfile("password=","password=" . $ehcpmysqlpass,"/etc/security/pam_dbauth_smtp.conf", true);
|
||||
|
|
|
@ -3050,55 +3050,67 @@ function fixSQMailPerms(){
|
|||
}
|
||||
|
||||
function installPipManuallyIfNeeded(){
|
||||
aptgetInstall "python-pip"
|
||||
curDir=$(pwd)
|
||||
|
||||
if [ ! -e "/usr/bin/python2" ]; then
|
||||
# We need python2 still
|
||||
cd "$patchDir"
|
||||
wget -N "https://www.python.org/ftp/python/2.7.18/Python-2.7.18.tgz"
|
||||
tar zxvf "Python-2.7.18.tgz"
|
||||
cd "Python-2.7.18"
|
||||
./configure --prefix=/usr --with-ensurepip=install
|
||||
make
|
||||
make install
|
||||
fi
|
||||
|
||||
# Create a symlink for python if one doesn't exist
|
||||
if [ ! -e "/usr/bin/python" ]; then
|
||||
if [ -e "/usr/bin/python2" ]; then
|
||||
ln -s "/usr/bin/python2" "/usr/bin/python"
|
||||
fi
|
||||
if [[ "$distro" == "ubuntu" && "$yrelease" -ge "23" ]] || [[ "$distro" == "debian" && "$yrelease" -ge "12" ]]; then
|
||||
aptgetInstall "python3"
|
||||
aptgetInstall "python3-pip"
|
||||
aptgetInstall "python3-configargparse"
|
||||
aptgetInstall "python3-passlib"
|
||||
aptgetInstall "python3-mysqldb"
|
||||
aptgetInstall "python3-chardet"
|
||||
aptgetInstall "python3-requests"
|
||||
else
|
||||
currentPythonVersion=$(python --version 2>&1 | grep -o "Python 3")
|
||||
if [ ! -z "$currentPythonVersion" ]; then
|
||||
aptgetInstall "python-pip"
|
||||
|
||||
if [ ! -e "/usr/bin/python2" ]; then
|
||||
# We need python2 still
|
||||
cd "$patchDir"
|
||||
wget -N "https://www.python.org/ftp/python/2.7.18/Python-2.7.18.tgz"
|
||||
tar zxvf "Python-2.7.18.tgz"
|
||||
cd "Python-2.7.18"
|
||||
./configure --prefix=/usr --with-ensurepip=install
|
||||
make
|
||||
make install
|
||||
fi
|
||||
|
||||
# Create a symlink for python if one doesn't exist
|
||||
if [ ! -e "/usr/bin/python" ]; then
|
||||
if [ -e "/usr/bin/python2" ]; then
|
||||
ln -f -s "/usr/bin/python2" "/usr/bin/python"
|
||||
ln -s "/usr/bin/python2" "/usr/bin/python"
|
||||
fi
|
||||
else
|
||||
currentPythonVersion=$(python --version 2>&1 | grep -o "Python 3")
|
||||
if [ ! -z "$currentPythonVersion" ]; then
|
||||
if [ -e "/usr/bin/python2" ]; then
|
||||
ln -f -s "/usr/bin/python2" "/usr/bin/python"
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
|
||||
# Create a symlink for python pip 2 if one doesn't exist
|
||||
if [ ! -e "/usr/bin/pip" ] && [ -e "/usr/bin/pip2" ]; then
|
||||
ln -s "/usr/bin/pip2" "/usr/bin/pip"
|
||||
fi
|
||||
# Create a symlink for python pip 2 if one doesn't exist
|
||||
if [ ! -e "/usr/bin/pip" ] && [ -e "/usr/bin/pip2" ]; then
|
||||
ln -s "/usr/bin/pip2" "/usr/bin/pip"
|
||||
fi
|
||||
|
||||
# Install pip if it's not found on the system manually
|
||||
currentPip=$(which pip)
|
||||
insPip2=0
|
||||
if [ ! -z "$currentPip" ]; then
|
||||
currentPipVersion=$(pip --version 2>&1 | grep -o "python3")
|
||||
if [ ! -z "$currentPipVersion" ]; then
|
||||
# Install pip if it's not found on the system manually
|
||||
currentPip=$(which pip)
|
||||
insPip2=0
|
||||
if [ ! -z "$currentPip" ]; then
|
||||
currentPipVersion=$(pip --version 2>&1 | grep -o "python3")
|
||||
if [ ! -z "$currentPipVersion" ]; then
|
||||
insPip2=1
|
||||
fi
|
||||
else
|
||||
insPip2=1
|
||||
fi
|
||||
else
|
||||
insPip2=1
|
||||
fi
|
||||
|
||||
if [ "$insPip2" == 1 ]; then
|
||||
cd "$patchDir"
|
||||
curl https://bootstrap.pypa.io/pip/2.7/get-pip.py -o get-pip.py
|
||||
python get-pip.py
|
||||
if [ "$insPip2" == 1 ]; then
|
||||
cd "$patchDir"
|
||||
curl https://bootstrap.pypa.io/pip/2.7/get-pip.py -o get-pip.py
|
||||
python get-pip.py
|
||||
fi
|
||||
|
||||
fi
|
||||
|
||||
cd "$curDir"
|
||||
|
|
Loading…
Reference in a new issue