mirror of
https://github.com/willfarrell/docker-crontab.git
synced 2025-04-04 14:05:11 +02:00
push multi commands to own script
This commit is contained in:
parent
0bbd009e23
commit
0fc4c3fd7a
@ -2,7 +2,7 @@ FROM library/docker:1.13
|
||||
|
||||
ENV HOME_DIR=/opt/crontab
|
||||
RUN apk add --no-cache --virtual .run-deps bash jq \
|
||||
&& mkdir -p ${HOME_DIR}/projects
|
||||
&& mkdir -p ${HOME_DIR}/jobs ${HOME_DIR}/projects
|
||||
|
||||
COPY docker-entrypoint /
|
||||
ENTRYPOINT ["/docker-entrypoint"]
|
||||
|
@ -27,8 +27,6 @@ make_container_cmd() {
|
||||
CONTAINER=$(echo ${1} | jq -r .container)
|
||||
TMP_COMMAND=$(echo ${1} | jq -r .command)
|
||||
|
||||
COMMAND_ARR=()
|
||||
|
||||
if [ "${PROJECT}" != "null" ]; then
|
||||
|
||||
# create bash script to detect all running containers
|
||||
@ -133,15 +131,23 @@ function build_crontab() {
|
||||
continue
|
||||
fi
|
||||
|
||||
COMMAND=$(make_cmd "$(jq -c .[$i] ${CONFIG})")
|
||||
SCRIPT_NAME=$(cat /proc/sys/kernel/random/uuid)
|
||||
COMMAND="/bin/bash ${HOME_DIR}/jobs/${SCRIPT_NAME}.sh"
|
||||
cat << EOF > ${HOME_DIR}/jobs/${SCRIPT_NAME}.sh
|
||||
#!/usr/bin/env bash
|
||||
set -e
|
||||
|
||||
$(make_cmd "$(jq -c .[$i] ${CONFIG})")
|
||||
EOF
|
||||
if [ "$(jq -r .[$i].trigger ${CONFIG})" != "null" ]; then
|
||||
while read j ; do
|
||||
if [ "$(jq .[$i].trigger[$j].command ${CONFIG})" == "null" ]; then
|
||||
echo "Command Missing: $(jq -r .[$i].trigger[$j].command ${CONFIG})"
|
||||
continue
|
||||
fi
|
||||
TRIGGER_COMMANDS=$(make_cmd "$(jq -c .[$i].trigger[$j] ${CONFIG})")
|
||||
COMMAND="${COMMAND} && ${TRIGGER_COMMANDS}"
|
||||
#TRIGGER_COMMAND=$(make_cmd "$(jq -c .[$i].trigger[$j] ${CONFIG})")
|
||||
$(make_cmd "$(jq -c .[$i].trigger[$j] ${CONFIG})") >> ${HOME_DIR}/jobs/${SCRIPT_NAME}.sh
|
||||
#COMMAND="${COMMAND} && ${TRIGGER_COMMAND}"
|
||||
done < <(jq -r '.['$i'].trigger|keys[]' ${CONFIG})
|
||||
fi
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user