-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathinstall-ubuntu.sh
executable file
·251 lines (176 loc) · 6.96 KB
/
install-ubuntu.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
#!/bin/bash
# This script downloads and installs the lpzrobots-environment and all necessary
# packages for compiling, building and running it.
#
# more information about the script and the license used can be found here:
# https://github.com/Larsg7/lpzrobots-install-script
# small function to check exit-status
function chExitStatus {
if [[ ! $? -eq 0 ]]; then
printf "\nSomething went wrong while running the last command. - Exiting\n"
exit 1
fi
}
function installPackages {
printf "\nMaking sure essentials are installed...\n"
pkg=( g++ make automake libtool xutils-dev m4 libreadline-dev libgsl0-dev \
libglu1-mesa-dev libgl1-mesa-dev freeglut3-dev libopenscenegraph-dev libqt4-dev libqt4-opengl \
libqt4-opengl-dev qt4-qmake libqt4-qt3support gnuplot gnuplot-x11 libncurses5-dev )
toInstall=()
for name in ${pkg[*]}; do
printf "Checking if $name is installed..."
if ! dpkg -s $name 2> /dev/null 1> /dev/null; then
toInstall+=( $name )
printf " - No\n"
continue
fi
printf " - Ok\n"
done
if [[ ! -z $toInstall ]]; then
printf "\nInstalling necessary packages for compiling...\n"
sudo apt-get -qq update # quiet-mode
sudo apt-get install ${toInstall[*]}
chExitStatus
printf "\nAll packages necessary for compiling are installed.\n"
fi
}
function makeProgram {
# call with location of files as first argument!
# replace installation location for easier install w/o sudo
#sed -i "s/{1:-\/usr\/local}/{1:-\/home\/${USER}\/Documents}/g" createMakefile.conf.sh
#sed -i "s/Please use either \/usr, \/usr\/local or you home directory/Please use either \/home\/${USER}\/Documents or your home directory/g" createMakefile.conf.sh
prefix=/home/$USER
# taken directly form the installation script by Bulcsu and Hendrik
if [[ `echo $PATH | grep "/home/$USER/bin"` && `echo $LD_LIBRARY_PATH | grep "/home/$USER/lib"` ]] ; then
# case: already in path
echo "not neccessary..."
else
# case: not yet in path
# write to .bashrc to set paths for further sessions
echo "adding paths to rc-file"
printf "\n\n# adding path variables for LPZrobots package\n" >> /home/$USER/.bashrc
printf "export PATH=$prefix/bin:$PATH\n" >> /home/$USER/.bashrc
printf "export LD_LIBRARY_PATH=$prefix/lib\n" >> /home/$USER/.bashrc
# directly export to path for current session
export PATH=$prefix/bin:$PATH
export LD_LIBRARY_PATH=$prefix/lib
fi
chExitStatus
# taken directly form createMakefile.conf.sh
echo -e "# configuration file for lpzrobots (automatically generated!)\n\
# Where to install the simulator and utils" > Makefile.conf
echo "PREFIX=$prefix" >> Makefile.conf
echo -e "\n# user or developement installation\n\
# Options:\n\
# DEVEL: only install the utility functions,\n\
# which is useful for development on the simulator\n\
# USER: install also the ode_robots and selforg libaries and include files\n\
# this is recommended for users" >> Makefile.conf
echo "TYPE=DEVEL" >> Makefile.conf
echo "// Automatically generated file! Use make conf in lpzrobots." > ode_robots/install_prefix.conf
echo "#define PREFIX \"$prefix\"" >> ode_robots/install_prefix.conf
printf "\nStarting the make-process.\n"
sleep 1
# start timer
START=$(date +%s.%N)
# start make-process
make all
# check if build process was successful
chExitStatus
# end timer
END=$(date +%s.%N)
# make symlink (otherwise there will be errors)
#sudo ln -sf ${1}/LpzRobots/lpzrobots-master/opende/ode/src/.libs/libode_dbl.so.1 /lib/libode_dbl.so.1
# calculate difference
DIFF=$(echo "($END - $START)" | bc)
# show user success message (is also displayed if user cancels build-process)
printf "\nLpzrobots should now be installed (the make-process took $DIFF seconds).\n"
}
function getFiles {
# call with location of files as first argument!
# move into the directory the user has specified
cd $1
# make directory LpzRobots
if [[ ! -d LpzRobots ]]; then mkdir LpzRobots; fi
# move into the newly created directory
cd LpzRobots
printf "Getting files from github...\n"
wget --quiet https://github.com/georgmartius/lpzrobots/archive/master.zip
chExitStatus
printf "Unzipping content...\n"
unzip -q master.zip
# check if directory exists
if [[ ! -e lpzrobots-master ]]; then
printf "\nSorry, something went wrong downloading or unzipping the files \
('lpzrobots-master'-directory does not exist). - Exiting\n"
exit 1
fi
# move into the correct directory
cd lpzrobots-master
}
function testInstall {
# call with location of files as first argument!
printf "\nOk, the robot-example 'basic' will be compiled and started. If there is no error message and a window \
with a basic robot-simulation opens everything works fine.\nPlease press ENTER.\n"
# wait for user to press ENTER
read ans
# enter basic-example directory
cd ${1}/LpzRobots/lpzrobots-master/ode_robots/examples/basic
chExitStatus
# compile the example
make
chExitStatus
# start the example
${1}/LpzRobots/lpzrobots-master/ode_robots/examples/basic/start
# wait for simulation to end
wait
chExitStatus
}
function cleanUp {
printf "\nCleaning up...\n"
if [[ -e ${1}/LpzRobots/master.zip ]];then rm ${1}/LpzRobots/master.zip; fi
}
trap "printf '\nExiting...\n'; exit 1" INT TERM
###### Initial setup ######
# first clear the screen
clear
# display some information about the program to the user
printf "\nThis script will download and install the lpzrobots-environment for you.\n"
printf "It has been tested on Ubuntu 14.04 and 16.04. Default values are in '[]' and/or capitalized, \
just press ENTER to use them.\n"
printf "THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND.\n"
# ask the user in which directory the files should go
while :
do
defLoc="/home/${USER}"
printf "\nIn which directory should the program be downloaded and compiled? ('/LpzRobots' \
will be added to the end of the path, don't use '~') [$defLoc]\n"
# read the answer from the command line
read location
# if location is empty take default value otherwise just keep the input
if [[ -z $location ]]; then location=$defLoc; fi
# check if $location exists, is a directory and if we have read/write access
if [[ ! -d $location || ! -w $location ]]; then
printf "Directory does not exist or you do not have read/write-access! \nChoose another one.\n"
continue
else
printf "\nThe lpzrobots-files will now be downloaded into the directory ${location}/LpzRobots.\n"
break
fi
done
# set up the trap for the clean up process
trap "cleanUp $location" EXIT
###### Downloading the files ######
getFiles $location
###### Installing packages ######
installPackages
###### Build/compile program ######
makeProgram $location
###### Check installation ######
printf "\nDo you want to test if the program is installed correctly? [n/Y]"
read ans
# again check answer
if [[ $ans == "Y" || $ans == "y" || -z $ans ]]; then testInstall $location; fi
printf "\nThat's it! You may have to close and reopen your terminal window before running any further simulations.\nHave a nice day.\n"
###### End ######
exit 0