Shared script file between principal package and luci app -- where to place? how to shellcheck?

What's the best way to share the script file with some functions between principal package (pbr) and its luci companion (luci-app-pbr)?

I use some functions in the RPCD script and manually copying them over is tedious. So if I were to create a shared functions script file:

  1. Where to store it? I kinda like /lib/functions/ but not sure if it's a preferred location. I already have some user-files in /usr/share/pbr so not sure if it should go there, my fear is it may get erroneously deleted.
  2. In my own source code repo, it's a flat structure for packages and luci apps, so I think I can set shellcheck to properly follow relative paths and check the shared script (and prevent it triggering on missing functions/variables). However with OpenWrt it's two different repositories, how can I set the shellcheck to not throw errors?

Thanks!

1 Like

According to the FHS and common practice of major Linux distributions:

  • Only the package manager is normally allowed to write to /usr/share.
  • System-wide customization should be provided with /usr/local or /etc.

Since /usr/local is uncommon for OpenWrt, it would be best to move everything customizeable to /etc and leave /usr/share as read-only.

This looks like a location for essential libraries/functions that can be used by other services, so it might be suitable if you plan providing functions which scope of application is not limited to the PBR package.

You can try to explicitly specify the source path or just ignore specific error codes.

1 Like

Do you have a suggestion on how to achieve it pointing to a different repository?