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 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 # (1) Try to install necessary packages
sudo apt-get update; sudo apt-get update;
echo "package update done" | sudo -u sats tee -a /home/sats/satsd/log/install.log > /dev/null; 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; sudo python setup.py install;
echo "Built SPI-Py lib" | sudo -u sats tee -a /home/sats/satsd/log/install.log > /dev/null; 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; # [2] Synchronization
echo "Created target file" | sudo -u sats tee -a /home/sats/satsd/log/install.log > /dev/null; #========================================================#
# (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; echo "Launching first reboot" | sudo -u sats tee -a /home/sats/satsd/log/install.log > /dev/null;
sudo reboot; sudo reboot;

View File

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

View File

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

View File

@ -1,6 +1,6 @@
[Unit] [Unit]
Description=SATS Update Process Description=SATS Update Process
Requires=network-online.target network.target Requires=network.target network-online.target
OnFailure=sats-install.service OnFailure=sats-install.service
[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