source: trunk/oarutils/oar-envsh

Last change on this file was 115, checked in by g7moreau, 8 years ago
  • Path for oarsh
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
[115]20MYOARSH=$(which oarsh)
21
[111]22# GNU Profiler
[107]23MYGMON=""
24if [ -n "$GMON_OUT_PREFIX" ]
25then
26   MYGMON="export GMON_OUT_PREFIX="$(echo $GMON_OUT_PREFIX | sed "s/$HOSTNAME/\$HOSTNAME/;")";"
27fi
28
[111]29# Ulimit support
[106]30MYLIMIT=""
31for option in 's' 'l' 'n'
32do
33   myvalue=$(ulimit "-$option")
34   [ -n "$myvalue" ] && MYLIMIT="${MYLIMIT} ulimit -$option $myvalue;"
35done
[104]36
[111]37# Environment variable
[16]38MYENV=$( env \
39   | grep "^[ABCDEFGHIJKLMNOPQRSTUVWXYZ]" \
[18]40   | egrep -v "^USER=|^TERM=|^OAR|^SGE_|^LS_COLORS=\
[110]41      |^ENV=|^BASH_ENV=|^BASH_FUNC_|^HOSTNAME=|^LOGNAME=|^MAIL=\
[108]42      |^MANPATH=|^PWD=\
43      |^OMPI_MCA_orte_rsh_agent=|^OMPI_MCA_plm_rsh_agent=\
[18]44      |^SHELL=|^SSH_|^SUDO_COMMAND=|^HOME=|^DISPLAY=\
45      |^SHLVL=" \
[16]46   | sort \
[20]47   | sed -e 's/^/export /; s/=/="/; s/$/"/' \
[16]48   | tr [\\\n] [\;] )
49
[115]50exec $MYOARSH $HOST "$MYLIMIT $MYENV $MYGMON $@"
[29]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
[110]76 ENV BASH_ENV BASH_FUNC_*
77 HOSTNAME LOGNAME MAIL
[108]78 MANPATH PWD
79 OMPI_MCA_orte_rsh_agent OMPI_MCA_plm_rsh_agent
[29]80 SHELL SSH_* SUDO_COMMAND= HOME DISPLAY
81 SHLVL
82
[114]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
[106]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
[29]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
[108]114Copyright (C) 2011-2015 Patrick Begou / LEGI - CNRS UMR 5519 - France
[29]115
116=cut
Note: See TracBrowser for help on using the repository browser.