#!/usr/bin/env bash # wrapper for curl with modified server name indication # exit if a command fails set -o errexit # exit if required variables are not set set -o nounset # if no scheme is provided, use https SCHEME="${SCHEME:-https}" # if scheme is https, use port 443 if [ "${SCHEME}" == "https" ]; then PORT=443 # if scheme is http, use port 80 elif [ "${SCHEME}" == "http" ]; then PORT=80 # otherwise exit with error else echo -e "\\nInvalid scheme. Valid options: http, https\\n" exit 1 fi # if exactly two arguments are provided, run non-interactively if [ "$#" -eq 2 ]; then DOMAIN="$1" IP_ADDR="$2" # if no arguments are provided, prompt user for information elif [ "$#" -eq 0 ]; then read -p -r "What domain would you like to access? " DOMAIN read -p -r "What IP would you like to resolve to? " IP_ADDR # otherwise exit with error else echo -e "\\nUsage: $0 [domain] [ip address]\\n" exit 1 fi # add a space for pretty formatting echo "" # run the actual curl command curl -k -I --resolve "${DOMAIN}":"${PORT}":"${IP_ADDR}" "${SCHEME}"://"${DOMAIN}"