зеркало из https://github.com/mozilla/MozDef.git
Make the docker environment variables available to cron jobs (#1158)
cron jobs don't have access to the docker environment variables. This, on instance launch, writes the environment to a file and configured the mozdef crontab to use this on disk environment
This commit is contained in:
Родитель
bccbf6b696
Коммит
17d99993a5
|
@ -84,7 +84,7 @@ services:
|
|||
env_file:
|
||||
- cloudy_mozdef.env
|
||||
restart: always
|
||||
command: bash -c 'crond -n'
|
||||
command: bash -c 'cd / && bash launch_cron'
|
||||
volumes:
|
||||
- cron:/opt/mozdef/envs/mozdef/cron
|
||||
- geolite_db:/opt/mozdef/envs/mozdef/data/
|
||||
|
|
|
@ -20,7 +20,12 @@ COPY docker/compose/mozdef_cron/files/syncAlertsToMongo.conf /opt/mozdef/envs/mo
|
|||
|
||||
RUN chown -R mozdef:mozdef /opt/mozdef/envs/mozdef/cron
|
||||
|
||||
# https://stackoverflow.com/a/48651061/168874
|
||||
COPY docker/compose/mozdef_cron/files/launch_cron /launch_cron
|
||||
|
||||
USER mozdef
|
||||
RUN crontab /cron_entries.txt
|
||||
|
||||
USER root
|
||||
WORKDIR /
|
||||
CMD ['./launch_cron']
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
BASH_ENV=/env
|
||||
* * * * * /opt/mozdef/envs/mozdef/cron/healthAndStatus.sh
|
||||
* * * * * /opt/mozdef/envs/mozdef/cron/healthToMongo.sh
|
||||
* * * * * /opt/mozdef/envs/mozdef/cron/collectAttackers.sh
|
||||
|
|
|
@ -0,0 +1,5 @@
|
|||
#!/bin/bash
|
||||
|
||||
# Export all root users environment variables, filtering out non custom variables and write them into /env
|
||||
declare -p | egrep -v ' HOSTNAME=| LS_COLORS=| TERM=| PATH=| PWD=| TZ=| SHLVL=| HOME=| LESSOPEN=| _=| affinity:container=| BASHOPTS=| BASH_VERSINFO=| EUID=| PPID=| SHELLOPTS=| UID=' > /env
|
||||
crond -n -x ext,sch,proc
|
Загрузка…
Ссылка в новой задаче