From 6a0075291cf95e796760e200286e9939625b139b Mon Sep 17 00:00:00 2001 From: Alexander Mnich <56564725+a-mnich@users.noreply.github.com> Date: Mon, 8 Sep 2025 22:50:39 +0200 Subject: [PATCH] [FIX] OpenWRT auto update (#1155) * switch to root crontab for OpenWRT auto update * fix: OpenWRT auto update restart condition --- supplemental/scripts/install-agent.sh | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/supplemental/scripts/install-agent.sh b/supplemental/scripts/install-agent.sh index 93aa9644..bda1af43 100755 --- a/supplemental/scripts/install-agent.sh +++ b/supplemental/scripts/install-agent.sh @@ -329,7 +329,12 @@ if [ "$UNINSTALL" = true ]; then # Remove the update service if it exists echo "Removing the daily update service..." + # Remove legacy beszel account based crontab file rm -f /etc/crontabs/beszel + # Install root crontab job + if crontab -u root -l 2>/dev/null | grep -q "beszel-agent.*update"; then + crontab -u root -l 2>/dev/null | grep -v "beszel-agent.*update" | crontab -u root - + fi elif is_freebsd; then echo "Stopping and disabling the agent service..." @@ -716,7 +721,7 @@ EXTRA_HELP=" update Update the Beszel agent restart Restart the Beszel agent" update() { - if /opt/beszel-agent/beszel-agent update | grep -q "Successfully updated"; then + if /opt/beszel-agent/beszel-agent update | grep -q "Update completed successfully"; then /etc/init.d/beszel-agent restart fi } @@ -745,9 +750,9 @@ EOF [Yy]*) echo "Setting up daily automatic updates for beszel-agent..." - cat >/etc/crontabs/beszel </dev/null | grep -q "beszel-agent.*update"; then + (crontab -u root -l 2>/dev/null; echo "12 0 * * * /etc/init.d/beszel-agent update") | crontab -u root - + fi /etc/init.d/cron restart