From f4817027c175dabe3f605231d4d9f1613c252377 Mon Sep 17 00:00:00 2001 From: Maximilian Bosch Date: Fri, 5 Feb 2021 12:25:22 +0100 Subject: [PATCH] nixos/nextcloud: fail early if {admin,db}passFile is not readable Otherwise `nextcloud-setup.service` fails during the installation and thus leaves a corrupted state. --- nixos/modules/services/web-apps/nextcloud.nix | 22 +++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/nixos/modules/services/web-apps/nextcloud.nix b/nixos/modules/services/web-apps/nextcloud.nix index 1b643bd3260..8b21b009abc 100644 --- a/nixos/modules/services/web-apps/nextcloud.nix +++ b/nixos/modules/services/web-apps/nextcloud.nix @@ -482,6 +482,28 @@ in { path = [ occ ]; script = '' chmod og+x ${cfg.home} + + ${optionalString (c.dbpassFile != null) '' + if [ ! -r "${c.dbpassFile}" ]; then + echo "dbpassFile ${c.dbpassFile} is not readable by nextcloud:nextcloud! Aborting..." + exit 1 + fi + if [ -z "$(<${c.dbpassFile})" ]; then + echo "dbpassFile ${c.dbpassFile} is empty!" + exit 1 + fi + ''} + ${optionalString (c.adminpassFile != null) '' + if [ ! -r "${c.adminpassFile}" ]; then + echo "adminpassFile ${c.adminpassFile} is not readable by nextcloud:nextcloud! Aborting..." + exit 1 + fi + if [ -z "$(<${c.adminpassFile})" ]; then + echo "adminpassFile ${c.adminpassFile} is empty!" + exit 1 + fi + ''} + ln -sf ${cfg.package}/apps ${cfg.home}/ # create nextcloud directories.