updated services

This commit is contained in:
xdrm-brackets 2017-07-21 12:43:37 +02:00
parent 052bd68ea0
commit e88f8e3089
5 changed files with 46 additions and 12 deletions

View File

@ -32,6 +32,15 @@ echo "pi password changed" | sudo -u sats tee -a /home/sats/satsd/log/install.lo
################################################
if [ ! -e /target/install ]; then
# (1) If no network -> exit #
if [ $(systemctl is-active network-online.target) != "active" ]; then
echo "not connection, rebooting" | sudo -u sats tee -a /home/sats/satsd/log/install.log > /dev/null;
exit 127;
fi;
# [1] Installation
#========================================================#
# (1) Try to install necessary packages
sudo apt-get update;
echo "package update done" | sudo -u sats tee -a /home/sats/satsd/log/install.log > /dev/null;
@ -70,9 +79,24 @@ if [ ! -e /target/install ]; then
sudo python setup.py install;
echo "Built SPI-Py lib" | sudo -u sats tee -a /home/sats/satsd/log/install.log > /dev/null;
# (4) Reboot to activate SPI #
sudo -u sats touch /target/install;
echo "Created target file" | sudo -u sats tee -a /home/sats/satsd/log/install.log > /dev/null;
# [2] Synchronization
#========================================================#
# (1) Exports #
__DIR__=/home/sats/satsd/source;
source $__DIR__/lib/include/bash/const;
source $__DIR__/lib/include/bash/func;
# (2) Process sync #
echo "Synchronization" | sudo -u sats tee -a /home/sats/satsd/log/install.log > /dev/null;
test "$($SOURCE_DIR/lib/api/sync)" = "127" && slog "sync failed" - "install" && exit 127;
sudo -u sats touch /target/sync;
echo "Created target file 'sync'" | sudo -u sats tee -a /home/sats/satsd/log/install.log > /dev/null;
# (3) Reboot to activate SPI #
echo "Launching first reboot" | sudo -u sats tee -a /home/sats/satsd/log/install.log > /dev/null;
sudo reboot;

View File

@ -1,7 +1,7 @@
[Unit]
Description=SATS Install Process
Requires=network-online.target
After=network-online.target network.target
Requires=network.target network-online.target
After=network.target network-online.target
Before=sats-loop.service
[Service]
@ -9,7 +9,4 @@ Type=oneshot
RemainAfterExit=yes
User=pi
Group=pi
ExecStart=/bin/sh /service/sats-install
[Install]
WantedBy=multi-user.target
ExecStart=/bin/bash /service/sats-install

View File

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

View File

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

View File

@ -0,0 +1,14 @@
[Unit]
Description=SATS DWC (Dynamic Wireless Credentials)
Requires=sats-install.service
Before=network.target
[Service]
Type=simple
User=sats
Group=sats
ExecStart=/bin/sh /service/sats-loop
Restart=always
[Install]
WantedBy=multi-user.target