From 84be64bec7eff036bd6403b303cf2a6a81c4f92e Mon Sep 17 00:00:00 2001 From: Jonas Heinrich Date: Thu, 16 Feb 2023 17:39:26 +0100 Subject: [PATCH] mail/maddy: check if account exists before creating --- server | 2 +- vm-nextcloud.nix | 40 +++++++++++++++++++++++++++++++++------- 2 files changed, 34 insertions(+), 8 deletions(-) diff --git a/server b/server index ad00a14..b4ac9d2 160000 --- a/server +++ b/server @@ -1 +1 @@ -Subproject commit ad00a149ea2bb262e62fbecf11051fd035f90ec4 +Subproject commit b4ac9d22d12b3623bd5b1a654a83bc5ba0190c78 diff --git a/vm-nextcloud.nix b/vm-nextcloud.nix index 5f68cff..955cd4b 100644 --- a/vm-nextcloud.nix +++ b/vm-nextcloud.nix @@ -124,14 +124,31 @@ }; # Creating mail users and inboxes + # FIXME: Upstream systemd.services.maddy-accounts = { script = '' - ${pkgs.maddy}/bin/maddyctl creds create --password test123 user1@localhost - ${pkgs.maddy}/bin/maddyctl imap-acct create user1@localhost - ${pkgs.maddy}/bin/maddyctl creds create --password test123 user2@localhost - ${pkgs.maddy}/bin/maddyctl imap-acct create user2@localhost - ${pkgs.maddy}/bin/maddyctl creds create --password test123 admin@localhost - ${pkgs.maddy}/bin/maddyctl imap-acct create admin@localhost + #!${runtimeShell} + + if not ${pkgs.maddy}/bin/maddyctl creds list | grep "user1@localhost"; then + ${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 + fi + + if not ${pkgs.maddy}/bin/maddyctl creds list | grep "user2@localhost"; then + ${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 + fi + + if not ${pkgs.maddy}/bin/maddyctl creds list | grep "admin@localhost"; then + ${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 + fi ''; serviceConfig = { Type = "oneshot"; @@ -164,7 +181,16 @@ 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.man.enable = false;