library/haproxy/1.8-alpine/bin/generate_https_sites_list.sh

36 lines
815 B
Bash
Raw Normal View History

2018-10-27 03:58:37 +00:00
#!/bin/sh
set -e
#domainname backendname
#one.example.com site:one.example.com
#two.example.com site:two.example.com
#etc.domain1.com site:etc.example.com
generate_https_sites_list() {
local HTTPS_SITES_MAP_PATH=/etc/haproxy/sites/https-sites.map
local SITES_DIR_PATH=/etc/haproxy/sites
local SITE_NAME=""
local HTTPS_SITES_MAP=""
mkdir -p $SITES_DIR_PATH
if [[ ! -f ${HTTPS_SITES_MAP_PATH} ]]; then
touch $HTTPS_SITES_MAP_PATH
fi
cd $SITES_DIR_PATH
for SITE_FILE_NAME in https-*.cfg; do
if [[ ! -f $SITE_FILE_NAME ]]; then
continue
fi
SITE_NAME=${SITE_FILE_NAME/https-/}
SITE_NAME=${SITE_NAME/.cfg/}
HTTPS_SITES_MAP=$HTTPS_SITES_MAP"$SITE_NAME site-https:$SITE_NAME\n"
done
echo -e "$HTTPS_SITES_MAP" > $HTTPS_SITES_MAP_PATH
}
generate_https_sites_list