ponysearch-docker/util.sh
Dalf 112768e71f [mod] move rules.json to rules.json.template
start.sh create rules.json from rules.json.template. It replaces $CHECK_SEARX_SPACE_IPS by the IPs of check.searx.space.

Related to https://github.com/asciimoo/filtron/issues/12
2020-07-10 10:46:01 +02:00

32 lines
801 B
Bash

set -e
DOCKERCOMPOSE=$(which docker-compose || echo "/usr/local/bin/docker-compose")
DOCKERCOMPOSEFILE="${DOCKERCOMPOSEFILE:-docker-compose.yaml}"
echo "use ${DOCKERCOMPOSEFILE}"
if [ ! -x "$(which docker)" ]; then
echo "docker not found" 1>&2
exit 1
fi
if ! docker version > /dev/null 2>&1; then
echo "can't execute docker (current user: $(whoami))" 1>&2
exit 1
fi
if [ ! -x "${DOCKERCOMPOSE}" ]; then
echo "docker-compose not found" 1>&2
exit 1
fi
if [ ! -f "${DOCKERCOMPOSEFILE}" ]; then
echo "${DOCKERCOMPOSEFILE} not found" 1>&2
exit 1
fi
create_rules_json() {
# $1 : requests host name $1 will bypass filtron
IPS="($(host $1 | rev | cut -d\ -f1 | rev | tr '\n' '|' | sed 's/.$//'))"
sed "s/\$CHECK_SEARX_SPACE_IPS/$IPS/" rules.json.template
}