🐛 Use bash as shell in cron jobs to make process substitution work

The cron jobs were executed, but dash (/bin/sh) complained, and so the
actual command was never run.  This is why our dyndns update did not
work through cron, but when executed manually in bash by an admin.

Example for such a fail when done manually in sh:

    # echo test3 > >(/usr/bin/logger -p user.debug -t dd24)
    /bin/sh: 7: Syntax error: redirection unexpected

Process substitution with `>(command)` is a feature supported by bash
and other shells, but not by POSIX shell which was supposed to used here
(set by `SHELL=…`).  Instead of building complicated redirect magic for
sh just switch to bash, which should be available on the hosts affected.

Link: https://www.shellcheck.net/wiki/SC3001
Fixes: 03dbd132eb ("🔊 Send DD24 cron errors to syslog")
Fixes: 38fbff30b5 ("feat: add role to manage dyndns entry on desec.io")
This commit is contained in:
Alexander Dahl 2025-02-27 13:38:29 +01:00
parent 7074d12bae
commit 58e27dec10
2 changed files with 2 additions and 2 deletions
roles
dd24_dyndns_cron/templates
desec_dyndns_cron/templates

View file

@ -1,6 +1,6 @@
# /etc/cron.d/dd24-dyndns: Cron call to renew DynDNS entry
SHELL=/bin/sh
SHELL=/bin/bash
PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
*/5 * * * * root curl --silent --show-error "https://dynamicdns.key-systems.net/update.php?hostname={{dyndns_domain}}&password={{dyndns_password}}&ip={{dyndns_ip}}" > /dev/null 2> >(/usr/bin/logger -p user.error -t dd24)

View file

@ -1,6 +1,6 @@
# /etc/cron.d/desec-dyndns: Cron call to renew DynDNS entry
SHELL=/bin/sh
SHELL=/bin/bash
PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
*/5 * * * * root curl --silent --show-error --user {{ dyndns_domain }}:{{ dyndns_token }} "https://update.dedyn.io/" > /dev/null 2> >(/usr/bin/logger -p user.error -t desec)