nextcloud: disableMaintenanceModeAtStart option

This commit is contained in:
Alexander Tomokhov
2025-04-29 01:24:44 +04:00
parent 3a84cc7ed4
commit 8e924d3aaf

View File

@@ -93,6 +93,16 @@ in
weight = 4; weight = 4;
}; };
}; };
disableMaintenanceModeAtStart = (lib.mkOption {
type = types.bool;
default = false;
description = "Disable maintenance mode at Nextcloud service startup";
}) // {
meta = {
type = "bool";
weight = 5;
};
};
}; };
# config = lib.mkIf sp.modules.nextcloud.enable # config = lib.mkIf sp.modules.nextcloud.enable
@@ -222,8 +232,16 @@ in
# the following part is active only when "auth" module is enabled # the following part is active only when "auth" module is enabled
(lib.mkIf is-auth-enabled { (lib.mkIf is-auth-enabled {
systemd.services.nextcloud-setup = { systemd.services.nextcloud-setup = {
serviceConfig = {
Restart = "on-failure";
RestartSec = "60";
};
path = [ pkgs.jq ]; path = [ pkgs.jq ];
script = '' script = lib.mkMerge [
(lib.strings.optionalString cfg.disableMaintenanceModeAtStart (
lib.mkBefore "${occ} maintenance:mode --no-interaction --off"
))
''
set -o errexit set -o errexit
set -o nounset set -o nounset
${lib.strings.optionalString cfg.debug "set -o xtrace"} ${lib.strings.optionalString cfg.debug "set -o xtrace"}
@@ -319,12 +337,14 @@ in
--group-provisioning=1 \ --group-provisioning=1 \
-vvv -vvv
'' + lib.optionalString deleteNextcloudAdmin '' ''
(lib.optionalString deleteNextcloudAdmin ''
if [[ ! -f /var/lib/nextcloud/.admin-user-deleted ]]; then if [[ ! -f /var/lib/nextcloud/.admin-user-deleted ]]; then
${occ} user:delete admin ${occ} user:delete admin
touch /var/lib/nextcloud/.admin-user-deleted touch /var/lib/nextcloud/.admin-user-deleted
fi fi
''; '')
];
}; };
selfprivacy.auth.clients."${oauthClientID}" = { selfprivacy.auth.clients."${oauthClientID}" = {
inherit adminsGroup usersGroup; inherit adminsGroup usersGroup;