#!/bin/sh set -u # This script will do an offline install of python. # It requires that the variable PYTHON_RPMS_TAR_GZ be set to the path of a # tar.gz file containing RPMs for python and it's dependencies. PROFILE_D_PYTHON=/etc/profile.d/python-scl.sh echo "Installing python from RPMs in $PYTHON_RPMS_TAR_GZ" # Create a temporary location to extract the RPMs to. mkdir tmp # Extract the RPM tar.gz file to a temporary directory. tar xvzf "$PYTHON_RPMS_TAR_GZ" -C ./tmp # Perform a localinstall of all the RPMs extracted from PYTHON_RPMS_TAR_GZ. # # Ignore the shellshock error about quoting the find, because in this case we # don't the string to split. # shellcheck disable=SC2046 yum localinstall --disablerepo=* --nogpgcheck -y $(find ./tmp -name "*.rpm") # Delete the temporary RPM package. rm -rf tmp # Add this to /etc/profile.d so that this python version will get loaded # automatically when a user logs in. echo "source /opt/rh/rh-python38/enable" | tee "$PROFILE_D_PYTHON" chown root:root "$PROFILE_D_PYTHON" chmod 644 "$PROFILE_D_PYTHON"