gluon-site: add better error message for domain name conflicts

When two domains alias the same name (or one aliases another), display a
meaningful error message like:

    Failed to alias domain 'foo' as 'bar', name already taken by
    domain 'baz'.

(cherry picked from commit c208fc4fd9)
This commit is contained in:
Matthias Schiffer 2019-03-22 20:15:25 +01:00 committed by Martin Weinelt
parent 371bdf3e28
commit 2dc2dca73e

View File

@ -49,9 +49,16 @@ define Build/Compile
$(foreach domain,$(patsubst $(GLUON_SITEDIR)/domains/%.conf,%,$(wildcard $(GLUON_SITEDIR)/domains/*.conf)),
[ ! -e '$(PKG_BUILD_DIR)/domains/$(domain).json' ]
$(call GenerateJSON,domains/$(domain))
lua ../../scripts/domain_aliases.lua '$(PKG_BUILD_DIR)/domains/$(domain).json' | while read alias; do \
@lua ../../scripts/domain_aliases.lua '$(PKG_BUILD_DIR)/domains/$(domain).json' | while read alias; do \
[ "$$$${alias}" != '$(domain)' ] || continue; \
ln -s '$(domain).json' $(PKG_BUILD_DIR)/domains/$$$${alias}.json || exit 1; \
link="$(PKG_BUILD_DIR)/domains/$$$${alias}.json"; \
if ! ln -s '$(domain).json' "$$$$link"; then \
other="$$$$(basename $$$$(readlink -f "$$$$link") .json)"; \
if [ "$$$$other" ]; then \
echo >&2 "Failed to alias domain '"'$(domain)'"' as '$$$$alias', name already taken by domain '$$$$other'."; \
fi; \
exit 1; \
fi; \
done
)
endif