Use Python3 Scripts for Newer Operating Systems

This commit is contained in:
earnolmartin 2023-08-09 11:16:34 -06:00
parent 9b0f0260d7
commit 2d8fe68344
3 changed files with 125 additions and 85 deletions

View file

@ -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
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
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,9 +3388,19 @@ function fixSQMailPerms(){
}
function installPipManuallyIfNeeded(){
aptgetInstall "python-pip"
curDir=$(pwd)
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
aptgetInstall "python-pip"
if [ ! -e "/usr/bin/python2" ]; then
# We need python2 still
cd "$patchDir"
@ -3430,6 +3448,7 @@ function installPipManuallyIfNeeded(){
curl https://bootstrap.pypa.io/pip/2.7/get-pip.py -o get-pip.py
python get-pip.py
fi
fi
cd "$curDir"
}

View file

@ -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");
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");
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);

View file

@ -3050,9 +3050,19 @@ function fixSQMailPerms(){
}
function installPipManuallyIfNeeded(){
aptgetInstall "python-pip"
curDir=$(pwd)
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
aptgetInstall "python-pip"
if [ ! -e "/usr/bin/python2" ]; then
# We need python2 still
cd "$patchDir"
@ -3101,6 +3111,8 @@ function installPipManuallyIfNeeded(){
python get-pip.py
fi
fi
cd "$curDir"
}