forked from Juniper/ansible-junos-stdlib
-
Notifications
You must be signed in to change notification settings - Fork 1
/
env-setup
executable file
·25 lines (20 loc) · 913 Bytes
/
env-setup
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
#!/bin/bash
# usage: source env-setup
# When run using source as directed, $0 gets set to bash, so we must use $BASH_SOURCE
if [ -n "$BASH_SOURCE" ] ; then
HACKING_DIR=`dirname $BASH_SOURCE`
elif [ $(basename $0) = "env-setup" ]; then
HACKING_DIR=`dirname $0`
else
HACKING_DIR="$PWD"
fi
# The below is an alternative to readlink -fn which doesn't exist on OS X
# Source: http://stackoverflow.com/a/1678636
FULL_PATH=`python -c "import os; print(os.path.realpath('$HACKING_DIR'))"`
PRJ_LIBRARY="$FULL_PATH/library"
# we are going to set the ANSIBLE_LIBRARY path, which also needs to include
# the installed library; so check to see if that is setup or not.
if [ -z "$ANSIBLE_LIBRARY" ]; then
export ANSIBLE_LIBRARY=$(grep library /etc/ansible/ansible.cfg | awk '{ /(.*) = (.*)/; print $3 }')
fi
[[ $ANSIBLE_LIBRARY != ${PRJ_LIBRARY}* ]] && export ANSIBLE_LIBRARY=$PRJ_LIBRARY:$ANSIBLE_LIBRARY