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
parent 16fcec4d40
commit 91f33f33a3
No known key found for this signature in database
GPG key ID: 7C2CB1EBD18D3E8E

View file

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