| 1 |
# |
| 2 |
# siteconfig.tcl - Site specific configuration script exposing additional |
| 3 |
# procedures and variables to the modulefile and modulerc evaluation |
| 4 |
# contexts |
| 5 |
# |
| 6 |
# Author: Xavier Delaruelle <[email protected]> |
| 7 |
# Compatibility: Modules v4.2+ |
| 8 |
# |
| 9 |
# Installation: put this file in the 'etc' directory of your Modules |
| 10 |
# installation. Refer to the "Modulecmd startup" section in the |
| 11 |
# module(1) man page to get this location. |
| 12 |
|
| 13 |
# append site-specific procedures referenced in the g_siteProcsToExposeToItrp |
| 14 |
# variable defined below to the list of procedures exposed in the modulefile |
| 15 |
# and modulerc evaluation interpreters |
| 16 |
proc addSiteProcsToItrpAliasList {itrpaliasvname keyname args} { |
| 17 |
# ensure this proc is only called once at itrpaliasvname initialization |
| 18 |
trace remove variable $itrpaliasvname write addSiteProcsToItrpAliasList |
| 19 |
upvar #0 $itrpaliasvname itrpaliasv |
| 20 |
# register each site-specific procedure |
| 21 |
foreach procname $::g_siteProcsToExposeToItrp { |
| 22 |
if {$keyname ne {}} { |
| 23 |
set itrpaliasv($procname) $procname |
| 24 |
} else { |
| 25 |
lappend itrpaliasv $procname $procname |
| 26 |
} |
| 27 |
} |
| 28 |
} |
| 29 |
trace add variable ::g_modfileBaseAliases write addSiteProcsToItrpAliasList |
| 30 |
trace add variable ::g_modrcAliases write addSiteProcsToItrpAliasList |
| 31 |
|
| 32 |
|
| 33 |
# Define here site-specific procedures that should be exposed to modulefile |
| 34 |
# and modulerc interpreter contexts |
| 35 |
# *Beware* not to override an existing procedure of modulecmd.tcl script |
| 36 |
proc mysiteproc {} { |
| 37 |
return sitevalue |
| 38 |
} |
| 39 |
|
| 40 |
# list all site-specific procedures to expose to modulefile and modulerc |
| 41 |
# interpreter contexts |
| 42 |
set g_siteProcsToExposeToItrp [list mysiteproc] |
| 43 |
|
| 44 |
# Define here site-specific variables that should be exposed to modulefile |
| 45 |
# and modulerc interpreter contexts. Use environment variable env array to |
| 46 |
# transmit these variables |
| 47 |
# *Beware* not to override an existing environment variable |
| 48 |
set env(mysitevar) sitevarvalue |
| 49 |
|
| 50 |
# vim:set tabstop=3 shiftwidth=3 expandtab autoindent: |