Thank you so much, will definitely look into this!
Roberto
On 27 May 2025 at 20:56 +0200, Kirker, Ian <i.k...@uc...>, wrote:
> Roberto,
>
> You can do this with an [exec my_script.sh] call inside a [module-info mode load] check, but as a slightly alternative approach, we have some modules in our setup that do something like this entirely in Tcl.
>
> We have a small library of procedures to do things like this here: https://github.com/UCL-ARC/UsefulModuleFunctions
>
> Which, as an example, are used by: https://github.com/UCL-ARC/rcps-modulefiles/blob/master/applications/ansys/2024.r1
>
> The createDir procedure does the kind of thing it sounds like you want to do, but also check out the getDirFreeSpace procedure to see an example of running an external command.
>
> -Ian Kirker
>
>
> > On 27 May 2025, at 17:39, InfnPi <rob...@pi...> wrote:
> >
> > ⚠ Caution: External sender
> >
> > Hi,
> > I have a (probably) stupid question.
> >
> > I would linke to set-up an user environment for a certain project for users and then configure it accordingly.
> >
> > The setup phase is usually done once and involves running a script which makes some changes to the filesystem.
> > Typically i will create some "standard" directory structures and link some files/directories to this structure.
> >
> > Once the setup is complete, i need to configure the environment for using it.
> >
> > This second part is easily dome with modules but i was wondering if there is any way to execute a script (that does not have environment settings) to check if a particular directory structure is in place.
> > If it is not there it will create it, otherwise it will just skip it and proceed to the configuration part.
> >
> > Of course this first part would have just to be executed on a module load command and should not be reverted by a module unload or switch command.
> >
> > Something like:
> > exec-shell-script bash ./path/to/script/Create.sh
> > (instead of bash it could be anything like another shell, a python script or even a program written by the user)
> >
> > followed by some standard modulefile commands that set user environment variables.
> >
> > A user would then alway call a single modulefile regardless of the fact that the directory structure is already in place.
> >
> > Something like:
> > module load setup/ProjectXXX
> >
> > If it is the first time it is run it will create the complete directory structure (with directories, links etc) and then setup the environment variables (tools, licenses, paths etc)
> > If the user runs it a second time the script would still be executed but being the directory structure already in place it would just skip that part (this is handled by the script itself) and go to the environment configuration part.
> >
> > Of course, in case of a:
> > module unload setup/ProjectXXX
> > only the environment part would be undone and the whole directory structure would stay as before.
> >
> > Of course this procedure has not to be a one step solution but it could well be one that reguires loading two different modules,
> > the first one that creates/checks the structure and a second one that configures the environment.
> >
> > I tried to look if this is possible but did not find a solution.
> >
> > Many thx in advance,
> > Roberto
> > _______________________________________________
> > Modules-interest mailing list
> > Mod...@li...
> > https://lists.sourceforge.net/lists/listinfo/modules-interest
>
> _______________________________________________
> Modules-interest mailing list
> Mod...@li...
> https://lists.sourceforge.net/lists/listinfo/modules-interest
|