source: trunk/oarutils/oar-envsh @ 108

Last change on this file since 108 was 108, checked in by g7moreau, 9 years ago
  • Add support for OMPI_MCA_orte_rsh_agent
File size: 2.4 KB
Line 
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
17HOST=$1
18shift
19
20MYGMON=""
21if [ -n "$GMON_OUT_PREFIX" ]
22then
23   MYGMON="export GMON_OUT_PREFIX="$(echo $GMON_OUT_PREFIX | sed "s/$HOSTNAME/\$HOSTNAME/;")";"
24fi
25
26MYLIMIT=""
27for option in 's' 'l' 'n'
28do
29   myvalue=$(ulimit "-$option")
30   [ -n "$myvalue" ] && MYLIMIT="${MYLIMIT} ulimit -$option $myvalue;"
31done
32
33MYENV=$( 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
45exec /opt/oar/current/bin/oarsh $HOST "$MYLIMIT $MYENV $MYGMON $@"
46
47exit
48
49################################################################
50
51Documentation 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
63C<oar-envsh> need to be executed inside an OAR cluster.
64It's a simple wrapper around C<oarsh> command
65which is a wrapper around C<ssh> command!
66
67With C<oar-envsh>, almost all env variable are export
68in 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
77With C<oar-envsh>, some ulimit are also transfert in the new shell.
78Actually, we only transfert:
79
80 -l locked memory
81 -n open files
82 -s stack size
83
84Alway use C<oarsh>,
85only use C<oar-envsh> if really needed!
86
87
88=head1 SEE ALSO
89
90oarsh
91
92
93=head1 AUTHORS
94
95Written by :
96
97 Nicolas Capit, Grenoble - France
98 Patrick Begou - Gabriel Moreau, Grenoble - France
99
100
101=head1 LICENSE AND COPYRIGHT
102
103GPL version 2 or later
104
105Copyright (C) 2011-2015 Patrick Begou / LEGI - CNRS UMR 5519 - France
106
107=cut
Note: See TracBrowser for help on using the repository browser.