You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
ansible-common/scripts/python-offline-install.sh

34 lines
1.0 KiB
Bash

#!/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"