forked from ghofree/lab4
-
Notifications
You must be signed in to change notification settings - Fork 0
/
check-setup.sh
126 lines (101 loc) · 2.81 KB
/
check-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
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
#!/bin/bash
short_system=$(uname -s)
sys_vagrant="0"
sys_cygwin="0"
sys_osx="0"
# set this to the number of the current lab
cur_lab=4
system=$(uname -a)
if [ "$system" == "Linux precise32 3.2.0-23-generic-pae #36-Ubuntu SMP Tue Apr 10 22:19:09 UTC 2012 i686 i686 i386 GNU/Linux" ]
then
sys_vagrant="1"
echo "Running on Vagrant guest"
elif [ $short_system == "Darwin" ]
then
sys_osx="1"
echo "Running on Mac OSX"
else
sys_cygwin="1"
echo "Running on Windows"
fi
if [ "$sys_vagrant" == "1" ]
then
# on vagrant guest
required_pkg=( "mongo" "heroku" "node")
all_present="1"
for i in ${required_pkg[@]}
do
binloc="$(which $i)"
if [ "${#binloc}" == "0" ]
then
echo "You don't have $i"
all_present="0"
fi
done
node_status=$(cd lab4;npm ls 2>&1)
if [[ $node_status == *"UNMET DEPENDENCY"* ]]
then
echo "FAIL: Node is missing packages"
echo "Attempting to repair."
install_status=$(cd lab4; npm install --no-bin-links)
node_status=$(cd lab4;npm ls 2>&1)
if [[ $node_status != *"UNMET DEPENDENCY"* ]]
then
echo "PASS: Repair successful. All node packages installed."
fi
fi
if [ $all_present == "1" ]
then
echo "PASS: Vagrant is correctly set up."
fi
else
if [ "$sys_osx" == "1" ]
then
#on osx host system
dirloc="$(pwd)"
IFS=/ read -a dirarr <<< "$dirloc"
if [ "${dirarr[4]}" != "introHCI" ]
then
echo "FAIL: Either you are not running this script in the introHCI directory or your directory is named incorrectly. (On Mac, your introHCI directory should be located at ~/Documents/introHCI)"
else
echo "PASS: introHCI directory named and positioned correctly"
fi
elif [ "$sys_cygwin" == "1" ]
then
dirloc="$(pwd)"
IFS=/ read -a dirarr <<< "$dirloc"
if [ "${dirarr[5]}" != "introHCI" ]
then
echo "FAIL: Either you are not running this script in the introHCI directory or your directory is named incorrectly. (On Windows, your introHCI directory should be located at Documents\introHCI)"
else
echo "PASS: introHCI directory named and positioned correctly"
fi
fi
vagrant_check=$(grep MSB Vagrantfile | wc -l | xargs)
if [ $vagrant_check == "4" ]
then
echo "PASS: You are using the correct Vagrantfile"
else
echo "FAIL: CS147 Vagrantfile not found. Are you running this in the introHCI directory?"
fi
missing_dirs="0"
hcidirs=$(ls)
# current lab hardcoded
for i in {1..4}
do
target_dir="lab$i"
if [[ $hcidirs == *"$target_dir"* ]]
then
echo "Found $target_dir"
else
echo "ERROR: Cannot find $target_dir"
missing_dirs="1"
fi
done
if [ $missing_dirs == "1" ]
then
echo "FAIL: Your introHCI directory is missing the above lab folders."
else
echo "PASS: All required lab directories present."
fi
fi