@@ -23,30 +23,60 @@ declare variable $dir external;
23
23
(: the target collection into which the app is deployed :)
24
24
declare variable $target external ;
25
25
26
- (: Until https://github.com/eXist-db/exist/issues/3734 is fixed, we hard code the default group name :)
27
- declare variable $repo-group :=
28
- (: config:repo-permissions()?group :)
29
- "repo"
30
- ;
31
- declare variable $repo-user :=
32
- (: config:repo-permissions()?user :)
33
- "repo"
34
- ;
26
+ (: Configuration file for the logs collection :)
27
+ declare variable $logs-xconf :=
28
+ <collection xmlns = "http://exist-db.org/collection-config/1.0" xmlns:xs = "http://www.w3.org/2001/XMLSchema" >
29
+ <index>
30
+ <range>
31
+ <create qname = "type" type = "xs:string" />
32
+ </range>
33
+ </index>
34
+ </collection>;
35
+
36
+ (: Helper function to recursively create a collection hierarchy :)
37
+ declare function local:mkcol-recursive ($collection as xs:string, $components as xs:string*) {
38
+ if (exists ($components)) then
39
+ let $newColl := concat ($collection, "/" , $components[1 ])
40
+ return (
41
+ xmldb:create-collection ($collection, $components[1 ]),
42
+ local:mkcol-recursive ($newColl, subsequence ($components, 2 ))
43
+ )
44
+ else
45
+ ()
46
+ };
47
+
48
+ (: Create a collection hierarchy :)
49
+ declare function local:mkcol ($collection as xs:string, $path as xs:string) {
50
+ local:mkcol-recursive ($collection, tokenize ($path, "/" ))
51
+ };
35
52
36
53
(:~
37
54
: Set user and group to be owner by values in repo.xml
38
55
:)
39
56
declare function local:set-data-collection-permissions ($resource as xs:string) {
40
- if (sm:get-permissions (xs:anyURI ($resource))/sm:permission/@group = $ repo-group) then
57
+ if (sm:get-permissions (xs:anyURI ($resource))/sm:permission/@group = config: repo-permissions ()? group ) then
41
58
()
42
59
else
43
60
(
44
- sm:chown ($resource, $ repo-user),
45
- sm:chgrp ($resource, $ repo-group),
46
- sm:chmod (xs:anyURI ($resource), "rwxrwxr-x" )
61
+ sm:chown ($resource, config: repo-permissions ()? user),
62
+ sm:chgrp ($resource, config: repo-permissions ()? group ),
63
+ sm:chmod (xs:anyURI ($resource), config:repo-permissions ()?mode )
47
64
)
48
65
};
49
66
67
+ (: Create the data collection hierarchy :)
68
+
69
+ xmldb:create-collection ($config:app-data-parent-col, $config:app-data-col-name),
70
+ for $col-name in ($config:icons-col-name, $config:metadata-col-name, $config:packages-col-name, $config:logs-col-name)
71
+ return
72
+ xmldb:create-collection ($config:app-data-col, $col-name),
73
+
74
+ (: Create log indexes :)
75
+
76
+ local:mkcol ("/db/system/config" , $config:logs-col),
77
+ xmldb:store ("/db/system/config" || $config:logs-col, "collection.xconf" , $logs-xconf),
78
+ xmldb:reindex ($config:logs-col),
79
+
50
80
(: Set user and group ownership on the package data collection hierarchy :)
51
81
52
82
for $col in ($config:app-data-col, xmldb:get-child-collections ($config:app-data-col) ! ($config:app-data-col || "/" || .))
@@ -58,10 +88,8 @@ return
58
88
if (doc-available ($config:raw-packages-doc) and doc-available ($config:package-groups-doc)) then
59
89
()
60
90
else
61
- (
62
- scanrepo:rebuild-all-package-metadata (),
63
- ($config:raw-packages-doc, $config:package-groups-doc) ! local:set-data-collection-permissions (.)
64
- ),
91
+ scanrepo:rebuild-all-package-metadata (),
65
92
66
- (: execute get-package.xq as repo group, so that it can write to logs :)
67
- sm:chmod (xs:anyURI ($target || "/modules/get-package.xq" ), "rwsrwxr-x" )
93
+ (: Ensure get-package.xq is run as "repo" group, so that it can write to logs :)
94
+
95
+ sm:chmod (xs:anyURI ($target || "/modules/get-package.xq" ), "g+s" )
0 commit comments