setup/clone/utility/sats-boot

33 lines
1.0 KiB
Bash

#!/bin/sh
# [1] Set random passwords for 'sats'
RANDOM_PASS=$(tr -cd A-Za-z0-9_ < /dev/urandom | head -c 256);
echo "$RANDOM_PASS\n$RANDOM_PASS\n" | sudo passwd sats;
# [2] Set random passwords for 'pi' itself
RANDOM_PASS=$(tr -cd A-Za-z0-9_ < /dev/urandom | head -c 256);
echo "$RANDOM_PASS\n$RANDOM_PASS\n" | sudo passwd pi;
# [3] Start ssh service
sudo systemctl start ssh;
# [4] Try to install necessary packages
sudo apt-get update;
sudo apt-get -y install git php5 php5-cli php5-curl python-dev;
################################################
#### ONLY ON FIRST BOOT ####
################################################
if [ -e /home/sats/satsd/first_boot ]; then
# [5] Enable SPI device #
echo "device_tree_param=spi=on" | sudo tee -a /boot/config.txt > /dev/null;
echo "dtoverlay=spi-bcm2708" | sudo tee -a /boot/config.txt > /dev/null;
# [6] Clone SPI python library #
sudo git clone https://github.com/lthiery/SPI-Py.git /home/pi/spi-lib;
sudo python /home/pi/spi-lib/setup.py install;
fi;