-
Notifications
You must be signed in to change notification settings - Fork 36
/
setup.sh
executable file
·37 lines (32 loc) · 1.56 KB
/
setup.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
#!/bin/bash
################## SKELETON: DO NOT TOUCH THESE 2 LINES
USAGE="USAGE: source $0
PURPOSE: set up PATH and other things necessary for BLANT and its scripts to work seamlessly."
################## SKELETON: DO NOT TOUCH CODE HERE
# check that you really did add a usage message above
USAGE=${USAGE:?"$0 should have a USAGE message before sourcing skel.sh"}
die(){ echo "$USAGE${NL}FATAL ERROR in $BASENAME:" "$@" >&2; exit 1; }
warn(){ (echo "WARNING: $@")>&2; }
not(){ if eval "$@"; then return 1; else return 0; fi; }
newlines(){ awk '{for(i=1; i<=NF;i++)print $i}' "$@"; }
parse(){ awk "BEGIN{print $*}" </dev/null; }
export TAB=' '; export NL='
'
#################### END OF SKELETON, ADD YOUR CODE BELOW THIS LINE
# if SETUP_USAGE have set, exit
if [ "`echo $0 | sed 's,.*/,,'`" = setup.sh ]; then
die "You've run this as a script; source it instead by typing:
source $0"
fi
MYDIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
case $# in
1) export BLANT_HOME="$1";;
*) export BLANT_HOME="$MYDIR" ;;
esac
if [ "$BLANT_HOME" = . ]; then BLANT_HOME=`/bin/pwd`; fi
[ -d libwayne ] || die "need libwayne directory, please clone libwayne while in $BLANT_HOME"
[ -d libwayne/bin ] || die "need libwayne/bin directory, please clone libwayne while in $BLANT_HOME"
[ -x libwayne/bin/hawk ] || die "no hawk in libwayne/bin???"
echo Setting PATH appropriately...
# the back-quote command removes duplicate directories in the PATH
export PATH=`echo "$BLANT_HOME/libwayne/bin:$BLANT_HOME/scripts:$PATH" | tr : "$NL" | awk '!seen[$0]{print}{++seen[$0]}' | tr "$NL" :`