Skip to content

Commit f5d95fa

Browse files
yarikopticJakub Kaczmarzyk
authored andcommitted
BF: set $USER to output of whoami if env var USER is not defined (#270)
* BF: set $USER to output of whoami if env var USER is not defined Current use case is a singularity image, which is ran with -e to avoid side effects from env vars on the host box. But USER variable is often used/relied upon different tools. Immediate use case - FSL 6.0.1 $ DISPLAY=:0 fsl Error in startup script: can't read "env(USER)": no such variable while executing "set USER $env(USER)" (file "/opt/fsl-6.0.1/tcl/fslstart.tcl" line 6) invoked from within "source [ file dirname [ info script ] ]/fslstart.tcl" (file "/opt/fsl-6.0.1/tcl/fsl.tcl" line 71) invoked from within "source ${FSLDIR}/tcl/${origname}.tcl" (file "/opt/fsl-6.0.1/bin/fsl" line 22) but I thought it would generally be useful and should not have side-effects, that is why added to the generic startup script. The only concern I just got is reprozip minimized images -- would they have whoami? But even then, the situation should not be grave since `whoami` seems to be not executed if USER is defined, so should generally work ;) * BF: USER variable must be exported
1 parent 78570bf commit f5d95fa

File tree

1 file changed

+1
-0
lines changed

1 file changed

+1
-0
lines changed

neurodocker/templates/_header.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ generic:
2525
if [ ! -f "$ND_ENTRYPOINT" ]; then
2626
echo '#!/usr/bin/env bash' >> "$ND_ENTRYPOINT"
2727
echo 'set -e' >> "$ND_ENTRYPOINT"
28+
echo 'export USER="${USER:=`whoami`}"' >> "$ND_ENTRYPOINT"
2829
echo 'if [ -n "$1" ]; then "$@"; else /usr/bin/env bash; fi' >> "$ND_ENTRYPOINT";
2930
fi
3031
chmod -R 777 /neurodocker && chmod a+s /neurodocker

0 commit comments

Comments
 (0)