You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
61 lines
1.8 KiB
61 lines
1.8 KiB
#!/bin/bash
|
|
|
|
## Init is run on host
|
|
## For now it is run every time the script is launched, but
|
|
## it should be launched only once after build.
|
|
|
|
## Accessible variables are:
|
|
## - SERVICE_NAME Name of current service
|
|
## - DOCKER_BASE_IMAGE Base image from which this service might be built if any
|
|
## - SERVICE_DATASTORE Location on host of the DATASTORE of this service
|
|
## - SERVICE_CONFIGSTORE Location on host of the CONFIGSTORE of this service
|
|
|
|
|
|
. lib/common
|
|
|
|
set -e
|
|
|
|
admin_user=$(options-get admin.user 2>&1) || {
|
|
admin_user="admin"
|
|
}
|
|
|
|
read-0 current_user current_password < <(get_admin_user_password) || {
|
|
info "Probably no admin user and password set before."
|
|
}
|
|
|
|
admin_password=$(options-get admin.password 2>&1) ||
|
|
admin_password=$(options-get admin-password 2>&1) || {
|
|
if [ "$current_password" ]; then
|
|
admin_password="$current_password"
|
|
else
|
|
info "Generating ${DARKYELLOW}$MASTER_BASE_SERVICE_NAME${NORMAL}'s"\
|
|
"admin password"
|
|
admin_password=$(gen_password)
|
|
fi
|
|
}
|
|
if [ "$current_password" != "$admin_password" ] ||
|
|
[ "$current_user" != "$admin_user" ]; then
|
|
set_admin_user_password "$admin_user" "$admin_password" || {
|
|
err "Failed to set admin user and password."
|
|
exit 2
|
|
}
|
|
fi
|
|
|
|
## XXXvlab: the directory here for datadir violates DRY as it is also
|
|
## in ``metadata.yml``
|
|
init-config-add "\
|
|
$MASTER_BASE_SERVICE_NAME:
|
|
environment:
|
|
NEXTCLOUD_ADMIN_USER: $admin_user
|
|
NEXTCLOUD_ADMIN_PASSWORD: $admin_password
|
|
NEXTCLOUD_DATA_DIR: /var/lib/nextcloud/data
|
|
"
|
|
|
|
## ensuring data directories are accessible by nextcloud
|
|
|
|
uid=$(docker_get_uid "$MASTER_BASE_SERVICE_NAME" "www-data")
|
|
|
|
|
|
dirs=("$SERVICE_DATASTORE/var/lib/nextcloud/data" "$SERVICE_DATASTORE/var/www/html")
|
|
mkdir -p "${dirs[@]}"
|
|
chown -R "$uid" "${dirs[@]}"
|