nextcloud-server externalStorage.userLocalMount config existing check
use `--output=json` and jq to check for existence of mount
This commit is contained in:
parent
16fcec4d40
commit
1d0b49f959
1 changed files with 10 additions and 10 deletions
|
|
@ -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
|
||||
'');
|
||||
})
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue