source: trunk/oarutils/oar-envsh @ 114

Last change on this file since 114 was 114, checked in by g7moreau, 9 years ago
  • Add doc about GMON_OUT_PREFIX
File size: 2.6 KB
RevLine 
[16]1#!/bin/bash
2#
[18]3# This wrapper try to remove system's unmodified environment variables
4# and propagate user environments on the nodes.
[16]5#
[18]6# This script is licence under the same licence as OAR program
7#  GNU GENERAL PUBLIC LICENSE
8#  http://oar.imag.fr/
[16]9#
[18]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!)
[20]12# 1.2 Gabriel Moreau (format, small bug and licence)
[106]13# 1.3 Gabriel Moreau (add initial support for ulimit)
[108]14# 1.4 Gabriel Moreau (add OMPI_MCA_orte_rsh_agent)
[18]15#
[16]16
17HOST=$1
18shift
19
[111]20# GNU Profiler
[107]21MYGMON=""
22if [ -n "$GMON_OUT_PREFIX" ]
23then
24   MYGMON="export GMON_OUT_PREFIX="$(echo $GMON_OUT_PREFIX | sed "s/$HOSTNAME/\$HOSTNAME/;")";"
25fi
26
[111]27# Ulimit support
[106]28MYLIMIT=""
29for option in 's' 'l' 'n'
30do
31   myvalue=$(ulimit "-$option")
32   [ -n "$myvalue" ] && MYLIMIT="${MYLIMIT} ulimit -$option $myvalue;"
33done
[104]34
[111]35# Environment variable
[16]36MYENV=$( env \
37   | grep "^[ABCDEFGHIJKLMNOPQRSTUVWXYZ]" \
[18]38   | egrep -v "^USER=|^TERM=|^OAR|^SGE_|^LS_COLORS=\
[110]39      |^ENV=|^BASH_ENV=|^BASH_FUNC_|^HOSTNAME=|^LOGNAME=|^MAIL=\
[108]40      |^MANPATH=|^PWD=\
41      |^OMPI_MCA_orte_rsh_agent=|^OMPI_MCA_plm_rsh_agent=\
[18]42      |^SHELL=|^SSH_|^SUDO_COMMAND=|^HOME=|^DISPLAY=\
43      |^SHLVL=" \
[16]44   | sort \
[20]45   | sed -e 's/^/export /; s/=/="/; s/$/"/' \
[16]46   | tr [\\\n] [\;] )
47
[107]48exec /opt/oar/current/bin/oarsh $HOST "$MYLIMIT $MYENV $MYGMON $@"
[29]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
[110]74 ENV BASH_ENV BASH_FUNC_*
75 HOSTNAME LOGNAME MAIL
[108]76 MANPATH PWD
77 OMPI_MCA_orte_rsh_agent OMPI_MCA_plm_rsh_agent
[29]78 SHELL SSH_* SUDO_COMMAND= HOME DISPLAY
79 SHLVL
80
[114]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
[106]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
[29]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
[108]112Copyright (C) 2011-2015 Patrick Begou / LEGI - CNRS UMR 5519 - France
[29]113
114=cut
Note: See TracBrowser for help on using the repository browser.