fix: simplifying logic.

This commit is contained in:
Robert Wlodarczyk 2022-07-16 08:28:20 -07:00
parent 882fb137f2
commit f18275eb0d

View File

@ -16,15 +16,17 @@ if [ "${LOG_FILE}" == "" ]; then
fi fi
get_config() { get_config() {
JSON_CONFIG={}
if [ -f "${HOME_DIR}/config.json" ]; then if [ -f "${HOME_DIR}/config.json" ]; then
jq 'map(.)' "${HOME_DIR}"/config.json > "${HOME_DIR}"/config.working.json JSON_CONFIG="$(cat "${HOME_DIR}"/config.json)"
elif [ -f "${HOME_DIR}/config.toml" ]; then elif [ -f "${HOME_DIR}/config.toml" ]; then
rq -t <<< "$(cat "${HOME_DIR}"/config.toml)" | jq 'map(.)' > "${HOME_DIR}"/config.json JSON_CONFIG="$(rq -t <<< "$(cat "${HOME_DIR}"/config.toml)")"
elif [ -f "${HOME_DIR}/config.yml" ]; then elif [ -f "${HOME_DIR}/config.yml" ]; then
rq -y <<< "$(cat "${HOME_DIR}"/config.yml)" | jq 'map(.)' > "${HOME_DIR}"/config.json JSON_CONFIG="$(rq -y <<< "$(cat "${HOME_DIR}"/config.yml)")"
elif [ -f "${HOME_DIR}/config.yaml" ]; then elif [ -f "${HOME_DIR}/config.yaml" ]; then
rq -y <<< "$(cat "${HOME_DIR}"/config.yaml)" | jq 'map(.)' > "${HOME_DIR}"/config.json JSON_CONFIG="$(rq -y <<< "$(cat "${HOME_DIR}"/config.yaml)")"
fi fi
jq 'map(.)' "${JSON_CONFIG}" > "${HOME_DIR}"/config.working.json
} }
DOCKER_SOCK=/var/run/docker.sock DOCKER_SOCK=/var/run/docker.sock
@ -263,19 +265,13 @@ ensure_docker_socket_accessible
start_app() { start_app() {
get_config get_config
if [ -f "${HOME_DIR}/config.working.json" ]; then export CONFIG=${HOME_DIR}/config.working.json
export CONFIG=${HOME_DIR}/config.working.json if [ ! -f "${CONFIG}" ]; then
elif [ -f "${HOME_DIR}/config.json" ]; then echo "Unable to find ${CONFIG}."
export CONFIG=${HOME_DIR}/config.json exit 1
else
echo "NO CONFIG FILE FOUND"
fi fi
if [ "$1" = "crond" ]; then if [ "$1" == "crond" ]; then
if [ -f "${CONFIG}" ]; then build_crontab
build_crontab
else
echo "Unable to find ${CONFIG}"
fi
fi fi
echo "$@" echo "$@"
exec "$@" exec "$@"