source: trunk/oarutils/oar-envsh @ 114

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