diff --git a/package/opt/hassbian/suites/duckdns.sh b/package/opt/hassbian/suites/duckdns.sh index f6648957..3e39ba7c 100644 --- a/package/opt/hassbian/suites/duckdns.sh +++ b/package/opt/hassbian/suites/duckdns.sh @@ -70,13 +70,14 @@ chmod 700 duck.sh echo "Creating cron job..." (crontab -l ; echo "*/5 * * * * /home/homeassistant/duckdns/duck.sh >/dev/null 2>&1")| crontab - -if [ "$SSL_RESPONSE" == "y" ] || [ "$SSL_RESPONSE" == "Y" ]; then -(crontab -l ; echo "0 1 1 * * /home/homeassistant/dehydrated/dehydrated -c")| crontab - -fi -echo "Changing to root user..." EOF +if [ "$SSL_RESPONSE" == "y" ] || [ "$SSL_RESPONSE" == "Y" ]; then + cp /opt/hassbian/suites/files/dehydrated_cron /etc/cron.daily/dehydrated + chmod +x /etc/cron.daily/dehydrated +fi + echo "Restarting cron service..." sudo systemctl restart cron.service diff --git a/package/opt/hassbian/suites/files/dehydrated_cron b/package/opt/hassbian/suites/files/dehydrated_cron new file mode 100644 index 00000000..46610974 --- /dev/null +++ b/package/opt/hassbian/suites/files/dehydrated_cron @@ -0,0 +1,9 @@ +#!/bin/bash +# Run the dehydrated script to renew certificates + +echo "Changing to homeassistant user..." +sudo -u homeassistant -H /bin/bash << EOF + cd /home/homeassistant/dehydrated || exit + ./dehydrated -c + date >> /home/homeassistant/dehydrated/run_log +EOF