#!/usr/bin/env bash ##################################################################### # 2ndQuadrant RPM repository: installation shell script # # Repository: dl/default/release at 2ndquadrant.com # # Copyright (C) 2018-2020 2ndQuadrant (www.2ndQuadrant.com) ##################################################################### set -eEu INSTALLATION_REPORT="$(mktemp -t 2ndq_packages_installation.log.XXXXX)" # The installation script is wrapped in the "do_install()" function # for two reasons: # 1. protect against partial download of the file (and subsequent # execution - e.g. "curl ... | sh") # 2. redirect stderr channel to a temporary file # some protection against only getting part of the file during the do_install() { # Enable trace inside the function set -x # Default connection timeout = 30 seconds. # You can override it with the SECONDQ_TIMEOUT environment variable. # For example, you can set it to 10 seconds as follows: # export SECONDQ_TIMEOUT = 10 SECONDQ_TIMEOUT=${SECONDQ_TIMEOUT:-30} # Check distribution compatibility if [ ! -d /etc/yum.repos.d/ ] then echo "Cannot install RPM packages: incompatible distribution" return fi # # Install the repository public GPG key # rpm_key_file="/etc/pki/rpm-gpg/RPM-GPG-KEY-2NDQ-DL-DEFAULT" cat > "$rpm_key_file" < /dev/null && echo $ID || echo centos) # Detect https_proxy variable to include it in single repository definitions proxy="" if [ -n "${https_proxy:-}" ] then proxy="proxy=${https_proxy}" elif [ -n "${HTTPS_PROXY:-}" ] then proxy="proxy=${HTTPS_PROXY}" fi cat > "$yum_repo_file" < "${INSTALLATION_REPORT}" rm -f "${INSTALLATION_REPORT}" # End of repository installation script ;)