Skip to content

Commit

Permalink
fix typo in package name deferable-reboot -> deferrable-reboot
Browse files Browse the repository at this point in the history
  • Loading branch information
ilario committed Dec 31, 2024
1 parent 9f6d346 commit 6c9a20a
Show file tree
Hide file tree
Showing 15 changed files with 58 additions and 58 deletions.
3 changes: 0 additions & 3 deletions packages/deferable-reboot/files/etc/config/deferable-reboot

This file was deleted.

10 changes: 0 additions & 10 deletions packages/deferable-reboot/files/usr/bin/deferable-reboot

This file was deleted.

17 changes: 0 additions & 17 deletions packages/deferable-reboot/files/usr/bin/deferable-reboot-check

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -9,29 +9,29 @@ include $(TOPDIR)/rules.mk
GIT_COMMIT_DATE:=$(shell git log -n 1 --pretty=%ad --date=short . )
GIT_COMMIT_TSTAMP:=$(shell git log -n 1 --pretty=%at . )

PKG_NAME:=deferable-reboot
PKG_NAME:=deferrable-reboot
PKG_VERSION=$(GIT_COMMIT_DATE)-$(GIT_COMMIT_TSTAMP)

include $(INCLUDE_DIR)/package.mk

define Package/$(PKG_NAME)
SECTION:=utils
CATEGORY:=Utilities
TITLE:=$(PKG_NAME) provides a deferable reboot.
TITLE:=$(PKG_NAME) provides a deferrable reboot.
MAINTAINER:=Santiago Piccinini <[email protected]>
DEPENDS:=+lua +lime-system
PKGARCH:=all
endef

define Package/$(PKG_NAME)/description
This $(PKG_NAME) provides a deferable reboot mechanism. The system
This $(PKG_NAME) provides a deferrable reboot mechanism. The system
will be rebooted when the uptime of the system reach a specified amount
of seconds and if /tmp/deferable-reboot.defer file does not contain a
of seconds and if /tmp/deferrable-reboot.defer file does not contain a
number that is greater than the current uptime.
This way if anyone wants to postpone the reboot, the way is to store the
next checkpoint in seconds. For example if the system must not reboot from
now and up to 120 seconds in the future then something like this can be donde
awk '{print $1 + 120}' /proc/uptime > /tmp/deferable-reboot.defer
awk '{print $1 + 120}' /proc/uptime > /tmp/deferrable-reboot.defer
endef

define Build/Configure
Expand Down
3 changes: 3 additions & 0 deletions packages/deferrable-reboot/files/etc/config/deferrable-reboot
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
config deferrable-reboot 'options'
#option deferrable_reboot_uptime '97200'

Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,5 @@ unique_append()
}

unique_append \
'*/1 * * * * ((deferable-reboot &> /dev/null)&)'\
'*/1 * * * * ((deferrable-reboot &> /dev/null)&)'\
/etc/crontabs/root
10 changes: 10 additions & 0 deletions packages/deferrable-reboot/files/usr/bin/deferrable-reboot
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#!/usr/bin/lua

local defreboot = require 'deferrable_reboot'

defreboot.config()

if defreboot.should_reboot() then
os.execute('logger -t deferrable-reboot -p ALERT Rebooting in 30 seconds!')
defreboot.reboot()
end
17 changes: 17 additions & 0 deletions packages/deferrable-reboot/files/usr/bin/deferrable-reboot-check
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#!/bin/sh

uci_config_path="lime-autogen.system.deferrable_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 "deferrable-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/deferrable-reboot.defer
fi
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,13 @@ local defreboot = {}
defreboot.DEFAULT_REBOOT_UPTIME = 60*60*27
defreboot.SLEEP_BEFORE_REBOOT_S = 30

defreboot.POSTPONE_FILE_PATH = '/tmp/deferable-reboot.defer'
defreboot.POSTPONE_FILE_PATH = '/tmp/deferrable-reboot.defer'

function defreboot.config(min_uptime)
if min_uptime == nil then
local uci = config.get_uci_cursor()
local lime_min_uptime = config.get("system", "deferable_reboot_uptime_s", false)
local general_min_uptime = uci:get("deferable-reboot", "options", "deferable_reboot_uptime_s")
local lime_min_uptime = config.get("system", "deferrable_reboot_uptime_s", false)
local general_min_uptime = uci:get("deferrable-reboot", "options", "deferrable_reboot_uptime_s")
min_uptime = tonumber(lime_min_uptime or general_min_uptime or defreboot.DEFAULT_REBOOT_UPTIME)
end
assert(type(min_uptime) == "number", "min_uptime must be a number")
Expand All @@ -39,7 +39,7 @@ end


--! use this function to postpone the reboot, also the following command can be used
--! replacing SECONDS: # awk '{print $1 + SECONDS}' /proc/uptime > /tmp/deferable-reboot.defer
--! replacing SECONDS: # awk '{print $1 + SECONDS}' /proc/uptime > /tmp/deferrable-reboot.defer
function defreboot.read_postpone_file()
local f = io.open(defreboot.POSTPONE_FILE_PATH)
if f ~= nil then
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
local config = require "lime.config"
local test_utils = require 'tests.utils'
local defreboot = require 'deferable_reboot'
local defreboot = require 'deferrable_reboot'

local uci = nil

