2016-11-30 06:21:53 +01:00
|
|
|
#!/bin/sh
|
|
|
|
|
|
|
|
set -eu
|
|
|
|
|
|
|
|
platform="$1"
|
|
|
|
|
|
|
|
env
|
|
|
|
|
|
|
|
cd ~/
|
|
|
|
|
|
|
|
if [ "${platform}" = "freebsd" ]; then
|
2017-07-14 06:24:22 +02:00
|
|
|
while true; do
|
2017-11-29 09:46:08 +01:00
|
|
|
env ASSUME_ALWAYS_YES=YES pkg bootstrap && \
|
2017-07-14 06:24:22 +02:00
|
|
|
pkg install -y \
|
|
|
|
bash \
|
|
|
|
curl \
|
|
|
|
devel/ruby-gems \
|
|
|
|
git \
|
|
|
|
gtar \
|
|
|
|
mercurial \
|
|
|
|
python \
|
|
|
|
rsync \
|
|
|
|
ruby \
|
|
|
|
subversion \
|
|
|
|
sudo \
|
|
|
|
zip \
|
|
|
|
&& break
|
|
|
|
echo "Failed to install packages. Sleeping before trying again..."
|
|
|
|
sleep 10
|
|
|
|
done
|
2017-07-08 07:28:53 +02:00
|
|
|
|
|
|
|
pip --version 2>/dev/null || curl --silent --show-error https://bootstrap.pypa.io/get-pip.py | python
|
2017-07-08 01:52:40 +02:00
|
|
|
elif [ "${platform}" = "rhel" ]; then
|
2017-07-14 06:24:22 +02:00
|
|
|
while true; do
|
|
|
|
yum install -y \
|
|
|
|
gcc \
|
|
|
|
git \
|
|
|
|
mercurial \
|
|
|
|
python-devel \
|
|
|
|
python-jinja2 \
|
|
|
|
python-virtualenv \
|
|
|
|
python2-cryptography \
|
|
|
|
rubygems \
|
|
|
|
subversion \
|
|
|
|
unzip \
|
|
|
|
&& break
|
|
|
|
echo "Failed to install packages. Sleeping before trying again..."
|
|
|
|
sleep 10
|
|
|
|
done
|
2017-07-08 01:52:40 +02:00
|
|
|
|
|
|
|
pip --version 2>/dev/null || curl --silent --show-error https://bootstrap.pypa.io/get-pip.py | python
|
2016-11-30 06:21:53 +01:00
|
|
|
fi
|
|
|
|
|
2017-07-08 01:52:40 +02:00
|
|
|
if [ "${platform}" = "freebsd" ] || [ "${platform}" = "osx" ]; then
|
|
|
|
pip install virtualenv
|
2016-11-30 06:21:53 +01:00
|
|
|
|
2017-07-08 01:52:40 +02:00
|
|
|
# Tests assume loopback addresses other than 127.0.0.1 will work.
|
|
|
|
# Add aliases for loopback addresses used by tests.
|
2016-11-30 06:21:53 +01:00
|
|
|
|
2017-07-08 01:52:40 +02:00
|
|
|
for i in 3 4 254; do
|
|
|
|
ifconfig lo0 alias "127.0.0.${i}" up
|
|
|
|
done
|
2016-11-30 06:21:53 +01:00
|
|
|
|
2017-07-08 01:52:40 +02:00
|
|
|
ifconfig lo0
|
|
|
|
fi
|
2016-11-30 06:21:53 +01:00
|
|
|
|
|
|
|
# Since tests run as root, we also need to be able to ssh to localhost as root.
|
2017-07-08 01:52:40 +02:00
|
|
|
sed -i= 's/^# *PermitRootLogin.*$/PermitRootLogin yes/;' /etc/ssh/sshd_config
|
2016-11-30 06:21:53 +01:00
|
|
|
|
|
|
|
if [ "${platform}" = "freebsd" ]; then
|
|
|
|
# Restart sshd for configuration changes and loopback aliases to work.
|
|
|
|
service sshd restart
|
|
|
|
fi
|
|
|
|
|
|
|
|
# Generate our ssh key and add it to our authorized_keys file.
|
|
|
|
# We also need to add localhost's server keys to known_hosts.
|
|
|
|
|
|
|
|
if [ ! -f "${HOME}/.ssh/id_rsa.pub" ]; then
|
|
|
|
ssh-keygen -q -t rsa -N '' -f "${HOME}/.ssh/id_rsa"
|
|
|
|
cp "${HOME}/.ssh/id_rsa.pub" "${HOME}/.ssh/authorized_keys"
|
|
|
|
for key in /etc/ssh/ssh_host_*_key.pub; do
|
|
|
|
pk=$(cat "${key}")
|
|
|
|
echo "localhost ${pk}" >> "${HOME}/.ssh/known_hosts"
|
|
|
|
done
|
|
|
|
fi
|
|
|
|
|
|
|
|
# Improve prompts on remote host for interactive use.
|
|
|
|
cat << EOF > ~/.bashrc
|
|
|
|
alias ls='ls -G'
|
|
|
|
export PS1='\[\e]0;\u@\h: \w\a\]\[\033[01;32m\]\u@\h\[\033[00m\]:\[\033[01;34m\]\w\[\033[00m\]\$ '
|
|
|
|
EOF
|
2017-07-08 01:52:40 +02:00
|
|
|
|
|
|
|
# Make sure ~/ansible/ is the starting directory for interactive shells.
|
|
|
|
if [ "${platform}" = "osx" ]; then
|
|
|
|
echo "cd ~/ansible/" >> ~/.bashrc
|
|
|
|
fi
|