-
Notifications
You must be signed in to change notification settings - Fork 2
/
ros_install.bash
executable file
·171 lines (141 loc) · 4.39 KB
/
ros_install.bash
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
#!/bin/bash
# The BSD License
# Copyright (c) 2014 OROCA and ROS Korea Users Group
function usage {
# Print out usage of this script.
echo >&2 "usage: $0 [catkin workspace name (default:catkin_ws)] [ROS distro (default: kinetic)"
exit 0
}
function get-shell {
current_user=`id -u -n`
shell=`cat /etc/passwd | grep $current_user | cut -d ':' -f 7`
echo ${shell##*/}
}
name_catkinws=$1
name_catkinws=${name_catkinws:="ros_ws"}
name_ros_distro=$2
name_ros_distro=${name_ros_distro:="kinetic"}
echo $name_catkinws
echo $name_ros_distro
username=`id -u -n`
user_shell=`get-shell`
if [ -d /etc/upstream-release ] ; then
relesenum=`cat /etc/upstream-release/lsb-release | grep DESCRIPTION | awk -F 'Ubuntu ' '{print $2}' | awk -F ' LTS' '{print $1}'`
ubuntu_version=`cat /etc/upstream-release/lsb-release | grep CODENAME | awk -F '=' '{print $2}'`
else
relesenum=`cat /etc/lsb-release | grep DESCRIPTION | awk -F 'Ubuntu ' '{print $2}' | awk -F ' LTS' '{print $1}'`
ubuntu_version=`cat /etc/lsb-release | grep CODENAME | awk -F '=' '{print $2}'`
fi
its_okay_to_install=false
read -p "Which package do you want to install? 1. Full Desktop, 2. Desktop, 3. Bare Bones? " answer
case "$answer" in
1)
package_type="desktop-full"
;;
2)
package_type="desktop"
;;
3)
package_type="ros-base"
;;
* )
package_type="ros-base"
;;
esac
install_rqt=""
read -p "Do you also install all rqt packages? (Y/n) " answer
case ${answer} in
n|N)
;;
*)
install_rqt="ros-${name_ros_distro}-rqt-*"
;;
esac
# check if ubuntu version and ros version is meet correctly
case $name_ros_distro in
"lunar" )
if [[ "$ubuntu_version" == +(xenial|yakkety|zesty) ]] ; then
its_okay_to_install=true
fi
;;
"kinetic" )
if [[ "$ubuntu_version" == +(wily|xenial) ]] ; then
its_okay_to_install=true
fi
;;
"jade" )
if [[ "$ubuntu_version" == +(trusty|utopic|vivid) ]] ; then
its_okay_to_install=true
fi
;;
"igloo" )
if [[ "$ubuntu_version" == +(saucy|trusty) ]] ; then
its_okay_to_install=true
fi
;;
esac
if ! $its_okay_to_install ; then
echo "Selected ros version and current ubuntu version is not met."
echo "Please refer to page: http://www.ros.org/reps/rep-0003.html"
exit 1
fi
echo "[Checking the ubuntu version]"
case $ubuntu_version in
"saucy" | "trusty" | "vivid" | "wily" | "xenial" | "yakkety" | "zesty" )
;;
*) echo "ERROR: This script will only work on Ubuntu Saucy(13.10) / Trusty(14.04) / Vivid / Wily / Xenial / Yakkety / Zesty and their forks. Exit."
exit 0
esac
if ! [ -x "$(command -v sudo)" ]
then
apt update
apt install sudo
fi
echo "[Update & upgrade the package]"
sudo apt-get update
sudo apt-get upgrade -y
echo "[Check the 14.04.2 TLS issue]"
if [ "$relesenum" = "14.04.2" ]
then
echo "Your ubuntu version is $relesenum"
echo "Intstall the libgl1-mesa-dev-lts-utopic package to solve the dependency issues for the ROS installation specifically on $relesenum"
sudo apt-get install -y libgl1-mesa-dev-lts-utopic
else
echo "Your ubuntu version is $relesenum"
fi
echo "[Installing chrony and setting the ntpdate]"
sudo apt-get install -y chrony ntpdate
sudo ntpdate ntp.ubuntu.com
echo "[Add the ROS repository]"
if [ ! -e /etc/apt/sources.list.d/ros-latest.list ]; then
sudo sh -c "echo \"deb http://packages.ros.org/ros/ubuntu ${ubuntu_version} main\" > /etc/apt/sources.list.d/ros-latest.list"
fi
echo "[Download the ROS keys]"
roskey=`apt-key list | grep "ROS builder"`
if [ -z "$roskey" ]; then
wget --quiet https://raw.githubusercontent.com/ros/rosdistro/master/ros.key -O - | sudo apt-key add -
fi
echo "[Update & upgrade the package]"
sudo apt-get update
sudo apt-get upgrade -y
echo "[Installing ROS]"
sudo apt-get install -y ros-${name_ros_distro}-${package_type} ${install_rqt}
if ! [ $? -eq 0 ] ; then
echo "Failure detected when installing ros packages, exiting"
exit 1
fi
echo "[rosdep init and python-rosinstall]"
sudo sh -c "rosdep init"
rosdep update
. /opt/ros/$name_ros_distro/setup.sh
sudo apt-get install -y python-rosinstall
echo "[Making the catkin workspace and testing the catkin_make]"
mkdir -p ~/$name_catkinws/src
cd ~/$name_catkinws/src
catkin_init_workspace
cd ~/$name_catkinws/
catkin_make
echo "[Setting the ROS evironment]"
echo "source ~/${name_catkinws}/devel/setup.${user_shell}" | tee -a ~/.${user_shell}rc
echo "[Complete!!!]"
exit 0