#!/bin/bash # # This wrapper try to remove system's unmodified environment variables # and propagate user environments on the nodes. # # This script is licence under the same licence as OAR program # GNU GENERAL PUBLIC LICENSE # http://oar.imag.fr/ # # 1.0 Nicolas Capit (initial version for PATH and LD_LIBRARY_PATH) # 1.1 Patrick Begou (all the environment excepted... that could make problems!) # 1.2 Gabriel Moreau (format, small bug and licence) # 1.3 Gabriel Moreau (add initial support for ulimit) # 1.4 Gabriel Moreau (add OMPI_MCA_orte_rsh_agent) # HOST=$1 shift MYOARSH=$(which oarsh) # GNU Profiler MYGMON="" if [ -n "$GMON_OUT_PREFIX" ] then MYGMON="export GMON_OUT_PREFIX="$(echo $GMON_OUT_PREFIX | sed "s/$HOSTNAME/\$HOSTNAME/;")";" fi # Ulimit support MYLIMIT="" for option in 's' 'l' 'n' do myvalue=$(ulimit "-$option") [ -n "$myvalue" ] && MYLIMIT="${MYLIMIT} ulimit -$option $myvalue;" done # Environment variable MYENV=$( env \ | grep "^[ABCDEFGHIJKLMNOPQRSTUVWXYZ]" \ | egrep -v "^USER=|^TERM=|^OAR|^SGE_|^LS_COLORS=\ |^ENV=|^BASH_ENV=|^BASH_FUNC_|^HOSTNAME=|^LOGNAME=|^MAIL=\ |^MANPATH=|^PWD=\ |^OMPI_MCA_orte_rsh_agent=|^OMPI_MCA_plm_rsh_agent=\ |^SHELL=|^SSH_|^SUDO_COMMAND=|^HOME=|^DISPLAY=\ |^SHLVL=" \ | sort \ | sed -e 's/^/export /; s/=/="/; s/$/"/' \ | tr [\\\n] [\;] ) exec $MYOARSH $HOST "$MYLIMIT $MYENV $MYGMON $@" exit ################################################################ Documentation in Perl POD format (man perlpod) =head1 NAME oar-envsh - oarsh with env variable transmit =head1 SYNOPSIS oar-envsh node command =head1 DESCRIPTION C need to be executed inside an OAR cluster. It's a simple wrapper around C command which is a wrapper around C command! With C, almost all env variable are export in the new shell except the following: USER TERM OAR* SGE_* LS_COLORS ENV BASH_ENV BASH_FUNC_* HOSTNAME LOGNAME MAIL MANPATH PWD OMPI_MCA_orte_rsh_agent OMPI_MCA_plm_rsh_agent SHELL SSH_* SUDO_COMMAND= HOME DISPLAY SHLVL Note: the variable GMON_OUT_PREFIX use by the GNU Profiler is exported if defined width the good C value on each node. With C, some ulimit are also transfert in the new shell. Actually, we only transfert: -l locked memory -n open files -s stack size Alway use C, only use C if really needed! =head1 SEE ALSO oarsh =head1 AUTHORS Written by : Nicolas Capit, Grenoble - France Patrick Begou - Gabriel Moreau, Grenoble - France =head1 LICENSE AND COPYRIGHT GPL version 2 or later Copyright (C) 2011-2015 Patrick Begou / LEGI - CNRS UMR 5519 - France =cut