vhost-stack/bin/vhost-varnish-update-sites.sh

55 lines
1.3 KiB
Bash
Raw Permalink Normal View History

2021-04-04 13:28:22 -07:00
#!/bin/bash
#
# vhost-stack
# https://git.stack-source.com/msb/vhost-stack
2022-08-22 13:22:16 -07:00
# Copyright (c) 2022 Matthew Saunders Brown <matthewsaundersbrown@gmail.com>
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
2021-04-04 13:28:22 -07:00
2021-04-04 14:15:16 -07:00
# load include file
source $(dirname $0)/vhost.sh
2021-04-04 13:28:22 -07:00
2021-09-16 16:21:35 -07:00
help()
{
thisfilename=$(basename -- "$0")
echo "Makes sure all existing varnish configs are loaded."
echo ""
2021-10-05 11:33:24 -07:00
echo "usage: $thisfilename [-h]"
2021-09-16 16:21:35 -07:00
echo ""
echo " -h Print this help."
echo ""
echo " The varnish config is broken down in to individual"
echo " configurations for each virtualhost. Each config has"
echo " to be included by the master sites.vcl. This tool makes"
echo " sure all existing virtualhost varnish configs are"
echo " properly included in sites.vcl, and removes includes"
echo " for varnish virtualhost configs that have been deleted."
exit
}
# check for -h
if [ -n "$1" ]; then
if [ $1 == "-h" ]; then
help
exit
fi
fi
2021-04-04 13:28:22 -07:00
if [ ! -f /etc/varnish/sites.d/example.com.vcl ]; then
echo "ERROR: example.vlc does not exist"
exit 1
fi
sitesArray=(`ls -1 /etc/varnish/sites.d/`)
truncate -s 0 /etc/varnish/sites.vcl
for site in "${sitesArray[@]}"
do
echo include \"sites.d/$site\"\; >> /etc/varnish/sites.vcl
done
exit 0