Clean up remote setup script for tests. (#54433)
* Only update sshd_config for FreeBSD tests. * Also skip service restart unless config changed. * Only pip install virtualenv for macOS tests. * Also add retries and disable pip version check. * Fix indentation. * Reduce noise during remote instance setup. * Refactor and clean up pip install. * Decrease verbosity of commands. * Remove unnecessary package install.
This commit is contained in:
parent
2b6413558b
commit
870abd7366
1 changed files with 37 additions and 31 deletions
|
@ -4,14 +4,20 @@ set -eu
|
||||||
|
|
||||||
platform="$1"
|
platform="$1"
|
||||||
|
|
||||||
env
|
|
||||||
|
|
||||||
cd ~/
|
cd ~/
|
||||||
|
|
||||||
|
install_pip () {
|
||||||
|
if ! pip --version --disable-pip-version-check 2>/dev/null; then
|
||||||
|
curl --silent --show-error https://bootstrap.pypa.io/get-pip.py -o /tmp/get-pip.py
|
||||||
|
python /tmp/get-pip.py --disable-pip-version-check --quiet
|
||||||
|
rm /tmp/get-pip.py
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
if [ "${platform}" = "freebsd" ]; then
|
if [ "${platform}" = "freebsd" ]; then
|
||||||
while true; do
|
while true; do
|
||||||
env ASSUME_ALWAYS_YES=YES pkg bootstrap && \
|
env ASSUME_ALWAYS_YES=YES pkg bootstrap && \
|
||||||
pkg install -y \
|
pkg install -q -y \
|
||||||
bash \
|
bash \
|
||||||
curl \
|
curl \
|
||||||
gtar \
|
gtar \
|
||||||
|
@ -20,29 +26,34 @@ if [ "${platform}" = "freebsd" ]; then
|
||||||
py27-virtualenv \
|
py27-virtualenv \
|
||||||
py27-cryptography \
|
py27-cryptography \
|
||||||
sudo \
|
sudo \
|
||||||
&& break
|
&& break
|
||||||
echo "Failed to install packages. Sleeping before trying again..."
|
echo "Failed to install packages. Sleeping before trying again..."
|
||||||
sleep 10
|
sleep 10
|
||||||
done
|
done
|
||||||
|
|
||||||
pip --version 2>/dev/null || curl --silent --show-error https://bootstrap.pypa.io/get-pip.py | python
|
install_pip
|
||||||
|
|
||||||
|
if ! grep '^PermitRootLogin yes$' /etc/ssh/sshd_config > /dev/null; then
|
||||||
|
sed -i '' 's/^# *PermitRootLogin.*$/PermitRootLogin yes/;' /etc/ssh/sshd_config
|
||||||
|
service sshd restart
|
||||||
|
fi
|
||||||
elif [ "${platform}" = "rhel" ]; then
|
elif [ "${platform}" = "rhel" ]; then
|
||||||
if grep '8\.' /etc/redhat-release; then
|
if grep '8\.' /etc/redhat-release; then
|
||||||
while true; do
|
while true; do
|
||||||
curl -o /etc/yum.repos.d/rhel-8-beta.repo http://downloads.redhat.com/redhat/rhel/rhel-8-beta/rhel-8-beta.repo && \
|
curl --silent --show-error -o /etc/yum.repos.d/rhel-8-beta.repo http://downloads.redhat.com/redhat/rhel/rhel-8-beta/rhel-8-beta.repo && \
|
||||||
dnf config-manager --set-enabled rhel-8-for-x86_64-baseos-beta-rpms && \
|
dnf config-manager --set-enabled rhel-8-for-x86_64-baseos-beta-rpms && \
|
||||||
dnf config-manager --set-enabled rhel-8-for-x86_64-appstream-beta-rpms && \
|
dnf config-manager --set-enabled rhel-8-for-x86_64-appstream-beta-rpms && \
|
||||||
yum -y module install python36 && \
|
yum module install -q -y python36 && \
|
||||||
yum install -y \
|
yum install -q -y \
|
||||||
gcc \
|
gcc \
|
||||||
python3-devel \
|
python3-devel \
|
||||||
python3-jinja2 \
|
python3-jinja2 \
|
||||||
python3-virtualenv \
|
python3-virtualenv \
|
||||||
python3-cryptography \
|
python3-cryptography \
|
||||||
iptables \
|
iptables \
|
||||||
&& break
|
&& break
|
||||||
echo "Failed to install packages. Sleeping before trying again..."
|
echo "Failed to install packages. Sleeping before trying again..."
|
||||||
sleep 10
|
sleep 10
|
||||||
done
|
done
|
||||||
|
|
||||||
# When running from source our python shebang is: #!/usr/bin/env python
|
# When running from source our python shebang is: #!/usr/bin/env python
|
||||||
|
@ -58,31 +69,26 @@ elif [ "${platform}" = "rhel" ]; then
|
||||||
fi
|
fi
|
||||||
else
|
else
|
||||||
while true; do
|
while true; do
|
||||||
yum install -y \
|
yum install -q -y \
|
||||||
gcc \
|
gcc \
|
||||||
python-devel \
|
python-devel \
|
||||||
python-jinja2 \
|
|
||||||
python-virtualenv \
|
python-virtualenv \
|
||||||
python2-cryptography \
|
python2-cryptography \
|
||||||
&& break
|
&& break
|
||||||
echo "Failed to install packages. Sleeping before trying again..."
|
echo "Failed to install packages. Sleeping before trying again..."
|
||||||
sleep 10
|
sleep 10
|
||||||
done
|
done
|
||||||
|
|
||||||
pip --version 2>/dev/null || curl --silent --show-error https://bootstrap.pypa.io/get-pip.py | python
|
install_pip
|
||||||
fi
|
fi
|
||||||
fi
|
elif [ "${platform}" = "osx" ]; then
|
||||||
|
while true; do
|
||||||
if [ "${platform}" = "freebsd" ] || [ "${platform}" = "osx" ]; then
|
pip install --disable-pip-version-check --quiet \
|
||||||
pip install virtualenv
|
virtualenv \
|
||||||
fi
|
&& break
|
||||||
|
echo "Failed to install packages. Sleeping before trying again..."
|
||||||
# Since tests run as root, we also need to be able to ssh to localhost as root.
|
sleep 10
|
||||||
sed -i= 's/^# *PermitRootLogin.*$/PermitRootLogin yes/;' /etc/ssh/sshd_config
|
done
|
||||||
|
|
||||||
if [ "${platform}" = "freebsd" ]; then
|
|
||||||
# Restart sshd for configuration changes and loopback aliases to work.
|
|
||||||
service sshd restart
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Generate our ssh key and add it to our authorized_keys file.
|
# Generate our ssh key and add it to our authorized_keys file.
|
||||||
|
|
Loading…
Reference in a new issue