# Copyright 2025-2026 Thomas Hintz

# This file is part of Nassella.

# Nassella 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 (at your option) any
# later version.

# Nassella 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 General Public License for more details.

# You should have received a copy of the GNU Affero General Public License
# along with Nassella. If not, see <https://www.gnu.org/licenses/>.

IMAGE_DEPS := $(IMAGE_DEPS) \
app/lldap/postgres_db \
app/lldap/postgres_user \
app/lldap/postgres_password \
app/lldap/admin_password \
app/lldap/jwt_secret \
app/lldap/lldap-config/lldap_config.toml

app/lldap/postgres_db: $(apps_config)
	bash -c 'source ./$(apps_config); printf "%s\n" "$$LLDAP_POSTGRES_DB" > $@'
app/lldap/postgres_user: $(apps_config)
	bash -c 'source ./$(apps_config); printf "%s\n" "$$LLDAP_POSTGRES_USER" > $@'
app/lldap/postgres_password: $(apps_config)
	bash -c 'source ./$(apps_config); printf "%s\n" "$$LLDAP_POSTGRES_PASSWORD" > $@'
app/lldap/admin_password: $(apps_config)
	bash -c 'source ./$(apps_config); printf "%s\n" "$$LLDAP_ADMIN_PASSWORD" > $@'
app/lldap/jwt_secret: $(apps_config)
	bash -c 'source ./$(apps_config); printf "%s\n" "$$LLDAP_JWT_SECRET" > $@'
app/lldap/lldap-config/lldap_config.toml: $(apps_config) app/lldap/lldap-config/lldap_config.toml.tmpl \
app/lldap/make-lldap-config.sh
	./app/lldap/make-lldap-config.sh $(apps_config)
