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