[fix] error in target management

This commit is contained in:
xdrm-brackets 2017-05-08 19:04:30 +02:00
parent eca2a82f41
commit 841ad8cfba
5 changed files with 19 additions and 5 deletions

View File

@ -3,19 +3,26 @@
#@@@@# #@@@@#
# [1] Set random passwords for 'sats' # [1] Set random passwords for 'sats'
test ! -e /target/install && sudo -u sats echo "First Boot" >> /home/sats/satsd/log/sats-install || sudo -u sats echo "Normal Boot" >> /home/sats/satsd/log/sats-install;
sudo -u sats echo "============" >> /home/sats/satsd/log/sats-install;
RANDOM_PASS=$(tr -cd A-Za-z0-9_ < /dev/urandom | head -c 256); RANDOM_PASS=$(tr -cd A-Za-z0-9_ < /dev/urandom | head -c 256);
echo "$RANDOM_PASS\n$RANDOM_PASS\n" | sudo passwd sats; echo "$RANDOM_PASS\n$RANDOM_PASS\n" | sudo passwd sats;
sudo -u sats echo "sats password changed" >> /home/sats/satsd/log/sats-install;
# [2] Set random passwords for 'pi' itself # [2] Set random passwords for 'pi' itself
RANDOM_PASS=$(tr -cd A-Za-z0-9_ < /dev/urandom | head -c 256); RANDOM_PASS=$(tr -cd A-Za-z0-9_ < /dev/urandom | head -c 256);
echo "$RANDOM_PASS\n$RANDOM_PASS\n" | sudo passwd pi; echo "$RANDOM_PASS\n$RANDOM_PASS\n" | sudo passwd pi;
sudo -u sats echo "pi password changed" >> /home/sats/satsd/log/sats-install;
# [3] Start ssh service # [3] Start ssh service
sudo systemctl start ssh; sudo systemctl start ssh;
sudo -u sats echo "started ssh service" >> /home/sats/satsd/log/sats-install;
# [4] Try to install necessary packages # [4] Try to install necessary packages
sudo apt-get update; sudo apt-get update;
sudo -u sats echo "package update done" >> /home/sats/satsd/log/sats-install;
sudo apt-get -y install git php5 php5-cli php5-curl python-dev; sudo apt-get -y install git php5 php5-cli php5-curl python-dev;
sudo -u sats echo "package install done" >> /home/sats/satsd/log/sats-install;
@ -32,10 +39,12 @@ if [ ! -e /target/install ]; then
# (1) With git if installed # # (1) With git if installed #
if [ $gitinstalled -eq 1 ]; then if [ $gitinstalled -eq 1 ]; then
echo "cloning source.." >> /home/sats/satsd/log/sats-install;
sudo -u sats git clone -b $BRANCH ssh://smmp-server/satsd/git /home/sats/satsd/source \ sudo -u sats git clone -b $BRANCH ssh://smmp-server/satsd/git /home/sats/satsd/source \
&& sudo -u sats touch /target/install \ && sudo -u sats touch /target/install \
|| exit; || exit;
echo "..done" >> /home/sats/satsd/log/sats-install;
fi; fi;
@ -43,17 +52,22 @@ if [ ! -e /target/install ]; then
# (2) Enable SPI device # # (2) Enable SPI device #
echo "dtparam=spi=on" | sudo tee -a /boot/config.txt > /dev/null; echo "dtparam=spi=on" | sudo tee -a /boot/config.txt > /dev/null;
echo "dtoverlay=spi-bcm2708" | sudo tee -a /boot/config.txt > /dev/null; echo "dtoverlay=spi-bcm2708" | sudo tee -a /boot/config.txt > /dev/null;
sudo -u sats echo "enabled SPI device" >> /home/sats/satsd/log/sats-install;
# (3) Clone SPI python library # # (3) Clone SPI python library #
sudo git clone https://github.com/lthiery/SPI-Py.git /home/pi/spi-lib; sudo git clone https://github.com/lthiery/SPI-Py.git /home/pi/spi-lib;
sudo -u sats echo "Cloned SPI-Py lib" >> /home/sats/satsd/log/sats-install;
# (4) Install SPI python library # # (4) Install SPI python library #
cd /home/pi/spi-lib; cd /home/pi/spi-lib;
sudo python setup.py build; sudo python setup.py build;
sudo python setup.py install; sudo python setup.py install;
sudo -u sats echo "Built SPI-Py lib" >> /home/sats/satsd/log/sats-install;
# (4) Reboot to activate SPI # # (4) Reboot to activate SPI #
sudo -u sats touch /target/install; sudo -u sats touch /target/install;
sudo -u sats echo "Created target file" >> /home/sats/satsd/log/sats-install;
sudo -u sats echo "Launching first reboot" >> /home/sats/satsd/log/sats-install;
sudo reboot; sudo reboot;
fi; fi;

View File

@ -1,7 +1,7 @@
#!/bin/sh #!/bin/sh
# [0] Check installed first # [0] Check installed first
if [ ! -e /target/install ]; then if [ ! -e /target/sync ]; then
exit 1; exit 1;
fi; fi;

View File

@ -1,7 +1,7 @@
[Unit] [Unit]
Description=SATS Daemon Description=SATS Daemon
Wants=sats-install.service Wants=sats-install.service
OnFailure=sats-install.service OnFailure=sats-update.service
[Service] [Service]
Type=simple Type=simple

View File

@ -1,7 +1,7 @@
#!/bin/sh #!/bin/sh
# [0] Check synced first # [0] Check installed first
if [ ! -e /target/sync ]; then if [ ! -e /target/install ]; then
exit 1; exit 1;
fi; fi;

View File

@ -1,7 +1,7 @@
[Unit] [Unit]
Description=SATS Update Process Description=SATS Update Process
Requires=network-online.target network.target Requires=network-online.target network.target
OnFailure=sats-loop.service OnFailure=sats-install.service
[Service] [Service]
RemainAfterExit=yes RemainAfterExit=yes