Skip to content

Commit 4d97256

Browse files
committed
Add licence and more extensive documentation
1 parent 78e286b commit 4d97256

5 files changed

Lines changed: 159 additions & 32 deletions

File tree

init/lmod/bash

Lines changed: 60 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,62 @@
1+
#!/usr/bin/env bash
2+
3+
# SPDX-License-Identifier: GPL-2.0-only
4+
# Copyright (C) 2020-2026 EESSI contributors
5+
#
6+
# EESSI - European Environment for Scientific Software Installations
7+
#
8+
# This file is a template for initialising EESSI via Lmod for the environment indicated by the shebang.
9+
#
10+
# Assumptions:
11+
# - EESSI accessible under $EESSI_CVMFS_REPO or /cvmfs/software.eessi.io
12+
# - expected to be true as this file is also meant to be shipped under that location
13+
# - Lmod must the shipped in the repository in the correct location
14+
#
15+
# Options:
16+
# - The script listens to environment variables so that it can be silently configured by a site
17+
# - EESSI_CVMFS_REPO: perform the initialisation from a respository other than /cvmfs/software.eessi.io
18+
# - EESSI_VERSION: loads a specific EESSI version ignoring the default in the file
19+
# - EESSI_DEFAULT_MODULES_PREPEND: environment variable allows you to prepend modules to the defaults (loaded last)
20+
# - EESSI_DEFAULT_MODULES_APPEND: environment variable allows you to append modules to the defaults (loaded first)
21+
# - EESSI_EXTRA_MODULEPATH: environment variable allows a site to append to MODULEPATH (lower priority than EESSI MODULEPATH)
22+
#
23+
# Other options that can be set to influence the end result:
24+
# - The EESSI module also listens to environment variables so that it can be silently configured by a site
25+
# - EESSI_MODULE_FAMILY_NAME: use the value of the environment variable to set an Lmod family for the EESSI module
26+
# - EESSI_MODULE_STICKY: make the EESSI module sticky
27+
# - EESSI_MODULE_UPDATE_PS1: have the EESSI module update PS1 to give a prompt that is prepended with "{EESSI/...} "
28+
#
29+
# Effects:
30+
# - Should always succeed
31+
# - Initialises Lmod from specific version of EESSI
32+
# - Clobbers any existing Lmod configuration
33+
# - Some special environment variables that are internal to Lmod (__LMOD_REF_COUNT_MODULEPATH and
34+
# _ModuleTable001_) are used to force a hard reset of an existing Lmod installation. This
35+
# approach may be brittle.
36+
# - Then loads module EESSI/... to initialise EESSI
37+
# - use `module show EESSI/...` to see the environment variables set by the EESSI module
38+
#
39+
# Reverting the effects:
40+
# - EESSI initialisation via `module unload EESSI/...`
41+
# - Lmod initialisation cannot be undone
42+
143
# Choose an EESSI CVMFS repository
244
EESSI_CVMFS_REPO="${EESSI_CVMFS_REPO:-/cvmfs/software.eessi.io}"
3-
# Choose an EESSI version
4-
EESSI_VERSION_DEFAULT="__EESSI_VERSION_DEFAULT__"
45+
46+
# Choose an EESSI version (the default is only used if the EESSI_VERSION environment variable is not provided)
47+
EESSI_VERSION_DEFAULT="${__EESSI_VERSION_USED_FOR_INIT:-__EESSI_VERSION_DEFAULT__}"
548
EESSI_VERSION="${EESSI_VERSION:-${EESSI_VERSION_DEFAULT}}"
6-
# Now that we know our EESSI version let's not forget it
7-
export EESSI_VERSION_DEFAULT="$EESSI_VERSION"
49+
# On the first run we want to record the EESSI version used for init as an environment variable so that if a different
50+
# version of this script is called (e.g, for a a different EESSI version) it retains a memory which EESSI
51+
# version was actually used in the initialisation. This is useful as __Init_EESSI_Default_Modules used below will
52+
# be defined on the first call and Lmod initialisation will not happen twice.
53+
# This sets the value only on first execution, if the variable already exists in the environment
54+
# the original value is retained.
55+
export __EESSI_VERSION_USED_FOR_INIT="${__EESSI_VERSION_USED_FOR_INIT:-${EESSI_VERSION}}"
856

