forked from 0k/0k-charms
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.
73 lines
2.0 KiB
73 lines
2.0 KiB
# -*- mode: shell-script -*-
|
|
|
|
|
|
CYCLOS_CONFIG="/usr/local/cyclos/WEB-INF/classes/cyclos.properties"
|
|
HOST_CYCLOS_CONFIG="$SERVICE_CONFIGSTORE$CYCLOS_CONFIG"
|
|
|
|
cyclos:build() {
|
|
docker pull "$DOCKER_BASE_IMAGE" || return 1
|
|
mkdir -p "$(dirname "$HOST_CYCLOS_CONFIG")"
|
|
container_id=$(docker run -d --entrypoint true "$DOCKER_BASE_IMAGE") || return 1
|
|
mkdir -p "$(dirname "$HOST_CYCLOS_CODE")" &&
|
|
docker cp "$container_id":"$CYCLOS_CONFIG" "$HOST_CYCLOS_CONFIG" &&
|
|
docker rm "$container_id"
|
|
}
|
|
|
|
|
|
named-relation-get-target-service() {
|
|
local relation="$1" ts
|
|
if ! read-0 ts _ _ < <(get_service_relation "$SERVICE_NAME" "$relation"); then
|
|
err "Couldn't find relation ${DARKCYAN}$relation${NORMAL}."
|
|
return 1
|
|
fi
|
|
e "$ts"
|
|
}
|
|
|
|
|
|
## XXXvlab: Consider for inclusion in compose-core
|
|
relation-get-config() {
|
|
local relation="$1" ts relation_dir
|
|
|
|
ts=$(named-relation-get-target-service "$relation") || return 1
|
|
relation_dir=$(get_relation_data_dir "$SERVICE_NAME" "$ts" "$relation") || return 1
|
|
cat "${relation_dir}/data"
|
|
}
|
|
|
|
|
|
named-relation-get() {
|
|
local relation="$1" key="$2" config
|
|
|
|
config=$(relation-get-config "$relation") || return 1
|
|
|
|
e "$config" | shyaml get-value "$key" || {
|
|
err "Couldn't get ${WHITE}$key${NORMAL} value" \
|
|
"in ${DARKCYAN}$relation${NORMAL} relation's data."
|
|
exit 1
|
|
}
|
|
}
|
|
|
|
|
|
sql() {
|
|
(
|
|
DBNAME="$(named-relation-get "postgres-database" dbname)" || exit 1
|
|
ts=$(named-relation-get-target-service "postgres-database") || exit 1
|
|
|
|
export SERVICE_NAME="$ts"
|
|
export SERVICE_DATASTORE="$DATASTORE/$SERVICE_NAME"
|
|
DOCKER_BASE_IMAGE=$(service_base_docker_image "$SERVICE_NAME")
|
|
export DOCKER_BASE_IMAGE
|
|
|
|
target_charm=$(get_service_charm "$ts") || exit 1
|
|
target_charm_path=$(charm.get_dir "$target_charm") || exit 1
|
|
|
|
set +e
|
|
|
|
. "$target_charm_path/lib/common"
|
|
|
|
set -e
|
|
|
|
ensure_db_docker_running
|
|
|
|
ddb "$DBNAME"
|
|
)
|
|
}
|