@webship.co/workspace-nextcloud 0.0.0-stage → 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +264 -2
- package/ai/agents/nextcloud-site-builder.md +104 -0
- package/ai/agents/nextcloud-tester.md +116 -0
- package/ai/commands/nextcloud-test.md +75 -0
- package/ai/prompts/nextcloud-build-and-test.md +27 -0
- package/ai/prompts/nextcloud-scenarios-for-an-area.md +26 -0
- package/ai/skills/nextcloud-scenarios/SKILL.md +102 -0
- package/ai/skills/nextcloud-scenarios/examples/account.feature +32 -0
- package/ai/skills/nextcloud-scenarios/examples/files.feature +33 -0
- package/ai/skills/nextcloud-scenarios/examples/sharing.feature +25 -0
- package/commands/cmd-nextcloud-project.sh +31 -0
- package/commands/cmd-tools-nextcloud-occ.sh +26 -0
- package/dist/src/index.d.ts +30 -0
- package/dist/src/index.js +54 -0
- package/dist/src/index.js.map +1 -0
- package/features/nextcloud.feature +36 -0
- package/package.json +96 -4
- package/scripts/args/arg-nextcloud-occ.sh +21 -0
- package/scripts/args/arg-nextcloud.sh +24 -0
- package/scripts/functions/fun-nextcloud.sh +446 -0
- package/scripts/nextcloud-site.sh +212 -0
- package/testing/site.feature +44 -0
|
@@ -0,0 +1,446 @@
|
|
|
1
|
+
#!/usr/bin/env bash
|
|
2
|
+
|
|
3
|
+
# Nextcloud for the Webship Workspace: build a file and collaboration server from its release tarball, run its
|
|
4
|
+
# command-line tool (occ), add its default accounts, and wire its step pack into the testing setup.
|
|
5
|
+
#
|
|
6
|
+
# Placed by `plugins.sh --install nextcloud` in core/scripts/plugins/nextcloud/functions/, where bootstrap sources
|
|
7
|
+
# it after the core's own functions. Everything runs in containers (DDEV by default), never on the host: the
|
|
8
|
+
# release tarball is fetched and checked in the web container, unpacked in nextcloud/ (the docroot of a PHP project
|
|
9
|
+
# served by Apache, with the release's own rewrite rules) with its data folder data/ beside it, outside the docroot,
|
|
10
|
+
# and installed with its own installer on the project's database; the project's mail catcher takes its mail, and a
|
|
11
|
+
# daemon of the web container runs its background jobs (cron.php every five minutes). Only the apps the release
|
|
12
|
+
# bundles: no app store, no account anywhere.
|
|
13
|
+
#
|
|
14
|
+
# DDEV has no project type for Nextcloud, so a site of this plugin is recognised by a file
|
|
15
|
+
# (.ddev/config.nextcloud.yaml, written by the builder), and four names are the ones the core's tools look for:
|
|
16
|
+
# set_nextcloud_users the default accounts (cmd-tools-add-users.sh <project> nextcloud)
|
|
17
|
+
# add_nextcloud_users create them with occ (the same tool, and --add-users of the builder)
|
|
18
|
+
# cancel_nextcloud_users delete them (cmd-tools-cancel-users.sh <project> nextcloud)
|
|
19
|
+
# testing_configure_nextcloud the step pack in the testing stack (cmd-tools-testing.sh <project>)
|
|
20
|
+
|
|
21
|
+
# The step pack a Nextcloud site is tested with, and the release line it is required at.
|
|
22
|
+
readonly NEXTCLOUD_STEPS_PACKAGE='@webship-js/nextcloud-steps';
|
|
23
|
+
readonly NEXTCLOUD_STEPS_VERSION='^2.0.0';
|
|
24
|
+
|
|
25
|
+
# The release the builder installs when none is asked for, and the PHP of the web container (the release takes 8.3
|
|
26
|
+
# to 8.5; DDEV offers 8.4).
|
|
27
|
+
readonly NEXTCLOUD_DEFAULT_VERSION='35.0.3';
|
|
28
|
+
readonly NEXTCLOUD_DEFAULT_PHP='8.4';
|
|
29
|
+
|
|
30
|
+
# The default accounts, the ones a scenario logs in as: an administrator (in the admin group), an editor and a user,
|
|
31
|
+
# each an account of its own. Accounts are configuration, created once on the site; a test suite never creates or
|
|
32
|
+
# deletes one. The administrator the installer makes with --install is the workspace account and is not in this list.
|
|
33
|
+
function set_nextcloud_users() {
|
|
34
|
+
users=(administrator editor user);
|
|
35
|
+
local user ;
|
|
36
|
+
for user in "${users[@]}" ; do
|
|
37
|
+
printf -v "user_${user}_name" '%s' "${user}" ;
|
|
38
|
+
printf -v "user_${user}_mail" '%s' "${user}@example.com" ;
|
|
39
|
+
printf -v "user_${user}_password" '%s' 'dD.123123ddd' ;
|
|
40
|
+
done
|
|
41
|
+
user_administrator_display='Administrator' ;
|
|
42
|
+
user_editor_display='Editor' ;
|
|
43
|
+
user_user_display='User' ;
|
|
44
|
+
user_administrator_role='admin' ;
|
|
45
|
+
user_editor_role='' ;
|
|
46
|
+
user_user_role='' ;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
# Is this folder a Nextcloud site of this plugin? The builder leaves .ddev/config.nextcloud.yaml in it.
|
|
50
|
+
function nextcloud_is_project() {
|
|
51
|
+
[ -f "$1/.ddev/config.nextcloud.yaml" ] ;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
# Is the site of a folder installed? Its installer writes nextcloud/config/config.php with 'installed' => true.
|
|
55
|
+
function nextcloud_is_installed() {
|
|
56
|
+
grep -qs "'installed' => true" "${1:-.}/nextcloud/config/config.php" ;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
# Go to the project a tool was asked about, or say why not.
|
|
60
|
+
function nextcloud_enter_project() {
|
|
61
|
+
local project_path="${WORKSPACE_ROOT}/${doc_name}/${PROJECT_NAME}";
|
|
62
|
+
if [ ! -d "${project_path}" ] ; then
|
|
63
|
+
echo "No project ${PROJECT_NAME} in ${WORKSPACE_ROOT}/${doc_name}." ;
|
|
64
|
+
return 1 ;
|
|
65
|
+
fi
|
|
66
|
+
if ! nextcloud_is_project "${project_path}" ; then
|
|
67
|
+
echo "${doc_name}/${PROJECT_NAME} is not a Nextcloud project of this plugin (it has no .ddev/config.nextcloud.yaml)." ;
|
|
68
|
+
return 1 ;
|
|
69
|
+
fi
|
|
70
|
+
cd "${project_path}" || return 1 ;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
# The payload of nextcloud-site.sh: lines of KEY=base64(value), all of it in base64 again, from variables.
|
|
74
|
+
function nextcloud_payload() {
|
|
75
|
+
local line="" key ;
|
|
76
|
+
for key in "$@" ; do
|
|
77
|
+
line="${line}${key}=$(printf '%s' "${!key}" | base64 -w0)"$'\n' ;
|
|
78
|
+
done
|
|
79
|
+
printf '%s' "${line}" | base64 -w0 ;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
# Run verbs of nextcloud-site.sh with bash in the web container, with the payload on its first line: no password on
|
|
83
|
+
# the host's command line, in a file of the project, or in what a failed run prints.
|
|
84
|
+
function nextcloud_site() {
|
|
85
|
+
local verbs="$1" ; shift ;
|
|
86
|
+
local script="${WORKSPACE_SCRIPTS}/plugins/nextcloud/nextcloud-site.sh" ;
|
|
87
|
+
if [ ! -f "${script}" ] ; then
|
|
88
|
+
echo "nextcloud-site.sh is not in ${WORKSPACE_SCRIPTS}/plugins/nextcloud: install the plugin (plugins.sh --install nextcloud)." ;
|
|
89
|
+
return 1 ;
|
|
90
|
+
fi
|
|
91
|
+
{ printf "SITE_PAYLOAD='%s'\n" "$(nextcloud_payload "$@")"; cat "${script}"; } \
|
|
92
|
+
| ddev exec "SITE_VERBS='${verbs}' bash -s" ;
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
# The default accounts (the list set_nextcloud_users loads) as the site script takes them: one line each,
|
|
96
|
+
# username|email|password|display name|groups.
|
|
97
|
+
function nextcloud_accounts_rows() {
|
|
98
|
+
local user name mail password display role ;
|
|
99
|
+
for user in "${users[@]}" ; do
|
|
100
|
+
name="user_${user}_name"; mail="user_${user}_mail"; password="user_${user}_password";
|
|
101
|
+
display="user_${user}_display"; role="user_${user}_role";
|
|
102
|
+
printf '%s|%s|%s|%s|%s\n' "${!name}" "${!mail}" "${!password}" "${!display:-${!name}}" "${!role}" ;
|
|
103
|
+
done
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
# The usernames of the default accounts, one per line.
|
|
107
|
+
function nextcloud_usernames() {
|
|
108
|
+
local user name ;
|
|
109
|
+
for user in "${users[@]}" ; do name="user_${user}_name" ; printf '%s\n' "${!name}" ; done
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
# Write the project's files for the server: its PHP settings, its background jobs, the site's own settings file.
|
|
113
|
+
function nextcloud_write_config() {
|
|
114
|
+
local project_path="$1" version="$2" ;
|
|
115
|
+
mkdir -p "${project_path}/.ddev/php" || return 1 ;
|
|
116
|
+
cat > "${project_path}/.ddev/php/nextcloud.ini" <<'INIEOF'
|
|
117
|
+
; The PHP settings of the file server (written by the Nextcloud builder of the workspace).
|
|
118
|
+
apc.enable_cli = 1
|
|
119
|
+
memory_limit = 1024M
|
|
120
|
+
upload_max_filesize = 512M
|
|
121
|
+
post_max_size = 512M
|
|
122
|
+
INIEOF
|
|
123
|
+
cat > "${project_path}/.ddev/nextcloud-cron.sh" <<'CRONEOF'
|
|
124
|
+
#!/usr/bin/env bash
|
|
125
|
+
# The background jobs of the file server: cron.php every five minutes, once the site is installed. Written by the
|
|
126
|
+
# Nextcloud builder of the workspace.
|
|
127
|
+
while true; do
|
|
128
|
+
if grep -qs "'installed' => true" /var/www/html/nextcloud/config/config.php; then
|
|
129
|
+
php -f /var/www/html/nextcloud/cron.php >> /tmp/nextcloud-cron.log 2>&1
|
|
130
|
+
fi
|
|
131
|
+
sleep 300
|
|
132
|
+
done
|
|
133
|
+
CRONEOF
|
|
134
|
+
cat > "${project_path}/.ddev/config.nextcloud.yaml" <<YAMLEOF
|
|
135
|
+
# Nextcloud in this project: its release, and its background jobs. Written by the Nextcloud builder of the
|
|
136
|
+
# workspace; build again rather than editing by hand.
|
|
137
|
+
web_environment:
|
|
138
|
+
- NEXTCLOUD_VERSION=${version}
|
|
139
|
+
web_extra_daemons:
|
|
140
|
+
- name: "nextcloud-cron"
|
|
141
|
+
command: "bash /var/www/html/.ddev/nextcloud-cron.sh"
|
|
142
|
+
directory: /var/www/html
|
|
143
|
+
YAMLEOF
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
# The release the site runs, as its own version.php says it.
|
|
147
|
+
function nextcloud_version() {
|
|
148
|
+
sed -n "s/^\$OC_VersionString = '\(.*\)';/\1/p" "${WORKSPACE_ROOT}/${doc_name}/${PROJECT_NAME}/nextcloud/version.php" 2>/dev/null | head -n 1 ;
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
# Build a Nextcloud site from nothing: the project and the release; with --install the installer, the workspace
|
|
152
|
+
# account as the administrator and the settings for testing; with --add-users the default accounts.
|
|
153
|
+
function nextcloud_build() {
|
|
154
|
+
trim_project_name ;
|
|
155
|
+
local base_url="https://${PROJECT_NAME}.ddev.site" ;
|
|
156
|
+
local version="${NEXTCLOUD_VERSION:-${site_nextcloud_version:-${NEXTCLOUD_DEFAULT_VERSION}}}" ;
|
|
157
|
+
local php_version="${PHP_VERSION:-${site_php_version:-${NEXTCLOUD_DEFAULT_PHP}}}" ;
|
|
158
|
+
local project_path="${WORKSPACE_ROOT}/${doc_name}/${PROJECT_NAME}" ;
|
|
159
|
+
|
|
160
|
+
if ! [[ "${version}" =~ ^[0-9]+(\.[0-9]+\.[0-9]+)?$ ]] ; then
|
|
161
|
+
echo "--nextcloud-version takes a release (35.0.3) or a major line (35), not ${version}. Nothing was changed." ;
|
|
162
|
+
exit 1 ;
|
|
163
|
+
fi
|
|
164
|
+
if ! [[ "${php_version}" =~ ^8\.[3-5]$ ]] ; then
|
|
165
|
+
echo "--php-version takes 8.3, 8.4 or 8.5 (what the release accepts), not ${php_version}. Nothing was changed." ;
|
|
166
|
+
exit 1 ;
|
|
167
|
+
fi
|
|
168
|
+
if [ "${ADD_USERS}" == 'yes' ] && [ "${INSTALL}" != 'yes' ] ; then
|
|
169
|
+
echo "--add-users needs --install: the default accounts go into the site --install makes." ;
|
|
170
|
+
exit 1 ;
|
|
171
|
+
fi
|
|
172
|
+
if [ ${#PROJECT_NAME} -gt 40 ] || ! [[ "${PROJECT_NAME}" =~ ^[a-z0-9][a-z0-9-]*$ ]] ; then
|
|
173
|
+
echo "The project name ${PROJECT_NAME} must be small letters, digits and dashes (its address and its container take it). Nothing was changed." ;
|
|
174
|
+
exit 1 ;
|
|
175
|
+
fi
|
|
176
|
+
if [ "${INSTALL}" == 'yes' ] && [ ${#account_pass} -lt 8 ] ; then
|
|
177
|
+
echo "The workspace account's password is not set (core/config/settings.yml): --install makes it the server's administrator. Nothing was changed." ;
|
|
178
|
+
exit 1 ;
|
|
179
|
+
fi
|
|
180
|
+
|
|
181
|
+
cd ${WORKSPACE_ROOT}/${doc_name} || exit 1 ;
|
|
182
|
+
|
|
183
|
+
# A project of the same name goes first, with its database.
|
|
184
|
+
drop_database ;
|
|
185
|
+
rm -rf "${PROJECT_NAME}" ;
|
|
186
|
+
mkdir -p "${PROJECT_NAME}" ;
|
|
187
|
+
cd "${project_path}" || exit 1 ;
|
|
188
|
+
|
|
189
|
+
# A PHP project served by Apache (the release's .htaccess rules) from nextcloud/, with the project's database and
|
|
190
|
+
# the Node.js of the workspace for a test suite run in the web container.
|
|
191
|
+
ddev config --project-type=php --docroot=nextcloud --webserver-type=apache-fpm --php-version="${php_version}" \
|
|
192
|
+
--project-name=${PROJECT_NAME} --nodejs-version=$(ddev_nodejs_version) < /dev/null || exit 1 ;
|
|
193
|
+
nextcloud_write_config "${project_path}" "${version}" || exit 1 ;
|
|
194
|
+
|
|
195
|
+
echo "Starting the project." ;
|
|
196
|
+
ddev_up start -y < /dev/null || exit 1 ;
|
|
197
|
+
echo "Fetching Nextcloud ${version} (about 240 MB) and checking its SHA-256 sum." ;
|
|
198
|
+
local VERSION="${version}" ;
|
|
199
|
+
nextcloud_site download VERSION || exit 1 ;
|
|
200
|
+
|
|
201
|
+
if [ "${INSTALL}" == 'yes' ] ; then
|
|
202
|
+
echo "Installing it, with the workspace account ${account_name} as its administrator." ;
|
|
203
|
+
local ADMIN_USER="${account_name}" ADMIN_PASSWORD="${account_pass}" ADMIN_EMAIL="${account_mail:-${account_name}@example.com}" HOST="${PROJECT_NAME}.ddev.site" ;
|
|
204
|
+
nextcloud_site "install configure" ADMIN_USER ADMIN_PASSWORD ADMIN_EMAIL HOST || { echo "The installer did not finish." ; exit 1 ; } ;
|
|
205
|
+
if [ "${ADD_USERS}" == 'yes' ] ; then
|
|
206
|
+
set_nextcloud_users ;
|
|
207
|
+
add_nextcloud_users || exit 1 ;
|
|
208
|
+
users=() ;
|
|
209
|
+
fi
|
|
210
|
+
echo "${doc_name} ${PROJECT_NAME} has been installed: Nextcloud $(nextcloud_version)." ;
|
|
211
|
+
echo "The site: ${base_url} · its mail: ${base_url}:8026 · its administrator: ${account_name}" ;
|
|
212
|
+
else
|
|
213
|
+
echo "${doc_name} ${PROJECT_NAME} is ready, not installed: Nextcloud $(nextcloud_version) at ${base_url} shows its installer." ;
|
|
214
|
+
echo "Build it again with --install (and --add-users) to install it with the workspace account as its administrator." ;
|
|
215
|
+
fi
|
|
216
|
+
|
|
217
|
+
if [ "${LAUNCH}" == 'yes' ] ; then
|
|
218
|
+
ddev launch "${base_url}" ;
|
|
219
|
+
fi
|
|
220
|
+
|
|
221
|
+
cd ${WORKSPACE_ROOT}/${doc_name};
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
# Create the default accounts with the server's own tool (occ): an account that is already there gets its password,
|
|
225
|
+
# email, display name and groups back. The list is loaded by the caller (set_nextcloud_users): the core's add_users,
|
|
226
|
+
# the builder, the tool.
|
|
227
|
+
function add_nextcloud_users() {
|
|
228
|
+
nextcloud_enter_project || return 1 ;
|
|
229
|
+
if ! nextcloud_is_installed . ; then
|
|
230
|
+
echo "${doc_name}/${PROJECT_NAME} is not installed: build it with --install first." ;
|
|
231
|
+
return 1 ;
|
|
232
|
+
fi
|
|
233
|
+
local user user_name user_mail user_password user_role ;
|
|
234
|
+
for user in "${users[@]}" ; do
|
|
235
|
+
user_name="user_${user}_name"; user_mail="user_${user}_mail";
|
|
236
|
+
user_password="user_${user}_password"; user_role="user_${user}_role";
|
|
237
|
+
|
|
238
|
+
echo " ---------------------------------------------------------------- ";
|
|
239
|
+
echo " User name: ${!user_name}";
|
|
240
|
+
echo " User mail: ${!user_mail}";
|
|
241
|
+
echo " User password: ${!user_password}";
|
|
242
|
+
echo " User role: ${!user_role:-(no group)}";
|
|
243
|
+
echo " ================================================================= ";
|
|
244
|
+
done
|
|
245
|
+
local ACCOUNTS ;
|
|
246
|
+
ACCOUNTS="$(nextcloud_accounts_rows)" ;
|
|
247
|
+
nextcloud_site accounts ACCOUNTS ;
|
|
248
|
+
local status=$? ;
|
|
249
|
+
cd ${WORKSPACE_ROOT}/${doc_name};
|
|
250
|
+
return ${status} ;
|
|
251
|
+
}
|
|
252
|
+
|
|
253
|
+
# Delete the default accounts (never the workspace account, the administrator the installer made).
|
|
254
|
+
function cancel_nextcloud_users() {
|
|
255
|
+
nextcloud_enter_project || return 1 ;
|
|
256
|
+
local user user_name ;
|
|
257
|
+
for user in "${users[@]}" ; do
|
|
258
|
+
user_name="user_${user}_name";
|
|
259
|
+
echo " ---------------------------------------------------------------- ";
|
|
260
|
+
echo " User name: ${!user_name}";
|
|
261
|
+
echo " ================================================================= ";
|
|
262
|
+
done
|
|
263
|
+
local USERNAMES ;
|
|
264
|
+
USERNAMES="$(nextcloud_usernames | grep -vx "${account_name}")" ;
|
|
265
|
+
nextcloud_site cancel USERNAMES ;
|
|
266
|
+
local status=$? ;
|
|
267
|
+
cd ${WORKSPACE_ROOT}/${doc_name};
|
|
268
|
+
return ${status} ;
|
|
269
|
+
}
|
|
270
|
+
|
|
271
|
+
# What cmd-tools-nextcloud-occ.sh does: the first of --occ, --add-users, --cancel-users, --empty-files that was
|
|
272
|
+
# asked for; with none of them, what the server is.
|
|
273
|
+
function nextcloud_occ_tool() {
|
|
274
|
+
trim_project_name ;
|
|
275
|
+
nextcloud_enter_project || exit 1 ;
|
|
276
|
+
|
|
277
|
+
if ! ddev describe -j 2>/dev/null | grep -q '"status":"running"' ; then
|
|
278
|
+
ddev start -y < /dev/null || exit 1 ;
|
|
279
|
+
fi
|
|
280
|
+
|
|
281
|
+
if [ ! "${OCC}" == '_none_' ] ; then
|
|
282
|
+
local OCC_ARGS="${OCC}" ;
|
|
283
|
+
nextcloud_site occ OCC_ARGS ;
|
|
284
|
+
exit $? ;
|
|
285
|
+
fi
|
|
286
|
+
|
|
287
|
+
if ! nextcloud_is_installed . ; then
|
|
288
|
+
echo "${doc_name}/${PROJECT_NAME}: Nextcloud $(nextcloud_version), not installed (build it again with --install)." ;
|
|
289
|
+
exit 0 ;
|
|
290
|
+
fi
|
|
291
|
+
set_nextcloud_users ;
|
|
292
|
+
if [ "${ADD_USERS}" == 'yes' ] ; then
|
|
293
|
+
add_nextcloud_users ;
|
|
294
|
+
elif [ "${CANCEL_USERS}" == 'yes' ] ; then
|
|
295
|
+
cancel_nextcloud_users ;
|
|
296
|
+
elif [ "${EMPTY_FILES}" == 'yes' ] ; then
|
|
297
|
+
local USERNAMES ;
|
|
298
|
+
USERNAMES="$(nextcloud_usernames)" ;
|
|
299
|
+
nextcloud_site empty USERNAMES ;
|
|
300
|
+
else
|
|
301
|
+
echo "${doc_name}/${PROJECT_NAME}: Nextcloud $(nextcloud_version)" ;
|
|
302
|
+
echo " the site: https://${PROJECT_NAME}.ddev.site" ;
|
|
303
|
+
echo " its mail: https://${PROJECT_NAME}.ddev.site:8026" ;
|
|
304
|
+
echo " its administrator: ${account_name}" ;
|
|
305
|
+
echo "" ;
|
|
306
|
+
local USERNAMES ;
|
|
307
|
+
USERNAMES="$(nextcloud_usernames)" ;
|
|
308
|
+
echo "Accounts:" ;
|
|
309
|
+
nextcloud_site list USERNAMES ;
|
|
310
|
+
fi
|
|
311
|
+
cd ${WORKSPACE_ROOT}/${doc_name};
|
|
312
|
+
}
|
|
313
|
+
|
|
314
|
+
# The step pack in the testing stack of a Nextcloud site. The core's testing_configure calls this in the project
|
|
315
|
+
# folder once webship-js is scaffolded and before the dependencies are installed; for a project that is not one of
|
|
316
|
+
# this plugin's it changes nothing.
|
|
317
|
+
#
|
|
318
|
+
# It adds the pack to package.json, lists its step definitions in cucumber.js after webship-js's own, gives
|
|
319
|
+
# cucumber.js the tags that keep the pack's assertions that must fail out of a normal run, the mail catcher (the
|
|
320
|
+
# project's own, from inside the web container where the suite runs), the handle the test-data steps work as
|
|
321
|
+
# (dataAdmin), the browser messages that are no error of a step, and the users registry of the default accounts (a
|
|
322
|
+
# handle a scenario reads, mapped to an account; never the workspace account), and writes a first feature when the
|
|
323
|
+
# project has none of its own. Every part is skipped when it is already there, so a second run adds what the first
|
|
324
|
+
# missed and never resets a suite.
|
|
325
|
+
function testing_configure_nextcloud() {
|
|
326
|
+
local project_path="$1";
|
|
327
|
+
nextcloud_is_project "${project_path}" || return 0 ;
|
|
328
|
+
if [ ! -f "${project_path}/cucumber.js" ] || [ ! -f "${project_path}/package.json" ] ; then
|
|
329
|
+
echo " Nextcloud: cucumber.js is not here yet — run the testing setup again once webship-js is scaffolded." ;
|
|
330
|
+
return 1 ;
|
|
331
|
+
fi
|
|
332
|
+
|
|
333
|
+
echo "Adding the Nextcloud step pack (${NEXTCLOUD_STEPS_PACKAGE} ${NEXTCLOUD_STEPS_VERSION}).";
|
|
334
|
+
set_nextcloud_users ;
|
|
335
|
+
local registry="" user user_name user_mail user_password user_display ;
|
|
336
|
+
for user in "${users[@]}" ; do
|
|
337
|
+
user_name="user_${user}_name"; user_mail="user_${user}_mail"; user_password="user_${user}_password"; user_display="user_${user}_display";
|
|
338
|
+
registry="${registry}${user}|${!user_name}|${!user_mail}|${!user_password}|${!user_display:-${!user_name}}"$'\n' ;
|
|
339
|
+
done
|
|
340
|
+
|
|
341
|
+
local site_name ;
|
|
342
|
+
site_name="$(sed -n 's/^name:[[:space:]]*"\{0,1\}\([A-Za-z0-9._-]*\)"\{0,1\}[[:space:]]*$/\1/p' "${project_path}/.ddev/config.yaml" | head -n 1)" ;
|
|
343
|
+
|
|
344
|
+
python3 - "${project_path}" "${NEXTCLOUD_STEPS_PACKAGE}" "${NEXTCLOUD_STEPS_VERSION}" 'NEXTCLOUD' "${registry}" "https://${site_name:-${PROJECT_NAME}}.ddev.site" <<'PYEOF' || return 1
|
|
345
|
+
import json, re, sys
|
|
346
|
+
|
|
347
|
+
project, pack, version, prefix, registry, address = sys.argv[1:7]
|
|
348
|
+
|
|
349
|
+
# package.json: the pack as a dev dependency, at the release line this plugin was proven on.
|
|
350
|
+
pkg_file = project + '/package.json'
|
|
351
|
+
pkg = json.load(open(pkg_file))
|
|
352
|
+
if pack not in pkg.get('dependencies', {}) and pack not in pkg.get('devDependencies', {}):
|
|
353
|
+
pkg.setdefault('devDependencies', {})[pack] = version
|
|
354
|
+
open(pkg_file, 'w').write(json.dumps(pkg, indent=4) + '\n')
|
|
355
|
+
print(' package.json: %s %s' % (pack, version))
|
|
356
|
+
|
|
357
|
+
cucumber_file = project + '/cucumber.js'
|
|
358
|
+
src = open(cucumber_file).read()
|
|
359
|
+
before = src
|
|
360
|
+
|
|
361
|
+
if ('node_modules/%s/' % pack) not in src:
|
|
362
|
+
line = "'node_modules/%s/tests/step-definitions/**/*.js'," % pack
|
|
363
|
+
core = re.search(r"^([ \t]*)'node_modules/webship-js/tests/step-definitions/[^']*',.*$", src, re.M)
|
|
364
|
+
opening = re.search(r"^([ \t]*)require:[ \t]*\[[ \t]*$", src, re.M)
|
|
365
|
+
if core:
|
|
366
|
+
src = src[:core.end()] + '\n' + core.group(1) + line + src[core.end():]
|
|
367
|
+
elif opening:
|
|
368
|
+
src = src[:opening.end()] + '\n' + opening.group(1) + ' ' + line + src[opening.end():]
|
|
369
|
+
else:
|
|
370
|
+
sys.exit(" cucumber.js has no require list this can add to. Add this line to it:\n " + line)
|
|
371
|
+
print(' cucumber.js: the step definitions of %s' % pack)
|
|
372
|
+
|
|
373
|
+
if not re.search(r"^[ \t]*tags:", src, re.M):
|
|
374
|
+
default = re.search(r"^([ \t]*)default:[ \t]*\{[ \t]*$", src, re.M)
|
|
375
|
+
if default:
|
|
376
|
+
pad = default.group(1) + ' '
|
|
377
|
+
block = [
|
|
378
|
+
pad + "// The pack's assertions that must fail are no part of a normal run.",
|
|
379
|
+
pad + "tags: process.env.CUCUMBER_TAGS || 'not @wip and not @must-fail',",
|
|
380
|
+
]
|
|
381
|
+
src = src[:default.end()] + '\n' + '\n'.join(block) + src[default.end():]
|
|
382
|
+
print(' cucumber.js: the tags that keep the assertions that must fail out of a normal run')
|
|
383
|
+
|
|
384
|
+
world = re.search(r"^([ \t]*)worldParameters:[ \t]*\{[ \t]*$", src, re.M)
|
|
385
|
+
if not world:
|
|
386
|
+
sys.exit(" cucumber.js has no worldParameters block to add the users registry to.")
|
|
387
|
+
pad = world.group(1) + ' '
|
|
388
|
+
additions = []
|
|
389
|
+
base = "(process.env.LAUNCH_URL || '%s').replace(/\\/+$/, '')" % address
|
|
390
|
+
if not re.search(r"^[ \t]*mailUrl:", src, re.M):
|
|
391
|
+
additions += [
|
|
392
|
+
pad + "// The project's mail catcher: in the web container (where the testing setup runs the suite) on its own port, else through the router.",
|
|
393
|
+
pad + "mailUrl: process.env.MAIL_URL || (process.env.IS_DDEV_PROJECT ? 'http://127.0.0.1:8025' : `${%s}:8026`)," % base,
|
|
394
|
+
]
|
|
395
|
+
if not re.search(r"^[ \t]*dataAdmin:", src, re.M):
|
|
396
|
+
additions += [
|
|
397
|
+
pad + "// The account the test-data steps and the clean-up use for what only an administrator may do: a handle of `users` in the admin group.",
|
|
398
|
+
pad + "dataAdmin: process.env.DATA_ADMIN || 'administrator',",
|
|
399
|
+
]
|
|
400
|
+
if not re.search(r"^[ \t]*javascript:", src, re.M):
|
|
401
|
+
additions += [
|
|
402
|
+
pad + "// Browser messages that are no error of a step: a request lost when the network changed, a listing the Files app",
|
|
403
|
+
pad + "// cancels, the sharing tab's list of actions, requests the apps make that answer 404 by design, the preview worker",
|
|
404
|
+
pad + "// a public link's page refuses.",
|
|
405
|
+
pad + "javascript: { mode: process.env.WEBSHIP_JS_ERROR_MODE || 'warn', levels: ['error'], ignore: 'net::ERR_NETWORK_CHANGED|signal is aborted without reason|external legacy actions|status of 404|preview-service-worker|SW registration failed', beforeScenario: false, afterScenario: true },",
|
|
406
|
+
]
|
|
407
|
+
if not re.search(r"^[ \t]*users:[ \t]*\{", src, re.M):
|
|
408
|
+
rows = [r.split('|') for r in registry.splitlines() if r.strip()]
|
|
409
|
+
additions += [
|
|
410
|
+
pad + "// The users registry: a handle a scenario reads, mapped to an account of the site (the default accounts:",
|
|
411
|
+
pad + "// cmd-tools-nextcloud-occ.sh --add-users). Override one with %s_<HANDLE>_USERNAME and %s_<HANDLE>_PASSWORD." % (prefix, prefix),
|
|
412
|
+
pad + "users: {",
|
|
413
|
+
]
|
|
414
|
+
for handle, username, email, password, display in rows:
|
|
415
|
+
env = '%s_%s' % (prefix, handle.upper())
|
|
416
|
+
additions.append(pad + " %s: { username: process.env.%s_USERNAME || '%s', email: '%s', displayName: '%s', password: process.env.%s_PASSWORD || '%s' }," % (handle, env, username, email, display, env, password))
|
|
417
|
+
additions.append(pad + "},")
|
|
418
|
+
print(' cucumber.js: the users registry (%s)' % ', '.join(r[0] for r in rows))
|
|
419
|
+
if additions:
|
|
420
|
+
src = src[:world.end()] + '\n' + '\n'.join(additions) + src[world.end():]
|
|
421
|
+
print(' cucumber.js: the mail catcher, the data administrator and the browser messages to leave out')
|
|
422
|
+
|
|
423
|
+
# The address the suite opens when LAUNCH_URL is not set: the placeholder of the scaffold becomes the site's.
|
|
424
|
+
placeholder = "process.env.LAUNCH_URL || 'http://localhost:8080'"
|
|
425
|
+
if placeholder in src:
|
|
426
|
+
src = src.replace(placeholder, "process.env.LAUNCH_URL || '%s'" % address)
|
|
427
|
+
print(' cucumber.js: the address of the site (%s)' % address)
|
|
428
|
+
|
|
429
|
+
if src != before:
|
|
430
|
+
open(cucumber_file, 'w').write(src)
|
|
431
|
+
PYEOF
|
|
432
|
+
|
|
433
|
+
# A first feature, when the project has none for the site yet.
|
|
434
|
+
local feature="${WORKSPACE_SCRIPTS}/plugins/nextcloud/site.feature" ;
|
|
435
|
+
if [ -f "${feature}" ] && [ ! -f "${project_path}/tests/features/site.feature" ] ; then
|
|
436
|
+
mkdir -p "${project_path}/tests/features" && cp "${feature}" "${project_path}/tests/features/site.feature" \
|
|
437
|
+
&& echo " tests/features/site.feature: a first feature for the site" ;
|
|
438
|
+
fi
|
|
439
|
+
|
|
440
|
+
# The scenarios log in as the default accounts: make sure an installed site has them.
|
|
441
|
+
if nextcloud_is_installed "${project_path}" && ( cd "${project_path}" && add_nextcloud_users > /dev/null 2>&1 ) ; then
|
|
442
|
+
echo " the default accounts are on the site (${users[*]})" ;
|
|
443
|
+
elif nextcloud_is_installed "${project_path}" ; then
|
|
444
|
+
echo " The default accounts could not be written: is the project running (ddev start in ${project_path})?" ;
|
|
445
|
+
fi
|
|
446
|
+
}
|
|
@@ -0,0 +1,212 @@
|
|
|
1
|
+
# The site script of the file server: run by bash in the project's web container, with the server's own
|
|
2
|
+
# command-line tool (occ), never on the host. The build of the test site and the Webship Workspace's builder
|
|
3
|
+
# both run it the same way:
|
|
4
|
+
#
|
|
5
|
+
# { printf "SITE_PAYLOAD='%s'\n" "<base64 of the payload>"; cat nextcloud-site.sh; } \
|
|
6
|
+
# | ddev exec "SITE_VERBS='<verbs>' bash -s"
|
|
7
|
+
#
|
|
8
|
+
# The payload travels on the first line of the input, as base64 of lines of KEY=base64(value): no password is
|
|
9
|
+
# ever on the command line of the host, in a file of the project, or in the output of a failed run.
|
|
10
|
+
# VERSION (download) the release to fetch: 35.0.3, or a line (35) for its newest release
|
|
11
|
+
# ADMIN_USER, ADMIN_PASSWORD (install) the administrator the installer makes
|
|
12
|
+
# ADMIN_EMAIL (install) its email address
|
|
13
|
+
# HOST (configure) the host name of the site: <project>.ddev.site
|
|
14
|
+
# ACCOUNTS (accounts) the accounts, one per line: username|email|password|display name|groups
|
|
15
|
+
# (groups: names separated by commas, or nothing)
|
|
16
|
+
# USERNAMES (cancel, empty, list) the usernames of the accounts, one per line
|
|
17
|
+
# OCC_ARGS (occ) the arguments of one occ command, quoted as in a shell
|
|
18
|
+
#
|
|
19
|
+
# Verbs, in the order given (SITE_VERBS):
|
|
20
|
+
# download fetch the release tarball from download.nextcloud.com, check its SHA-256 sum, and unpack it in
|
|
21
|
+
# nextcloud/ (the docroot); the data folder is data/, beside it, outside the docroot
|
|
22
|
+
# install run the installer (occ maintenance:install) on the project's database, with ADMIN_USER
|
|
23
|
+
# configure set the site up for its address and for testing: its host name, https behind the router, short
|
|
24
|
+
# addresses, a local memory cache, no app store, no first-run wizard, new accounts start with
|
|
25
|
+
# empty files, no connection to the internet, the mail to the project's mail catcher, background
|
|
26
|
+
# jobs by cron
|
|
27
|
+
# accounts create the accounts of ACCOUNTS, or give an existing one back its password, email, display
|
|
28
|
+
# name and groups (and enable it)
|
|
29
|
+
# cancel delete the accounts of USERNAMES (never an administrator the installer made)
|
|
30
|
+
# empty delete every file and folder of the accounts of USERNAMES, with their trash bin and their versions
|
|
31
|
+
# list print the accounts of USERNAMES: their email, display name, groups and whether they are enabled
|
|
32
|
+
# version print the release the site runs
|
|
33
|
+
# occ run one occ command (OCC_ARGS) and print what it prints
|
|
34
|
+
set -uo pipefail
|
|
35
|
+
|
|
36
|
+
ROOT=/var/www/html
|
|
37
|
+
SERVER="$ROOT/nextcloud"
|
|
38
|
+
DATA="$ROOT/data"
|
|
39
|
+
|
|
40
|
+
# One KEY=base64 line per value; the line is split by hand (read would drop a single trailing "=").
|
|
41
|
+
declare -A P
|
|
42
|
+
while IFS= read -r line; do
|
|
43
|
+
[ -z "$line" ] && continue
|
|
44
|
+
P["${line%%=*}"]="$(printf '%s' "${line#*=}" | base64 -d)"
|
|
45
|
+
done < <(printf '%s' "${SITE_PAYLOAD:-}" | base64 -d)
|
|
46
|
+
value() { printf '%s' "${P[$1]:-}"; }
|
|
47
|
+
|
|
48
|
+
occ() { php "$SERVER/occ" --no-interaction --no-ansi "$@"; }
|
|
49
|
+
|
|
50
|
+
# Whether an account exists.
|
|
51
|
+
exists() { occ user:info "$1" > /dev/null 2>&1; }
|
|
52
|
+
|
|
53
|
+
for verb in ${SITE_VERBS:-}; do
|
|
54
|
+
case "$verb" in
|
|
55
|
+
download)
|
|
56
|
+
version="$(value VERSION)"
|
|
57
|
+
case "$version" in
|
|
58
|
+
*.*.*) file="nextcloud-$version.tar.bz2" ;;
|
|
59
|
+
*) file="latest-$version.tar.bz2" ;;
|
|
60
|
+
esac
|
|
61
|
+
url="https://download.nextcloud.com/server/releases/$file"
|
|
62
|
+
tmp="$(mktemp -d)"
|
|
63
|
+
echo "Fetching $url"
|
|
64
|
+
# A transfer that stays under 10 KB/s for a minute, or a connection that does not open in 30 seconds, is given
|
|
65
|
+
# up and tried again (three times): a stalled connection would otherwise keep curl waiting forever.
|
|
66
|
+
fetch() { curl -fsSL --connect-timeout 30 --speed-limit 10240 --speed-time 60 --retry 3 --retry-delay 5 "$1" -o "$2"; }
|
|
67
|
+
if ! fetch "$url" "$tmp/$file" || ! fetch "$url.sha256" "$tmp/$file.sha256"; then
|
|
68
|
+
echo "The release $version could not be fetched from $url." >&2
|
|
69
|
+
rm -rf "$tmp"
|
|
70
|
+
exit 1
|
|
71
|
+
fi
|
|
72
|
+
# The sum file lists the tarball and its metadata file: the tarball's line is checked.
|
|
73
|
+
if ! (cd "$tmp" && awk -v f="$file" '$2 == f' "$file.sha256" | grep -q . && awk -v f="$file" '$2 == f' "$file.sha256" | sha256sum -c --quiet -); then
|
|
74
|
+
echo "The SHA-256 sum of $file does not match the one the server publishes." >&2
|
|
75
|
+
rm -rf "$tmp"
|
|
76
|
+
exit 1
|
|
77
|
+
fi
|
|
78
|
+
rm -rf "$SERVER" && mkdir -p "$SERVER" "$DATA" || exit 1
|
|
79
|
+
tar -xjf "$tmp/$file" -C "$ROOT" || { rm -rf "$tmp"; exit 1; }
|
|
80
|
+
rm -rf "$tmp"
|
|
81
|
+
echo "Unpacked $(sed -n "s/^\$OC_VersionString = '\(.*\)';/\1/p" "$SERVER/version.php") in nextcloud/."
|
|
82
|
+
;;
|
|
83
|
+
install)
|
|
84
|
+
if [ -f "$SERVER/config/config.php" ] && grep -q "'installed' => true" "$SERVER/config/config.php"; then
|
|
85
|
+
echo "The site is installed already." >&2
|
|
86
|
+
exit 1
|
|
87
|
+
fi
|
|
88
|
+
if ! occ maintenance:install --database=mysql --database-host=db --database-name=db --database-user=db \
|
|
89
|
+
--database-pass=db --admin-user="$(value ADMIN_USER)" --admin-pass="$(value ADMIN_PASSWORD)" \
|
|
90
|
+
--admin-email="$(value ADMIN_EMAIL)" --data-dir="$DATA"; then
|
|
91
|
+
echo "The installer did not finish." >&2
|
|
92
|
+
exit 1
|
|
93
|
+
fi
|
|
94
|
+
;;
|
|
95
|
+
configure)
|
|
96
|
+
host="$(value HOST)"
|
|
97
|
+
set_system() { occ config:system:set "$@" > /dev/null || { echo "occ config:system:set $1 failed." >&2; exit 1; }; }
|
|
98
|
+
# The address of the site, behind the router of the container tool, which serves it over https.
|
|
99
|
+
set_system trusted_domains 1 --value="$host"
|
|
100
|
+
set_system overwrite.cli.url --value="https://$host"
|
|
101
|
+
set_system overwriteprotocol --value=https
|
|
102
|
+
# Short addresses (/apps/files, not /index.php/apps/files): the web server's rewrite rules.
|
|
103
|
+
set_system htaccess.RewriteBase --value=/
|
|
104
|
+
occ maintenance:update:htaccess > /dev/null
|
|
105
|
+
# A local memory cache (APCu), on the command line too.
|
|
106
|
+
set_system memcache.local --value='\OC\Memcache\APCu'
|
|
107
|
+
# No app store and no connection to the internet: only the apps the release bundles, no call to any
|
|
108
|
+
# outside service (updates, news, the lookup server).
|
|
109
|
+
set_system appstoreenabled --value=false --type=boolean
|
|
110
|
+
set_system has_internet_connection --value=false --type=boolean
|
|
111
|
+
# New accounts start with no files and no templates: a suite brings its own files.
|
|
112
|
+
set_system skeletondirectory --value=''
|
|
113
|
+
set_system templatedirectory --value=''
|
|
114
|
+
# Every request reaches the server from the router's address: the failed logins of one test run would
|
|
115
|
+
# slow down the logins of every later one, so the throttling of failed logins is off on a test site.
|
|
116
|
+
set_system auth.bruteforce.protection.enabled --value=false --type=boolean
|
|
117
|
+
# The rate limits are off for the same reason: the server sends an account at most five password reset
|
|
118
|
+
# mails in thirty minutes, and a suite run twice asks for more than that.
|
|
119
|
+
set_system ratelimit.protection.enabled --value=false --type=boolean
|
|
120
|
+
# The mail of the site goes to the project's mail catcher.
|
|
121
|
+
set_system mail_smtpmode --value=smtp
|
|
122
|
+
set_system mail_smtphost --value=127.0.0.1
|
|
123
|
+
set_system mail_smtpport --value=1025 --type=integer
|
|
124
|
+
set_system mail_from_address --value=noreply
|
|
125
|
+
set_system mail_domain --value=example.com
|
|
126
|
+
set_system default_phone_region --value=US
|
|
127
|
+
set_system maintenance_window_start --value=1 --type=integer
|
|
128
|
+
# Background jobs by cron (the project runs cron.php every five minutes).
|
|
129
|
+
occ background:cron > /dev/null
|
|
130
|
+
# No first-run wizard.
|
|
131
|
+
occ app:disable firstrunwizard > /dev/null 2>&1 || true
|
|
132
|
+
echo "Configured for https://$host."
|
|
133
|
+
;;
|
|
134
|
+
accounts)
|
|
135
|
+
while IFS='|' read -r name email password display groups; do
|
|
136
|
+
[ -z "$name" ] && continue
|
|
137
|
+
if exists "$name"; then
|
|
138
|
+
OC_PASS="$password" occ user:resetpassword --password-from-env "$name" > /dev/null || { echo "The password of $name could not be set." >&2; exit 1; }
|
|
139
|
+
occ user:enable "$name" > /dev/null
|
|
140
|
+
else
|
|
141
|
+
OC_PASS="$password" occ user:add --password-from-env --display-name="$display" "$name" > /dev/null || { echo "The account $name could not be made." >&2; exit 1; }
|
|
142
|
+
fi
|
|
143
|
+
# The display name and the email through the server's own API: occ has no command that changes the display name of an
|
|
144
|
+
# existing account, and `occ user:profile <name> email` sets only the profile's copy of the address.
|
|
145
|
+
if ! NAME="$name" DISPLAY_NAME="$display" EMAIL="$email" php -r '
|
|
146
|
+
require "/var/www/html/nextcloud/lib/base.php";
|
|
147
|
+
$user = \OCP\Server::get(\OCP\IUserManager::class)->get(getenv("NAME"));
|
|
148
|
+
if ($user === null) { exit(1); }
|
|
149
|
+
$user->setDisplayName(getenv("DISPLAY_NAME"));
|
|
150
|
+
$user->setSystemEMailAddress(getenv("EMAIL"));'; then
|
|
151
|
+
echo "The display name and email of $name could not be set." >&2
|
|
152
|
+
exit 1
|
|
153
|
+
fi
|
|
154
|
+
if [ -n "$groups" ]; then
|
|
155
|
+
IFS=',' read -ra wanted <<< "$groups"
|
|
156
|
+
for group in "${wanted[@]}"; do
|
|
157
|
+
occ group:add "$group" > /dev/null 2>&1 || true
|
|
158
|
+
occ group:adduser "$group" "$name" > /dev/null 2>&1 || true
|
|
159
|
+
done
|
|
160
|
+
fi
|
|
161
|
+
echo "The account $name ($email) is ready${groups:+, in $groups}."
|
|
162
|
+
done <<< "$(value ACCOUNTS)"
|
|
163
|
+
;;
|
|
164
|
+
cancel)
|
|
165
|
+
while read -r name; do
|
|
166
|
+
[ -z "$name" ] && continue
|
|
167
|
+
if exists "$name"; then
|
|
168
|
+
occ user:delete "$name" > /dev/null && echo "The account $name is deleted."
|
|
169
|
+
else
|
|
170
|
+
echo "There is no account $name."
|
|
171
|
+
fi
|
|
172
|
+
done <<< "$(value USERNAMES)"
|
|
173
|
+
;;
|
|
174
|
+
empty)
|
|
175
|
+
# Every file and folder of the accounts (their shares go with them), then their trash bin and their versions:
|
|
176
|
+
# an account as the build left it, with no files.
|
|
177
|
+
while read -r name; do
|
|
178
|
+
[ -z "$name" ] && continue
|
|
179
|
+
exists "$name" || continue
|
|
180
|
+
NAME="$name" php -r '
|
|
181
|
+
require "/var/www/html/nextcloud/lib/base.php";
|
|
182
|
+
$folder = \OCP\Server::get(\OCP\Files\IRootFolder::class)->getUserFolder(getenv("NAME"));
|
|
183
|
+
foreach ($folder->getDirectoryListing() as $node) { $node->delete(); }' || { echo "The files of $name could not be deleted." >&2; exit 1; }
|
|
184
|
+
occ trashbin:cleanup "$name" > /dev/null 2>&1
|
|
185
|
+
occ versions:cleanup "$name" > /dev/null 2>&1
|
|
186
|
+
echo "The files of $name are deleted."
|
|
187
|
+
done <<< "$(value USERNAMES)"
|
|
188
|
+
;;
|
|
189
|
+
list)
|
|
190
|
+
while read -r name; do
|
|
191
|
+
[ -z "$name" ] && continue
|
|
192
|
+
if exists "$name"; then
|
|
193
|
+
occ user:info "$name" --output=json | php -r '$u = json_decode(stream_get_contents(STDIN), true); printf(" %-14s %-28s %-16s groups: %-12s %s\n", $u["user_id"], $u["email"] ?? "", $u["display_name"] ?? "", implode(",", $u["groups"] ?? []) ?: "none", ($u["enabled"] ?? true) ? "enabled" : "disabled");'
|
|
194
|
+
else
|
|
195
|
+
printf " %-14s (missing)\n" "$name"
|
|
196
|
+
fi
|
|
197
|
+
done <<< "$(value USERNAMES)"
|
|
198
|
+
;;
|
|
199
|
+
version)
|
|
200
|
+
occ status --output=json | php -r '$s = json_decode(stream_get_contents(STDIN), true); echo $s["versionstring"] ?? "", "\n";'
|
|
201
|
+
;;
|
|
202
|
+
occ)
|
|
203
|
+
eval "args=($(value OCC_ARGS))"
|
|
204
|
+
occ "${args[@]}"
|
|
205
|
+
exit $?
|
|
206
|
+
;;
|
|
207
|
+
*)
|
|
208
|
+
echo "Unknown verb: $verb" >&2
|
|
209
|
+
exit 1
|
|
210
|
+
;;
|
|
211
|
+
esac
|
|
212
|
+
done
|