9-
# ability to predefine elsewhere the default list (with options to append or prepend)
57+
# Ability to predefine elsewhere the default list of modules to load (colon separated):
58+
# - EESSI_DEFAULT_MODULES_PREPEND environment variable allows you to prepend modules (loaded last)
59+
# - EESSI_DEFAULT_MODULES_APPEND environment variable allows you to append modules (loaded first)
1060
LMOD_SYSTEM_DEFAULT_MODULES="${EESSI_DEFAULT_MODULES_PREPEND:+$EESSI_DEFAULT_MODULES_PREPEND:}EESSI/$EESSI_VERSION${EESSI_DEFAULT_MODULES_APPEND:+:$EESSI_DEFAULT_MODULES_APPEND}"
1161
export LMOD_SYSTEM_DEFAULT_MODULES
1262

@@ -17,11 +67,14 @@ if [ -z "$__Init_EESSI_Default_Modules" ]; then
1767
# (has no effect except on Lmod itself, and compatible caches are still created/supported by EESSI)
1868
LMOD_EESSI_VERSION=${EESSI_VERSION/2023.06/2025.06}
1969

20-
# If there is a local Lmod, make it forget about the system set MODULEPATH
70+
# Lmod may have been initialised so we need to clear some internal variables to allow for a full reset
71+
# - make it forget about the system set MODULEPATH
2172
unset __LMOD_REF_COUNT_MODULEPATH
22-
# and clear out any memory Lmod might have
73+
# - and clear out any memory Lmod might have
2374
unset _ModuleTable001_
75+
2476
# Path to top-level module tree
77+
# - EESSI_EXTRA_MODULEPATH environment variable allows a site to append to MODULEPATH (lower priority than EESSI MODULEPATH)
2578
export MODULEPATH="${EESSI_CVMFS_REPO}/init/modules${EESSI_EXTRA_MODULEPATH:+:$EESSI_EXTRA_MODULEPATH}"
2679
. "${EESSI_CVMFS_REPO}/versions/${LMOD_EESSI_VERSION}/compat/linux/$(uname -m)/usr/share/Lmod/init/bash"
2780
module --initial_load --no_redirect restore

init/lmod/csh

Lines changed: 32 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,41 @@
1+
#!/usr/bin/env csh
2+
3+
# SPDX-License-Identifier: GPL-2.0-only
4+
# Copyright (C) 2020-2026 EESSI contributors
5+
#
6+
# EESSI - European Environment for Scientific Software Installations
7+
#
8+
# This file is a template for initialising EESSI via Lmod for the environment indicated by the shebang.
9+
#
10+
# Please refer to the reference bash implementation for full documentation, only minimal comments are included here
11+
112
# Choose an EESSI CVMFS repository
213
if ( ! $?EESSI_CVMFS_REPO) then
314
set EESSI_CVMFS_REPO = "/cvmfs/software.eessi.io"
415
endif
5-
# Choose an EESSI version
6-
setenv EESSI_VERSION_DEFAULT "__EESSI_VERSION_DEFAULT__"
7-
if ( ! $?EESSI_VERSION) then
8-
set EESSI_VERSION = "${EESSI_VERSION_DEFAULT}"
16+
17+
# Choose an EESSI version (default is used if EESSI_VERSION is not provided)
18+
if ( ! $?__EESSI_VERSION_USED_FOR_INIT ) then
19+
set EESSI_VERSION_DEFAULT = "__EESSI_VERSION_DEFAULT__"
20+
else
21+
set EESSI_VERSION_DEFAULT = "$__EESSI_VERSION_USED_FOR_INIT"
22+
endif
23+
if ( ! $?EESSI_VERSION ) then
24+
set EESSI_VERSION = "$EESSI_VERSION_DEFAULT"
25+
endif
26+
# On first run, record the EESSI version used for init as an environment variable.
27+
# We use setenv to ensure it is available to child processes (equivalent to export).
28+
if ( ! $?__EESSI_VERSION_USED_FOR_INIT ) then
29+
setenv __EESSI_VERSION_USED_FOR_INIT "$EESSI_VERSION"
930
endif
10-
# Now that we know our EESSI version let's not forget it
11-
setenv EESSI_VERSION_DEFAULT "${EESSI_VERSION}"
1231

1332
# ability to predefine elsewhere the default list (with options to append or prepend)
14-
set LMOD_SYSTEM_DEFAULT_MODULES="EESSI/${EESSI_VERSION}"
33+
set LMOD_SYSTEM_DEFAULT_MODULES = "EESSI/${EESSI_VERSION}"
1534
if ( $?EESSI_DEFAULT_MODULES_PREPEND ) then
16-
set LMOD_SYSTEM_DEFAULT_MODULES="${EESSI_DEFAULT_MODULES_PREPEND}:${LMOD_SYSTEM_DEFAULT_MODULES}"
35+
set LMOD_SYSTEM_DEFAULT_MODULES = "${EESSI_DEFAULT_MODULES_PREPEND}:${LMOD_SYSTEM_DEFAULT_MODULES}"
1736
endif
1837
if ( $?EESSI_DEFAULT_MODULES_APPEND ) then
19-
set LMOD_SYSTEM_DEFAULT_MODULES="${LMOD_SYSTEM_DEFAULT_MODULES}:${EESSI_DEFAULT_MODULES_APPEND}"
38+
set LMOD_SYSTEM_DEFAULT_MODULES = "${LMOD_SYSTEM_DEFAULT_MODULES}:${EESSI_DEFAULT_MODULES_APPEND}"
2039
endif
2140
setenv LMOD_SYSTEM_DEFAULT_MODULES "${LMOD_SYSTEM_DEFAULT_MODULES}"
2241

