diff --git a/gogocarto/hooks/post_deploy b/gogocarto/hooks/post_deploy index 06877dc..ee74214 100755 --- a/gogocarto/hooks/post_deploy +++ b/gogocarto/hooks/post_deploy @@ -28,34 +28,17 @@ fi ## Get domain in option of relation "publish-dir" ## -## XXXvlab: there is a tiny lapse of time where database is not yet -## installed, and admin password is the default value. -## XXXvlab: can't get real config here -if ! read-0 publish_dir_ts _ _ < <(get_service_relation "$SERVICE_NAME" "publish-dir"); then - err "Couldn't find relation ${DARKCYAN}publish-dir${NORMAL}." - exit 1 -fi - -publish_dir_relation_dir=$(get_relation_data_dir "$SERVICE_NAME" "$publish_dir_ts" "publish-dir") || { - err "Failed to find relation file" - exit 1 -} - -publish_dir_relation_config=$(cat "$publish_dir_relation_dir/data") || exit 2 -domain=$(e "$publish_dir_relation_config" | shyaml get-value domain) || { - err "Couldn't get domain information in ${DARKCYAN}publish-dir${NORMAL} relation's data." +if ! url=$(relation:get "$SERVICE_NAME":publish-dir url) || [ -z "$url" ]; then + err "Couldn't get ${WHITE}url${NORMAL} information in ${DARKCYAN}publish-dir${NORMAL} relation's data." exit 1 -} +fi -url=$(e "$publish_dir_relation_config" | shyaml get-value url) || { - err "Couldn't get domain information in ${DARKCYAN}publish-dir${NORMAL} relation's data." - exit 1 -} protocol="${url%%://*}" - +domain="${url#$protocol://}" +domain="${domain%%/*}" ## ## We are in post_deploy, so our service is up, we need to get