Skip to content

Commit

Permalink
Merge pull request #278 from Toutzn/master
Browse files Browse the repository at this point in the history
enable cron support
  • Loading branch information
jjethwa authored Feb 23, 2022
2 parents 9b704e4 + 16c1311 commit 64163c9
Show file tree
Hide file tree
Showing 7 changed files with 41 additions and 0 deletions.
2 changes: 2 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ RUN export DEBIAN_FRONTEND=noninteractive \
supervisor \
unzip \
wget \
cron \
&& apt-get -y --purge remove exim4 exim4-base exim4-config exim4-daemon-light \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/*
Expand Down Expand Up @@ -131,6 +132,7 @@ RUN true \
&& mkdir -p /var/log/icinga2 \
&& chmod 755 /var/log/icinga2 \
&& chown nagios:adm /var/log/icinga2 \
&& touch /var/log/cron.log \
&& rm -rf \
/var/lib/mysql/* \
&& chmod u+s,g+s \
Expand Down
2 changes: 2 additions & 0 deletions Dockerfile.arm32v7
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ RUN export DEBIAN_FRONTEND=noninteractive \
supervisor \
unzip \
wget \
cron \
&& apt-get -y --purge remove exim4 exim4-base exim4-config exim4-daemon-light \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/*
Expand Down Expand Up @@ -139,6 +140,7 @@ RUN true \
&& mkdir -p /var/log/icinga2 \
&& chmod 755 /var/log/icinga2 \
&& chown nagios:adm /var/log/icinga2 \
&& touch /var/log/cron.log \
&& rm -rf \
/var/lib/mysql/* \
&& chmod u+s,g+s \
Expand Down
2 changes: 2 additions & 0 deletions Dockerfile.arm64v8
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ RUN export DEBIAN_FRONTEND=noninteractive \
supervisor \
unzip \
wget \
cron \
&& apt-get -y --purge remove exim4 exim4-base exim4-config exim4-daemon-light \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/*
Expand Down Expand Up @@ -140,6 +141,7 @@ RUN true \
&& mkdir -p /var/log/icinga2 \
&& chmod 755 /var/log/icinga2 \
&& chown nagios:adm /var/log/icinga2 \
&& touch /var/log/cron.log \
&& rm -rf \
/var/lib/mysql/* \
&& chmod u+s,g+s \
Expand Down
8 changes: 8 additions & 0 deletions content/etc/supervisor/conf.d/cron.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
[program:crond]
command = /opt/supervisor/cron_supervisor
autostart = true
autorestart = true
stdout_logfile = /dev/stdout
stdout_logfile_maxbytes = 0
stderr_logfile = /dev/stderr
stderr_logfile_maxbytes = 0
16 changes: 16 additions & 0 deletions content/opt/setup/55-cron
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#!/bin/bash

. /opt/helpers

if [ ! -f "/etc/cron.d/icinga" ]; then
echo "=> Copying icinga cronfile for /etc/cron.d"

cat >/etc/cron.d/icinga <<-END
# If you enabled x509 module you can use the cronjobs to insert/refresh your certificates.
#30 2 * * * /usr/bin/icingacli x509 import --file /etc/ssl/certs/ca-certificates.crt 2>&1
#00 4 * * * /usr/bin/icingacli x509 scan --job <JOBNAME> 2>&1
END

chmod 0644 /etc/cron.d/icinga
fi
10 changes: 10 additions & 0 deletions content/opt/supervisor/cron_supervisor
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#!/bin/bash

. /opt/helpers

service cron start

# Allow any signal which would kill a process to stop server
trap "service cron stop" HUP INT QUIT ABRT ALRM TERM TSTP

while pgrep -u root cron > /dev/null; do sleep 5; done
1 change: 1 addition & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ services:
- ./data/icinga/log/icingaweb2:/var/log/icingaweb2
- ./data/icinga/log/mysql:/var/log/mysql
- ./data/icinga/spool:/var/spool/icinga2
- ./data/icinga/cron.d/icinga:/etc/cron.d/icinga
# Sending e-mail
# See: https://github.com/jjethwa/icinga2#sending-notification-mails
# If you want to enable outbound e-mail, edit the file mstmp/msmtprc
Expand Down

0 comments on commit 64163c9

Please sign in to comment.