-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathconfigure
executable file
·153 lines (134 loc) · 4.67 KB
/
configure
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
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
#!/bin/bash
ORANGE='\033[0;33m'
GREEN='\033[0;32m'
NC='\033[0m'
function install_man() {
cp docs/mirage.1.gz /usr/share/man/man1/mirage.1.gz
if [ $? -ne 0 ]
then
echo -e "${ORANGE}WARNING: Could not install Mirage's man page. Please run the command \"./configure --man\" with super user priviledges to install the man page.${NC}" > /dev/stderr
else
echo -e "${GREEN}Man page installed${NC}"
fi
}
# Here starts the actual script.
#First, if the --man flag, run that and exit.
if [ "$1" = "--man" ]
then
install_man
exit
fi
#Now for the regular config setup.
#First, I need to find what python interperiter to use.
interpereters=($(whereis -b python | sed 's/ /\n/g' | grep "python3$\|python3.[[:digit:]]$" | xargs file -L | grep -v "directory" | sed "s/://g" | awk '{print $1 }'))
build_modes=('.analysis_pip' '.sim_pip' '.dev_pip')
if [ interpereters = "" ]
then
echo -e "${ORANGE}Error: Mirage requires a python3 interpereter. Please install python3 and try again${NC}"
exit
fi
echo "Welcome to Mirage's setup tool. This tool will help you create the environment"
echo "necessary to build and install Mirage."
echo ""
echo "There are several decisions to be made. I will walk you through the setup process."
echo "If you want to change a decision in the future, simply run the setup tool again."
echo "------------------------------------------------------------------------------------"
echo ""
echo "Please select a python3 interpereter by number."
for ((idx=0; idx<${#interpereters[@]}; ++idx)); do
echo " [$idx]:" "${interpereters[idx]}"
done
read -p "> " int_ind
if [ $int_ind -ge ${#interpereters[@]} ]
then
echo -e "${ORANGE} ERROR: Please select a valid interpereter from the list"
exit
fi
interpereter="${interpereters[int_ind]}"
echo ""
echo "Should I create a virtual environment for Mirage?"
read -p "y/n (Recommended yes): " mk_venv
if [ -n "$(echo "$mk_venv" | grep -i -o "y")" ]
then
$interpereter -m venv "mirage_venv"
if [ $? -ne 0 ]
then
echo -e "${ORANGE}Error: Could not construct virtual environment. Please make sure your chosen python interpreter has the venv module installed, or try another interpreter${NC}" > /dev/stderr
exit
fi
source mirage_venv/bin/activate
else
echo "No venv needed"
fi
echo "Current interperiter is " $(which python)
echo ""
echo "What dependencies will you need?"
echo " [0]: Dependencies for analyzing simulation results"
echo " [1]: Dependencies for performing simulations"
echo " [2]: Dependencies for developers"
read -p "> " dependency_col
if [ $dependency_col -ge 3 ]
then
echo -e "${ORANGE} ERROR: Please select a valid dependency pack from the list"
exit
fi
build_pack="${build_modes[dependency_col]}"
pip install --disable-pip-version-check wheel
pip install --disable-pip-version-check -r "$build_pack"
if [ $? -ne 0 ]
then
echo -e "${ORANGE}Error. Could not install requested packages using pip.${NC}"
exit
else
echo "Python environment configured."
fi
JAR_HOME=""
if [ -d "spark_mirage" ]
then
JAR_HOME="$(pwd)/spark_mirage/target/scala-2.11/spark_mirage-assembly-beta.jar"
make scala
else
pushd mirage_venv > /dev/null
wget "http://www.cs.trinity.edu/~jkoeller/Mirage/spark_mirage-assembly-beta.jar"
JAR_HOME="$(pwd)/spark_mirage-assembly-beta.jar"
popd > /dev/null
fi
echo "Environment made. Now generating executable scripts..."
LA_HOME="$(pwd)"
pushd scripts > /dev/null
touch mirage
echo "#!/bin/bash" >> mirage
if [ -d "../mirage_venv" ]
then
echo "source \"$LA_HOME/mirage_venv/bin/activate\"" >> mirage
fi
echo "export PYTHONPATH=\"$LA_HOME\"" >> mirage
echo "export PYTHONSTARTUP=\"$LA_HOME/scripts/shell.py\"" >> mirage
echo "export JAR_LOC=\"$JAR_HOME\"" >> mirage
cat mirage.template >> mirage
touch cluster_config
echo '#!/bin/bash' >> cluster_config
echo 'export MASTER="local[*]"' >> cluster_config
echo 'export EXECUTOR_MEMORY="1024m"' >> cluster_config
echo 'export DRIVER_MEMORY="1024m"' >> cluster_config
echo 'export EXTRA_ARGS=""' >> cluster_config
echo 'export NUM_EXECUTORS="4"' >> cluster_config
chmod u+x mirage
popd > /dev/null
if [ ! -f ".custom_preferences.json" ]
then
echo "No preferences file found. Making the default preferences file"
cp .default_preferences.json .custom_preferences.json
fi
make build
echo "Done."
echo "Would you like to make an alias to mirage in your .bashrc?"
read -p "y/n (recommend yes):" make_alias
if [ -n "$(echo "$make_alias" | grep -i -o "y")" ]
then
echo "alias mirage=\"$LA_HOME/scripts/mirage\"" >> "$HOME/.bashrc"
echo -e "${GREEN}Alias made.${NC}"
echo -e "${GREEN} Once you source your bash, mirage can be ran from any directory with the command \"mirage\".${NC}"
fi
install_man
echo -e "${GREEN}mirage configured. For info on using mirage, see the man entry.${NC}"