Name: my-script Version: 1.0 Release: 1%{?dist} Summary: A wrapper script to ensure the AWS cli is using proxy variables License: MIT BuildArch: noarch %description This RPM contains a simple shell script to wrap the AWS cli ensuring the proxies are set. %prep # Nothing to prep %build # Nothing to build %install mkdir -p %{buildroot}%{_bindir} # This "cat" command creates the script file inside the build environment cat << 'EOF' > %{buildroot}%{_bindir}/aws.sh #!/usr/bin/env bash set \ -o nounset \ -o pipefail \ -o errexit export HTTPS_PROXY=squid.corp.redhat.com:3128 export HTTP_PROXY=squid.corp.redhat.com:3128 if ! command -v curl &> /dev/null then # if curl isn't installed, print a warning echo "WARN: curl is not installed, cannot preflight VPN connection. If this command seems to hang you might need to connect to the VPN" 1>&2 else # Fail fast if not connected to the VPN instead of a very long timeout (exit code is curls proxy exit code) # This connect-timeout may need to be tuned depending on SRE geolocation and latency to the proxy if ! curl --connect-timeout 1 "${HTTPS_PROXY}" > /dev/null 2>&1 then echo "Proxy Unavailable. Are you on the VPN?" 1>&2 exit 1 fi fi EOF # Ensure the script is executable chmod 0755 %{buildroot}%{_bindir}/aws.sh %files %{_bindir}/aws.sh