#!/bin/sh
#
# Copyright (C) 2021 Nethesis S.r.l.
# http://www.nethesis.it - info@nethesis.it
#
# This file is part of Icaro project.
#
# Icaro is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as published by
# the Free Software Foundation, either version 3 of the License,
# or any later version.
#
# Icaro is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with Icaro.  If not, see COPYING.
#

source /var/dedalo/config
HS_DIGEST=$(echo -n "$HS_SECRET$HS_UUID" | md5sum | awk '{print $1}')
HS_AAA_HOST=$(echo "$HS_AAA_URL" | sed -e 's|https\?://\([^/:]\+\)\(.*\)|\1|')
HS_TIMEZONE=$(/sbin/uci -q get system.@system[0].zonename)
HS_WALLED_GARDEN_INTEGRATIONS=$(find /opt/icaro/dedalo/walled_gardens/integrations/ -type f -exec echo include {} \;)

eval "cat <<EOF
$(cat "$1")
EOF" > /var/dedalo/chilli.conf
