[fix] error in target management
This commit is contained in:
parent
eca2a82f41
commit
841ad8cfba
|
@ -3,19 +3,26 @@
|
|||
#@@@@#
|
||||
|
||||
# [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);
|
||||
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
|
||||
RANDOM_PASS=$(tr -cd A-Za-z0-9_ < /dev/urandom | head -c 256);
|
||||
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
|
||||
sudo systemctl start ssh;
|
||||
sudo -u sats echo "started ssh service" >> /home/sats/satsd/log/sats-install;
|
||||
|
||||
# [4] Try to install necessary packages
|
||||
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 -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 #
|
||||
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 touch /target/install \
|
||||
|| exit;
|
||||
|
||||
echo "..done" >> /home/sats/satsd/log/sats-install;
|
||||
fi;
|
||||
|
||||
|
||||
|
@ -43,17 +52,22 @@ if [ ! -e /target/install ]; then
|
|||
# (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;
|
||||
sudo -u sats echo "enabled SPI device" >> /home/sats/satsd/log/sats-install;
|
||||
|
||||
# (3) Clone SPI python library #
|
||||
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 #
|
||||
cd /home/pi/spi-lib;
|
||||
sudo python setup.py build;
|
||||
sudo python setup.py install;
|
||||
sudo -u sats echo "Built SPI-Py lib" >> /home/sats/satsd/log/sats-install;
|
||||
|
||||
# (4) Reboot to activate SPI #
|
||||
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;
|
||||
|
||||
fi;
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
#!/bin/sh
|
||||
|
||||
# [0] Check installed first
|
||||
if [ ! -e /target/install ]; then
|
||||
if [ ! -e /target/sync ]; then
|
||||
exit 1;
|
||||
fi;
|
||||
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
[Unit]
|
||||
Description=SATS Daemon
|
||||
Wants=sats-install.service
|
||||
OnFailure=sats-install.service
|
||||
OnFailure=sats-update.service
|
||||
|
||||
[Service]
|
||||
Type=simple
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
#!/bin/sh
|
||||
|
||||
# [0] Check synced first
|
||||
if [ ! -e /target/sync ]; then
|
||||
# [0] Check installed first
|
||||
if [ ! -e /target/install ]; then
|
||||
exit 1;
|
||||
fi;
|
||||
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
[Unit]
|
||||
Description=SATS Update Process
|
||||
Requires=network-online.target network.target
|
||||
OnFailure=sats-loop.service
|
||||
OnFailure=sats-install.service
|
||||
|
||||
[Service]
|
||||
RemainAfterExit=yes
|
||||
|
|
Loading…
Reference in New Issue