#!/usr/bin/env bash # Unoffical bash safe mode set -euo pipefail BIN_DIRECTORY="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )" waitproxy() { while ! nc -z localhost 8080 ; do sleep 1 ; done } if nc -z localhost 8080; then echo "Error: port 8080 already in use. Is mitmdump already running?" pgrep -f -l mitmdump exit 2 fi echo "Launching proxy..." mitmdump -w proxy~~.dump &> /dev/null & mitm_process="$!" echo "Waiting for proxy..." waitproxy echo "Recording downloads..." source tests/shared-functions.bash unset_n_env setup_tmp_prefix # Hack curl to avoid certificate issues with proxy readonly CURL_HOME="$(dirname "${BIN_DIRECTORY}")/config" export CURL_HOME # Go through proxy so it can record traffic, http for taobao redirects http_proxy="$(hostname):8080" export http_proxy https_proxy="$(hostname):8080" export https_proxy # Need to do wget first, as curl gets compressed index.tab which will break wget. # linux, archlinux-curl gets gz archives docker-compose run archlinux-curl /mnt/test/tests/install-reference-versions.bash # linux, ubuntu-curl would get compressed index and gz archives docker-compose run ubuntu-wget /mnt/test/tests/install-reference-versions.bash # native tests/install-reference-versions.bash rm -rf "${TMP_PREFIX_DIR}" echo "Stopping proxy" kill "${mitm_process}"