nextcloud-server externalStorage.userLocalMount config existing check

use `--output=json` and jq to check for existence of mount
This commit is contained in:
Armin Fröhlich 2025-06-08 08:22:45 +02:00 committed by Pierre Penninckx
parent 16fcec4d40
commit 1d0b49f959

View file

@ -963,18 +963,18 @@ in
'' + lib.optionalString (cfg.apps.externalStorage.userLocalMount != null) (
let
cfg' = cfg.apps.externalStorage.userLocalMount;
escape = x: builtins.replaceStrings ["/"] [''\\\/''] x;
jq = "${pkgs.jq}/bin/jq";
in
# sh
''
${occ} files_external:list \
| grep '${escape cfg'.mountName}' \
| grep '${escape cfg'.directory}' \
|| ${occ} files_external:create \
'${cfg'.mountName}' \
local \
null::null \
--config datadir='${cfg'.directory}'
exists=$(${occ} files_external:list --output=json | ${jq} 'any(.[]; .mount_point == "${cfg'.mountName}" and .configuration.datadir == "${cfg'.directory}")')
if [[ "$exists" == "false" ]]; then
${occ} files_external:create \
'${cfg'.mountName}' \
local \
null::null \
--config datadir='${cfg'.directory}'
fi
'');
})