chore: reorganization.

This commit is contained in:
Robert Wlodarczyk 2022-07-16 08:33:41 -07:00
parent 99aa59ddb4
commit dc18a5199d

View File

@ -1,12 +1,19 @@
#!/usr/bin/env bash #!/usr/bin/env bash
set -e set -e
DOCKER_SOCK=/var/run/docker.sock
CRONTAB_FILE=/etc/crontabs/docker
# For local testing only.
#HOME_DIR=.
# Ensure dir exist - in case of volume mapping.
mkdir -p "${HOME_DIR}"/jobs "${HOME_DIR}"/projects
if [ -z "$DOCKER_HOST" ] && [ -a "$DOCKER_PORT_2375_TCP" ]; then if [ -z "$DOCKER_HOST" ] && [ -a "$DOCKER_PORT_2375_TCP" ]; then
export DOCKER_HOST='tcp://docker:2375' export DOCKER_HOST='tcp://docker:2375'
fi fi
# For local testing only.
#HOME_DIR=.
if [ "${LOG_FILE}" == "" ]; then if [ "${LOG_FILE}" == "" ]; then
LOG_DIR=/var/log/crontab LOG_DIR=/var/log/crontab
@ -29,12 +36,6 @@ get_config() {
jq 'map(.)' "${JSON_CONFIG}" > "${HOME_DIR}"/config.working.json jq 'map(.)' "${JSON_CONFIG}" > "${HOME_DIR}"/config.working.json
} }
DOCKER_SOCK=/var/run/docker.sock
CRONTAB_FILE=/etc/crontabs/docker
# Ensure dir exist - in case of volume mapping.
mkdir -p "${HOME_DIR}"/jobs "${HOME_DIR}"/projects
ensure_docker_socket_accessible() { ensure_docker_socket_accessible() {
if ! grep -q "^docker:" /etc/group; then if ! grep -q "^docker:" /etc/group; then
# Ensure 'docker' user has permissions for docker socket (without changing permissions). # Ensure 'docker' user has permissions for docker socket (without changing permissions).
@ -243,8 +244,6 @@ EOF
done done
} }
ensure_docker_socket_accessible
start_app() { start_app() {
get_config get_config
export CONFIG=${HOME_DIR}/config.working.json export CONFIG=${HOME_DIR}/config.working.json
@ -259,4 +258,5 @@ start_app() {
exec "$@" exec "$@"
} }
ensure_docker_socket_accessible
start_app "$@" start_app "$@"