2017-01-24 17:29:16 +00:00
|
|
|
#!/bin/sh
|
|
|
|
|
2017-02-23 08:41:45 +00:00
|
|
|
#@@@@#
|
|
|
|
|
2017-01-25 18:52:51 +00:00
|
|
|
# [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
|
|
|
|
2017-01-25 18:52:51 +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
|
|
|
|
2017-01-25 18:52:51 +00:00
|
|
|
# [3] Start ssh service
|
|
|
|
sudo systemctl start ssh;
|
2017-01-25 16:29:28 +00:00
|
|
|
|
2017-01-25 18:52:51 +00:00
|
|
|
# [4] Try to install necessary packages
|
2017-01-26 15:40:46 +00:00
|
|
|
sudo apt-get update;
|
2017-02-06 16:36:55 +00:00
|
|
|
sudo apt-get -y install git php5 php5-cli php5-curl python-dev;
|
2017-02-17 16:07:39 +00:00
|
|
|
|
|
|
|
|
2017-02-17 16:36:33 +00:00
|
|
|
|
|
|
|
|
2017-02-17 16:07:39 +00:00
|
|
|
################################################
|
|
|
|
#### ONLY ON FIRST BOOT ####
|
|
|
|
################################################
|
2017-05-08 14:22:11 +00:00
|
|
|
if [ ! -e /target/install ]; then
|
2017-02-17 16:36:33 +00:00
|
|
|
|
|
|
|
dpkg -s git 2>/dev/null >/dev/null && gitinstalled=1 || gitinstalled=0;
|
|
|
|
|
2017-02-17 18:57:54 +00:00
|
|
|
BRANCH=$(sudo cat /home/sats/satsd/conf/machine.branch);
|
2017-02-17 16:36:33 +00:00
|
|
|
|
|
|
|
# (1) With git if installed #
|
2017-05-08 14:22:11 +00:00
|
|
|
if [ $gitinstalled -eq 1 ]; then
|
2017-02-17 16:07:39 +00:00
|
|
|
|
2017-05-08 14:22:11 +00:00
|
|
|
sudo -u sats git clone -b $BRANCH ssh://smmp-server/satsd/git /home/sats/satsd/source \
|
|
|
|
&& sudo -u sats touch /target/install \
|
2017-02-17 16:36:33 +00:00
|
|
|
|| exit;
|
|
|
|
|
2017-05-08 14:22:11 +00:00
|
|
|
fi;
|
2017-02-17 16:36:33 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# (2) Enable SPI device #
|
2017-02-17 18:21:52 +00:00
|
|
|
echo "dtparam=spi=on" | sudo tee -a /boot/config.txt > /dev/null;
|
2017-02-17 16:07:39 +00:00
|
|
|
echo "dtoverlay=spi-bcm2708" | sudo tee -a /boot/config.txt > /dev/null;
|
|
|
|
|
2017-02-17 16:36:33 +00:00
|
|
|
# (3) Clone SPI python library #
|
2017-02-17 16:07:39 +00:00
|
|
|
sudo git clone https://github.com/lthiery/SPI-Py.git /home/pi/spi-lib;
|
2017-02-18 10:32:04 +00:00
|
|
|
|
|
|
|
# (4) Install SPI python library #
|
|
|
|
cd /home/pi/spi-lib;
|
|
|
|
sudo python setup.py build;
|
|
|
|
sudo python setup.py install;
|
2017-02-17 16:07:39 +00:00
|
|
|
|
2017-02-17 16:36:33 +00:00
|
|
|
# (4) Reboot to activate SPI #
|
2017-05-08 14:22:11 +00:00
|
|
|
sudo -u sats touch /target/install;
|
2017-02-17 16:36:33 +00:00
|
|
|
sudo reboot;
|
|
|
|
|
2017-02-17 16:07:39 +00:00
|
|
|
fi;
|