describe('Deferable Reboot tests #defreboot', function()
describe('Deferrable Reboot tests #defreboot', function()

it('test load config from lime.config default value', function()
defreboot.config()
Expand All @@ -13,25 +13,25 @@ describe('Deferable Reboot tests #defreboot', function()

it('test load config from lime.config', function()
config.set('system', 'lime')
config.set('system', 'deferable_reboot_uptime_s', '120')
config.set('system', 'deferrable_reboot_uptime_s', '120')
defreboot.config()
assert.is.equal(120, defreboot.min_uptime)
end)

it('test load config from config/deferable-reboot', function()
uci:set('deferable-reboot', 'options', 'deferable-reboot')
uci:set('deferable-reboot', 'options', 'deferable_reboot_uptime_s', '99')
uci:commit('deferable-reboot')
it('test load config from config/deferrable-reboot', function()
uci:set('deferrable-reboot', 'options', 'deferrable-reboot')
uci:set('deferrable-reboot', 'options', 'deferrable_reboot_uptime_s', '99')
uci:commit('deferrable-reboot')
defreboot.config()
assert.is.equal(99, defreboot.min_uptime)
end)

it('test lime.config has precedence over config/deferable-reboot ', function()
it('test lime.config has precedence over config/deferrable-reboot ', function()
config.set('system', 'lime')
config.set('system', 'deferable_reboot_uptime_s', '120')
uci:set('deferable-reboot', 'options', 'deferable-reboot')
uci:set('deferable-reboot', 'options', 'deferable_reboot_uptime_s', '99')
uci:commit('deferable-reboot')
config.set('system', 'deferrable_reboot_uptime_s', '120')
uci:set('deferrable-reboot', 'options', 'deferrable-reboot')
uci:set('deferrable-reboot', 'options', 'deferrable_reboot_uptime_s', '99')
uci:commit('deferrable-reboot')
defreboot.config()
assert.is.equal(120, defreboot.min_uptime)
end)
Expand Down
4 changes: 2 additions & 2 deletions packages/lime-docs/files/www/docs/lime-example.txt
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ config lime system
option keep_on_upgrade 'libremesh dropbear minimum-essential /etc/sysupgrade.conf' # Files defining the list of files and directories to backup when upgrade. Relative to /lib/upgrade/keep.d if no '/' defined.
option root_password_policy 'DO_NOTHING' # When configured to SET_SECRET, the root password secret will be configured as specified in root_password_secret. When set to RANDOM a strong random password will be set if root has no password, use this if your firmware is built with the ssh keys inside. DO_NOTHING does nothing, leaving the root password empty (you will have to set it manually or through FirstBootWizard).
option root_password_secret '' # This is the password hash as stored in /etc/shadow, it is only used when root_password_policy=SET_SECRET. You can generate the secret with 'openssl passwd -1' to be compatible with most openwrt firmwares, use a strong password with at least 10 numbers and letters, the longer the better!. For improved security use "openssl passwd -6" for SHA512 (or -5 for SHA256) but be aware that not all firmwares support this.
option deferable_reboot_uptime_s '97200'
option deferable_reboot_ping_target '4.2.2.2' # b.resolvers.Level3.net # the reboot scheduled by deferable_reboot, if installed, will be deferred if the ping to this IP is succesful
option deferrable_reboot_uptime_s '97200'
option deferrable_reboot_ping_target '4.2.2.2' # b.resolvers.Level3.net # the reboot scheduled by deferrable_reboot, if installed, will be deferred if the ping to this IP is succesful
option firstbootwizard_configured false
option firstbootwizard_dismissed false # When true fbw banner will be hidden.

Expand Down
4 changes: 2 additions & 2 deletions packages/lime-system/files/etc/config/lime-defaults
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ config lime system
option keep_on_upgrade 'libremesh dropbear minimum-essential /etc/sysupgrade.conf'
option root_password_policy 'DO_NOTHING'
option root_password_secret ''
option deferable_reboot_uptime_s '97200'
option deferable_reboot_ping_target '4.2.2.2'
option deferrable_reboot_uptime_s '97200'
option deferrable_reboot_ping_target '4.2.2.2'
option firstbootwizard_configured false
option firstbootwizard_dismissed false

Expand Down
2 changes: 1 addition & 1 deletion packages/safe-upgrade/files/usr/sbin/safe-upgrade
Original file line number Diff line number Diff line change
Expand Up @@ -327,7 +327,7 @@ local function upgrade(args)
su.preserve_files_to_new_partition(args)

-- postpone 10m defarable-reboot
os.execute("awk '{print $1 + 600}' /proc/uptime > /tmp/deferable-reboot.defer")
os.execute("awk '{print $1 + 600}' /proc/uptime > /tmp/deferrable-reboot.defer")

print(string.format("erasing partition %d", partitions.other))
os.execute(string.format("mtd erase fw%d", partitions.other))
Expand Down
2 changes: 1 addition & 1 deletion tests/utils.lua
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ UCI_CONFIG_FILES = {
"6relayd", "babeld", "batman-adv", "check-date", "dhcp", "dropbear", "fstab", "firewall",
"libremap", "lime", "lime-app", "location",
"luci", "network", "pirania", "rpcd", "shared-state", "system", "ucitrack",
"uhttpd", "wireless", "deferable-reboot", config.UCI_AUTOGEN_NAME, config.UCI_NODE_NAME,
"uhttpd", "wireless", "deferrable-reboot", config.UCI_AUTOGEN_NAME, config.UCI_NODE_NAME,
config.UCI_COMMUNITY_NAME, config.UCI_DEFAULTS_NAME
}

Expand Down

0 comments on commit 6c9a20a

Please sign in to comment.