Skip to content

Commit

Permalink
Create our own cron file rather than copying the one from the core re…
Browse files Browse the repository at this point in the history
…po (which contains non-standard cron syntax)

Signed-off-by: Adam Warner <me@adamwarner.co.uk>
  • Loading branch information
PromoFaux committed Jul 3, 2023
1 parent cc3789d commit d415bff
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 8 deletions.
8 changes: 1 addition & 7 deletions src/Dockerfile
Expand Up @@ -48,6 +48,7 @@ RUN if [ "$TARGETPLATFORM" = "linux/amd64" ]; then FTLARCH=amd64; \


ADD https://ftl.pi-hole.net/macvendor.db /macvendor.db
ADD crontab.txt /crontab.txt

RUN cd /etc/.pihole && \
install -Dm755 -d /opt/pihole && \
Expand All @@ -57,17 +58,10 @@ RUN cd /etc/.pihole && \
install -Dm755 -t /opt/pihole ./advanced/Scripts/COL_TABLE && \
install -Dm755 -t /usr/local/bin pihole && \
install -Dm644 ./advanced/bash-completion/pihole /etc/bash_completion.d/pihole && \
install -Dm644 ./advanced/Templates/pihole.cron /var/spool/cron/crontabs/pihole && \
# Randomize gravity update time
sed -i "s/59 1 /$((1 + RANDOM % 58)) $((3 + RANDOM % 2))/" /var/spool/cron/crontabs/pihole && \
# Randomize update checker time
sed -i "s/59 17/$((1 + RANDOM % 58)) $((12 + RANDOM % 8))/" /var/spool/cron/crontabs/pihole && \
# Grab some useful bits from FTL's service scripts
install -T -m 0755 ./advanced/Templates/pihole-FTL-prestart.sh /opt/pihole/pihole-FTL-prestart.sh && \
install -T -m 0755 ./advanced/Templates/pihole-FTL-poststop.sh /opt/pihole/pihole-FTL-poststop.sh



ENV DNSMASQ_USER=pihole
ENV FTL_CMD=no-daemon
RUN addgroup -S pihole && adduser -S pihole -G pihole
Expand Down
3 changes: 3 additions & 0 deletions src/crontab.txt
@@ -0,0 +1,3 @@
59 1 * * 6 PATH="$PATH:/usr/sbin:/usr/local/bin/" pihole updateGravity >/var/log/pihole/pihole_updateGravity.log || cat /var/log/pihole/pihole_updateGravity.log
00 00 * * * PATH="$PATH:/usr/sbin:/usr/local/bin/" pihole flush once quiet
59 17 * * * PATH="$PATH:/usr/sbin:/usr/local/bin/" pihole updatechecker
10 changes: 9 additions & 1 deletion src/start.sh
Expand Up @@ -69,7 +69,15 @@ sh /opt/pihole/pihole-FTL-prestart.sh
capsh --user=$DNSMASQ_USER --keep=1 -- -c "/usr/bin/pihole-FTL $FTL_CMD >/dev/null" &

# Start crond for scheduled scripts (logrotate, pihole flush, gravity update etc)
crond
# crond

# Randomize gravity update time
sed -i "s/59 1 /$((1 + RANDOM % 58)) $((3 + RANDOM % 2))/" /crontab.txt
# Randomize update checker time
sed -i "s/59 17/$((1 + RANDOM % 58)) $((12 + RANDOM % 8))/" /crontab.txt
/usr/bin/crontab /crontab.txt

/usr/sbin/crond

pihole -g

Expand Down

0 comments on commit d415bff

Please sign in to comment.