Skip to content

Commit 4f7951f

Browse files
jdidiongeetduggal
authored andcommitted
First draft of an environment file for fish shell (#359)
1 parent 93ea0fd commit 4f7951f

File tree

1 file changed

+81
-0
lines changed

1 file changed

+81
-0
lines changed

environment.fish

+81
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
# -*- Mode: shell-script -*-
2+
#
3+
# Copyright (C) 2013-2016 DNAnexus, Inc.
4+
#
5+
# This file is part of dx-toolkit (DNAnexus platform client libraries).
6+
#
7+
# Licensed under the Apache License, Version 2.0 (the "License"); you may not
8+
# use this file except in compliance with the License. You may obtain a copy
9+
# of the License at
10+
#
11+
# http://www.apache.org/licenses/LICENSE-2.0
12+
#
13+
# Unless required by applicable law or agreed to in writing, software
14+
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
15+
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
16+
# License for the specific language governing permissions and limitations
17+
# under the License.
18+
#
19+
#
20+
# Source this file in a fish shell to initialize DNAnexus environment
21+
# variables:
22+
# $ source environment.fish
23+
24+
if test ! -n "$version" -a -n "(echo $SHELL | grep -q fish)"
25+
echo "You are not using fish shell. Try 'environment' or 'environment.csh' instead."
26+
exit
27+
end
28+
29+
set SOURCE (status --current-filename)
30+
31+
while test -L "$SOURCE"
32+
set SOURCE (readlink "$SOURCE")
33+
end
34+
35+
switch (uname)
36+
case Darwin FreeBSD NetBSD DragonFly
37+
set -x DNANEXUS_HOME ( dirname (realpath "$SOURCE" ) )
38+
case Linux
39+
set -x DNANEXUS_HOME ( cd -P ( dirname "$SOURCE" ) ; pwd )
40+
case '*'
41+
echo "It doesn't look like you're on a linux system"
42+
end
43+
44+
# Get RHEL version
45+
if test -e /etc/redhat-release
46+
set RHEL_MAJOR_VERSION (grep -o "Red Hat Enterprise Linux .* release [0-9]\+" /etc/redhat-release | sed -e "s/Red Hat Enterprise Linux .* release //")
47+
end
48+
49+
# Detect system installation of dx-toolkit
50+
if [ "$DNANEXUS_HOME" = "/etc/profile.d" ]
51+
set -x DNANEXUS_HOME "/usr/share/dnanexus"
52+
# Private Python packages. We really ought not pollute PYTHONPATH with these though.
53+
set -xg PYTHONPATH /usr/share/dnanexus/lib/python2.7/site-packages $PYTHONPATH
54+
set -xg CLASSPATH /usr/share/java/dnanexus-api-0.1.0.jar $CLASSPATH
55+
else
56+
set -x PATH $DNANEXUS_HOME/bin $PATH
57+
set -xg CLASSPATH $DNANEXUS_HOME/lib/java/*/ $CLASSPATH
58+
59+
if [ "$RHEL_MAJOR_VERSION" = "7" ]
60+
set -xg PYTHONPATH $DNANEXUS_HOME/share/dnanexus/lib/python2.7/site-packages:$DNANEXUS_HOME/lib64/python2.7/site-packages $PYTHONPATH
61+
else
62+
set -xg PYTHONPATH $DNANEXUS_HOME/share/dnanexus/lib/python2.7/site-packages:$DNANEXUS_HOME/lib/python2.7 $PYTHONPATH
63+
end
64+
end
65+
66+
# Note: The default I/O stream encoding in Python 2.7 (as configured on ubuntu) is ascii, not UTF-8 or the system locale
67+
# encoding. We reset it here to avoid having to set it for every I/O operation explicitly.
68+
set -x PYTHONIOENCODING UTF-8
69+
70+
# Clean up old session files
71+
if [ $HOME != "" ]
72+
for session_dir in "$HOME/.dnanexus_config/sessions/"*
73+
if test ! 'ps -p (basename "$session_dir") &> /dev/null'
74+
rm -rf "$session_dir"
75+
end
76+
end
77+
end
78+
79+
if test -z "$DX_SECURITY_CONTEXT" -a -n "$DX_AUTH_TOKEN"
80+
set -x DX_SECURITY_CONTEXT "{\"auth_token_type\":\"Bearer\",\"auth_token\":\"$DX_AUTH_TOKEN\"}"
81+
end

0 commit comments

Comments
 (0)