mail/maddy: check if account exists before creating

This commit is contained in:
Jonas Heinrich 2023-02-16 17:39:26 +01:00
parent f42fef0ab8
commit 84be64bec7
2 changed files with 34 additions and 8 deletions

2
server

@ -1 +1 @@
Subproject commit ad00a149ea2bb262e62fbecf11051fd035f90ec4 Subproject commit b4ac9d22d12b3623bd5b1a654a83bc5ba0190c78

View file

@ -124,14 +124,31 @@
}; };
# Creating mail users and inboxes # Creating mail users and inboxes
# FIXME: Upstream
systemd.services.maddy-accounts = { systemd.services.maddy-accounts = {
script = '' script = ''
#!${runtimeShell}
if not ${pkgs.maddy}/bin/maddyctl creds list | grep "user1@localhost"; then
${pkgs.maddy}/bin/maddyctl creds create --password test123 user1@localhost ${pkgs.maddy}/bin/maddyctl creds create --password test123 user1@localhost
fi
if not ${pkgs.maddy}/bin/maddyctl imap-acct list | grep "user1@localhost"; then
${pkgs.maddy}/bin/maddyctl imap-acct create user1@localhost ${pkgs.maddy}/bin/maddyctl imap-acct create user1@localhost
fi
if not ${pkgs.maddy}/bin/maddyctl creds list | grep "user2@localhost"; then
${pkgs.maddy}/bin/maddyctl creds create --password test123 user2@localhost ${pkgs.maddy}/bin/maddyctl creds create --password test123 user2@localhost
fi
if not ${pkgs.maddy}/bin/maddyctl imap-acct list | grep "user2@localhost"; then
${pkgs.maddy}/bin/maddyctl imap-acct create user2@localhost ${pkgs.maddy}/bin/maddyctl imap-acct create user2@localhost
fi
if not ${pkgs.maddy}/bin/maddyctl creds list | grep "admin@localhost"; then
${pkgs.maddy}/bin/maddyctl creds create --password test123 admin@localhost ${pkgs.maddy}/bin/maddyctl creds create --password test123 admin@localhost
fi
if not ${pkgs.maddy}/bin/maddyctl imap-acct list | grep "admin@localhost"; then
${pkgs.maddy}/bin/maddyctl imap-acct create admin@localhost ${pkgs.maddy}/bin/maddyctl imap-acct create admin@localhost
fi
''; '';
serviceConfig = { serviceConfig = {
Type = "oneshot"; Type = "oneshot";
@ -164,7 +181,16 @@
wantedBy = [ "multi-user.target" ]; wantedBy = [ "multi-user.target" ];
}; };
system.stateVersion = "21.11"; # Required for php unit testing
environment.systemPackages = [ pkgs.php ];
# FIXME Package phpunit?
# Inside /var/lib/nextcloud/server run
# composer require phpunit/phpunit
environment.interactiveShellInit = ''
export PATH="$PATH:/var/lib/nextcloud/server/lib/composer/bin"
'';
system.stateVersion = "22.11";
documentation.info.enable = false; documentation.info.enable = false;
documentation.man.enable = false; documentation.man.enable = false;