-
Notifications
You must be signed in to change notification settings - Fork 11
/
setup.sh
102 lines (86 loc) · 3.23 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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
#!/bin/sh
# Traveler setup script for Bourne-type shells
# This file is typically sourced in user's .bashrc file
if [ -n "$BASH_SOURCE" ]; then
input_param=$BASH_SOURCE
elif [ -n "$ZSH_VERSION" ]; then
setopt function_argzero
input_param=$0
else
echo 1>&2 "Unsupported shell. Please use bash or zsh."
exit 2
fi
myDir=`dirname $input_param`
currentDir=`pwd` && cd $myDir
# TRAVELER_ROOT_DIR is not empty and the different from current directory
if [ ! -z "$TRAVELER_ROOT_DIR" -a "$TRAVELER_ROOT_DIR" != `pwd` ]; then
echo "WARNING: Resetting TRAVELER_ROOT_DIR environment variable (old value: $TRAVELER_ROOT_DIR)"
fi
export TRAVELER_ROOT_DIR=`pwd`
export TRAVELER_INSTALL_DIR=$TRAVELER_ROOT_DIR/..
# it is an existant directory
if [ -d $TRAVELER_INSTALL_DIR ]; then
cd $TRAVELER_INSTALL_DIR
export TRAVELER_INSTALL_DIR=`pwd`
fi
# TRAVELER_DATA_DIR is not set
export TRAVELER_DATA_DIR=$TRAVELER_INSTALL_DIR/data
if [ -d $TRAVELER_DATA_DIR ]; then
cd $TRAVELER_DATA_DIR
export TRAVELER_DATA_DIR=`pwd`
fi
# TRAVELER_VAR_DIR is not set
export TRAVELER_VAR_DIR=$TRAVELER_INSTALL_DIR/var
if [ -d $TRAVELER_VAR_DIR ]; then
cd $TRAVELER_VAR_DIR;
export TRAVELER_VAR_DIR=`pwd`
fi
# TRAVELER_SUPPORT_DIR is not set
export TRAVELER_SUPPORT_DIR=$TRAVELER_INSTALL_DIR/support
if [ -d $TRAVELER_SUPPORT_DIR ]; then
cd $TRAVELER_SUPPORT_DIR
export TRAVELER_SUPPORT_DIR=`pwd`
fi
# TRAVELER_INSTALL_ETC_DIRECTORY is not set
export TRAVELER_INSTALL_ETC_DIR=$TRAVELER_INSTALL_DIR/etc
if [ -d $TRAVELER_INSTALL_ETC_DIR ]; then
cd $TRAVELER_INSTALL_ETC_DIR
export TRAVELER_INSTALL_ETC_DIRECTORY=`pwd`
fi
export TRAVELER_CONFIG_DIR=$TRAVELER_INSTALL_ETC_DIRECTORY/traveler-config
if [ -d $TRAVELER_CONFIG_DIR ]; then
cd $TRAVELER_CONFIG_DIR
export TRAVELER_CONFIG_DIR=`pwd`
fi
#Notify user of nonexistatnt directories.
if [ ! -d $TRAVELER_SUPPORT_DIR ]; then
echo "Warning: $TRAVELER_SUPPORT_DIR directory does not exist. Developers should point TRAVELER_SUPPORT_DIR to desired area."
fi
if [ ! -d $TRAVELER_DATA_DIR ]; then
echo "Warning: $TRAVELER_DATA_DIR directory does not exist. Developers should point TRAVELER_DATA_DIR to desired area."
fi
if [ ! -d $TRAVELER_VAR_DIR ]; then
echo "Warning: $TRAVELER_VAR_DIR directory does not exist. Developers should point TRAVELER_VAR_DIR to desired area."
fi
if [ ! -d $TRAVELER_INSTALL_ETC_DIR ]; then
echo "Warning: $TRAVELER_INSTALL_ETC_DIR directory does not exist. Developers should point TRAVELER_INSTALL_ETC_DIR to desired area."
fi
if [ ! -d $TRAVELER_CONFIG_DIR ]; then
echo "Warning: $TRAVELER_CONFIG_DIR directory does not exist. Developers should point TRAVELER_CONFIG_DIR to desired area."
echo "Specify env variable, TRAVELER_CONFIG_DIR when starting node to point to the correct directory"
fi
# SET PATH variable
HOST_ARCH="`uname | tr '[:upper:]' '[:lower:]'`-`uname -m`"
# Add to path only if directory exists.
prependPathIfDirExists() {
_dir=$1
if [ -d ${_dir} ]; then
PATH=${_dir}:$PATH
else
echo "Warning: PATH $_dir was not added. it does not exist."
fi
}
prependPathIfDirExists $TRAVELER_SUPPORT_DIR/mongodb/$HOST_ARCH/bin
prependPathIfDirExists $TRAVELER_SUPPORT_DIR/nodejs/$HOST_ARCH/bin
# Done
cd $currentDir