forked from vpenso/prometheus-slurm-exporter
-
Notifications
You must be signed in to change notification settings - Fork 0
/
source_me.sh
43 lines (35 loc) · 1.27 KB
/
source_me.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
#
# Copyright 2012-2017 Victor Penso
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
# Find the correct path even if dereferenced by a link
__source=$0
if [[ "$__source" == *bash* ]]; then
__source=${BASH_SOURCE[0]}
fi
__dir="$( dirname $__source )"
while [ -h $__source ]
do
__source="$( readlink "$__source" )"
[[ $__source != /* ]] && __source="$__dir/$__source"
__dir="$( cd -P "$( dirname "$__source" )" && pwd )"
done
__dir="$( cd -P "$( dirname "$__source" )" && pwd )"
export SCRIPTS=$__dir
unset __dir
unset __source
export GOPATH=$SCRIPTS:/usr/share/gocode
export PATH=$SCRIPTS/bin:$PATH
PATH=$(echo "$PATH" | awk -v RS=':' -v ORS=":" '!a[$1]++{if (NR > 1) printf ORS; printf $a[$1]}')