/[metamod]/trunk/activate_env
ViewVC logotype

Contents of /trunk/activate_env

Parent Directory Parent Directory | Revision Log Revision Log


Revision 2422 - (show annotations) (download)
Tue Jul 9 08:17:56 2013 UTC (7 years, 1 month ago) by geira
File size: 3031 byte(s)
added perl version of python's virtualenv (needed for uwsgi)
- generates env script into config dir
- activate_env is now deprecated

1 # Create an environment for running METAMOD from the commandline.
2 # This is just a convenience for setting the correct lib paths and
3 # master config environment
4 #
5 # This file must be used with "source activate_env" *from bash*
6 # you cannot run it directly
7 #
8 # This file has been more or less copied from what virtualenv creates.
9
10 deactivate_mm () {
11
12 if [ -n "$_OLD_VIRTUAL_PERL5LIB" ] ; then
13 export PERL5LIB="$_OLD_VIRTUAL_PERL5LIB"
14 else
15 unset PERL5LIB
16 fi
17 unset _OLD_VIRTUAL_PERL5LIB
18
19
20 # This should detect bash and zsh, which have a hash command that must
21 # be called to get it to forget past commands. Without forgetting
22 # past commands the $PATH changes we made may not be respected
23 if [ -n "$BASH" -o -n "$ZSH_VERSION" ] ; then
24 hash -r
25 fi
26
27 if [ -n "$_OLD_VIRTUAL_PS1" ] ; then
28 PS1="$_OLD_VIRTUAL_PS1"
29 export PS1
30 unset _OLD_VIRTUAL_PS1
31 fi
32
33 if [ -n "$_OLD_VIRTUAL_PATH" ] ; then
34 PATH="$_OLD_VIRTUAL_PATH"
35 export PATH
36 unset _OLD_VIRTUAL_PATH
37 fi
38
39 if [ ! "$1" = "nondestructive" ]
40 then
41 # Self destruct!
42 unset -f deactivate_mm
43 fi
44 }
45
46 activate_mm() {
47
48 # unset irrelavent variables
49 deactivate_mm nondestructive
50
51 METAMOD_MASTER_CONFIG=`readlink -f $1`
52 export METAMOD_MASTER_CONFIG
53
54 _OLD_VIRTUAL_PATH="$PATH"
55
56 # we are sourcing the file so we cannot use dirname $0 to find the location of the script
57 SCRIPT_PATH=`readlink -f ${BASH_SOURCE[0]}`
58 SCRIPT_PATH=`dirname $SCRIPT_PATH`
59 PATH=$PATH:"$SCRIPT_PATH/base/init":"$SCRIPT_PATH/base/userinit":"$SCRIPT_PATH/common":"$SCRIPT_PATH/common/scripts":"$SCRIPT_PATH/catalyst/script"
60 export PATH
61
62 export _OLD_VIRTUAL_PERL5LIB="$PERL5LIB"
63 if [ -e "$SCRIPT_PATH/local/lib/perl5" ] ; then
64 export PERL5LIB=$PERL5LIB:"$SCRIPT_PATH/local/lib/perl5"
65 else
66 # FIXME find a way to update version number automagically
67 export PERL5LIB=$PERL5LIB:"/opt/metno-metamod-2.13/local/lib/perl5"
68 # should ideally use CATALYST_LIB, but config params not available
69 fi
70
71 _OLD_VIRTUAL_PS1="$PS1"
72 if [ -f $1 ] ; then
73 PS1="(`dirname \"$METAMOD_MASTER_CONFIG\"`)$PS1"
74 else
75 PS1="(`dirname \"$METAMOD_MASTER_CONFIG\"`/`basename \"$METAMOD_MASTER_CONFIG\"`)$PS1"
76 fi
77 export PS1
78
79 # This should detect bash and zsh, which have a hash command that must
80 # be called to get it to forget past commands. Without forgetting
81 # past commands the $PATH changes we made may not be respected
82 if [ -n "$BASH" -o -n "$ZSH_VERSION" ] ; then
83 hash -r
84 fi
85 }
86
87 echo "This script has been deprecated. Use common/script/virtualenv.pl to generate $METAMOD_MASTER_CONFIG/bin/activate instead."
88
89 if [ $# != 1 ]
90 then
91 echo "You must supply the config dir as a parameter, or -d (deactivate)"
92 else
93 if [[ $1 == 'deactivate' || $1 == '-d' ]] ; then
94 deactivate_mm
95 # or you could just type "deactivate_mm" instead of running this script
96 else
97 activate_mm $1
98 fi
99 fi

Properties

Name Value
svn:executable *

svn@met.no
ViewVC Help
Powered by ViewVC 1.1.5