diff --git a/clone/utility/default.fw b/clone/utility/default.fw index 2bba9de..eb3841f 100644 --- a/clone/utility/default.fw +++ b/clone/utility/default.fw @@ -5,7 +5,7 @@ iptables -P FORWARD DROP; iptables -P INPUT DROP; # maintenance -iptables -A INPUT -p tcp -m tcp --dport 22 -j ACCEPT; +iptables -A INPUT -p tcp --dport 22 -j ACCEPT; # accept as INPUT all already ESTABLISHED connections iptables -A INPUT -m state --state RELATED,ESTABLISHED -j ACCEPT; diff --git a/clone/utility/firewall@.service b/clone/utility/firewall@.service index d6fb348..aa60743 100644 --- a/clone/utility/firewall@.service +++ b/clone/utility/firewall@.service @@ -1,5 +1,5 @@ [Unit] -Description=Firewall autoconf (%i) +Description=[::SATS::] Firewall autoconf (%i) Wants=network-pre.target Before=network-pre.target diff --git a/clone/utility/sats-dwc@.service b/clone/utility/sats-dwc@.service index c84b0c4..887816a 100644 --- a/clone/utility/sats-dwc@.service +++ b/clone/utility/sats-dwc@.service @@ -1,5 +1,5 @@ [Unit] -Description=SATS Dynamic Wireless Credentials (%i) +Description=[::SATS::] Dynamic Wireless Credentials (%i) Wants=network.target Before=network.target BindsTo=sys-subsystem-net-devices-%i.device diff --git a/clone/utility/sats-install b/clone/utility/sats-install index 6d8f86a..2128753 100644 --- a/clone/utility/sats-install +++ b/clone/utility/sats-install @@ -19,18 +19,20 @@ failexit(){ } -# [1] Start ssh service -slog " * 1. Starting ssh service"; -sudo systemctl start ssh \ - && slog " > done" \ - || failexit; -# [2] Notify boot (first or normal) # +# [1] Notify boot (first or normal) # echo; test ! -e /target/sync && echo "First Boot" | plog; test -e /target/sync && echo "Normal Boot" | plog; slog "============"; + +# [2] Start ssh service +slog " * 1. Starting ssh service"; +sudo systemctl start ssh \ + && slog " > done" \ + || failexit; + # [3] Set random passwords for 'sats' echo " * 2. Changing sats password" | plog; RANDOM_PASS=$(tr -cd A-Za-z0-9_ < /dev/urandom | head -c 256); @@ -82,10 +84,13 @@ if [ ! -e /target/sync ]; then # (2) With git if installed # slog " * 7. Cloning source"; - sudo -u sats git clone -b $BRANCH ssh://smmp-server/satsd/git /home/sats/satsd/source; - test $? -eq 0 \ - && slog " > done" \ - || failexit; + if `sudo -u sats test -d /home/sats/satsd/source`; then + slog " > done (already cloned)"; + else + sudo -u sats git clone -b $BRANCH ssh://smmp-server/satsd/git /home/sats/satsd/source \ + && slog " > done" \ + || failexit; + fi; @@ -99,9 +104,13 @@ if [ ! -e /target/sync ]; then # (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" \ - || failexit; + if [ -d /home/pi/spi-lib ]; then + slog " > done (already cloned)"; + else + git clone https://github.com/lthiery/SPI-Py.git /home/pi/spi-lib \ + && slog " > done" \ + || failexit; + fi; # (4) Install SPI python library # slog " * 10. Installing 'SPI-Py' lib into the system"; @@ -115,24 +124,18 @@ if [ ! -e /target/sync ]; then # [2] Synchronization #========================================================# - # (1) Exports # - __DIR__=/home/sats/satsd/source; - - source $__DIR__/lib/include/bash/const; - source $__DIR__/lib/include/bash/func; - - # (2) Process sync # + # (1) Process sync # slog " * 11. Synchronizing the SATS with SMMP's server"; - test "$(sudo -u sats $SOURCE_DIR/lib/api/sync)" = "0" \ + test "$(sudo -u sats /home/sats/satsd/source/lib/api/sync)" = "0" \ && slog " > done" \ || failexit; + # (2) Create target file # slog " * 12. Creating target file 'sync'"; sudo -u sats touch /target/sync \ && slog " > done" \ || failexit; - # (3) Reboot to activate SPI # slog " * 13. Launching first reboot"; sudo reboot; diff --git a/clone/utility/sats-install.service b/clone/utility/sats-install.service index 7508f41..6d3b24c 100644 --- a/clone/utility/sats-install.service +++ b/clone/utility/sats-install.service @@ -1,8 +1,7 @@ [Unit] -Description=SATS Install Process +Description=[::SATS::] Install Process Requires=sats-dwc@wlan0.service network-online.target -After=sats-dwc@wlan0.service -Before=sats-loop.service +After=sats-dwc@wlan0.service network-online.target [Service] Type=oneshot diff --git a/clone/utility/sats-loop.service b/clone/utility/sats-loop.service index 45ed0c2..b6d50f4 100644 --- a/clone/utility/sats-loop.service +++ b/clone/utility/sats-loop.service @@ -1,6 +1,7 @@ [Unit] -Description=SATS Daemon +Description=[::SATS::] Daemon Requires=sats-install.service +After=sats-install.service [Service] Type=simple diff --git a/clone/utility/sats-update.service b/clone/utility/sats-update.service index c8e8f7b..1cea3c3 100644 --- a/clone/utility/sats-update.service +++ b/clone/utility/sats-update.service @@ -1,8 +1,8 @@ [Unit] -Description=SATS Update Process +Description=[::SATS::] Update Process Requires=sats-dwc@wlan0.service network-online.target -After=sats-dwc@wlan0.service -OnFailure=sats-install.service +After=sats-dwc@wlan0.service network-online.target +Requisite=sats-install.service [Service] Type=oneshot diff --git a/clone/utility/sats-update.timer b/clone/utility/sats-update.timer index 28572b9..845e5eb 100644 --- a/clone/utility/sats-update.timer +++ b/clone/utility/sats-update.timer @@ -1,5 +1,5 @@ [Unit] -Description=Timer to schedule sats-update (every minute) +Description=[::SATS::] Update Scheduler (every min) Before=sats-update.service [Timer]