forked from LockerProject/Locker
-
Notifications
You must be signed in to change notification settings - Fork 0
/
checkEnv.sh
executable file
·39 lines (35 loc) · 1009 Bytes
/
checkEnv.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
#!/bin/sh
txtrst=$(tput sgr0) # Text reset
txtred=$(tput setaf 1) # Red
txtgrn=$(tput setaf 2) # Green
check_for() {
found=`which $2`
version=`$3 2>&1 | grep -o -E [-0-9.]\{1,\} | head -n 1`
if [ -z "$found" ]; then
echo "${txtred}$1 not found!${txtrst}" >&2
else
echo "$1 version $version found." >&2
if [ -z "$4" ]; then
return
fi
fi
if [ -n "$4" ]; then
if [ "$version" \< "$4" ]; then
echo "${txtred}$1 version $4 or greater required!${txtrst}" >&2
fi
if [ -n "$5" ]; then
if [ "$version" \> "$5" ]; then
echo "${txtred}$1 version $5 or less required!${txtrst}" >&2
fi
fi
else
exit 1
fi
}
check_for Python python 'python -V' 2.6
check_for Node.js node 'node -v' 0.4.6 0.4.9
check_for npm npm "npm -v" 1
check_for mongoDB mongod "mongod --version" 1.4.0
if [ "$1" = "--vows" ] ; then
check_for Vows vows "vows --version" 0.5.8
fi