# SCRIPT TO EXECUTE MANUALLY, STEP BY STEP # Create a new Raspoid image (based on Raspbian Jessie) # # Raspoid - Easily combine a Raspberry Pi, NXT LEGO and electronics with a Java framework. # # Julien Louette & Gael Wittorski sudo apt-get update sudo apt-get dist-upgrade # ----------------------------------- # raspi-config sudo raspi-config # 1. Expand Filesystem # 2. Change User Password => raspoid # 3. Boot Options => Desktop Autologin (Desktop GUI, automatically logged in as 'pi' user) # 4. (need to connect a keyboard to the RPi) Internationalisation Options => Change Keyboard Layout => ... Generic Azerty configured # 5. Internationalisation Options => Change Timezone => Europe / Brussels # 5. Enable Camera => Enable # 6. Advanced Options => Hostname => raspoid # 7. Advanced Options => I2C => Yes => Load by Default # 8. Finish => Reboot now # ----------------------------------- # GStreamer # note: didn't work with v1.0 of GStreamer - works only with v.0.10 sudo apt-get install gstreamer-tools gstreamer0.10-plugins-base gstreamer0.10-plugins-good gstreamer0.10-plugins-bad gstreamer0.10-plugins-ugly # ----------------------------------- # OpenCV # http://stefanshacks.blogspot.be/2015/05/build-opencv-with-java-bindings-on_6.html wget http://www.linux-projects.org/listing/uv4l_repo/lrkey.asc && sudo apt-key add ./lrkey.asc sudo nano /etc/apt/sources.list # add the following deb http://www.linux-projects.org/listing/uv4l_repo/raspbian/ wheezy main # update and install sudo apt-get update sudo apt-get install uv4l uv4l-raspicam sudo apt-get install uv4l-raspicam-extras sudo apt-get install git ant sudo apt-get install build-essential cmake pkg-config libpng12-0 libpng12-dev libpng++-dev libpng3 sudo apt-get install libpnglite-dev zlib1g-dbg zlib1g zlib1g-dev pngtools libtiff5-dev # small difference with tutorial # -----install ffmpeg for Jessie START # https://www.assetbank.co.uk/support/documentation/install/ffmpeg-debian-squeeze/ffmpeg-debian-jessie/ # Ffmpeg will be installed into /usr/local/bin sudo nano /etc/apt/sources.list # add the following deb http://www.deb-multimedia.org jessie main non-free deb-src http://www.deb-multimedia.org jessie main non-free sudo apt-get update sudo apt-get install deb-multimedia-keyring sudo apt-get update sudo apt-get remove ffmpeg apt-get install build-essential libmp3lame-dev libvorbis-dev libtheora-dev libspeex-dev yasm pkg-config libfaac-dev libopenjpeg-dev libx264-dev mkdir software cd software wget http://ffmpeg.org/releases/ffmpeg-2.7.2.tar.bz2 cd .. mkdir src cd src tar xvjf ../software/ffmpeg-2.7.2.tar.bz2 cd ffmpeg-2.7.2 ./configure --enable-gpl --enable-postproc --enable-swscale --enable-avfilter --enable-libmp3lame --enable-libvorbis --enable-libtheora --enable-libx264 --enable-libspeex --enable-shared --enable-pthreads --enable-libopenjpeg --enable-libfaac --enable-nonfree make # >> 2h sudo make install sudo /sbin/ldconfig cd rm -rf software rm -rf src # -----install ffmpeg END # update and install sudo apt-get install libtiff4 libtiffxx0c2 libtiff-tools libjpeg8 libjpeg8-dev libjpeg8-dbg libjpeg-progs libavcodec-dev PROBLEMS WITH THESE TWO libavcodec53 libavformat53 sudo apt-get install libavformat-dev libgstreamer0.10-0-dbg libgstreamer0.10-0 libgstreamer0.10-dev sudo apt-get install libxine2-ffmpeg libxine2-dev libxine2-bin libunicap2 libunicap2-dev libdc1394-22-dev libdc1394-22 libdc1394-utils sudo apt-get install swig libv4l-0 libv4l-dev sudo nano /etc/environment # add the following JAVA_HOME=/usr/lib/jvm/jdk-8-oracle-arm32-vfp-hflt # download OpenCV git clone git://github.com/Itseez/opencv.git cd opencv git checkout 2.4 mkdir build cd build cmake -D CMAKE_BUILD_TYPE=RELEASE -D CMAKE_INSTALL_PREFIX=/usr/local -D BUILD_EXAMPLES=OFF –D BUILD_PNG=ON .. make # ~5hours sudo cp lib/libopencv_java2*.so $JAVA_HOME/jre/lib/arm/ cp bin/opencv-2413.jar ~ cd mkdir opencd_tmp cd opencd_tmp mkdir data mkdir samples cd samples mkdir java cd .. mkdir build cd build mkdir lib cd cp -r opencv/data/* opencd_tmp/data/ cp -r opencv/samples/java/* opencd_tmp/samples/java/ cp opencv/build/bin/opencv-2413.jar opencd_tmp/ cp -r opencv/build/lib/* opencd_tmp/build/lib/ rm -rf opencv mv opencd_tmp opencv # ----------------------------------- # Install BrickPi components # http://www.dexterindustries.com/BrickPi/getting-started/pi-prep/ cd git clone https://github.com/DexterInd/BrickPi.git cd BrickPi/Setup\ Files/ sudo chmod +x install.sh sudo ./install.sh # personally, I prefere to execute manually each step of the script # /!\ the procedure to disable getty has changed with Jessie. Use the following: sudo systemctl disable serial-getty@ttyAMA0.service # ----------------------------------- # MP4 converter sudo apt-get install -y libav-tools # ----------------------------------- # EZ Server Monitor sudo apt-get install apache2 libapache2-mod-php5 php5-cgi php5-cli php5-common php5-curl php5-fpm php5-gd sudo nano /etc/apache2/sites-available/000-default.conf # change the line DocumentRoot /var/www/html with DocumentRoot /var/www/ez_monitor cd /var/www sudo mkdir ez_monitor cd ez_monitor sudo wget http://ezservermonitor.com/esm-web/downloads/version/2.5 sudo unzip 2.5 cd eZServerMonitor-2.5 sudo mv * .. cd .. sudo rm -rf eZServerMonitor-2.5 2.5 sudo service apache2 restart # ----------------------------------- # VNC server # http://elinux.org/RPi_VNC_Server#Instructions sudo apt-get install tightvncserver vncserver :1 # setted pwd: raspoid sudo bash nano /etc/init.d/vncboot # content #!/bin/sh ### BEGIN INIT INFO # Provides: vncboot # Required-Start: $remote_fs $syslog # Required-Stop: $remote_fs $syslog # Default-Start: 2 3 4 5 # Default-Stop: 0 1 6 # Short-Description: Start VNC Server at boot time # Description: Start VNC Server at boot time. ### END INIT INFO USER=pi HOME=/home/pi export USER HOME case "$1" in start) echo "Starting VNC Server" #Insert your favoured settings for a VNC session su - ${USER} -c "/usr/bin/vncserver :0" ;; stop) echo "Stopping VNC Server" su - ${USER} -c "/usr/bin/vncserver -kill :0" ;; *) echo "Usage: /etc/init.d/vncboot {start|stop}" exit 1 ;; esac exit 0 # update permissions chmod 755 /etc/init.d/vncboot # enable dependency based boot sequencing update-rc.d vncboot defaults # ----------------------------------- # WiFi hostpot (Specificaly for Edimax) sudo apt-get install hostapd udhcpd # 1 - Edimax driver # http://www.daveconroy.com/turn-your-raspberry-pi-into-a-wifi-hotspot-with-edimax-nano-usb-ew-7811un-rtl8188cus-chipset/ wget http://www.daveconroy.com/wp3/wp-content/uploads/2013/07/hostapd.zip unzip hostapd.zip sudo mv /usr/sbin/hostapd /usr/sbin/hostapd.bak sudo mv hostapd /usr/sbin/hostapd.edimax sudo ln -sf /usr/sbin/hostapd.edimax /usr/sbin/hostapd sudo chown root.root /usr/sbin/hostapd sudo chmod 755 /usr/sbin/hostapd rm hostapd.zip # 2 - configuration # http://elinux.org/RPI-Wireless-Hotspot pi@raspoid:~ $ sudo nano /etc/udhcpd.conf pi@raspoid:~ $ sudo nano /etc/default/udhcpd pi@raspoid:~ $ sudo ifconfig wlan0 192.168.42.1 pi@raspoid:~ $ sudo nano /etc/network/interfaces pi@raspoid:~ $ sudo nano /etc/hostapd/hostapd.conf pi@raspoid:~ $ sudo nano /etc/default/hostapd pi@raspoid:~ $ sudo sh -c "echo 1 > /proc/sys/net/ipv4/ip_forward" pi@raspoid:~ $ sudo nano /etc/sysctl.conf pi@raspoid:~ $ sudo iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE pi@raspoid:~ $ sudo iptables -A FORWARD -i eth0 -o wlan0 -m state --state RELATED,ESTABLISHED -j ACCEPT pi@raspoid:~ $ sudo iptables -A FORWARD -i wlan0 -o eth0 -j ACCEPT pi@raspoid:~ $ sudo sh -c "iptables-save > /etc/iptables.ipv4.nat" pi@raspoid:~ $ sudo nano /etc/network/interfaces pi@raspoid:~ $ sudo service hostapd start pi@raspoid:~ $ sudo service udhcpd start pi@raspoid:~ $ sudo update-rc.d hostapd enable pi@raspoid:~ $ sudo update-rc.d udhcpd enable pi@raspoid:~ $ sudo nano /etc/default/udhcpd pi@raspoid:~ $ sudo nano /etc/default/hostapd pi@raspoid:~ $ sudo nano /etc/hostapd/hostapd.conf pi@raspoid:~ $ sudo reboot interface=wlan0 driver=rtl871xdrv ssid=Raspoid hw_mode=g channel=6 macaddr_acl=0 auth_algs=1 ignore_broadcast_ssid=0 wpa=2 wpa_passphrase=raspoid wpa_key_mgmt=WPA-PSK wpa_pairwise=TKIP rsn_pairwise=CCMP # ----------------------------------- # Autodetect sudo nano /etc/autodetect_sender.sh # content #!/bin/sh sleep 10 python /etc/autodetect_sender.py sudo chmod +x /etc/autodetect_sender.sh sudo nano /etc/autodetect_sender.py # content #!/usr/bin/env python # -*- coding: utf-8 -*- # # Send broadcast packets on port UDP_PORT to be easily detected on the network # import time import json import socket UDP_IP = '' UDP_PORT = 4242 sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM) sock.bind((UDP_IP, 0)) sock.setsockopt(socket.SOL_SOCKET, socket.SO_BROADCAST, 1) while True: ip_addresses = [l for l in ([ip for ip in socket.gethostbyname_ex(socket.gethostname())[2] if not ip.startswith("127.")][:1], [[(s.connect(('8.8.8.8', 80)), s.getsockname()[0], s.close()) for s in [socket.socket(socket.AF_INET, socket.SOCK_DGRAM)]][0][1]]) if l][0][0] hostname = socket.gethostname() data = json.dumps({'id': "robot_detected", 'ip_addresses': ip_addresses, 'hostname': hostname}) sock.sendto(data, ('', UDP_PORT)) time.sleep(2) # automatic start at launch sudo nano /etc/rc.local # add the following: /etc/autodetect_sender.sh # example script for detection: https://bitbucket.org/snippets/julien0305/aKBgr (send stop command to stop the program) # ----------------------------------- # Raspoid # Script to download the last release of the framework from Raspoid.com cd nano update_raspoid_last_release # content #!/bin/sh wget -O raspoid_last_release.jar http://raspoid.com/download/jar chmod 755 update_raspoid_last_release # ----------------------------------- # Message of the day sudo nano /etc/motd # add this content ____ _ _ | _ \ __ _ ___ _ __ ___ (_) __| | | |_) / _` / __| '_ \ / _ \| |/ _` | | _ < (_| \__ \ |_) | (_) | | (_| | |_| \_\__,_|___/ .__/ \___/|_|\__,_| |_| +----------------------------------+ | Website: http://www.raspoid.com | +----------------------------------+ # ----------------------------------- # Retrieve up to 1.4Go sudo apt-get autoremove --purge wolfram-engine minecraft-pi sonic-pi libreoffice* sudo apt-get clean