Skip to content

Commit 64163c9

Browse files
authored
Merge pull request #278 from Toutzn/master
enable cron support
2 parents 9b704e4 + 16c1311 commit 64163c9

File tree

7 files changed

+41
-0
lines changed

7 files changed

+41
-0
lines changed

Dockerfile

+2
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ RUN export DEBIAN_FRONTEND=noninteractive \
5151
supervisor \
5252
unzip \
5353
wget \
54+
cron \
5455
&& apt-get -y --purge remove exim4 exim4-base exim4-config exim4-daemon-light \
5556
&& apt-get clean \
5657
&& rm -rf /var/lib/apt/lists/*
@@ -131,6 +132,7 @@ RUN true \
131132
&& mkdir -p /var/log/icinga2 \
132133
&& chmod 755 /var/log/icinga2 \
133134
&& chown nagios:adm /var/log/icinga2 \
135+
&& touch /var/log/cron.log \
134136
&& rm -rf \
135137
/var/lib/mysql/* \
136138
&& chmod u+s,g+s \

Dockerfile.arm32v7

+2
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@ RUN export DEBIAN_FRONTEND=noninteractive \
5959
supervisor \
6060
unzip \
6161
wget \
62+
cron \
6263
&& apt-get -y --purge remove exim4 exim4-base exim4-config exim4-daemon-light \
6364
&& apt-get clean \
6465
&& rm -rf /var/lib/apt/lists/*
@@ -139,6 +140,7 @@ RUN true \
139140
&& mkdir -p /var/log/icinga2 \
140141
&& chmod 755 /var/log/icinga2 \
141142
&& chown nagios:adm /var/log/icinga2 \
143+
&& touch /var/log/cron.log \
142144
&& rm -rf \
143145
/var/lib/mysql/* \
144146
&& chmod u+s,g+s \

Dockerfile.arm64v8

+2
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ RUN export DEBIAN_FRONTEND=noninteractive \
6060
supervisor \
6161
unzip \
6262
wget \
63+
cron \
6364
&& apt-get -y --purge remove exim4 exim4-base exim4-config exim4-daemon-light \
6465
&& apt-get clean \
6566
&& rm -rf /var/lib/apt/lists/*
@@ -140,6 +141,7 @@ RUN true \
140141
&& mkdir -p /var/log/icinga2 \
141142
&& chmod 755 /var/log/icinga2 \
142143
&& chown nagios:adm /var/log/icinga2 \
144+
&& touch /var/log/cron.log \
143145
&& rm -rf \
144146
/var/lib/mysql/* \
145147
&& chmod u+s,g+s \
+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
[program:crond]
2+
command = /opt/supervisor/cron_supervisor
3+
autostart = true
4+
autorestart = true
5+
stdout_logfile = /dev/stdout
6+
stdout_logfile_maxbytes = 0
7+
stderr_logfile = /dev/stderr
8+
stderr_logfile_maxbytes = 0

content/opt/setup/55-cron

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
#!/bin/bash
2+
3+
. /opt/helpers
4+
5+
if [ ! -f "/etc/cron.d/icinga" ]; then
6+
echo "=> Copying icinga cronfile for /etc/cron.d"
7+
8+
cat >/etc/cron.d/icinga <<-END
9+
# If you enabled x509 module you can use the cronjobs to insert/refresh your certificates.
10+
11+
#30 2 * * * /usr/bin/icingacli x509 import --file /etc/ssl/certs/ca-certificates.crt 2>&1
12+
#00 4 * * * /usr/bin/icingacli x509 scan --job <JOBNAME> 2>&1
13+
END
14+
15+
chmod 0644 /etc/cron.d/icinga
16+
fi
+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
#!/bin/bash
2+
3+
. /opt/helpers
4+
5+
service cron start
6+
7+
# Allow any signal which would kill a process to stop server
8+
trap "service cron stop" HUP INT QUIT ABRT ALRM TERM TSTP
9+
10+
while pgrep -u root cron > /dev/null; do sleep 5; done

docker-compose.yml

+1
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ services:
3737
- ./data/icinga/log/icingaweb2:/var/log/icingaweb2
3838
- ./data/icinga/log/mysql:/var/log/mysql
3939
- ./data/icinga/spool:/var/spool/icinga2
40+
- ./data/icinga/cron.d/icinga:/etc/cron.d/icinga
4041
# Sending e-mail
4142
# See: https://github.com/jjethwa/icinga2#sending-notification-mails
4243
# If you want to enable outbound e-mail, edit the file mstmp/msmtprc

0 commit comments

Comments
 (0)