2016-04-11 06:29:41 +00:00
|
|
|
#!/bin/bash -e
|
|
|
|
|
2016-11-24 20:07:05 +00:00
|
|
|
install -m 644 files/regenerate_ssh_host_keys.service ${ROOTFS_DIR}/lib/systemd/system/
|
2016-04-11 06:29:41 +00:00
|
|
|
install -m 755 files/apply_noobs_os_config ${ROOTFS_DIR}/etc/init.d/
|
|
|
|
install -m 755 files/resize2fs_once ${ROOTFS_DIR}/etc/init.d/
|
|
|
|
|
|
|
|
install -d ${ROOTFS_DIR}/etc/systemd/system/rc-local.service.d
|
|
|
|
install -m 644 files/ttyoutput.conf ${ROOTFS_DIR}/etc/systemd/system/rc-local.service.d/
|
|
|
|
|
|
|
|
install -m 644 files/50raspi ${ROOTFS_DIR}/etc/apt/apt.conf.d/
|
|
|
|
|
2017-02-16 14:22:27 +00:00
|
|
|
install -m 644 files/console-setup ${ROOTFS_DIR}/etc/default/
|
2016-04-11 06:29:41 +00:00
|
|
|
|
2016-11-14 23:55:45 +00:00
|
|
|
on_chroot << EOF
|
2016-04-11 06:29:41 +00:00
|
|
|
systemctl disable hwclock.sh
|
|
|
|
systemctl disable nfs-common
|
|
|
|
systemctl disable rpcbind
|
2017-01-23 17:43:42 +00:00
|
|
|
systemctl enable ssh
|
2016-04-11 06:29:41 +00:00
|
|
|
systemctl enable regenerate_ssh_host_keys
|
|
|
|
systemctl enable apply_noobs_os_config
|
|
|
|
systemctl enable resize2fs_once
|
|
|
|
EOF
|
|
|
|
|
2016-11-14 23:55:45 +00:00
|
|
|
on_chroot << \EOF
|
2016-04-11 06:29:41 +00:00
|
|
|
for GRP in input spi i2c gpio; do
|
|
|
|
groupadd -f -r $GRP
|
|
|
|
done
|
|
|
|
for GRP in adm dialout cdrom audio users sudo video games plugdev input gpio spi i2c netdev; do
|
|
|
|
adduser pi $GRP
|
|
|
|
done
|
|
|
|
EOF
|
|
|
|
|
2016-11-14 23:55:45 +00:00
|
|
|
on_chroot << EOF
|
2016-04-11 06:29:41 +00:00
|
|
|
setupcon --force --save-only -v
|
|
|
|
EOF
|
|
|
|
|
2016-11-14 23:55:45 +00:00
|
|
|
on_chroot << EOF
|
2016-04-11 06:29:41 +00:00
|
|
|
usermod --pass='*' root
|
|
|
|
EOF
|
|
|
|
|
|
|
|
rm -f ${ROOTFS_DIR}/etc/ssh/ssh_host_*_key*
|
2017-01-22 18:41:19 +00:00
|
|
|
|
|
|
|
on_chroot << EOF
|
|
|
|
|
|
|
|
|
|
|
|
#-------------------------------------------------------
|
|
|
|
# Script to check if all is good before install script runs
|
|
|
|
#-------------------------------------------------------
|
|
|
|
|
|
|
|
echo "====== Dride install script ======"
|
|
|
|
echo ""
|
|
|
|
echo ""
|
|
|
|
echo ""
|
|
|
|
echo "██████╗ ██████╗ ██╗██████╗ ███████╗"
|
|
|
|
echo "██╔══██╗██╔══██╗██║██╔══██╗██╔════╝"
|
|
|
|
echo "██║ ██║██████╔╝██║██║ ██║█████╗ "
|
|
|
|
echo "██║ ██║██╔══██╗██║██║ ██║██╔══╝ "
|
|
|
|
echo "██████╔╝██║ ██║██║██████╔╝███████╗"
|
|
|
|
echo "╚═════╝ ╚═╝ ╚═╝╚═╝╚═════╝ ╚══════╝"
|
|
|
|
echo ""
|
|
|
|
echo ""
|
|
|
|
echo "This will install all the necessary dependences and software for dride."
|
|
|
|
echo "======================================================="
|
|
|
|
echo ""
|
|
|
|
echo ""
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
echo ""
|
|
|
|
echo ""
|
|
|
|
echo "==============================="
|
|
|
|
echo "*******************************"
|
|
|
|
echo " *** STARTING INSTALLATION ***"
|
|
|
|
echo " ** this may take a while **"
|
|
|
|
echo " *************************"
|
|
|
|
echo " ========================="
|
|
|
|
echo ""
|
|
|
|
echo ""
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
cd /home
|
|
|
|
|
|
|
|
# Install dependencies
|
|
|
|
echo "========== Update Aptitude ==========="
|
2017-01-25 14:23:35 +00:00
|
|
|
# sudo apt-get update -y
|
2017-01-22 18:41:19 +00:00
|
|
|
# sudo apt-get upgrade
|
|
|
|
|
|
|
|
echo "========== Installing build-essential ============"
|
|
|
|
sudo apt-get install build-essential -y
|
|
|
|
|
2017-01-24 14:30:32 +00:00
|
|
|
|
2017-01-22 18:41:19 +00:00
|
|
|
echo "========== Installing libgtk2.0-dev pkg-config libavcodec-dev libavformat-dev libswscale-dev libjasper-dev python2.7-dev ============"
|
|
|
|
sudo apt-get install cmake git libgtk2.0-dev pkg-config libavcodec-dev libavformat-dev libswscale-dev libjasper-dev python2.7-dev -y
|
|
|
|
|
2017-01-25 12:53:27 +00:00
|
|
|
|
|
|
|
# Install Node
|
|
|
|
echo "========== Installing Node ============"
|
|
|
|
sudo wget http://node-arm.herokuapp.com/node_latest_armhf.deb
|
|
|
|
sudo dpkg -i node_latest_armhf.deb
|
|
|
|
|
2017-01-25 14:23:35 +00:00
|
|
|
sudo rm /home/node_latest_armhf.deb
|
2017-01-25 12:53:27 +00:00
|
|
|
|
|
|
|
|
2017-01-25 14:50:24 +00:00
|
|
|
|
2017-01-22 18:41:19 +00:00
|
|
|
echo "========== Installing pip ============"
|
2017-04-12 11:15:54 +00:00
|
|
|
sudo apt-get install python-pip -y
|
2017-01-22 18:41:19 +00:00
|
|
|
|
|
|
|
echo "========== Installing Numpy ============"
|
|
|
|
sudo pip install numpy
|
|
|
|
|
2017-04-13 12:43:17 +00:00
|
|
|
echo "========== Install picamera ============"
|
2017-04-13 14:28:29 +00:00
|
|
|
sudo pip install "picamera[array]==1.12"
|
2017-04-13 12:43:17 +00:00
|
|
|
|
|
|
|
|
2017-05-10 18:25:56 +00:00
|
|
|
# enable camera on raspi-config and allocate more ram to the GPU
|
2017-04-13 12:43:17 +00:00
|
|
|
echo "" >> /boot/config.txt
|
|
|
|
echo "#enable piCaera" >> /boot/config.txt
|
|
|
|
echo "start_x=1" >> /boot/config.txt
|
2017-05-10 18:25:56 +00:00
|
|
|
echo "gpu_mem=256" >> /boot/config.txt
|
2017-04-13 12:43:17 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
2017-04-12 10:37:58 +00:00
|
|
|
echo "========== Install mpg123 ============"
|
|
|
|
sudo apt-get install mpg123 -y
|
2017-01-22 18:41:19 +00:00
|
|
|
|
|
|
|
|
|
|
|
# Install WIFi
|
2017-01-25 14:50:24 +00:00
|
|
|
echo iptables-persistent iptables-persistent/autosave_v4 boolean true | sudo debconf-set-selections
|
|
|
|
echo iptables-persistent iptables-persistent/autosave_v6 boolean true | sudo debconf-set-selections
|
|
|
|
|
2017-01-22 18:41:19 +00:00
|
|
|
sudo apt-get install hostapd isc-dhcp-server -y
|
|
|
|
sudo apt-get install iptables-persistent -y
|
|
|
|
|
|
|
|
cd /home
|
|
|
|
# get the dhcpd config file
|
|
|
|
sudo wget https://dride.io/code/dhcpd.conf
|
|
|
|
|
|
|
|
sudo cp dhcpd.conf /etc/dhcp/dhcpd.conf
|
|
|
|
sudo rm dhcpd.conf
|
|
|
|
|
|
|
|
|
|
|
|
sudo bash -c 'echo "INTERFACES=\"wlan0\""> /etc/default/isc-dhcp-server'
|
|
|
|
|
|
|
|
sudo ifdown wlan0
|
|
|
|
|
|
|
|
|
|
|
|
sudo wget https://dride.io/code/interfaces
|
|
|
|
|
|
|
|
sudo cp interfaces /etc/network/interfaces
|
|
|
|
sudo rm interfaces
|
|
|
|
|
|
|
|
|
|
|
|
sudo ifconfig wlan0 192.168.42.1
|
|
|
|
|
|
|
|
|
|
|
|
sudo wget https://dride.io/code/hostapd.conf
|
|
|
|
|
|
|
|
sudo cp hostapd.conf /etc/hostapd/hostapd.conf
|
|
|
|
sudo rm hostapd.conf
|
|
|
|
|
|
|
|
sudo bash -c 'echo "DAEMON_CONF=\"/etc/hostapd/hostapd.conf\""> /etc/default/hostapd'
|
|
|
|
|
|
|
|
sudo wget https://dride.io/code/hostapd
|
|
|
|
|
|
|
|
sudo cp hostapd /etc/init.d/hostapd
|
|
|
|
sudo rm hostapd
|
|
|
|
|
|
|
|
|
|
|
|
sudo bash -c 'echo "net.ipv4.ip_forward=1"> /etc/sysctl.conf'
|
|
|
|
sudo sh -c "echo 1 > /proc/sys/net/ipv4/ip_forward"
|
|
|
|
|
|
|
|
sudo iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE
|
|
|
|
sudo iptables -A FORWARD -i eth0 -o wlan0 -m state --state RELATED,ESTABLISHED -j ACCEPT
|
|
|
|
sudo iptables -A FORWARD -i wlan0 -o eth0 -j ACCEPT
|
|
|
|
|
|
|
|
|
|
|
|
sudo sh -c "iptables-save > /etc/iptables/rules.v4"
|
|
|
|
|
|
|
|
sudo mv /usr/share/dbus-1/system-services/fi.epitest.hostap.WPASupplicant.service ~/
|
|
|
|
|
|
|
|
|
|
|
|
sudo service hostapd start
|
|
|
|
sudo service isc-dhcp-server start
|
|
|
|
sudo update-rc.d hostapd enable
|
|
|
|
sudo update-rc.d isc-dhcp-server enable
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
sudo wget https://dride.io/code/startup/dride-ws
|
|
|
|
sudo wget https://dride.io/code/startup/dride-core
|
2017-05-07 14:24:16 +00:00
|
|
|
sudo wget https://dride.io/code/startup/drideOS-resize
|
2017-01-22 18:41:19 +00:00
|
|
|
|
|
|
|
#startup script's
|
|
|
|
|
|
|
|
# express on startup
|
|
|
|
sudo cp dride-ws /etc/init.d/dride-ws
|
|
|
|
sudo chmod +x /etc/init.d/dride-ws
|
|
|
|
sudo update-rc.d dride-ws defaults
|
|
|
|
sudo rm dride-ws
|
|
|
|
|
|
|
|
# dride-core on startup
|
|
|
|
sudo cp dride-core /etc/init.d/dride-core
|
|
|
|
sudo chmod +x /etc/init.d/dride-core
|
|
|
|
sudo update-rc.d dride-core defaults
|
|
|
|
sudo rm dride-core
|
|
|
|
|
2017-05-07 14:24:16 +00:00
|
|
|
# drideOS-resize on startup
|
2017-05-08 05:51:45 +00:00
|
|
|
sudo cp drideOS-resize /etc/init.d/drideOS-resize
|
2017-05-07 14:24:16 +00:00
|
|
|
sudo chmod +x /etc/init.d/drideOS-resize
|
|
|
|
sudo update-rc.d drideOS-resize defaults
|
|
|
|
sudo rm drideOS-resize
|
|
|
|
|
2017-01-22 18:41:19 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2017-04-16 07:24:32 +00:00
|
|
|
## GPS https://www.raspberrypi.org/forums/viewtopic.php?p=947968#p947968
|
|
|
|
echo "========== Install GPS ============"
|
|
|
|
sudo apt-get install gpsd gpsd-clients cmake subversion build-essential espeak freeglut3-dev imagemagick libdbus-1-dev libdbus-glib-1-dev libdevil-dev libfontconfig1-dev libfreetype6-dev libfribidi-dev libgarmin-dev libglc-dev libgps-dev libgtk2.0-dev libimlib2-dev libpq-dev libqt4-dev libqtwebkit-dev librsvg2-bin libsdl-image1.2-dev libspeechd-dev libxml2-dev ttf-liberation -y
|
|
|
|
|
|
|
|
sudo pip install pyserial
|
|
|
|
|
|
|
|
|
|
|
|
echo "" >> /boot/config.txt
|
|
|
|
echo "core_freq=250" >> /boot/config.txt
|
|
|
|
echo "enable_uart=1" >> /boot/config.txt
|
|
|
|
|
2017-05-07 14:24:16 +00:00
|
|
|
# this will be done after initial boot
|
|
|
|
# echo "dwc_otg.lpm_enable=0 console=tty1 root=/dev/mmcblk0p2 rootfstype=ext4 elevator=deadline fsck.repair=yes rootwait" > /boot/cmdline.txt
|
2017-04-16 07:24:32 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# 3)Run
|
|
|
|
sudo systemctl stop serial-getty@ttyS0.service
|
|
|
|
sudo systemctl disable serial-getty@ttyS0.service
|
|
|
|
sudo systemctl stop gpsd.socket
|
|
|
|
sudo systemctl disable gpsd.socket
|
|
|
|
|
|
|
|
# reboot
|
|
|
|
|
|
|
|
# 5) Execute the daemon reset
|
2017-04-17 09:33:18 +00:00
|
|
|
#sudo killall gpsd
|
|
|
|
#sudo gpsd /dev/ttyS0 -F /var/run/gpsd.sock
|
2017-04-16 07:24:32 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2017-04-13 18:56:53 +00:00
|
|
|
echo "========== Downloading and installing OpenCV ============"
|
|
|
|
cd /
|
|
|
|
# git clone https://github.com/Itseez/opencv.git --depth 1
|
|
|
|
wget -c -O "opencv-3.1.0.zip" "https://github.com/Itseez/opencv/archive/3.1.0.zip"
|
|
|
|
sudo apt-get install unzip
|
|
|
|
unzip -q -n "opencv-3.1.0.zip"
|
|
|
|
|
|
|
|
cd opencv-3.1.0
|
|
|
|
echo "==>>>====== Building OpenCV ============"
|
|
|
|
cd /home/opencv-3.1.0
|
|
|
|
mkdir build
|
|
|
|
cd build
|
|
|
|
cmake -D CMAKE_BUILD_TYPE=RELEASE -D BUILD_EXAMPLES=OFF -D BUILD_opencv_apps=OFF -D BUILD_DOCS=OFF -D BUILD_PERF_TESTS=OFF -D BUILD_TESTS=OFF -D CMAKE_INSTALL_PREFIX=/usr/local ..
|
|
|
|
echo "==>>>====== This might take a long time.. ============"
|
|
|
|
make -j1
|
|
|
|
|
|
|
|
sudo make install
|
|
|
|
sudo ldconfig
|
|
|
|
|
|
|
|
# remove the installation file
|
|
|
|
cd /
|
|
|
|
sudo rm opencv-3.1.0.zip
|
2017-01-22 18:41:19 +00:00
|
|
|
|
2017-04-13 18:56:53 +00:00
|
|
|
# TODO: Add a test if openCV was installed correctly
|
2017-01-22 18:41:19 +00:00
|
|
|
|
|
|
|
|
2017-04-23 05:50:19 +00:00
|
|
|
echo "========== Setup sound to I2S ============"
|
|
|
|
sudo curl -sS https://dride.io/code/i2samp.sh | bash
|
2017-01-22 18:41:19 +00:00
|
|
|
|
|
|
|
|
2017-04-24 10:07:35 +00:00
|
|
|
echo "========== Install Dride-core [Cardigan] ============"
|
|
|
|
cd /home
|
2017-04-30 06:21:16 +00:00
|
|
|
# https://s3.amazonaws.com/dride/releases/cardigan/latest.zip
|
2017-04-24 10:07:35 +00:00
|
|
|
sudo mkdir Cardigan && cd Cardigan
|
2017-04-30 06:21:16 +00:00
|
|
|
sudo wget -c -O "cardigan.zip" "https://s3.amazonaws.com/dride/releases/cardigan/latest.zip"
|
|
|
|
sudo unzip "cardigan.zip"
|
2017-04-24 10:07:35 +00:00
|
|
|
|
|
|
|
sudo rm -R __MACOSX
|
2017-04-30 06:21:16 +00:00
|
|
|
sudo rm -R cardigan.zip
|
2017-04-24 10:07:35 +00:00
|
|
|
|
|
|
|
|
|
|
|
# make the video dir writable
|
|
|
|
sudo chmod 777 -R /home/Cardigan/modules/video/
|
2017-04-25 06:03:56 +00:00
|
|
|
sudo chmod 777 -R /home/Cardigan/settings/video/
|
2017-04-24 10:07:35 +00:00
|
|
|
#make gps position writable
|
|
|
|
sudo chmod +x /home/Cardigan/daemons/gps/position
|
|
|
|
|
2017-04-30 06:19:50 +00:00
|
|
|
# make the firmware dir writable
|
|
|
|
cd /home/Cardigan
|
|
|
|
sudo mkdir firmware
|
|
|
|
sudo chmod 777 -R /home/Cardigan/firmware/
|
2017-04-24 10:07:35 +00:00
|
|
|
|
|
|
|
|
|
|
|
# run npm install on dride-ws
|
|
|
|
cd /home/Cardigan/dride-ws
|
|
|
|
|
|
|
|
sudo npm i --production
|
|
|
|
|
|
|
|
|
|
|
|
|
2017-01-22 18:41:19 +00:00
|
|
|
echo ""
|
|
|
|
echo '============================='
|
|
|
|
echo '*****************************'
|
|
|
|
echo '========= Finished =========='
|
|
|
|
echo '*****************************'
|
|
|
|
echo '============================='
|
|
|
|
echo ""
|
|
|
|
|
|
|
|
|
|
|
|
EOF
|