[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) |
---|
[18] | 14 | # |
---|
[16] | 15 | |
---|
| 16 | HOST=$1 |
---|
| 17 | shift |
---|
| 18 | |
---|
[107] | 19 | MYGMON="" |
---|
| 20 | if [ -n "$GMON_OUT_PREFIX" ] |
---|
| 21 | then |
---|
| 22 | MYGMON="export GMON_OUT_PREFIX="$(echo $GMON_OUT_PREFIX | sed "s/$HOSTNAME/\$HOSTNAME/;")";" |
---|
| 23 | fi |
---|
| 24 | |
---|
[106] | 25 | MYLIMIT="" |
---|
| 26 | for option in 's' 'l' 'n' |
---|
| 27 | do |
---|
| 28 | myvalue=$(ulimit "-$option") |
---|
| 29 | [ -n "$myvalue" ] && MYLIMIT="${MYLIMIT} ulimit -$option $myvalue;" |
---|
| 30 | done |
---|
[104] | 31 | |
---|
[16] | 32 | MYENV=$( env \ |
---|
| 33 | | grep "^[ABCDEFGHIJKLMNOPQRSTUVWXYZ]" \ |
---|
[18] | 34 | | egrep -v "^USER=|^TERM=|^OAR|^SGE_|^LS_COLORS=\ |
---|
| 35 | |^ENV=|^BASH_ENV=|^HOSTNAME=|^LOGNAME=|^MAIL=\ |
---|
| 36 | |^MANPATH=|^OMPI_MCA_plm_rsh_agent=|^PWD=\ |
---|
| 37 | |^SHELL=|^SSH_|^SUDO_COMMAND=|^HOME=|^DISPLAY=\ |
---|
| 38 | |^SHLVL=" \ |
---|
[16] | 39 | | sort \ |
---|
[20] | 40 | | sed -e 's/^/export /; s/=/="/; s/$/"/' \ |
---|
[16] | 41 | | tr [\\\n] [\;] ) |
---|
| 42 | |
---|
[107] | 43 | exec /opt/oar/current/bin/oarsh $HOST "$MYLIMIT $MYENV $MYGMON $@" |
---|
[29] | 44 | |
---|
| 45 | exit |
---|
| 46 | |
---|
| 47 | ################################################################ |
---|
| 48 | |
---|
| 49 | Documentation in Perl POD format (man perlpod) |
---|
| 50 | |
---|
| 51 | =head1 NAME |
---|
| 52 | |
---|
| 53 | oar-envsh - oarsh with env variable transmit |
---|
| 54 | |
---|
| 55 | =head1 SYNOPSIS |
---|
| 56 | |
---|
| 57 | oar-envsh node command |
---|
| 58 | |
---|
| 59 | =head1 DESCRIPTION |
---|
| 60 | |
---|
| 61 | C<oar-envsh> need to be executed inside an OAR cluster. |
---|
| 62 | It's a simple wrapper around C<oarsh> command |
---|
| 63 | which is a wrapper around C<ssh> command! |
---|
| 64 | |
---|
| 65 | With C<oar-envsh>, almost all env variable are export |
---|
| 66 | in the new shell except the following: |
---|
| 67 | |
---|
| 68 | USER TERM OAR* SGE_* LS_COLORS |
---|
| 69 | ENV BASH_ENV HOSTNAME LOGNAME MAIL |
---|
| 70 | MANPATH OMPI_MCA_plm_rsh_agent PWD |
---|
| 71 | SHELL SSH_* SUDO_COMMAND= HOME DISPLAY |
---|
| 72 | SHLVL |
---|
| 73 | |
---|
[106] | 74 | With C<oar-envsh>, some ulimit are also transfert in the new shell. |
---|
| 75 | Actually, we only transfert: |
---|
| 76 | |
---|
| 77 | -l locked memory |
---|
| 78 | -n open files |
---|
| 79 | -s stack size |
---|
| 80 | |
---|
[29] | 81 | Alway use C<oarsh>, |
---|
| 82 | only use C<oar-envsh> if really needed! |
---|
| 83 | |
---|
| 84 | |
---|
| 85 | =head1 SEE ALSO |
---|
| 86 | |
---|
| 87 | oarsh |
---|
| 88 | |
---|
| 89 | |
---|
| 90 | =head1 AUTHORS |
---|
| 91 | |
---|
| 92 | Written by : |
---|
| 93 | |
---|
| 94 | Nicolas Capit, Grenoble - France |
---|
| 95 | Patrick Begou - Gabriel Moreau, Grenoble - France |
---|
| 96 | |
---|
| 97 | |
---|
| 98 | =head1 LICENSE AND COPYRIGHT |
---|
| 99 | |
---|
| 100 | GPL version 2 or later |
---|
| 101 | |
---|
[106] | 102 | Copyright (C) 2011-2014 Patrick Begou / LEGI - CNRS UMR 5519 - France |
---|
[29] | 103 | |
---|
| 104 | =cut |
---|