source: trunk/oarutils/oar-envsh @ 110

Last change on this file since 110 was 110, checked in by g7moreau, 9 years ago
  • No transmit bash function
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=|^BASH_FUNC_|^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 BASH_FUNC_*
72 HOSTNAME LOGNAME MAIL
73 MANPATH PWD
74 OMPI_MCA_orte_rsh_agent OMPI_MCA_plm_rsh_agent
75 SHELL SSH_* SUDO_COMMAND= HOME DISPLAY
76 SHLVL
77
78With C<oar-envsh>, some ulimit are also transfert in the new shell.
79Actually, we only transfert:
80
81 -l locked memory
82 -n open files
83 -s stack size
84
85Alway use C<oarsh>,
86only use C<oar-envsh> if really needed!
87
88
89=head1 SEE ALSO
90
91oarsh
92
93
94=head1 AUTHORS
95
96Written by :
97
98 Nicolas Capit, Grenoble - France
99 Patrick Begou - Gabriel Moreau, Grenoble - France
100
101
102=head1 LICENSE AND COPYRIGHT
103
104GPL version 2 or later
105
106Copyright (C) 2011-2015 Patrick Begou / LEGI - CNRS UMR 5519 - France
107
108=cut
Note: See TracBrowser for help on using the repository browser.