minmod
This commit is contained in:
parent
3a150eab95
commit
ba30eb1bc6
|
@ -13,12 +13,17 @@ slog(){
|
|||
echo "$1" | plog;
|
||||
}
|
||||
|
||||
failexit(){
|
||||
slog " > failed";
|
||||
exit 127;
|
||||
}
|
||||
|
||||
|
||||
# [1] Start ssh service
|
||||
slog " * 1. Starting ssh service";
|
||||
sudo systemctl start ssh \
|
||||
&& slog " > done" \
|
||||
|| ( slog " > failed" && exit 127 );
|
||||
|| failexit;
|
||||
|
||||
# [2] Notify boot (first or normal) #
|
||||
echo;
|
||||
|
@ -32,7 +37,7 @@ RANDOM_PASS=$(tr -cd A-Za-z0-9_ < /dev/urandom | head -c 256);
|
|||
echo -ne "$RANDOM_PASS\n$RANDOM_PASS\n" | sudo passwd sats;
|
||||
test $? -eq 0 \
|
||||
&& slog " > done" \
|
||||
|| ( slog " > failed" && exit 127 );
|
||||
|| failexit;
|
||||
|
||||
# [4] Set random passwords for 'pi' itself
|
||||
echo " * 3. Changing pi password" | plog;
|
||||
|
@ -40,7 +45,7 @@ RANDOM_PASS=$(tr -cd A-Za-z0-9_ < /dev/urandom | head -c 256);
|
|||
echo -ne "$RANDOM_PASS\n$RANDOM_PASS\n" | sudo passwd pi;
|
||||
test $? -eq 0 \
|
||||
&& slog " > done" \
|
||||
|| ( slog " > failed" && exit 127 );
|
||||
|| failexit;
|
||||
|
||||
|
||||
|
||||
|
@ -54,7 +59,7 @@ if [ ! -e /target/sync ]; then
|
|||
slog " * 4. Checking connectivity";
|
||||
test $(systemctl is-active network-online.target) = "active" \
|
||||
&& slog " > done" \
|
||||
|| ( slog " > failed" && exit 127 );
|
||||
|| failexit;
|
||||
|
||||
|
||||
# [1] Installation
|
||||
|
@ -64,13 +69,13 @@ if [ ! -e /target/sync ]; then
|
|||
sudo apt-get update;
|
||||
test $? -eq 0 \
|
||||
&& slog " > done" \
|
||||
|| ( slog " > failed" && exit 127 );
|
||||
|| failexit;
|
||||
|
||||
slog " * 6. Installing necessary packages";
|
||||
sudo apt-get -y install git php5 php5-cli php5-curl python-dev;
|
||||
test $? -eq 0 \
|
||||
&& slog " > done" \
|
||||
|| ( slog " > failed" && exit 127 );
|
||||
|| failexit;
|
||||
|
||||
|
||||
BRANCH=$(sudo cat /home/sats/satsd/conf/machine.branch) > /dev/null;
|
||||
|
@ -80,31 +85,31 @@ if [ ! -e /target/sync ]; then
|
|||
sudo -u sats git clone -b $BRANCH ssh://smmp-server/satsd/git /home/sats/satsd/source;
|
||||
test $? -eq 0 \
|
||||
&& slog " > done" \
|
||||
|| ( slog " > failed" && exit 127 );
|
||||
|| failexit;
|
||||
|
||||
|
||||
|
||||
# (2) Enable SPI device #
|
||||
echo " * 8. Enabling spi device";
|
||||
echo "dtparam=spi=on" | sudo tee -a /boot/config.txt > /dev/null \
|
||||
|| ( slog " > failed" && exit 127 );
|
||||
|| failexit;
|
||||
echo "dtoverlay=spi-bcm2708" | sudo tee -a /boot/config.txt > /dev/null \
|
||||
|| ( slog " > failed" && exit 127 );
|
||||
|| failexit;
|
||||
slog " > done";
|
||||
|
||||
# (3) Clone SPI python library #
|
||||
slog " * 9. Cloning 'SPI-Py' lib";
|
||||
git clone https://github.com/lthiery/SPI-Py.git /home/pi/spi-lib \
|
||||
&& slog " > done" \
|
||||
|| ( slog " > failed" && exit 127 );
|
||||
|| failexit;
|
||||
|
||||
# (4) Install SPI python library #
|
||||
slog " * 10. Installing 'SPI-Py' lib into the system";
|
||||
cd /home/pi/spi-lib;
|
||||
sudo python setup.py build \
|
||||
|| ( slog " > failed" && exit 127 );
|
||||
|| failexit;
|
||||
sudo python setup.py install \
|
||||
|| ( slog " > failed" && exit 127 );
|
||||
|| failexit;
|
||||
slog " > done";
|
||||
|
||||
|
||||
|
@ -120,12 +125,12 @@ if [ ! -e /target/sync ]; then
|
|||
slog " * 11. Synchronizing the SATS with SMMP's server";
|
||||
test "$(sudo -u sats $SOURCE_DIR/lib/api/sync)" = "0" \
|
||||
&& slog " > done" \
|
||||
|| ( slog " > failed" && exit 127 );
|
||||
|| failexit;
|
||||
|
||||
slog " * 12. Creating target file 'sync'";
|
||||
sudo -u sats touch /target/sync \
|
||||
&& slog " > done" \
|
||||
|| ( slog " > failed" && exit 127 );
|
||||
|| failexit;
|
||||
|
||||
|
||||
# (3) Reboot to activate SPI #
|
||||
|
|
Loading…
Reference in New Issue