Skip to content

Commit

Permalink
deferable-reboot move cron command to file
Browse files Browse the repository at this point in the history
  • Loading branch information
ilario committed Jan 1, 2025
1 parent 8e7e17d commit bd233d5
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,5 @@ unique_append()
}

unique_append \
"*/3 * * * * ((sleep $((RANDOM % 120)); if ping -c 10 -W 10 \$(uci -q get lime-autogen.system.deferable_reboot_ping_target) &> /dev/null; then awk '{print \$1 + 1800}' /proc/uptime > /tmp/deferable-reboot.defer ; fi )&) "\
/etc/crontabs/root
"*/3 * * * * ((sleep $((RANDOM % 120)); /usr/bin/deferable-reboot-check )&)" /etc/crontabs/root

17 changes: 17 additions & 0 deletions packages/deferable-reboot/files/usr/bin/deferable-reboot-check
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#!/bin/sh

uci_config_path="lime-autogen.system.deferable_reboot_ping_target"
target=$(uci -q get $uci_config_path &> /dev/null)

if [ -n "$target" ]; then
if ping -c 10 -W 10 $target; then
action=defer
fi
else
echo "deferable-reboot: Could not get the ping target from UCI $uci_config_path, deferring anyway"
action=defer
fi

if [ "$action" == "defer" ]; then
awk '{print $1 + 1800}' /proc/uptime > /tmp/deferable-reboot.defer
fi

0 comments on commit bd233d5

Please sign in to comment.