Created
December 12, 2018 02:51
-
-
Save tisyang/20416802156bd91b344473b451b83385 to your computer and use it in GitHub Desktop.
Ubuntu 16.04 ROS Kinetic 一键安装脚本
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
# 安装 ros-kinetic 脚本,适用于 ubuntu 16.04 | |
#set -e | |
# 检查是否是 root | |
if [ `whoami` = "root" ];then | |
echo "$0 SHOULD NOT run as root, EXIT!" | |
exit 1 | |
fi | |
# 配置 Ubuntu 源镜像 | |
echo "Setup Ubuntu mirror sources.list..." | |
sudo sh -c 'echo "# 默认注释了源码仓库,如有需要可自行取消注释" > /etc/apt/sources.list' | |
sudo sh -c '. /etc/lsb-release && echo "deb http://mirrors.ustc.edu.cn/ubuntu/ $DISTRIB_CODENAME main restricted universe multiverse" >> /etc/apt/sources.list' | |
sudo sh -c '. /etc/lsb-release && echo "# deb-src http://mirrors.ustc.edu.cn/ubuntu/ $DISTRIB_CODENAME main restricted universe multiverse" >> /etc/apt/sources.list' | |
sudo sh -c '. /etc/lsb-release && echo "deb http://mirrors.ustc.edu.cn/ubuntu/ $DISTRIB_CODENAME-updates main restricted universe multiverse" >> /etc/apt/sources.list' | |
sudo sh -c '. /etc/lsb-release && echo "# deb-src http://mirrors.ustc.edu.cn/ubuntu/ $DISTRIB_CODENAME-updates main restricted universe multiverse" >> /etc/apt/sources.list' | |
sudo sh -c '. /etc/lsb-release && echo "deb http://mirrors.ustc.edu.cn/ubuntu/ $DISTRIB_CODENAME-backports main restricted universe multiverse" >> /etc/apt/sources.list' | |
sudo sh -c '. /etc/lsb-release && echo "# deb-src http://mirrors.ustc.edu.cn/ubuntu/ $DISTRIB_CODENAME-backports main restricted universe multiverse" >> /etc/apt/sources.list' | |
sudo sh -c '. /etc/lsb-release && echo "deb http://mirrors.ustc.edu.cn/ubuntu/ $DISTRIB_CODENAME-security main restricted universe multiverse" >> /etc/apt/sources.list' | |
sudo sh -c '. /etc/lsb-release && echo "# deb-src http://mirrors.ustc.edu.cn/ubuntu/ $DISTRIB_CODENAME-security main restricted universe multiverse">> /etc/apt/sources.list' | |
sudo sh -c 'echo "# 预发布软件源,不建议启用" >> /etc/apt/sources.list' | |
sudo sh -c '. /etc/lsb-release && echo "# deb http://mirrors.ustc.edu.cn/ubuntu/ $DISTRIB_CODENAME-proposed main restricted universe multiverse" >> /etc/apt/sources.list' | |
sudo sh -c '. /etc/lsb-release && echo "# deb-src http://mirrors.ustc.edu.cn/ubuntu/ $DISTRIB_CODENAME-proposed main restricted universe multiverse" >> /etc/apt/sources.list' | |
# 更新安装常用软件 | |
echo "Update and install basic softwares..." | |
sudo apt-get update | |
sudo apt-get -y install fonts-wqy-microhei fonts-wqy-zenhei fonts-noto-cjk | |
sudo apt-get -y install aptitude vim git cmake | |
# 配置系统 | |
# 安装 git bash 辅助提示工具 | |
cd ~ | |
git_prompt_set=$(cat ~/.bashrc | grep -e "~/.bash-git-prompt/gitprompt.sh") | |
if [ -z "$has_ros_set" ]; then | |
git clone https://github.com/magicmonty/bash-git-prompt.git .bash-git-prompt --depth=1 | |
echo "GIT_PROMPT_ONLY_IN_REPO=1" >> ~/.bashrc | |
echo "GIT_PROMPT_FETCH_REMOTE_STATUS=0" >> ~/.bashrc | |
echo "source ~/.bash-git-prompt/gitprompt.sh" >> ~/.bashrc | |
fi | |
# 安装图形界面工具 | |
echo "Install graphic softwares..." | |
sudo apt-get -y install vim-gtk git-gui cmake-gui qtcreator | |
# 安装 ROS Kinetic | |
echo "Setup ROS sources.list..." | |
sudo sh -c '. /etc/lsb-release && echo "deb http://mirrors.ustc.edu.cn/ros/ubuntu/ $DISTRIB_CODENAME main" > /etc/apt/sources.list.d/ros-latest.list' | |
echo "Setup ROS keys..." | |
sudo apt-key adv --keyserver hkp://ha.pool.sks-keyservers.net:80 --recv-key 421C365BD9FF1F717815A3895523BAEEB01FA116 | |
echo "Update sources.list..." | |
sudo apt-get update | |
echo "Install ros-kinetic..." | |
sudo apt-get -y install ros-kinetic-desktop-full | |
echo "Initialize rosdep..." | |
sudo rosdep init | |
rosdep -y update | |
echo "Setup enviaronment..." | |
ros_set=$(cat ~/.bashrc | grep -e "/opt/ros/kinetic/setup.bash") | |
if [ -z "$ros_set" ]; then | |
echo "source /opt/ros/kinetic/setup.bash" >> ~/.bashrc | |
fi | |
source ~/.bashrc | |
echo "Install ependencies..." | |
sudo apt-get -y install python-rosinstall python-rosinstall-generator python-wstool build-essential | |
echo "==== DONE ====" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment