Last active
March 9, 2018 08:56
-
-
Save gonzalocasas/b7072aa937ba80438ea8ddd3c7557840 to your computer and use it in GitHub Desktop.
Installer for ROS into a Raspberry Pi
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
#!/bin/bash | |
# Stop on the first sign of trouble | |
set -e | |
if [ $UID != 0 ]; then | |
echo "ERROR: Operation not permitted. Forgot sudo?" | |
exit 1 | |
fi | |
main() { | |
CURRENT_HOSTNAME=$(hostname) | |
NEW_HOSTNAME="ur5-ros-controller" | |
echo "Updating hostname to '$NEW_HOSTNAME'..." | |
hostname $NEW_HOSTNAME | |
echo $NEW_HOSTNAME > /etc/hostname | |
sed -i "s/$CURRENT_HOSTNAME/$NEW_HOSTNAME/" /etc/hosts | |
echo "Upgrading apt-get and source lists..." | |
update-locale LANG=C LANGUAGE=C LC_ALL=C LC_MESSAGES=POSIX | |
# TODO: Check. Looks like dirmngr install only needed in Debian? | |
# apt-get install -y dirmngr | |
sh -c 'echo "deb http://packages.ros.org/ros/ubuntu $(lsb_release -sc) main" > /etc/apt/sources.list.d/ros-latest.list' | |
apt-key adv --keyserver hkp://ha.pool.sks-keyservers.net:80 --recv-key 421C365BD9FF1F717815A3895523BAEEB01FA116 | |
apt-get update | |
apt-get -y upgrade | |
# Installing ROS packages | |
echo "Installing ROS packages and setting up basic ROS core..." | |
apt-get install -y ros-kinetic-desktop-full | |
rosdep init | |
rosdep update | |
echo "source /opt/ros/kinetic/setup.bash" >> ~/.bashrc | |
source ~/.bashrc | |
apt-get install -y ros-kinetic-rosbridge-server ros-kinetic-tf2-web-republisher | |
apt-get install -y ros-kinetic-universal-robot | |
echo "Installing access point and configuring network..." | |
# If Ubuntu MATE: apt-get install -y dhcpcd5 | |
apt-get install -y dnsmasq hostapd | |
systemctl stop dnsmasq | |
systemctl stop hostapd | |
printf 'interface wlan0\n static ip_address=192.168.10.1/24\n' | tee -a /etc/dhcpcd.conf | |
service dhcpcd restart | |
printf 'dhcp-range=192.168.10.2,192.168.10.100,255.255.255.0,24h\n' | tee /etc/dnsmasq.conf | |
printf 'interface=wlan0\ndriver=nl80211\nssid=%s-wifi\nhw_mode=g\nchannel=7\nwmm_enabled=0\nmacaddr_acl=0\nauth_algs=1\nignore_broadcast_ssid=0\nwpa=2\nwpa_passphrase=%s\nwpa_key_mgmt=WPA-PSK\nwpa_pairwise=TKIP\nrsn_pairwise=CCMP\n' $(hostname) 'robopocalypse' | tee -a /etc/hostapd/hostapd.conf | |
sed -i -e 's@#DAEMON_CONF=""@DAEMON_CONF="/etc/hostapd/hostapd.conf"@g' /etc/default/hostapd | |
systemctl start hostapd | |
systemctl start dnsmasq | |
sed -i -e 's/#net.ipv4.ip_forward=1/net.ipv4.ip_forward=1/g' /etc/sysctl.conf | |
iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE | |
sh -c "iptables-save > /etc/iptables.ipv4.nat" | |
sed -i -e 's@exit 0@iptables-restore < /etc/iptables.ipv4.nat@g' /etc/rc.local | |
echo "exit 0" | tee -a /etc/rc.local | |
echo "Everything is awesome!" | |
echo "The system will reboot in 5 seconds..." | |
sleep 5 | |
shutdown -r now | |
} | |
main |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment