2022-01-27 02:25:52 +00:00
|
|
|
#!/bin/bash
|
2023-08-17 00:41:22 +00:00
|
|
|
set -euo pipefail
|
|
|
|
IFS=$'\n\t'
|
2022-01-27 02:25:52 +00:00
|
|
|
|
2023-08-23 02:34:47 +00:00
|
|
|
: "${EXISTING_OPS_FILE:=SKIP}"
|
|
|
|
: "${EXISTING_WHITELIST_FILE:=SKIP}"
|
|
|
|
|
2023-10-14 22:25:35 +00:00
|
|
|
# shellcheck source=start-utils
|
|
|
|
. "${SCRIPTS:-/}start-utils"
|
|
|
|
isDebugging && set -x
|
|
|
|
|
2023-08-23 02:34:47 +00:00
|
|
|
if [[ -v APPEND_OPS ]] && isTrue "${APPEND_OPS}"; then
|
|
|
|
EXISTING_OPS_FILE=MERGE
|
|
|
|
elif [[ -v OVERRIDE_OPS ]] && isTrue "${OVERRIDE_OPS}"; then
|
|
|
|
EXISTING_OPS_FILE=SYNCHRONIZE
|
|
|
|
fi
|
|
|
|
|
|
|
|
if [[ -v APPEND_WHITELIST ]] && isTrue "${APPEND_WHITELIST}"; then
|
|
|
|
EXISTING_WHITELIST_FILE=MERGE
|
|
|
|
elif [[ -v OVERRIDE_WHITELIST ]] && isTrue "${OVERRIDE_WHITELIST}"; then
|
|
|
|
EXISTING_WHITELIST_FILE=SYNCHRONIZE
|
|
|
|
fi
|
|
|
|
|
2023-08-17 00:41:22 +00:00
|
|
|
sharedArgs=(--version="$VERSION")
|
2022-01-27 02:25:52 +00:00
|
|
|
|
2023-08-17 00:41:22 +00:00
|
|
|
if [[ -v OPS_FILE ]]; then
|
2023-08-23 02:34:47 +00:00
|
|
|
existing="$EXISTING_OPS_FILE"
|
|
|
|
if [[ "$EXISTING_OPS_FILE" = SYNC_FILE_MERGE_LIST ]]; then
|
|
|
|
existing=SYNCHRONIZE
|
|
|
|
fi
|
2023-08-17 00:41:22 +00:00
|
|
|
mc-image-helper manage-users \
|
|
|
|
"${sharedArgs[@]}" \
|
|
|
|
--type=JAVA_OPS \
|
|
|
|
--input-is-file \
|
2023-08-23 02:34:47 +00:00
|
|
|
--existing="${existing}" \
|
2023-08-17 00:41:22 +00:00
|
|
|
"$OPS_FILE"
|
2022-01-27 02:25:52 +00:00
|
|
|
fi
|
2023-08-17 00:41:22 +00:00
|
|
|
if [[ -v OPS ]]; then
|
|
|
|
args=()
|
|
|
|
if isTrue "${APPEND_OPS:-false}" || isFalse "${OVERRIDE_OPS:-true}"; then
|
|
|
|
args+=(--append-only)
|
|
|
|
fi
|
2023-08-23 02:34:47 +00:00
|
|
|
existing="$EXISTING_OPS_FILE"
|
|
|
|
if [[ "$EXISTING_OPS_FILE" = SYNC_FILE_MERGE_LIST ]]; then
|
|
|
|
existing=MERGE
|
|
|
|
fi
|
2023-08-17 00:41:22 +00:00
|
|
|
# shellcheck disable=SC2086
|
|
|
|
mc-image-helper manage-users \
|
|
|
|
"${sharedArgs[@]}" "${args[@]}" \
|
|
|
|
--type=JAVA_OPS \
|
2023-08-23 02:34:47 +00:00
|
|
|
--existing="${existing}" \
|
2023-08-17 00:41:22 +00:00
|
|
|
$OPS
|
2022-01-27 02:25:52 +00:00
|
|
|
fi
|
|
|
|
|
2023-08-17 00:41:22 +00:00
|
|
|
if [[ -v WHITELIST_FILE ]]; then
|
2023-08-23 02:34:47 +00:00
|
|
|
existing="$EXISTING_WHITELIST_FILE"
|
|
|
|
if [[ "$EXISTING_WHITELIST_FILE" = SYNC_FILE_MERGE_LIST ]]; then
|
|
|
|
existing=SYNCHRONIZE
|
|
|
|
fi
|
2023-08-17 00:41:22 +00:00
|
|
|
mc-image-helper manage-users \
|
|
|
|
"${sharedArgs[@]}" \
|
|
|
|
--type=JAVA_WHITELIST \
|
|
|
|
--input-is-file \
|
2023-08-23 02:34:47 +00:00
|
|
|
--existing="${existing}" \
|
|
|
|
"$WHITELIST_FILE"
|
2022-01-27 02:25:52 +00:00
|
|
|
fi
|
2023-08-17 00:41:22 +00:00
|
|
|
if [[ -v WHITELIST ]]; then
|
|
|
|
args=()
|
|
|
|
if isTrue "${APPEND_WHITELIST:-false}" || isFalse "${OVERRIDE_WHITELIST:-true}"; then
|
|
|
|
args+=(--append-only)
|
|
|
|
fi
|
2023-08-23 02:34:47 +00:00
|
|
|
existing="$EXISTING_WHITELIST_FILE"
|
|
|
|
if [[ "$EXISTING_WHITELIST_FILE" = SYNC_FILE_MERGE_LIST ]]; then
|
|
|
|
existing=MERGE
|
|
|
|
fi
|
2023-08-17 00:41:22 +00:00
|
|
|
# shellcheck disable=SC2086
|
|
|
|
mc-image-helper manage-users \
|
|
|
|
"${sharedArgs[@]}" "${args[@]}" \
|
|
|
|
--type=JAVA_WHITELIST \
|
2023-08-23 02:34:47 +00:00
|
|
|
--existing="${existing}" \
|
2023-08-17 00:41:22 +00:00
|
|
|
$WHITELIST
|
2022-01-27 02:25:52 +00:00
|
|
|
fi
|
|
|
|
|
|
|
|
exec "${SCRIPTS:-/}start-finalExec" "$@"
|