source: trunk/oarutils/oar-envsh @ 107

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