gerd.starwart: setup domain for stalwart automatically
This commit is contained in:
parent
bd70d0a603
commit
26ce9ac33b
1 changed files with 23 additions and 0 deletions
|
@ -113,6 +113,29 @@ in {
|
|||
};
|
||||
};
|
||||
|
||||
# ensure that the configured domain is added to stalwart
|
||||
systemd.services.stalwart-mail.serviceConfig.ExecStartPost = let
|
||||
stalwart-cli = config.services.stalwart-mail.package + "/bin/stalwart-cli";
|
||||
in pkgs.writeShellScript "stalwart-setup" ''
|
||||
# TODO(eyjhb): at some point this should be changed
|
||||
sleep 10
|
||||
|
||||
export URL="http://127.0.0.1:${builtins.toString ports.http_management}"
|
||||
export CREDENTIALS="$(cat ${config.age.secrets.stalwart-admin-fallback-password.path})"
|
||||
|
||||
if ${stalwart-cli} domain list | grep --quiet -- '${config.mine.shared.settings.domain}'; then
|
||||
echo "Domain is already created, doing nothing."
|
||||
else
|
||||
echo "Domain was not created, creating it now."
|
||||
${stalwart-cli} domain create '${config.mine.shared.settings.domain}'
|
||||
fi
|
||||
|
||||
echo "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!IMPORTANT!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"
|
||||
echo "Remember to setup the correct DNS records. Run the following command to get them:"
|
||||
echo "URL=\"$URL\" stalwart-cli domain dns-records ${config.mine.shared.settings.domain}"
|
||||
echo "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!IMPORTANT!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"
|
||||
'';
|
||||
|
||||
# setup so that stalwart can access and write to the directory
|
||||
systemd.services.stalwart-mail.serviceConfig.ReadWritePaths = [ stateDir ];
|
||||
systemd.tmpfiles.rules = [
|
||||
|
|
Loading…
Reference in a new issue