[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;
|
iptables -P INPUT DROP;
|
||||||
|
|
||||||
# maintenance
|
# 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
|
# accept as INPUT all already ESTABLISHED connections
|
||||||
iptables -A INPUT -m state --state RELATED,ESTABLISHED -j ACCEPT;
|
iptables -A INPUT -m state --state RELATED,ESTABLISHED -j ACCEPT;
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
[Unit]
|
[Unit]
|
||||||
Description=Firewall autoconf (%i)
|
Description=[::SATS::] Firewall autoconf (%i)
|
||||||
Wants=network-pre.target
|
Wants=network-pre.target
|
||||||
Before=network-pre.target
|
Before=network-pre.target
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
[Unit]
|
[Unit]
|
||||||
Description=SATS Dynamic Wireless Credentials (%i)
|
Description=[::SATS::] Dynamic Wireless Credentials (%i)
|
||||||
Wants=network.target
|
Wants=network.target
|
||||||
Before=network.target
|
Before=network.target
|
||||||
BindsTo=sys-subsystem-net-devices-%i.device
|
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;
|
echo;
|
||||||
test ! -e /target/sync && echo "First Boot" | plog;
|
test ! -e /target/sync && echo "First Boot" | plog;
|
||||||
test -e /target/sync && echo "Normal Boot" | plog;
|
test -e /target/sync && echo "Normal Boot" | plog;
|
||||||
slog "============";
|
slog "============";
|
||||||
|
|
||||||
|
|
||||||
|
# [2] Start ssh service
|
||||||
|
slog " * 1. Starting ssh service";
|
||||||
|
sudo systemctl start ssh \
|
||||||
|
&& slog " > done" \
|
||||||
|
|| failexit;
|
||||||
|
|
||||||
# [3] Set random passwords for 'sats'
|
# [3] Set random passwords for 'sats'
|
||||||
echo " * 2. Changing sats password" | plog;
|
echo " * 2. Changing sats password" | plog;
|
||||||
RANDOM_PASS=$(tr -cd A-Za-z0-9_ < /dev/urandom | head -c 256);
|
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 #
|
# (2) With git if installed #
|
||||||
slog " * 7. Cloning source";
|
slog " * 7. Cloning source";
|
||||||
sudo -u sats git clone -b $BRANCH ssh://smmp-server/satsd/git /home/sats/satsd/source;
|
if `sudo -u sats test -d /home/sats/satsd/source`; then
|
||||||
test $? -eq 0 \
|
slog " > done (already cloned)";
|
||||||
&& slog " > done" \
|
else
|
||||||
|| failexit;
|
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 #
|
# (3) Clone SPI python library #
|
||||||
slog " * 9. Cloning 'SPI-Py' lib";
|
slog " * 9. Cloning 'SPI-Py' lib";
|
||||||
git clone https://github.com/lthiery/SPI-Py.git /home/pi/spi-lib \
|
if [ -d /home/pi/spi-lib ]; then
|
||||||
&& slog " > done" \
|
slog " > done (already cloned)";
|
||||||
|| failexit;
|
else
|
||||||
|
git clone https://github.com/lthiery/SPI-Py.git /home/pi/spi-lib \
|
||||||
|
&& slog " > done" \
|
||||||
|
|| failexit;
|
||||||
|
fi;
|
||||||
|
|
||||||
# (4) Install SPI python library #
|
# (4) Install SPI python library #
|
||||||
slog " * 10. Installing 'SPI-Py' lib into the system";
|
slog " * 10. Installing 'SPI-Py' lib into the system";
|
||||||
|
@ -115,24 +124,18 @@ if [ ! -e /target/sync ]; then
|
||||||
|
|
||||||
# [2] Synchronization
|
# [2] Synchronization
|
||||||
#========================================================#
|
#========================================================#
|
||||||
# (1) Exports #
|
# (1) Process sync #
|
||||||
__DIR__=/home/sats/satsd/source;
|
|
||||||
|
|
||||||
source $__DIR__/lib/include/bash/const;
|
|
||||||
source $__DIR__/lib/include/bash/func;
|
|
||||||
|
|
||||||
# (2) Process sync #
|
|
||||||
slog " * 11. Synchronizing the SATS with SMMP's server";
|
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" \
|
&& slog " > done" \
|
||||||
|| failexit;
|
|| failexit;
|
||||||
|
|
||||||
|
# (2) Create target file #
|
||||||
slog " * 12. Creating target file 'sync'";
|
slog " * 12. Creating target file 'sync'";
|
||||||
sudo -u sats touch /target/sync \
|
sudo -u sats touch /target/sync \
|
||||||
&& slog " > done" \
|
&& slog " > done" \
|
||||||
|| failexit;
|
|| failexit;
|
||||||
|
|
||||||
|
|
||||||
# (3) Reboot to activate SPI #
|
# (3) Reboot to activate SPI #
|
||||||
slog " * 13. Launching first reboot";
|
slog " * 13. Launching first reboot";
|
||||||
sudo reboot;
|
sudo reboot;
|
||||||
|
|
|
@ -1,8 +1,7 @@
|
||||||
[Unit]
|
[Unit]
|
||||||
Description=SATS Install Process
|
Description=[::SATS::] Install Process
|
||||||
Requires=sats-dwc@wlan0.service network-online.target
|
Requires=sats-dwc@wlan0.service network-online.target
|
||||||
After=sats-dwc@wlan0.service
|
After=sats-dwc@wlan0.service network-online.target
|
||||||
Before=sats-loop.service
|
|
||||||
|
|
||||||
[Service]
|
[Service]
|
||||||
Type=oneshot
|
Type=oneshot
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
[Unit]
|
[Unit]
|
||||||
Description=SATS Daemon
|
Description=[::SATS::] Daemon
|
||||||
Requires=sats-install.service
|
Requires=sats-install.service
|
||||||
|
After=sats-install.service
|
||||||
|
|
||||||
[Service]
|
[Service]
|
||||||
Type=simple
|
Type=simple
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
[Unit]
|
[Unit]
|
||||||
Description=SATS Update Process
|
Description=[::SATS::] Update Process
|
||||||
Requires=sats-dwc@wlan0.service network-online.target
|
Requires=sats-dwc@wlan0.service network-online.target
|
||||||
After=sats-dwc@wlan0.service
|
After=sats-dwc@wlan0.service network-online.target
|
||||||
OnFailure=sats-install.service
|
Requisite=sats-install.service
|
||||||
|
|
||||||
[Service]
|
[Service]
|
||||||
Type=oneshot
|
Type=oneshot
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
[Unit]
|
[Unit]
|
||||||
Description=Timer to schedule sats-update (every minute)
|
Description=[::SATS::] Update Scheduler (every min)
|
||||||
Before=sats-update.service
|
Before=sats-update.service
|
||||||
|
|
||||||
[Timer]
|
[Timer]
|
||||||
|
|
Loading…
Reference in New Issue