-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinterface.sh
executable file
·295 lines (250 loc) · 8.24 KB
/
interface.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
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
#!/bin/bash
#-------------------------------------------------------
# Part 1: Source files
#-------------------------------------------------------
export pwd=`pwd`
. $pwd/source/main.sh
. $pwd/source/log.sh
. $pwd/source/moos.sh
. $pwd/source/ros.sh
#-------------------------------------------------------
# Part 2: Env params
#-------------------------------------------------------
export user=`whoami`
export host=`hostname`
export date=`date -u +%Y%m%d%a%b%c`
export user_info=`find ~/ -name "user.log"`
export CHECK_MARK="\e[0;32m\xE2\x9C\x94\e[0m"
export todo_list=(moos-ivp moos-ivp-aquaticus moos-ivp-UAL)
export done_list=()
export waiting_list=()
setup_own_tree=false
setup_ros=false
setup_ivp=false
setup_aquaticus=false
setup_UAL=false
# Modify
setup_pi_ros=false
export ivp_stdout_path=`find ~/ -name "ivp_stdout.log"` #(main.sh, moos.sh)
export ivp_stderr_path=`find ~/ -name "ivp_stderr.log"`
export aqua_stdout_path=`find ~/ -name "aqua_stdout.log"`
export aqua_stderr_path=`find ~/ -name "aqua_stderr.log"`
export UAL_stdout_path=`find ~/ -name "UAL_stdout.log"`
export UAL_stderr_path=`find ~/ -name "UAL_stderr.log"`
export own_tree_stdout_path=`find ~/ -name "own_tree_stdout.log"`
export own_tree_stderr_path=`find ~/ -name "own_tree_stderr.log"`
export ros_stdout_path=`find ~/ -name "ros_stdout.log"` #(interface.sh ros.sh)
export ros_stderr_path=`find ~/ -name "ros_stderr.log"`
#-------------------------------------------------------
# Part 3: Program start
#-------------------------------------------------------
startup
printf "\e[37mPlease enter sudo password: \e[0m"
read sudo_passwd
export sudo_passwd
#-------------------------------------------------------
# Part 4: Setup logfile
#-------------------------------------------------------
# Edit logfile header
header=`log_header`
#echo "$header" | tee $stdout_path | grep "" > $stderr_path
echo "$header" >> $user_info
#-------------------------------------------------------
# Part 5: Backup bashrc
#-------------------------------------------------------
cp -rp ~/.bashrc ~/.bashrc_backup
#-------------------------------------------------------
# Part 6: Main option
#-------------------------------------------------------
while :
do
clear_screen
echo -e "\e[1;92mInstalltion list: \e[0m"
echo -e "1) moos-ivp/aquaticus/UAL"
echo -e "2) moos-ivp-your-own-tree"
echo -e "3) ROS Melodic (Desktop)"
echo -e "4) ROS Melodic (Raspberry pi)"
echo -e "5) Start installation process"
read choices
case $choices in
#-------------------------------------------------------
# Part 7: Main option 1 (MOOS installation page)
#-------------------------------------------------------
1)
# Check installed app
check_install
# Retrun to main page if already setup install list or already setup every MOOS
if [ ${#todo_list[@]} == 0 ] && [ "${#waiting_list[@]}" != "0" ]
then
echo -ne "\r\e[1;97mYour MOOS is ready to install \e[0m"
sleep 1
continue
elif [ ${#todo_list[@]} == 0 ] && [ "${#done_list[@]}" != "3" ]
then
echo -e "\e[1;97mYou already have every MOOS in your system \e[0m"
sleep 1
continue
fi
# Enter moos install page
clear_screen
# Show installation status
show_list "${done_list[*]}" "${todo_list[*]}" "${waiting_list[*]}"
while : # To show selection list multiple time
do
# If todo_list is empty after selection, quit to main page
if [ ${#todo_list[@]} == 0 ]
then
echo -e "\e[1;97mYour MOOS is ready to install \e[0m"
sleep 1
break
fi
PS3=':'
select opt in ${todo_list[*]}
do
case $opt in
moos-ivp)
# If moos-ivp in todo_list
# add moos-ivp to waiting_list, rm from todo_list
add_remove "moos-ivp"
setup_ivp=true
# Show list status (This should be function)
clear_screen
show_list "${done_list[*]}" "${todo_list[*]}" "${waiting_list[*]}"
break
;;
#=====================================================================
moos-ivp-aquaticus)
# If moos-ivp-aquaticus in todo_list
# add moos-ivp-aquaticus to waiting_list, rm from todo_list
add_remove "moos-ivp-aquaticus"
setup_aquaticus=true
# Show list status (This should be function)
clear_screen
show_list "${done_list[*]}" "${todo_list[*]}" "${waiting_list[*]}"
break
;;
#=====================================================================
moos-ivp-UAL)
# If moos-ivp-UAL in todo_list
# add moos-ivp-UAL to waiting_list, rm from todo_list
add_remove "moos-ivp-UAL"
setup_UAL=true
# Show list status (This should be function)
clear_screen
show_list "${done_list[*]}" "${todo_list[*]}" "${waiting_list[*]}"
break
;;
#=====================================================================
*) clear_screen;break 2;;
esac
done # MOOS installation page select done # select do
done # Main page option1 loop
;;
#-------------------------------------------------------
# Part 8: Main option 2 (Setup my own tree)
#-------------------------------------------------------
2)
# If setup_own_tree=true, back to Main page
if [ "$setup_own_tree" = true ] ; then
echo -ne "\r\e[1;97mYour own tree is ready to install \e[0m"
sleep 1
continue
fi
# Enter own tree page
clear_screen
# Input own tree github URL
echo -e "\r\e[1;97mPlease input you github moos repository URL: \e[0m"
printf "https://github.com/"
read URL
#export URL
# finish setup, set setup_own_tree to true
setup_own_tree=true
echo -e "\e[1;97mYour own tree is ready to install \e[0m"
sleep 1
;; # end of my own tree case
#-------------------------------------------------------
# Part 9: Main option 3 (Setup ROS Melodic Desktop)
#-------------------------------------------------------
3)
# set setup_ros to true
setup_ros=true
echo -e "\e[1;97mROS Melodic is ready to install \e[0m"
sleep 1
;; # end of ROS case
#-------------------------------------------------------
# Part 10: Main option 4 (Setup ROS Melodic Raspberry pi)
#-------------------------------------------------------
4)
# set setup_pi_ros to true
setup_pi_ros=true
echo -e "\e[1;97mROS Melodic (Raspberry pi) is ready to install \e[0m"
sleep 1
;; # end of ROS case
#-------------------------------------------------------
# Part 11: Main option 5 (Start installation process)
#-------------------------------------------------------
5)
# Main option 5 case
clear_screen
echo -e "\e[1;31mStart installation process\e[0m\e[1;5;31m... \e[0m"
# ivp, aquaticus and UAL part
#echo waiting_list size ${#waiting_list[@]}
for i in ${waiting_list[*]}
do
#echo "this is $i"
if [ "$i" == "moos-ivp" ]
then
setup_ivp
fi
if [ "$i" == "moos-ivp-aquaticus" ]
then
setup_aquaticus
fi
if [ "$i" == "moos-ivp-UAL" ]
then
setup_UAL
fi
done
# own-tree part
if [ "$setup_own_tree" = true ] ; then
setup_my_tree "$URL"
fi
# ROS part (Desktop)
if [ "$setup_ros" = true ] ; then
# Check if deamon apt.systemd.daily update is running
# Error: Could not get lock /var/lib/dpkg/lock-frontend
if [ "`ps aux | grep -i apt | wc -l`" -gt "1" ] ; then
echo -e "\e[31m apt.systemd.daily is currently running. \e[0m"
echo -e "\e[31m Please install ROS later. \e[0m"
echo -e "Error: Could not get lock /var/lib/dpkg/lock-frontend" >> $ros_stderr_path
setup_ros=false
sleep 3
else
setup_ros
fi
fi
# ROS part (Raspberry pi)
if [ "$setup_pi_ros" = true ] ; then
setup_pi_ros
fi
# Check installation result
echo -e "\e[1;33m${CHECK_MARK} All process completed\e[0m"
sleep 1
clear_screen
echo -e "\e[1;34m${CHECK_MARK} All process completed\e[0m"
echo -e "--\e[1;33mCheck results... \e[0m" #92:Light green
final_check_install "$setup_ivp" "$setup_aquaticus" "$setup_UAL" "$setup_own_tree" "$setup_ros" "$setup_pi_ros"
echo
echo
echo -e "${CHECK_MARK} Please close terminal or source ~/.bashrc!"
echo -e "\e[94m==============================================\e[0m"
echo -e "\e[94mThank you for using Alonzo Setup Wizard!\e[0m"
echo -e "\e[94mContact email below if any problem occured.\e[0m"
echo -e "\e[94mEmail: r07525074@ntu.edu.tw\e[0m"
echo -e "\e[94m==============================================\e[0m"
exit
;;
q) exit
;;
esac # end of Main option 1 case
done # end of Main option while