[16] | 1 | #!/bin/bash |
---|
| 2 | # |
---|
[18] | 3 | # This wrapper try to remove system's unmodified environment variables |
---|
| 4 | # and propagate user environments on the nodes. |
---|
[16] | 5 | # |
---|
[18] | 6 | # This script is licence under the same licence as OAR program |
---|
| 7 | # GNU GENERAL PUBLIC LICENSE |
---|
| 8 | # http://oar.imag.fr/ |
---|
[16] | 9 | # |
---|
[18] | 10 | # 1.0 Nicolas Capit (initial version for PATH and LD_LIBRARY_PATH) |
---|
| 11 | # 1.1 Patrick Begou (all the environment excepted... that could make problems!) |
---|
[20] | 12 | # 1.2 Gabriel Moreau (format, small bug and licence) |
---|
[106] | 13 | # 1.3 Gabriel Moreau (add initial support for ulimit) |
---|
[108] | 14 | # 1.4 Gabriel Moreau (add OMPI_MCA_orte_rsh_agent) |
---|
[18] | 15 | # |
---|
[16] | 16 | |
---|
| 17 | HOST=$1 |
---|
| 18 | shift |
---|
| 19 | |
---|
[115] | 20 | MYOARSH=$(which oarsh) |
---|
| 21 | |
---|
[111] | 22 | # GNU Profiler |
---|
[107] | 23 | MYGMON="" |
---|
| 24 | if [ -n "$GMON_OUT_PREFIX" ] |
---|
| 25 | then |
---|
| 26 | MYGMON="export GMON_OUT_PREFIX="$(echo $GMON_OUT_PREFIX | sed "s/$HOSTNAME/\$HOSTNAME/;")";" |
---|
| 27 | fi |
---|
| 28 | |
---|
[111] | 29 | # Ulimit support |
---|
[106] | 30 | MYLIMIT="" |
---|
| 31 | for option in 's' 'l' 'n' |
---|
| 32 | do |
---|
| 33 | myvalue=$(ulimit "-$option") |
---|
| 34 | [ -n "$myvalue" ] && MYLIMIT="${MYLIMIT} ulimit -$option $myvalue;" |
---|
| 35 | done |
---|
[104] | 36 | |
---|
[111] | 37 | # Environment variable |
---|
[16] | 38 | MYENV=$( env \ |
---|
| 39 | | grep "^[ABCDEFGHIJKLMNOPQRSTUVWXYZ]" \ |
---|
[18] | 40 | | egrep -v "^USER=|^TERM=|^OAR|^SGE_|^LS_COLORS=\ |
---|
[110] | 41 | |^ENV=|^BASH_ENV=|^BASH_FUNC_|^HOSTNAME=|^LOGNAME=|^MAIL=\ |
---|
[108] | 42 | |^MANPATH=|^PWD=\ |
---|
| 43 | |^OMPI_MCA_orte_rsh_agent=|^OMPI_MCA_plm_rsh_agent=\ |
---|
[18] | 44 | |^SHELL=|^SSH_|^SUDO_COMMAND=|^HOME=|^DISPLAY=\ |
---|
| 45 | |^SHLVL=" \ |
---|
[16] | 46 | | sort \ |
---|
[20] | 47 | | sed -e 's/^/export /; s/=/="/; s/$/"/' \ |
---|
[16] | 48 | | tr [\\\n] [\;] ) |
---|
| 49 | |
---|
[115] | 50 | exec $MYOARSH $HOST "$MYLIMIT $MYENV $MYGMON $@" |
---|
[29] | 51 | |
---|
| 52 | exit |
---|
| 53 | |
---|
| 54 | ################################################################ |
---|
| 55 | |
---|
| 56 | Documentation in Perl POD format (man perlpod) |
---|
| 57 | |
---|
| 58 | =head1 NAME |
---|
| 59 | |
---|
| 60 | oar-envsh - oarsh with env variable transmit |
---|
| 61 | |
---|
| 62 | =head1 SYNOPSIS |
---|
| 63 | |
---|
| 64 | oar-envsh node command |
---|
| 65 | |
---|
| 66 | =head1 DESCRIPTION |
---|
| 67 | |
---|
| 68 | C<oar-envsh> need to be executed inside an OAR cluster. |
---|
| 69 | It's a simple wrapper around C<oarsh> command |
---|
| 70 | which is a wrapper around C<ssh> command! |
---|
| 71 | |
---|
| 72 | With C<oar-envsh>, almost all env variable are export |
---|
| 73 | in the new shell except the following: |
---|
| 74 | |
---|
| 75 | USER TERM OAR* SGE_* LS_COLORS |
---|
[110] | 76 | ENV BASH_ENV BASH_FUNC_* |
---|
| 77 | HOSTNAME LOGNAME MAIL |
---|
[108] | 78 | MANPATH PWD |
---|
| 79 | OMPI_MCA_orte_rsh_agent OMPI_MCA_plm_rsh_agent |
---|
[29] | 80 | SHELL SSH_* SUDO_COMMAND= HOME DISPLAY |
---|
| 81 | SHLVL |
---|
| 82 | |
---|
[114] | 83 | Note: the variable GMON_OUT_PREFIX use by the GNU Profiler is exported |
---|
| 84 | if defined width the good C<Hostname> value on each node. |
---|
| 85 | |
---|
[106] | 86 | With C<oar-envsh>, some ulimit are also transfert in the new shell. |
---|
| 87 | Actually, we only transfert: |
---|
| 88 | |
---|
| 89 | -l locked memory |
---|
| 90 | -n open files |
---|
| 91 | -s stack size |
---|
| 92 | |
---|
[29] | 93 | Alway use C<oarsh>, |
---|
| 94 | only use C<oar-envsh> if really needed! |
---|
| 95 | |
---|
| 96 | |
---|
| 97 | =head1 SEE ALSO |
---|
| 98 | |
---|
| 99 | oarsh |
---|
| 100 | |
---|
| 101 | |
---|
| 102 | =head1 AUTHORS |
---|
| 103 | |
---|
| 104 | Written by : |
---|
| 105 | |
---|
| 106 | Nicolas Capit, Grenoble - France |
---|
| 107 | Patrick Begou - Gabriel Moreau, Grenoble - France |
---|
| 108 | |
---|
| 109 | |
---|
| 110 | =head1 LICENSE AND COPYRIGHT |
---|
| 111 | |
---|
| 112 | GPL version 2 or later |
---|
| 113 | |
---|
[108] | 114 | Copyright (C) 2011-2015 Patrick Begou / LEGI - CNRS UMR 5519 - France |
---|
[29] | 115 | |
---|
| 116 | =cut |
---|