#!/usr/bin/env bash
# Copyright (c) 2021 The Toltec Contributors
# SPDX-License-Identifier: MIT

for file in /opt/etc/xochitl.env.d/*.env; do
    if [[ -r $file ]]; then
        echo "Sourcing $file"
        # shellcheck disable=SC1090
        source "$file"
    fi
done
# If for some reason, sync.service is no longer masked, re-mask it
# The package install should have handled this, but something may
# have changed it.
if [[ "x$(systemctl is-enabled sync.service)" != "xmasked" ]]; then
    systemctl mask sync.service
fi
if ! systemctl is-active --quiet manual-sync.service; then
    systemctl enable --now manual-sync.service
fi
exec -a /usr/bin/xochitl /usr/bin/xochitl "$@"
