Skip to content

lime-utils: init the package with the script unique_append - #1276

Draft
a-gave wants to merge 2 commits into
libremesh:masterfrom
a-gave:packages/lime-utils
Draft

lime-utils: init the package with the script unique_append#1276
a-gave wants to merge 2 commits into
libremesh:masterfrom
a-gave:packages/lime-utils

Conversation

@a-gave

@a-gave a-gave commented Sep 4, 2026

Copy link
Copy Markdown
Contributor

[WIP] still untested

lime-system: utils.lua use nixio.fs for file operations
This includes also a similar minor fix:

  • fix: use the lua native #var to count tableLength(var)

lime-utils: init the package with the script unique_append
The following changes are made:

  • initialize the package lime-utils with the script unique_append
  • add a dependency on lime-utils to all packages
  • always 'exit 0' on uci defaults that add new crontabs, to execute them
    only at firstboot and not at every boot

Fixes: #949

The following changes are made:
- initialize the package lime-utils with the script unique_append
- add a dependency on lime-utils to all packages
- always 'exit 0' on uci defaults that add new crontabs, to execute them
only at firstboot and not at every boot

Fixes: libremesh#949
@a-gave
a-gave force-pushed the packages/lime-utils branch 2 times, most recently from 2882400 to d28e343 Compare September 4, 2026 14:21
This includes also a similar minor fix:
- fix: use the lua native #var to count tableLength(var)
else
return false
end
return fs.stat(name, "type") == "reg"

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like the new implementation!
But this function passed to be true also for directories to be true only for regular files, and this requires updating this test:

assert.is_true(utils.file_exists(dir))

and some (mostly unused) code here (just checked the ones where the variable name looked like a directory's one):

if not utils.file_exists(dst_dirname) then

if not utils.file_exists(workdir) then

And also here as it seems that keeping directories over updates is supported (according to lime-example.txt, I did not check):

@ilario

ilario commented Sep 5, 2026

Copy link
Copy Markdown
Member

I love the new lime-utils package!!!
Do you think that eventually, slowly slowly, it could contain the utils.lua, config.lua and modules.lua files from lime-system, as proposed in #771 ?


define Package/$(PKG_NAME)
TITLE:=LibreMesh utils core
CATEGORY:=LibreMesh

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you think this package could be used out of LibreMesh and be pushed to OpenWrt's repositories, eventually?
In this case, you could already place the package in the Utilities category.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes is seems sensed, ok for the category good catch will do!

@a-gave

a-gave commented Sep 7, 2026

Copy link
Copy Markdown
Contributor Author

I love the new lime-utils package!!! Do you think that eventually, slowly slowly, it could contain the utils.lua, config.lua and modules.lua files from lime-system, as proposed in #771 ?

Yes the intention is that!

I started looking at utils.lua and I'm planning to move the functions like 'set_root_secret' to the module /usr/lib/lua/lime/system.lua and to port to the new lime-utils 'utils.lua' and 'config.lua'

I initially tought that modules could remain in lime-system, maybe also they should have their own directory which could be /usr/lib/lua/lime/modules and the list of modules is a list of files contained in that folder, to ease the possibility to add new modules

what do you think?

@ilario

ilario commented Sep 7, 2026

Copy link
Copy Markdown
Member

I love the new lime-utils package!!! Do you think that eventually, slowly slowly, it could contain the utils.lua, config.lua and modules.lua files from lime-system, as proposed in #771 ?

Yes the intention is that!

Great!!!

I started looking at utils.lua and I'm planning to move the functions like 'set_root_secret' to the module /usr/lib/lua/lime/system.lua and to port to the new lime-utils 'utils.lua' and 'config.lua'

Wow, so that utils.lua would be free of LibreMesh-specific functions? It would be amazing, but also a lot of work for moving many functions (I did not check them one by one, but I suspect they are many)!

I initially tought that modules could remain in lime-system,

You are right, it is better.
To keep modules.lua in lime-system without having lime-utils depending on it, we could eliminate utils.isModuleAvailable (a function in utils that calls one in modules) and use modules.is_available instead.

Now that I check this again, also config.lua should stay in lime-system, as it is LibreMesh-specific. For removing the dependency of utils.lua from config.lua, we could move out of utils.lua the functions utils.network_id and utils.set_shared_root_password.

maybe also they should have their own directory which could be /usr/lib/lua/lime/modules and the list of modules is a list of files contained in that folder, to ease the possibility to add new modules

Nice! It would be more tidy :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

unique_append should check if /etc/crontabs/root file exist before appending

2 participants