[FIX] OpenWRT auto update (#1155)

* switch to root crontab for OpenWRT auto update

* fix: OpenWRT auto update restart condition
This commit is contained in:
Alexander Mnich
2025-09-08 22:50:39 +02:00
committed by GitHub
parent f542bc70a1
commit 6a0075291c

View File

@@ -329,7 +329,12 @@ if [ "$UNINSTALL" = true ]; then
# Remove the update service if it exists # Remove the update service if it exists
echo "Removing the daily update service..." echo "Removing the daily update service..."
# Remove legacy beszel account based crontab file
rm -f /etc/crontabs/beszel 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 elif is_freebsd; then
echo "Stopping and disabling the agent service..." echo "Stopping and disabling the agent service..."
@@ -716,7 +721,7 @@ EXTRA_HELP=" update Update the Beszel agent
restart Restart the Beszel agent" restart Restart the Beszel agent"
update() { 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 /etc/init.d/beszel-agent restart
fi fi
} }
@@ -745,9 +750,9 @@ EOF
[Yy]*) [Yy]*)
echo "Setting up daily automatic updates for beszel-agent..." echo "Setting up daily automatic updates for beszel-agent..."
cat >/etc/crontabs/beszel <<EOF if ! crontab -u root -l 2>/dev/null | grep -q "beszel-agent.*update"; then
12 0 * * * /etc/init.d/beszel-agent update (crontab -u root -l 2>/dev/null; echo "12 0 * * * /etc/init.d/beszel-agent update") | crontab -u root -
EOF fi
/etc/init.d/cron restart /etc/init.d/cron restart