library/haproxy/1.8-alpine/bin/generate_https_sites_list.sh
crusader 1f98fc734c ing
2018-10-27 12:58:37 +09:00

36 lines
815 B
Bash

#!/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