#!/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" } admin_password=$(options-get admin.password 2>&1) || { err "Please specify an ${WHITE}admin.password${NORMAL} option" \ "in ${DARKYELLOW}$SERVICE_NAME${NORMAL} service." exit 1 } ## 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[@]}"