@@ -25,21 +44,21 @@ if ( ! $?__Init_EESSI_Default_Modules ) then
2544

2645
# Lmod version in 2023.06 has a problem with newer Lmod caches, so let's stick to more recent Lmod
2746
# (has no effect except on Lmod itself, and compatible caches are still created/supported by EESSI)
28-
set LMOD_EESSI_VERSION="${EESSI_VERSION}"
47+
set LMOD_EESSI_VERSION = "${EESSI_VERSION}"
2948
if ( "${LMOD_EESSI_VERSION}" == "2023.06" ) then
30-
set LMOD_EESSI_VERSION="2025.06"
49+
set LMOD_EESSI_VERSION = "2025.06"
3150
endif
3251

3352
# If there is a local Lmod, make it forget about the system set MODULEPATH
3453
unsetenv __LMOD_REF_COUNT_MODULEPATH
3554
# and clear out any memory Lmod might have
3655
unsetenv _ModuleTable001_
3756
# Path to top-level module tree
38-
set modulepath="${EESSI_CVMFS_REPO}/init/modules"
57+
set modulepath = "${EESSI_CVMFS_REPO}/init/modules"
3958
if ( $?EESSI_EXTRA_MODULEPATH ) then
4059
# Now that we know it exists, check IF it is not empty
4160
if ( "$EESSI_EXTRA_MODULEPATH" != "" ) then
42-
set modulepath="${modulepath}:${EESSI_EXTRA_MODULEPATH}"
61+
set modulepath = "${modulepath}:${EESSI_EXTRA_MODULEPATH}"
4362
endif
4463
endif
4564
setenv MODULEPATH "$modulepath"

init/lmod/fish

Lines changed: 25 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,31 @@
1+
#!/usr/bin/env fish
2+
3+
# SPDX-License-Identifier: GPL-2.0-only
4+
# Copyright (C) 2020-2026 EESSI contributors
5+
#
6+
# EESSI - European Environment for Scientific Software Installations
7+
#
8+
# This file is a template for initialising EESSI via Lmod for the environment indicated by the shebang.
9+
#
10+
# Please refer to the reference bash implementation for full documentation, only minimal comments are included here
11+
112
# Choose an EESSI CVMFS repository
213
set EESSI_CVMFS_REPO (set -q EESSI_CVMFS_REPO; and echo "$EESSI_CVMFS_REPO"; or echo "/cvmfs/software.eessi.io")
14+
315
# Choose an EESSI version
4-
set EESSI_VERSION_DEFAULT "__EESSI_VERSION_DEFAULT__"
5-
set EESSI_VERSION (set -q EESSI_VERSION; and echo "$EESSI_VERSION"; or echo "$EESSI_VERSION_DEFAULT")
6-
# Now that we know our EESSI version let's not forget it
7-
set -x EESSI_VERSION_DEFAULT "$EESSI_VERSION"
16+
if not set -q __EESSI_VERSION_USED_FOR_INIT
17+
set EESSI_VERSION_DEFAULT "__EESSI_VERSION_DEFAULT__"
18+
else
19+
set EESSI_VERSION_DEFAULT "$__EESSI_VERSION_USED_FOR_INIT"
20+
end
21+
if not set -q EESSI_VERSION
22+
set EESSI_VERSION "$EESSI_VERSION_DEFAULT"
23+
end
24+
25+
# Record version used for init; -x exports it to the environment
26+
if not set -q __EESSI_VERSION_USED_FOR_INIT
27+
set -x __EESSI_VERSION_USED_FOR_INIT "$EESSI_VERSION"
28+
end
829

930
# ability to predefine elsewhere the default list (with options to append or prepend)
1031
set LMOD_SYSTEM_DEFAULT_MODULES "EESSI/$EESSI_VERSION"

init/lmod/ksh

