[bigupdate] Updated /service and /target folders + renames sats-boot to sats-install + whole new service hierarchy + 2 states in /target
This commit is contained in:
parent
34bca18357
commit
0e9e40f154
84
clone/clone
84
clone/clone
|
@ -16,7 +16,6 @@ echo "<<< done";
|
|||
|
||||
# [!] Check parameter : device file
|
||||
#========================================================#
|
||||
|
||||
echo ">>> [!] Checking parameter : device";
|
||||
# (1) Check parameter existence #
|
||||
test $# -lt 1 && echo "Missing parameter : device" && exit;
|
||||
|
@ -251,35 +250,64 @@ step7(){
|
|||
echo -e "\n>>> [7] Set up systemd background";
|
||||
|
||||
|
||||
# (0) Create useful folders #
|
||||
echo " (.) Create useful folder";
|
||||
echo " - /service";
|
||||
sudo mkdir /mnt/service;
|
||||
echo " - /target";
|
||||
sudo mkdir /mnt/target;
|
||||
sudo chown 666:666 /mnt/service/*;
|
||||
sudo chown 666:666 /mnt/target;
|
||||
sudo chmod 777 /mnt/service/*;
|
||||
sudo chmod 777 /mnt/target;
|
||||
|
||||
# (1) Create link in order to be handled #
|
||||
echo " (.) Emulate \`systemctl set-default multi-user.target\`";
|
||||
sudo ln -fs /lib/systemd/system/multi-user.target /mnt/etc/systemd/system/default.target;
|
||||
|
||||
#echo " (.) Set autologin for tty1.service";
|
||||
#sudo mkdir -pv /mnt/etc/systemd/system/getty@tty1.service.d;
|
||||
#sudo touch /mnt/etc/systemd/system/getty@tty1.service.d/autologin.conf;
|
||||
#cat ./utility/autologin_overload.conf | sudo tee /mnt/etc/systemd/system/getty@tty1.service.d/autologin.conf > /dev/null;
|
||||
|
||||
# (2) Install sats-boot service #
|
||||
echo " (.) Create sats-boot service";
|
||||
# (2) Install sats-install service #
|
||||
echo " (.) Create sats-install service";
|
||||
echo " - /lib/systemd/system";
|
||||
sudo cp ./utility/sats-boot.service /mnt/lib/systemd/system/sats-boot.service;
|
||||
|
||||
|
||||
echo " (.) Create sats-boot script";
|
||||
sudo cp ./utility/sats-boot /mnt/home/pi/sats-boot;
|
||||
|
||||
sudo touch /mnt/home/pi/first_boot;
|
||||
sudo chown 1000:1000 /mnt/home/pi/sats-boot;
|
||||
sudo chown 1000:1000 /mnt/home/pi/first_boot;
|
||||
sudo chmod 770 /mnt/home/pi/sats-boot;
|
||||
sudo chmod 770 /mnt/home/pi/first_boot;
|
||||
sudo cp ./utility/sats-install.service /mnt/lib/systemd/system/sats-install.service;
|
||||
|
||||
# (3) Install sats-boot service #
|
||||
echo " (.) Create sats-update service";
|
||||
echo " - /lib/systemd/system";
|
||||
sudo cp ./utility/sats-update.service /mnt/lib/systemd/system/sats-update.service;
|
||||
|
||||
# (4) Install sats-loop service #
|
||||
echo " (.) Create sats-loop service";
|
||||
echo " - /lib/systemd/system";
|
||||
sudo cp ./utility/sats-loop.service /mnt/lib/systemd/system/sats-loop.service;
|
||||
|
||||
# (5) Enable startup service unit #
|
||||
echo " (.) Emulate \`systemctl enable sats-loop.service\`";
|
||||
sudo mkdir -p /mnt/etc/systemd/system/multi-user.target.wants;
|
||||
sudo ln -fs /lib/systemd/system/sats-loop.service /mnt/etc/systemd/system/multi-user.target.wants/sats-loop.service;
|
||||
|
||||
# (6) Create sats-install script #
|
||||
echo " (.) Create sats-install script";
|
||||
sudo cp ./utility/sats-install /mnt/service/sats-install;
|
||||
|
||||
# (8) Create sats-update script #
|
||||
echo " (.) Create sats-update script";
|
||||
cat ./utility/sats-update | sudo tee /mnt/service/sats-update > /dev/null;
|
||||
|
||||
# (8) Create sats-loop script #
|
||||
echo " (.) Create sats-loop script";
|
||||
cat ./utility/sats-loop | sudo tee /mnt/service/sats-loop > /dev/null;
|
||||
|
||||
# (9) Set up permissions #
|
||||
echo " (.) Set up permissions";
|
||||
echo " - sats-install @pi";
|
||||
sudo chown 1000:1000 /mnt/service/sats-install;
|
||||
sudo chmod 770 /mnt/service/sats-install;
|
||||
echo " - sats-update @sats";
|
||||
sudo chown 666:666 /mnt/service/sats-update;
|
||||
sudo chmod 770 /mnt/service/sats-update;
|
||||
echo " - sats-loop @sats";
|
||||
sudo chown 666:666 /mnt/service/sats-loop;
|
||||
sudo chmod 770 /mnt/service/sats-loop;
|
||||
|
||||
echo "<<< done";
|
||||
|
||||
|
@ -348,26 +376,12 @@ step9(){
|
|||
|
||||
echo "$MACHINE_ID;$UNLOCK_CODE" | tee ./server/created > /dev/null;
|
||||
|
||||
|
||||
# (3) Set up SATS botting script #
|
||||
echo " (.) Set up SATS booting script";
|
||||
cat ./utility/sats-loop | sudo tee /mnt/home/sats/satsd/sats-loop > /dev/null;
|
||||
|
||||
# (4) Set up service unit #
|
||||
echo " (.) Set up service unit (sats-loop.service)";
|
||||
cat ./utility/sats-loop.service | sudo tee /mnt/lib/systemd/system/sats-loop.service > /dev/null;
|
||||
|
||||
# (5) Enable startup service unit #
|
||||
echo " (.) Emulate \`systemctl enable sats-loop.service\`";
|
||||
sudo mkdir -p /mnt/etc/systemd/system/multi-user.target.wants;
|
||||
sudo ln -fs /lib/systemd/system/sats-loop.service /mnt/etc/systemd/system/multi-user.target.wants/sats-loop.service;
|
||||
|
||||
# (6) Adjust permissions #
|
||||
# (3) Adjust permissions #
|
||||
echo " (.) Adjust permissions";
|
||||
sudo chown -R 666:666 /mnt/home/sats/satsd;
|
||||
sudo chmod -R 770 /mnt/home/sats/satsd;
|
||||
|
||||
# (7) Add entry in /etc/hosts if LOCAL_TEST not empty #
|
||||
# (4) Add entry in /etc/hosts if LOCAL_TEST not empty #
|
||||
test -n "$LOCAL_TEST" && echo -e "\n$LOCAL_TEST\n" | sudo tee -a /mnt/etc/hosts > /dev/null;
|
||||
|
||||
echo "<<< done";
|
||||
|
|
|
@ -17,4 +17,4 @@ iface eth0 inet manual
|
|||
allow-hotplug wlan0
|
||||
iface wlan0 inet manual
|
||||
wpa-conf /etc/wpa_supplicant/wpa_supplicant.conf
|
||||
up /bin/systemctl start sats-update.service
|
||||
up /bin/systemctl start sats-update.service
|
||||
|
|
|
@ -23,20 +23,20 @@ sudo apt-get -y install git php5 php5-cli php5-curl python-dev;
|
|||
################################################
|
||||
#### ONLY ON FIRST BOOT ####
|
||||
################################################
|
||||
if [ -e /home/pi/first_boot ]; then
|
||||
if [ ! -e /target/install ]; then
|
||||
|
||||
dpkg -s git 2>/dev/null >/dev/null && gitinstalled=1 || gitinstalled=0;
|
||||
|
||||
BRANCH=$(sudo cat /home/sats/satsd/conf/machine.branch);
|
||||
|
||||
# (1) With git if installed #
|
||||
if [ $gitinstalled -eq 1 ]; then
|
||||
if [ $gitinstalled -eq 1 ]; then
|
||||
|
||||
sudo -u sats git clone -b $BRANCH ssh://smmp-server/satsd/git /home/sats/satsd/source \
|
||||
&& rm /home/pi/first_boot \
|
||||
sudo -u sats git clone -b $BRANCH ssh://smmp-server/satsd/git /home/sats/satsd/source \
|
||||
&& sudo -u sats touch /target/install \
|
||||
|| exit;
|
||||
|
||||
fi;
|
||||
fi;
|
||||
|
||||
|
||||
|
||||
|
@ -53,6 +53,7 @@ if [ -e /home/pi/first_boot ]; then
|
|||
sudo python setup.py install;
|
||||
|
||||
# (4) Reboot to activate SPI #
|
||||
sudo -u sats touch /target/install;
|
||||
sudo reboot;
|
||||
|
||||
fi;
|
|
@ -5,11 +5,11 @@ After=network-online.target network.target
|
|||
Before=sats-loop.service
|
||||
|
||||
[Service]
|
||||
Type=oneshot
|
||||
Type=simple
|
||||
RemainAfterExit=yes
|
||||
User=pi
|
||||
Group=pi
|
||||
ExecStart=/bin/sh /home/pi/sats-boot
|
||||
ExecStart=/bin/sh /home/pi/sats-install
|
||||
|
||||
[Install]
|
||||
WantedBy=multi-user.target
|
|
@ -1,18 +1,9 @@
|
|||
#!/bin/sh
|
||||
|
||||
# [0] Exit if no argument
|
||||
test $# -lt 1 && exit;
|
||||
|
||||
# [1] Propagate script to DAEMON
|
||||
if [ "$1" = "daemon" ]; then
|
||||
|
||||
|
||||
/bin/bash /home/sats/satsd/source/daemon 2>> /home/sats/satsd/log/daemon.log >> /home/sats/satsd/log/daemon.log;
|
||||
|
||||
# [2] Propagate script to UPDATE
|
||||
elif [ "$1" = "update" ]; then
|
||||
|
||||
/bin/bash /home/sats/satsd/source/update 2>> /home/sats/satsd/log/update.log >> /home/sats/satsd/log/update.log;
|
||||
|
||||
# [0] Check installed first
|
||||
if [ ! -e /target/install ]; then
|
||||
exit 1;
|
||||
fi;
|
||||
|
||||
# [1] Propagate script to DAEMON
|
||||
/bin/bash /home/sats/satsd/source/daemon 2>> /home/sats/satsd/log/daemon.log >> /home/sats/satsd/log/daemon.log;
|
|
@ -1,14 +1,14 @@
|
|||
[Unit]
|
||||
Description=SATS (Secure Authentication and Tracking SYSTEM) Daemon
|
||||
Wants=sats-boot.service
|
||||
Description=SATS Daemon
|
||||
Wants=sats-install.service
|
||||
OnFailure=sats-install.service
|
||||
|
||||
[Service]
|
||||
Type=simple
|
||||
User=sats
|
||||
Group=sats
|
||||
ExecStart=/bin/sh /home/sats/satsd/sats-loop daemon
|
||||
ExecStart=/bin/sh /service/sats-loop
|
||||
Restart=always
|
||||
|
||||
|
||||
[Install]
|
||||
WantedBy=multi-user.target
|
|
@ -0,0 +1,9 @@
|
|||
#!/bin/sh
|
||||
|
||||
# [0] Check synced first
|
||||
if [ ! -e /target/sync ]; then
|
||||
exit 1;
|
||||
fi;
|
||||
|
||||
# [1] Propagate script to UPDATE
|
||||
/bin/bash /home/sats/satsd/source/update 2>> /home/sats/satsd/log/update.log >> /home/sats/satsd/log/update.log;
|
|
@ -1,10 +1,11 @@
|
|||
[Unit]
|
||||
Description=SATS Update Process
|
||||
Requires=network-online.target network.target sats-loop.service sats-boot.service
|
||||
Requires=network-online.target network.target
|
||||
OnFailure=sats-loop.service
|
||||
|
||||
[Service]
|
||||
RemainAfterExit=yes
|
||||
Type=oneshot
|
||||
User=sats
|
||||
Group=sats
|
||||
ExecStart=/bin/bash /home/sats/satsd/sats-loop update
|
||||
ExecStart=/bin/bash /service/sats-update
|
Loading…
Reference in New Issue