source: trunk/oarutils/oar-envsh @ 106

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