-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Updated scripts for the new base image
- Loading branch information
1 parent
7df7d93
commit d78d931
Showing
4 changed files
with
55 additions
and
95 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
enabled: true | ||
mode: all | ||
template: | ||
# Any of the required ports are enough to succeed | ||
mode: any | ||
initialDelay: 10 | ||
delay: 10 | ||
timeout: 10 | ||
attempts: 120 | ||
dependencies: | ||
acme: | ||
url: "@env:ACME_URL" | ||
app-artifacts: | ||
url: "@env:DEPL_URL" | ||
content: | ||
url: "@env:ARKCASE_CONTENT_URL" | ||
ldap: | ||
url: "@env:ARKCASE_LDAP_URL" | ||
messaging: | ||
url: "@env:ARKCASE_MQ_AMQP_URL" | ||
rdbms: | ||
host: "@env:ARKCASE_JDBC_HOST" | ||
port: "@env:ARKCASE_JDBC_PORT" | ||
search: | ||
url: "@env:ARKCASE_SOLR_URL" | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,77 +1,35 @@ | ||
#!/bin/bash | ||
|
||
set -euo pipefail | ||
|
||
timestamp() | ||
{ | ||
date -Ins -u | ||
} | ||
|
||
say() | ||
{ | ||
echo -e "$(timestamp): ${@}" | ||
} | ||
|
||
err() | ||
{ | ||
say "❌ ${@}" 1>&2 | ||
} | ||
|
||
fail() | ||
{ | ||
err "${@}" | ||
exit ${EXIT_CODE:-1} | ||
} | ||
|
||
quit() | ||
{ | ||
say "${@}" | ||
exit ${EXIT_CODE:-0} | ||
} | ||
|
||
to_boolean() | ||
{ | ||
case "${1,,}" in | ||
true | t | 1 | yes | on | enabled | enable ) echo "true" ;; | ||
* ) echo "false" ;; | ||
esac | ||
} | ||
. /.functions | ||
|
||
[ -v WRAPPED_STATE ] || fail "Must set the WRAPPED_STATE environment variable to point to the location where to track if the initializer script has already been run" | ||
[ -e "${WRAPPED_STATE}" ] || fail "The wrapped script [${WRAPPED_STATE}] does not exist" | ||
[ -d "${WRAPPED_STATE}" ] || fail "The path [${WRAPPED_STATE}] is not a directory" | ||
[ -r "${WRAPPED_STATE}" ] || fail "The wrapped script [${WRAPPED_STATE}] is not readable" | ||
[ -w "${WRAPPED_STATE}" ] || fail "The wrapped script [${WRAPPED_STATE}] is not writable" | ||
[ -x "${WRAPPED_STATE}" ] || fail "The wrapped script [${WRAPPED_STATE}] is not executable" | ||
|
||
require_dir_readwrite "${WRAPPED_STATE}" | ||
|
||
[ -v WRAPPED_SCRIPT ] || fail "Must set the WRAPPED_SCRIPT environment variable to point to the script to be wrapped" | ||
[ -e "${WRAPPED_SCRIPT}" ] || fail "The wrapped script [${WRAPPED_SCRIPT}] does not exist" | ||
[ -f "${WRAPPED_SCRIPT}" ] || fail "The path [${WRAPPED_SCRIPT}] is not a regular file" | ||
[ -r "${WRAPPED_SCRIPT}" ] || fail "The wrapped script [${WRAPPED_SCRIPT}] is not readable" | ||
[ -x "${WRAPPED_SCRIPT}" ] || fail "The wrapped script [${WRAPPED_SCRIPT}] is not executable" | ||
require_file_executable "${WRAPPED_SCRIPT}" | ||
|
||
# In case the arguments haven't been defined | ||
[ -v WRAPPED_SCRIPT_ARGS ] || WRAPPED_SCRIPT_ARGS="" | ||
|
||
# If we're not given an explicit name to track state with, we deduce it from the script's | ||
# filename and add a dot in front to hide the file | ||
[ -v WRAPPED_STATE_NAME ] || WRAPPED_STATE_NAME=".${WRAPPED_SCRIPT##*/}" | ||
set_or_default WRAPPED_STATE_NAME ".${WRAPPED_SCRIPT##*/}" | ||
|
||
MARKER="${WRAPPED_STATE}/${WRAPPED_STATE_NAME}" | ||
[ -e "${MARKER}" ] && quit "The state has already been initialized" | ||
|
||
[ -v SSL_DIR ] || SSL_DIR="/.ssl" | ||
acme-init | ||
init_ssl | ||
|
||
say "🚀 Calling the wrapped script" | ||
running "Calling the wrapped script" | ||
( | ||
# This should help mitigate exploitation | ||
eval CMD=( "${WRAPPED_SCRIPT@Q}" ${WRAPPED_SCRIPT_ARGS} ) || fail "Failed to define the wrapped command using script [${WRAPPED_SCRIPT}] and args [${WRAPPED_SCRIPT_ARGS}]" | ||
say "🚀 Launching the wrapped script: ${CMD[@]@Q}" | ||
exec "${CMD[@]}" | ||
execute "${CMD[@]}" | ||
) || fail "Failed to execute the wrapped script (rc=${?})" | ||
|
||
TS="$(timestamp)" | ||
say "✅ Wrapped script succeeded, marking the state to [${MARKER}] (timestamp = ${TS})" | ||
ok "Wrapped script succeeded, marking the state to [${MARKER}] (timestamp = ${TS})" | ||
echo "${TS}" > "${MARKER}" || fail "Failed to create the state tracking marker" | ||
exit 0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
export ACME_URL="https://acme:9000" | ||
export DEPL_URL="https://deploy" | ||
export ARKCASE_CONTENT_URL="https://content-server:333" | ||
export ARKCASE_LDAP_URL="https://content-server:222" | ||
export ARKCASE_SOLR_URL="https://content-server:111" | ||
export ARKCASE_JDBC_HOST="some-host-name" | ||
export ARKCASE_JDBC_PORT="gopher" | ||
export ARKCASE_JDBC_PORT="gopher" | ||
export ARKCASE_MQ_AMQP_URL="ssl://messaging:61616" |