-
-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathpost-extract
executable file
·50 lines (40 loc) · 1.35 KB
/
post-extract
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
#!/usr/bin/env bash
source "$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)/config"
set -eo pipefail
[[ $DOKKU_TRACE ]] && set -x
source "$PLUGIN_CORE_AVAILABLE_PATH/common/functions"
solr-post-extract() {
declare APP="$1" TMPDIR="$2"
local LINKED_SERVICES SERVICE SERVICE_CONTAINER_ID SERVICE_ROOT TMPDIR
LINKED_SERVICES="$(solr-linked-services "$APP")"
if [[ -z $LINKED_SERVICES ]]; then
return
fi
if [[ -d "${TMPDIR}/solr" ]]; then
for SERVICE in $LINKED_SERVICES; do
SERVICE_CONTAINER_ID="$(cat "$SERVICE_ROOT/ID")"
SERVICE_ROOT="${PLUGIN_DATA_ROOT}/${SERVICE}"
for f in ${TMPDIR}/solr/*; do
dokku_log_info1_quiet "Copying $f to $SERVICE solr service"
"$DOCKER_BIN" container cp "$f" "${SERVICE_CONTAINER_ID}:$SERVICE_ROOT/data/${SERVICE}/conf/"
done
pushd "${SERVICE_ROOT}/data/${SERVICE}/conf/" >/dev/null
sudo /bin/chown 8983 *
sudo /bin/chgrp 8983 *
popd &>/dev/null || pushd "/tmp" >/dev/null
done
fi
}
solr-linked-services() {
declare APP="$1"
local LINKS_FILE SERVICES SERVICE_ROOT
SERVICES=$(ls "$PLUGIN_DATA_ROOT" 2>/dev/null)
for SERVICE in $SERVICES; do
SERVICE_ROOT="${PLUGIN_DATA_ROOT}/${SERVICE}"
LINKS_FILE="${SERVICE_ROOT}/LINKS"
if grep -Fxq "$APP" "$LINKS_FILE" >/dev/null; then
echo -n "${SERVICE} "
fi
done
}
solr-post-extract "$@"