1- #! /usr/bin/env bash
1+ #! /usr/bin/env sh
22
33# SPDX-License-Identifier: GPL-2.0-only
44# Copyright (C) 2020-2026 EESSI contributors
@@ -49,7 +49,12 @@ EESSI_CVMFS_REPO="${EESSI_CVMFS_REPO:-/cvmfs/software.eessi.io}"
4949# (Note: in the repository which is home to this file a template value __EESSI_VERSION_DEFAULT__ is present in
5050# the line below which is replaced within our deployment pipeline.)
5151EESSI_VERSION_DEFAULT=" ${__EESSI_VERSION_USED_FOR_INIT:- __EESSI_VERSION_DEFAULT__} "
52- EESSI_VERSION=" ${EESSI_VERSION:- ${EESSI_VERSION_DEFAULT} } "
52+ if [ -z " $__Init_EESSI_Default_Modules " ]; then
53+ EESSI_VERSION=" ${EESSI_VERSION:- ${EESSI_VERSION_DEFAULT} } "
54+ else
55+ # If we have already initiaised and this is being called again, then we must want the specific version
56+ EESSI_VERSION=" __EESSI_VERSION_DEFAULT__"
57+ fi
5358# On the first run we want to record the EESSI version used for init as an environment variable so that if a different
5459# version of this script is called (e.g, for a a different EESSI version) it retains a memory which EESSI
5560# version was actually used in the initialisation. This is useful as __Init_EESSI_Default_Modules used below will
@@ -75,7 +80,7 @@ if [ -z "$__Init_EESSI_Default_Modules" ]; then
7580
7681 # Lmod version in 2023.06 has a problem with newer Lmod caches, so let's stick to more recent Lmod
7782 # (has no effect except on Lmod itself, and compatible caches are still created/supported by EESSI)
78- LMOD_EESSI_VERSION=${ EESSI_VERSION/ 2023.06/ 2025.06}
83+ LMOD_EESSI_VERSION=$( printf ' %s\n ' " $ EESSI_VERSION" | sed ' s /2023\ .06/2025\ .06/ ' )
7984
8085 # Let's attempt a purge of any loaded modules as any environment variables currently set will survive EESSI initialisation
8186 # (it's ok if the module command does not exist)
@@ -96,10 +101,21 @@ if [ -z "$__Init_EESSI_Default_Modules" ]; then
96101 export EESSI_MODULE_UPDATE_PS1=1
97102 fi
98103
104+ # Figure out what shell we have
105+ if [ -n " ${BASH_VERSION-} " ]; then
106+ shell=bash
107+ elif [ -n " ${ZSH_VERSION-} " ]; then
108+ shell=zsh
109+ elif [ -n " ${KSH_VERSION-} " ]; then
110+ shell=ksh
111+ else
112+ shell=sh
113+ fi
114+
99115 # Path to top-level module tree
100116 # - EESSI_EXTRA_MODULEPATH environment variable allows a site to append to MODULEPATH (lower priority than EESSI MODULEPATH)
101117 export MODULEPATH=" ${EESSI_CVMFS_REPO} /init/modules${EESSI_EXTRA_MODULEPATH: +: $EESSI_EXTRA_MODULEPATH } "
102- . " ${EESSI_CVMFS_REPO} /versions/${LMOD_EESSI_VERSION} /compat/linux/$( uname -m) /usr/share/Lmod/init/bash "
118+ . " ${EESSI_CVMFS_REPO} /versions/${LMOD_EESSI_VERSION} /compat/linux/$( uname -m) /usr/share/Lmod/init/${shell} "
103119 module --initial_load --no_redirect restore
104120
105121 # After initialising, we now know the architecture(s) that was/were selected so let's report them
0 commit comments