Hi,
I had the same issue. This is how we resolved it:
We have a file called os_detect.tcl in the root of our modules folder.
https://gist.github.com/ErikParawell-SiFive/fac611a6fa8acb4868f9da420c3c43a5 <https://gist.github.com/ErikParawell-SiFive/fac611a6fa8acb4868f9da420c3c43a5>
And this is what our module file looks like:
https://gist.github.com/ErikParawell-SiFive/020b0d8774d49b5d2164ec141234bbe5 <https://gist.github.com/ErikParawell-SiFive/020b0d8774d49b5d2164ec141234bbe5>
> On Jun 2, 2022, at 11:47 AM, Paul Markfort <pau...@gm...> wrote:
>
> Note.
>
> The module initadd script modifies the module load command in the user's shell initialization scripts.
> So, different locations for those files is what you need (hence the suggestion of different home directories).
>
> Alternatively, users can learn to modify their own init scripts (including adding in code to make decisions based on OS).
>
> From the man module page:
>
> initadd modulefile...
> Add modulefile to the shell's initialization file in the user's
> home directory. The startup files checked (in order) are:
>
> C Shell
> .modules, .cshrc, .csh_variables and .login
>
> TENEX C Shell
> .modules, .tcshrc, .cshrc, .csh_variables and .login
>
> Bourne and Korn Shells
> .modules, .profile
>
> GNU Bourne Again Shell
> .modules, .bash_profile, .bash_login, .profile and .bashrc
>
> Z Shell
> .modules, .zshrc, .zshenv and .zlogin
>
> Friendly Interactive Shell
> .modules, .config/fish/config.fish
>
> If a module load line is found in any of these files, the mod-
> ulefiles are appended to any existing list of modulefiles. The
> module load line must be located in at least one of the files
> listed above for any of the init sub-commands to work properly.
> If the module load line is found in multiple shell initializa-
> tion files, all of the lines are changed.
>
>
> Note, the man page does not specify how the .modules file is used (I suspect it is specifically used by the module command - not by the shell, but when I am not sure).
> The libexec/modulecmd.tcl file doesn't seem to directly use it (only modifies it, if there).
>
>
> On 2022-06-02 10:09 AM, Pierre Girard wrote:
>> De : Jason Edgecombe <jwe...@un...>
>> I just realized that I didn't explain my problem very well. I'm looking for how to split each user's automatically-loaded modules for each OS. In other words, if I run "module initadd foo" on Ubuntu then the foo module will be automatically loaded on Ubuntu, but not RHEL.
>> So if I understand correctly, you have 2 sets of modules that differ depending on the OS. So having module load foo in the configuration file would work on ubuntu and an error on RHEL or something along those lines.
>> Maybe write the module itself so it adjusts to the platform you’re on? Something like this:
>> switch $env(DISTRO) {
>> ubuntu {
>> # do something
>> }
>> rhel {
>> # do something else
>> }
>> default {
>> # unknown system
>> }
>> }
>> On Thu, Jun 2, 2022 at 10:18 AM Pierre Girard <pie...@ge... <mailto:pie...@ge...><mailto:pie...@ge... <mailto:pie...@ge...>>> wrote:
>> [Caution: Email from External Sender. Do not click or open links or attachments unless you know this sender.]
>> De : Jason Edgecombe <jwe...@un... <mailto:jwe...@un...><mailto:jwe...@un... <mailto:jwe...@un...>>>
>> Envoyé : 2 juin 2022 09:34
>> À : mod...@li... <mailto:mod...@li...><mailto:mod...@li... <mailto:mod...@li...>>
>> Objet : [Modules] modules on different Linux distros with shared NFS home directories
>> I want to start using modules in our Linux environment. I support both RHEL and Ubuntu machines that use the same shared NFS path for each user's home directory. Is there a way for me to override the ~/.modules path to make it something like ~/.modules-$DISTRO ? I would prefer to not modify the core modulecmd.tcl file. I tried using trace commands in my site config, but I can't seem to trace the cmdModuleInit procedure to override things.
>> You should be able to change MODULEPATH environment variable.
>> export MODULEPATH=~/modulefiles:/home/modules/modulefiles-$DISTRO
>> _______________________________________________
>> Modules-interest mailing list
>> Mod...@li... <mailto:Mod...@li...><mailto:Mod...@li... <mailto:Mod...@li...>>
>> https://lists.sourceforge.net/lists/listinfo/modules-interest <https://lists.sourceforge.net/lists/listinfo/modules-interest>
>> _______________________________________________
>> Modules-interest mailing list
>> Mod...@li... <mailto:Mod...@li...>
>> https://lists.sourceforge.net/lists/listinfo/modules-interest <https://lists.sourceforge.net/lists/listinfo/modules-interest>
>
> --
> --------------------------------------------------------
> The views and opinions expressed above are strictly
> those of the author(s). The content of this message has
> not been reviewed nor approved by any entity whatsoever.
> --------------------------------------------------------
> Paul FM Info: http://paulfm.com/~paulfm/ <http://paulfm.com/~paulfm/>
> --------------------------------------------------------
>
>
> _______________________________________________
> Modules-interest mailing list
> Mod...@li... <mailto:Mod...@li...>
> https://lists.sourceforge.net/lists/listinfo/modules-interest <https://lists.sourceforge.net/lists/listinfo/modules-interest>
|