-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathassignment2_init_script.sh
executable file
·93 lines (75 loc) · 2.17 KB
/
assignment2_init_script.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
#!/bin/bash
#Title :assignment2_init_script.sh
#description :This script will download and install the template for assignment2.
#Author :Swetank Kumar Saha <swetankk@buffalo.edu>
#Version :1.1
#====================================================================================
# https://gist.github.com/davejamesmiller/1965569
function ask {
while true; do
if [ "${2:-}" = "Y" ]; then
prompt="Y/n"
default=Y
elif [ "${2:-}" = "N" ]; then
prompt="y/N"
default=N
else
prompt="y/n"
default=
fi
# Ask the question
read -p "$1 [$prompt] " REPLY
# Default?
if [ -z "$REPLY" ]; then
REPLY=$default
fi
# Check if the reply is valid
case "$REPLY" in
Y*|y*) return 0 ;;
N*|n*) return 1 ;;
esac
done
}
echo -n "Enter your UBIT username (without the @buffalo.edu part) and press [ENTER]: "
read ubitname
while true; do
echo -n "Enter 1 (for C) OR 2 (for C++): "
read -n 1 lang_choice
if [ -z $lang_choice ]; then
continue
elif [ $lang_choice == "1" ]; then
language="C"
lang_option="c"
break
elif [ $lang_choice == "2" ]; then
language="C++"
lang_option="cpp"
break
else
continue
fi
done
echo
echo
echo "UBIT username: $ubitname"
echo "Programming language: $language"
if ask "Do you want to continue?" Y; then
wget https://ubwins.cse.buffalo.edu/cse-489_589/assignment2_package.sh
chmod +x assignment2_package.sh
wget https://ubwins.cse.buffalo.edu/cse-489_589/assignment2_update_scripts.sh
chmod +x assignment2_update_scripts.sh
wget https://ubwins.cse.buffalo.edu/cse-489_589/assignment2_template_${lang_option}.tar
tar -xvf assignment2_template_${lang_option}.tar
mv ./ubitname $ubitname
rm assignment2_template_${lang_option}.tar
mkdir scripts
cd scripts
wget -r --no-parent -nH --cut-dirs=3 -R index.html https://ubwins.cse.buffalo.edu/cse-489_589/scripts/
chmod +x run_experiments
chmod +x sanity_tests
cd ..
echo
echo "Installation ... Success!"
else
exit 0
fi