Compare commits
merge into: 0k:master
0k:0k/dev/master
0k:backup
0k:bgallet/nextcloud
0k:boris/smtp-extern
0k:charm-codimd-new
0k:cups_service_alpha
0k:dev
0k:dev1
0k:dhcp
0k:element
0k:etherpad-upd
0k:framadate
0k:get-version
0k:lokavaluto/dev/master
0k:master
0k:matomo
0k:new-mailhog-charms
0k:new-monujo-options
0k:nj-collabra-office
0k:nj-keycloak-17.0
0k:nj-organice-charm
0k:nj-vaulwarden-migrate
0k:ntfy-install
0k:odoo_fix_webhook_url
0k:postgres
0k:test
0k:upd-docker
0k:update-latest-synapse
0k:wip
pull from: 0k:test
0k:0k/dev/master
0k:backup
0k:bgallet/nextcloud
0k:boris/smtp-extern
0k:charm-codimd-new
0k:cups_service_alpha
0k:dev
0k:dev1
0k:dhcp
0k:element
0k:etherpad-upd
0k:framadate
0k:get-version
0k:lokavaluto/dev/master
0k:master
0k:matomo
0k:new-mailhog-charms
0k:new-monujo-options
0k:nj-collabra-office
0k:nj-keycloak-17.0
0k:nj-organice-charm
0k:nj-vaulwarden-migrate
0k:ntfy-install
0k:odoo_fix_webhook_url
0k:postgres
0k:test
0k:upd-docker
0k:update-latest-synapse
0k:wip
2 Commits
Author | SHA1 | Message | Date |
---|---|---|---|
Valentin Lab | 9083c17534 |
fixup! chg: [nextcloud] change to admin password are supported
Signed-off-by: Valentin Lab <valentin.lab@kalysto.org> |
5 years ago |
Valentin Lab | 0d592e8690 |
chg: [nextcloud] change to admin password are supported
Signed-off-by: Valentin Lab <valentin.lab@kalysto.org> |
5 years ago |
4 changed files with 115 additions and 48 deletions
-
30nextcloud/actions/occ
-
23nextcloud/hooks/init
-
16nextcloud/hooks/postgres_database-relation-joined
-
94nextcloud/lib/common
@ -1,3 +1,97 @@ |
|||||
# -*- mode: shell-script -*- |
# -*- mode: shell-script -*- |
||||
|
|
||||
|
## This place is not accessible from container on purpose: container |
||||
|
## don't need that. This should be stored in /var/lib/compose/ in a |
||||
|
## project, service directory a little like relation data. |
||||
|
PASSWORD_FILE="$SERVICE_CONFIGSTORE/etc/$SERVICE_NAME/pass" |
||||
|
|
||||
|
|
||||
|
has_user() { |
||||
|
local user="$1" |
||||
|
if ! out=$(occ user:info "$user"); then |
||||
|
if [ "$out" == "user not found" ]; then |
||||
|
return 1 |
||||
|
else |
||||
|
err "Command 'occ user:info $user' failed:" |
||||
|
echo "OUT: '$out'" | prefix " | " >&2 |
||||
|
return 2 |
||||
|
fi |
||||
|
fi |
||||
|
return 0 |
||||
|
} |
||||
|
|
||||
|
|
||||
|
set_admin_user_password() { |
||||
|
local user="$1" password="$2" |
||||
|
|
||||
|
[ -z "$password" ] && { |
||||
|
err "Refusing to set admin user an empty password." |
||||
|
return 3 |
||||
|
} |
||||
|
|
||||
|
if ! has_user "$user"; then |
||||
|
info "User $user not found. Creating it in default 'admin' group." |
||||
|
( |
||||
|
occ_docker_run_opts=("-e" "OC_PASS=$password") |
||||
|
occ user:add --group=admin --password-from-env --display-name="$user" "$user" |
||||
|
) |
||||
|
else |
||||
|
( |
||||
|
occ_docker_run_opts=("-e" "OC_PASS=$password") |
||||
|
occ user:resetpassword "$user" "--password-from-env" |
||||
|
) |
||||
|
fi |
||||
|
mkdir -p "$(dirname "$PASSWORD_FILE")" |
||||
|
p0 "$user" "$password" > "$PASSWORD_FILE" |
||||
|
} |
||||
|
|
||||
|
|
||||
|
get_admin_user_password() { |
||||
|
if [ -e "$PASSWORD_FILE" ]; then |
||||
|
cat "$PASSWORD_FILE" |
||||
|
else |
||||
|
return 1 |
||||
|
fi |
||||
|
} |
||||
|
|
||||
|
|
||||
|
create_occ_if_not_exists() { |
||||
|
|
||||
|
if ! [ -e "$SERVICE_DATASTORE/var/www/html/occ" ]; then |
||||
|
## Here we use a nasty trick to launch only the initialisation |
||||
|
## part of the ``entrypoint.sh``. By setting 'apache' as first |
||||
|
## call argument, we satisfy the big first 'if' condition |
||||
|
## triggering the installation if necessary, and will fail to |
||||
|
## launch any apache |
||||
|
|
||||
|
## Last, we do not want the relation web-proxy to run in this |
||||
|
## bare-minimum nextcloud run AND we will use occ to set some info |
||||
|
## in this very same relation. |
||||
|
export COMPOSE_IGNORE_ORPHANS=true |
||||
|
compose --debug --no-init --without-relation="$SERVICE_NAME":web-proxy run \ |
||||
|
--rm --entrypoint /entrypoint.sh "$SERVICE_NAME" apache >&2 || true |
||||
|
if ! [ -e "$SERVICE_DATASTORE/var/www/html/occ" ]; then |
||||
|
err "Expected last command to create /var/www/html/occ" |
||||
|
return 1 |
||||
|
fi |
||||
|
fi |
||||
|
} |
||||
|
|
||||
|
|
||||
|
occ() { |
||||
|
|
||||
|
create_occ_if_not_exists |
||||
|
|
||||
|
## occ.batch will require /var/www/html to be populated ('occ' is |
||||
|
## supposed to exist). For that we need to make sure nextcloud have |
||||
|
## be ran and setup prior to running this next command. |
||||
|
export COMPOSE_IGNORE_ORPHANS=true |
||||
|
compose --debug -q --no-init --no-relations run \ |
||||
|
"${occ_docker_run_opts[@]}" \ |
||||
|
-v "$HOST_CHARM_STORE/${CHARM_REL_PATH#${CHARM_STORE}/}/src/occ.batch:/var/www/html/occ.batch" \ |
||||
|
-T --rm -u www-data "$SERVICE_NAME" /var/www/html/occ.batch "$@" | cat |
||||
|
|
||||
|
return "${PIPESTATUS[0]}" |
||||
|
} |
||||
|
|
||||
|
|
Write
Preview
Loading…
Cancel
Save
Reference in new issue