[bigfix] fixed services + fixed firewall rule + fixed sats-install (on shutdown during install, commands can run again for next boot)
This commit is contained in:
parent
a26f3478b7
commit
a438c6f939
|
@ -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;
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
[Unit]
|
||||
Description=Firewall autoconf (%i)
|
||||
Description=[::SATS::] Firewall autoconf (%i)
|
||||
Wants=network-pre.target
|
||||
Before=network-pre.target
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
[Unit]
|
||||
Description=SATS Daemon
|
||||
Description=[::SATS::] Daemon
|
||||
Requires=sats-install.service
|
||||
After=sats-install.service
|
||||
|
||||
[Service]
|
||||
Type=simple
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
[Unit]
|
||||
Description=Timer to schedule sats-update (every minute)
|
||||
Description=[::SATS::] Update Scheduler (every min)
|
||||
Before=sats-update.service
|
||||
|
||||
[Timer]
|
||||
|
|
Loading…
Reference in New Issue