2022-11-23 19:30:45 -05:00
|
|
|
#!/usr/bin/env bash
|
|
|
|
|
source "$PLUGIN_CORE_AVAILABLE_PATH/common/functions"
|
|
|
|
|
source "$PLUGIN_AVAILABLE_PATH/nginx-vhosts/internal-functions"
|
|
|
|
|
set -eo pipefail
|
|
|
|
|
[[ $DOKKU_TRACE ]] && set -x
|
|
|
|
|
|
2022-11-25 17:38:15 -05:00
|
|
|
fn-nginx-vhosts-copy-from-image() {
|
|
|
|
|
declare APP="$1" IMAGE_NAME="$2" CONF_SIGIL_PATH="$3"
|
|
|
|
|
|
2022-11-25 19:58:52 -05:00
|
|
|
mkdir -p "${DOKKU_LIB_ROOT}/data/nginx-vhosts/app-$APP"
|
2023-08-27 19:20:45 -04:00
|
|
|
find "${DOKKU_LIB_ROOT}/data/nginx-vhosts/app-$APP/" -maxdepth 1 -type f -name 'nginx.conf.sigil.*' -delete
|
2022-11-25 17:38:15 -05:00
|
|
|
copy_from_image "$IMAGE_NAME" "$CONF_SIGIL_PATH" "${DOKKU_LIB_ROOT}/data/nginx-vhosts/app-$APP/nginx.conf.sigil.$DOKKU_PID" 2>/dev/null || true
|
|
|
|
|
if [[ ! -f "${DOKKU_LIB_ROOT}/data/nginx-vhosts/app-$APP/nginx.conf.sigil.$DOKKU_PID" ]]; then
|
|
|
|
|
touch "${DOKKU_LIB_ROOT}/data/nginx-vhosts/app-$APP/nginx.conf.sigil.$DOKKU_PID.missing"
|
|
|
|
|
fi
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
fn-nginx-vhosts-copy-from-directory() {
|
|
|
|
|
declare APP="$1" SOURCECODE_WORK_DIR="$2" CONF_SIGIL_PATH="$3"
|
2022-11-23 19:30:45 -05:00
|
|
|
|
2022-11-25 17:38:15 -05:00
|
|
|
pushd "$SOURCECODE_WORK_DIR" >/dev/null
|
2022-11-24 00:51:58 -05:00
|
|
|
mkdir -p "${DOKKU_LIB_ROOT}/data/nginx-vhosts/app-$APP"
|
2022-11-23 19:30:45 -05:00
|
|
|
|
|
|
|
|
if [[ -z "$CONF_SIGIL_PATH" ]]; then
|
2022-11-24 00:51:58 -05:00
|
|
|
touch "${DOKKU_LIB_ROOT}/data/nginx-vhosts/app-$APP/nginx.conf.sigil.$DOKKU_PID.missing"
|
2022-11-23 19:30:45 -05:00
|
|
|
return
|
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
if [[ ! -f "$CONF_SIGIL_PATH" ]]; then
|
2022-11-24 00:51:58 -05:00
|
|
|
touch "${DOKKU_LIB_ROOT}/data/nginx-vhosts/app-$APP/nginx.conf.sigil.$DOKKU_PID.missing"
|
2022-11-23 19:30:45 -05:00
|
|
|
return
|
|
|
|
|
fi
|
|
|
|
|
|
2023-08-27 19:20:45 -04:00
|
|
|
find "${DOKKU_LIB_ROOT}/data/nginx-vhosts/app-$APP/" -maxdepth 1 -type f -name 'nginx.conf.sigil.*' -delete
|
2022-11-23 20:16:28 -05:00
|
|
|
cp -f "$CONF_SIGIL_PATH" "${DOKKU_LIB_ROOT}/data/nginx-vhosts/app-$APP/nginx.conf.sigil.$DOKKU_PID"
|
2022-11-23 19:30:45 -05:00
|
|
|
popd &>/dev/null || pushd "/tmp" >/dev/null
|
|
|
|
|
}
|
|
|
|
|
|
2022-11-25 17:38:15 -05:00
|
|
|
trigger-nginx-vhosts-core-post-extract() {
|
|
|
|
|
declare desc="nginx-vhosts post-extract plugin trigger"
|
|
|
|
|
declare trigger="post-extract"
|
|
|
|
|
declare APP="$1" SOURCECODE_WORK_DIR="$2"
|
|
|
|
|
local CONF_SIGIL_PATH="$(fn-nginx-computed-nginx-conf-sigil-path "$APP")"
|
2022-12-18 17:57:24 -05:00
|
|
|
local app_source_image
|
2022-11-25 17:38:15 -05:00
|
|
|
|
2022-12-18 17:57:24 -05:00
|
|
|
app_source_image="$(plugn trigger git-get-property "$APP" "source-image")"
|
|
|
|
|
if [[ -n "$app_source_image" ]]; then
|
|
|
|
|
fn-nginx-vhosts-copy-from-image "$APP" "$app_source_image" "$CONF_SIGIL_PATH"
|
2022-11-25 17:38:15 -05:00
|
|
|
else
|
|
|
|
|
fn-nginx-vhosts-copy-from-directory "$APP" "$SOURCECODE_WORK_DIR" "$CONF_SIGIL_PATH"
|
|
|
|
|
fi
|
|
|
|
|
}
|
|
|
|
|
|
2022-11-23 19:30:45 -05:00
|
|
|
trigger-nginx-vhosts-core-post-extract "$@"
|