9

I have a few bash scripts running system checks. These scripts source configuration options from a file /etc/healthchecks/config.

Along with the config file, I have a shared functions file. The scripts should be able to source that file and run the functions therein.

Based on the Filesystem Hierarchy Standard, where should I put the shared functions file? It's not a configuration, so it doesn't seem like it belongs in /etc, but it's also not being executed so /usr/bin seems incorrect. Maybe /usr/lib?

7

You should put your healthchecks executables in /usr/local/bin or in /opt/bin. If you see your folder /opt is empty, means your linux distribution doesn't use it. So, the suitable place would be /usr/local.

/usr/local and /opt are where every "manual" package/program must be placed. /usr is for packages managed by package managers (i.e, dpkg). /opt is the "standard place" for manual packages according to FHS, but debian distros use /usr/local instead.

For configuration files, they must be placed on /usr/local/etc, since /etc is for configuration files of automatic packages and other system programs.

The correct place for your shared functions is then /usr/local/share (/usr/share is for shared files of automatic packages). Every file which is designed to be read-only and independent of the arquitecture belongs to /usr/share or /usr/local/share (if they are own by "automatic" or "manual" packages).

/usr/lib is for dynamic and static binary libraries (.so or .a), and not for "interpreted" libraries/functions.

Usually, interpreters have different subfolders in /etc/share/ for each version, and inside each version folder, different folders for scripts, locales, tests, samples and so on.

If some day you create an official repository for your package healthchecks, you could migrate your /usr/local/healthchecks contents to /usr/healthchecks and /etc/healthchecks.

  • 2
    I went ahead and deleted my answer because 1) yours covers the topic well enough, and 2) libexec technically isn't part of the FHS yet. It's present in the 3.0 draft and Redhat's Overview of the FHS, but isn't technically part of the FHS yet. (use it if you want, basically) – Andrew B Oct 7 '14 at 23:18
1

I generally try to keep site specific things outside of these reserved system areas. You might consider using your own top-level directory hierarchy as when using system areas special site files can easily get lost or forgotten during system evolution. Another possibility could be /usr/local/etc.....

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.