forked from crisward/dokku-require
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpre-receive-app
executable file
·39 lines (32 loc) · 1.14 KB
/
pre-receive-app
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
#!/usr/bin/env bash
set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x
DOKKU_REQUIRE_PREFIX="${DOKKU_REQUIRE_PREFIX:-dokku}"
source "$PLUGIN_CORE_AVAILABLE_PATH/common/functions"
source "$PLUGIN_AVAILABLE_PATH/require/functions"
require_pre_receive_app() {
declare desc="reads app.json and builds plugins"
local APP="$1" IMAGE_SOURCE_TYPE="$2" TMP_WORK_DIR="$3" REV="$4"
local APP_JSON_FILE="$TMP_WORK_DIR/app.json"
local TOTAL PLUGIN
if [[ ! -f "$APP_JSON_FILE" ]]; then
return
fi
# get each plugin from json, limit to 10 to prevent silly loop
COUNTER=0
if TOTAL=$(require_get_json_len "[\"$DOKKU_REQUIRE_PREFIX\"][\"plugins\"]" < "$APP_JSON_FILE" 2>&1); then
while [[ "$COUNTER" -lt "$TOTAL" ]]; do
PLUGIN=$(require_get_app_plugins "[\"$DOKKU_REQUIRE_PREFIX\"][\"plugins\"][${COUNTER}]" < "$APP_JSON_FILE" 2>&1)
if [[ $? -ne 0 ]]; then
break
fi
if [[ "$PLUGIN" == *"{"* ]]; then
require_install_commands "$APP" "$COUNTER"
else
require_install_link "$APP" "$PLUGIN"
fi
let COUNTER=$((COUNTER + 1))
done
fi
require_add_volumes "$APP"
}
require_pre_receive_app "$@"