2020-03-06 17:09:11 +01:00
|
|
|
#!/bin/bash
|
2019-11-25 22:58:18 +01:00
|
|
|
|
2023-05-15 13:13:25 +02:00
|
|
|
[ -z "$CRON_USER_ID" ] && CRON_USER_ID=1
|
|
|
|
|
2022-11-30 17:42:16 +01:00
|
|
|
term_procs() {
|
|
|
|
echo "Entrypoint CRON caught SIGTERM signal!"
|
|
|
|
echo "Killing process $p1_pid"
|
2022-11-30 10:51:57 +01:00
|
|
|
kill -TERM "$p1_pid" 2>/dev/null
|
2022-11-30 17:42:16 +01:00
|
|
|
echo "Killing process $p2_pid"
|
2022-11-30 10:51:57 +01:00
|
|
|
kill -TERM "$p2_pid" 2>/dev/null
|
|
|
|
}
|
|
|
|
|
2022-11-30 17:42:16 +01:00
|
|
|
trap term_procs SIGTERM
|
2022-11-30 10:51:57 +01:00
|
|
|
|
2019-11-27 15:09:20 +01:00
|
|
|
# Create the misp cron tab
|
2019-11-26 22:18:52 +01:00
|
|
|
cat << EOF > /etc/cron.d/misp
|
2022-11-30 10:51:57 +01:00
|
|
|
20 2 * * * www-data /var/www/MISP/app/Console/cake Server cacheFeed "$CRON_USER_ID" all > /tmp/cronlog 2>&1
|
|
|
|
30 2 * * * www-data /var/www/MISP/app/Console/cake Server fetchFeed "$CRON_USER_ID" all > /tmp/cronlog 2>&1
|
2019-11-25 22:58:18 +01:00
|
|
|
|
2022-11-30 10:51:57 +01:00
|
|
|
0 0 * * * www-data /var/www/MISP/app/Console/cake Server pullAll "$CRON_USER_ID" > /tmp/cronlog 2>&1
|
|
|
|
0 1 * * * www-data /var/www/MISP/app/Console/cake Server pushAll "$CRON_USER_ID" > /tmp/cronlog 2>&1
|
2022-11-04 18:22:12 +01:00
|
|
|
|
2022-11-30 10:51:57 +01:00
|
|
|
00 3 * * * www-data /var/www/MISP/app/Console/cake Admin updateGalaxies > /tmp/cronlog 2>&1
|
|
|
|
10 3 * * * www-data /var/www/MISP/app/Console/cake Admin updateTaxonomies > /tmp/cronlog 2>&1
|
|
|
|
20 3 * * * www-data /var/www/MISP/app/Console/cake Admin updateWarningLists > /tmp/cronlog 2>&1
|
|
|
|
30 3 * * * www-data /var/www/MISP/app/Console/cake Admin updateNoticeLists > /tmp/cronlog 2>&1
|
|
|
|
45 3 * * * www-data /var/www/MISP/app/Console/cake Admin updateObjectTemplates "$CRON_USER_ID" > /tmp/cronlog 2>&1
|
2019-11-25 22:58:18 +01:00
|
|
|
|
2019-11-26 22:18:52 +01:00
|
|
|
EOF
|
2019-11-25 22:58:18 +01:00
|
|
|
|
2019-11-27 15:09:20 +01:00
|
|
|
# Build a fifo buffer for the cron logs, 777 so anyone can write to it
|
2020-03-06 17:09:11 +01:00
|
|
|
if [[ ! -p /tmp/cronlog ]]; then
|
2022-11-30 10:51:57 +01:00
|
|
|
mkfifo -m 777 /tmp/cronlog
|
2020-03-06 17:09:11 +01:00
|
|
|
fi
|
2019-11-27 15:09:20 +01:00
|
|
|
|
2022-11-30 10:51:57 +01:00
|
|
|
# Build another fifo for the cron pipe
|
|
|
|
if [[ ! -p /tmp/cronpipe ]]; then
|
|
|
|
mkfifo /tmp/cronpipe
|
|
|
|
fi
|
|
|
|
|
|
|
|
# Execute the cron pipe
|
|
|
|
cron -l -f > /tmp/cronpipe & p1_pid=$!
|
|
|
|
tail -f /tmp/cronlog < /tmp/cronpipe & p2_pid=$!
|
|
|
|
|
|
|
|
# Wait for both processes of the cron pipe
|
|
|
|
wait "$p2_pid"
|
|
|
|
wait "$p1_pid"
|