source: trunk/oarutils/oar-envsh @ 326

Last change on this file since 326 was 115, checked in by g7moreau, 9 years ago
  • Path for oarsh
File size: 2.6 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
20MYOARSH=$(which oarsh)
21
22# GNU Profiler
23MYGMON=""
24if [ -n "$GMON_OUT_PREFIX" ]
25then
26   MYGMON="export GMON_OUT_PREFIX="$(echo $GMON_OUT_PREFIX | sed "s/$HOSTNAME/\$HOSTNAME/;")";"
27fi
28
29# Ulimit support
30MYLIMIT=""
31for option in 's' 'l' 'n'
32do
33   myvalue=$(ulimit "-$option")
34   [ -n "$myvalue" ] && MYLIMIT="${MYLIMIT} ulimit -$option $myvalue;"
35done
36
37# Environment variable
38MYENV=$( env \
39   | grep "^[ABCDEFGHIJKLMNOPQRSTUVWXYZ]" \
40   | egrep -v "^USER=|^TERM=|^OAR|^SGE_|^LS_COLORS=\
41      |^ENV=|^BASH_ENV=|^BASH_FUNC_|^HOSTNAME=|^LOGNAME=|^MAIL=\
42      |^MANPATH=|^PWD=\
43      |^OMPI_MCA_orte_rsh_agent=|^OMPI_MCA_plm_rsh_agent=\
44      |^SHELL=|^SSH_|^SUDO_COMMAND=|^HOME=|^DISPLAY=\
45      |^SHLVL=" \
46   | sort \
47   | sed -e 's/^/export /; s/=/="/; s/$/"/' \
48   | tr [\\\n] [\;] )
49
50exec $MYOARSH $HOST "$MYLIMIT $MYENV $MYGMON $@"
51
52exit
53
54################################################################
55
56Documentation 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
68C<oar-envsh> need to be executed inside an OAR cluster.
69It's a simple wrapper around C<oarsh> command
70which is a wrapper around C<ssh> command!
71
72With C<oar-envsh>, almost all env variable are export
73in the new shell except the following:
74
75 USER TERM OAR* SGE_* LS_COLORS
76 ENV BASH_ENV BASH_FUNC_*
77 HOSTNAME LOGNAME MAIL
78 MANPATH PWD
79 OMPI_MCA_orte_rsh_agent OMPI_MCA_plm_rsh_agent
80 SHELL SSH_* SUDO_COMMAND= HOME DISPLAY
81 SHLVL
82
83Note: the variable GMON_OUT_PREFIX use by the GNU Profiler is exported
84if defined width the good C<Hostname> value on each node.
85
86With C<oar-envsh>, some ulimit are also transfert in the new shell.
87Actually, we only transfert:
88
89 -l locked memory
90 -n open files
91 -s stack size
92
93Alway use C<oarsh>,
94only use C<oar-envsh> if really needed!
95
96
97=head1 SEE ALSO
98
99oarsh
100
101
102=head1 AUTHORS
103
104Written by :
105
106 Nicolas Capit, Grenoble - France
107 Patrick Begou - Gabriel Moreau, Grenoble - France
108
109
110=head1 LICENSE AND COPYRIGHT
111
112GPL version 2 or later
113
114Copyright (C) 2011-2015 Patrick Begou / LEGI - CNRS UMR 5519 - France
115
116=cut
Note: See TracBrowser for help on using the repository browser.