Lines changed: 21 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,27 @@
1+
#!/usr/bin/env ksh
2+
3+
# SPDX-License-Identifier: GPL-2.0-only
4+
# Copyright (C) 2020-2026 EESSI contributors
5+
#
6+
# EESSI - European Environment for Scientific Software Installations
7+
#
8+
# This file is a template for initialising EESSI via Lmod for the environment indicated by the shebang.
9+
#
10+
# Please refer to the reference bash implementation for full documentation, only minimal comments are included here
11+
112
# Choose an EESSI CVMFS repository
213
EESSI_CVMFS_REPO="${EESSI_CVMFS_REPO:-/cvmfs/software.eessi.io}"
3-
# Choose an EESSI version
4-
EESSI_VERSION_DEFAULT="__EESSI_VERSION_DEFAULT__"
14+
15+
# Choose an EESSI version (the default is only used if the EESSI_VERSION environment variable is not provided)
16+
EESSI_VERSION_DEFAULT="${__EESSI_VERSION_USED_FOR_INIT:-__EESSI_VERSION_DEFAULT__}"
517
EESSI_VERSION="${EESSI_VERSION:-${EESSI_VERSION_DEFAULT}}"
6-
# Now that we know our EESSI version let's not forget it
7-
export EESSI_VERSION_DEFAULT="$EESSI_VERSION"
18+
# On the first run we want to record the EESSI version used for init as an environment variable so that if a different
19+
# version of this script is called (e.g, for a a different EESSI version) it retains a memory which EESSI
20+
# version was actually used in the initialisation. This is useful as __Init_EESSI_Default_Modules used below will
21+
# be defined on the first call and Lmod initialisation will not happen twice.
22+
# This sets the value only on first execution, if the variable already exists in the environment
23+
# the original value is retained.
24+
export __EESSI_VERSION_USED_FOR_INIT="${__EESSI_VERSION_USED_FOR_INIT:-${EESSI_VERSION}}"
825

926
# ability to predefine elsewhere the default list (with options to append or prepend)
1027
LMOD_SYSTEM_DEFAULT_MODULES="${EESSI_DEFAULT_MODULES_PREPEND:+$EESSI_DEFAULT_MODULES_PREPEND:}EESSI/$EESSI_VERSION${EESSI_DEFAULT_MODULES_APPEND:+:$EESSI_DEFAULT_MODULES_APPEND}"

init/lmod/zsh

Lines changed: 21 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,27 @@
1+
#!/usr/bin/env zsh
2+
3+
# SPDX-License-Identifier: GPL-2.0-only
4+
# Copyright (C) 2020-2026 EESSI contributors
5+
#
6+
# EESSI - European Environment for Scientific Software Installations
7+
#
8+
# This file is a template for initialising EESSI via Lmod for the environment indicated by the shebang.
9+
#
10+
# Please refer to the reference bash implementation for full documentation, only minimal comments are included here
11+
112
# Choose an EESSI CVMFS repository
213
EESSI_CVMFS_REPO="${EESSI_CVMFS_REPO:-/cvmfs/software.eessi.io}"
3-
# Choose an EESSI version
4-
EESSI_VERSION_DEFAULT="__EESSI_VERSION_DEFAULT__"
14+
15+
# Choose an EESSI version (the default is only used if the EESSI_VERSION environment variable is not provided)
16+
EESSI_VERSION_DEFAULT="${__EESSI_VERSION_USED_FOR_INIT:-__EESSI_VERSION_DEFAULT__}"
517
EESSI_VERSION="${EESSI_VERSION:-${EESSI_VERSION_DEFAULT}}"
6-
# Now that we know our EESSI version let's not forget it
7-
export EESSI_VERSION_DEFAULT="$EESSI_VERSION"
18+
# On the first run we want to record the EESSI version used for init as an environment variable so that if a different
19+
# version of this script is called (e.g, for a a different EESSI version) it retains a memory which EESSI
20+
# version was actually used in the initialisation. This is useful as __Init_EESSI_Default_Modules used below will
21+
# be defined on the first call and Lmod initialisation will not happen twice.
22+
# This sets the value only on first execution, if the variable already exists in the environment
23+
# the original value is retained.
24+
export __EESSI_VERSION_USED_FOR_INIT="${__EESSI_VERSION_USED_FOR_INIT:-${EESSI_VERSION}}"
825

926
# ability to predefine elsewhere the default list (with options to append or prepend)
1027
LMOD_SYSTEM_DEFAULT_MODULES="${EESSI_DEFAULT_MODULES_PREPEND:+$EESSI_DEFAULT_MODULES_PREPEND:}EESSI/$EESSI_VERSION${EESSI_DEFAULT_MODULES_APPEND:+:$EESSI_DEFAULT_MODULES_APPEND}"

0 commit comments

Comments
 (0)