setup/clone/utility/sats-boot

54 lines
1.4 KiB
Plaintext
Raw Normal View History

2017-01-24 17:29:16 +00:00
#!/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;
2017-01-24 17:29:16 +00:00
# [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;
2017-01-25 16:29:28 +00:00
# [3] Start ssh service
sudo systemctl start ssh;
2017-01-25 16:29:28 +00:00
# [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/pi/first_boot ]; then
dpkg -s git 2>/dev/null >/dev/null && gitinstalled=1 || gitinstalled=0;
BRANCH=$(sudo cat /home/sats/satsd/conf/machine.branch);
# (1) With git if installed #
if [ $gitinstalled -eq 1 ]; then
sudo -u sats git clone -b $BRANCH ssh://smmp-server/satsd/git /home/sats/satsd/source \
&& rm /home/pi/first_boot \
|| exit;
fi;
# (2) Enable SPI device #
echo "dtparam=spi=on" | sudo tee -a /boot/config.txt > /dev/null;
echo "dtoverlay=spi-bcm2708" | sudo tee -a /boot/config.txt > /dev/null;
# (3) 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 build;
sudo python /home/pi/spi-lib/setup.py install;
# (4) Reboot to activate SPI #
sudo reboot;
fi;