source: trunk/oarutils/oar-envsh @ 111

Last change on this file since 111 was 111, checked in by g7moreau, 11 years ago
  • Just update comment !
File size: 2.5 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
81With C<oar-envsh>, some ulimit are also transfert in the new shell.
82Actually, we only transfert:
83
84 -l locked memory
85 -n open files
86 -s stack size
87
88Alway use C<oarsh>,
89only use C<oar-envsh> if really needed!
90
91
92=head1 SEE ALSO
93
94oarsh
95
96
97=head1 AUTHORS
98
99Written by :
100
101 Nicolas Capit, Grenoble - France
102 Patrick Begou - Gabriel Moreau, Grenoble - France
103
104
105=head1 LICENSE AND COPYRIGHT
106
107GPL version 2 or later
108
109Copyright (C) 2011-2015 Patrick Begou / LEGI - CNRS UMR 5519 - France
110
111=cut
Note: See TracBrowser for help on using the repository browser.