updated all sats/ structure according to new 'com' lib
This commit is contained in:
parent
2ac0ddce13
commit
b34844d3dc
61
sats/daemon
61
sats/daemon
|
@ -1,61 +0,0 @@
|
|||
#!/bin/bash
|
||||
|
||||
# (1) Primary init.
|
||||
#--------------------------------------------------------#
|
||||
# (1) Get absolute folder #
|
||||
ROOT=$(dirname `realpath $0`);
|
||||
ROOT=`dirname $ROOT`;
|
||||
|
||||
# (2) Check required arguments
|
||||
test $# -lt 1 && echo -e "ERR: Missing argument\n\n\tSATS_ID\tThe id for the bash-socket\n" && exit 1;
|
||||
|
||||
|
||||
# (2) Start server in background (keep PID)
|
||||
#--------------------------------------------------------#
|
||||
# (1) Start server #
|
||||
$ROOT/com/launch sats $1 44441 44440 9999&
|
||||
SERV_PID=$!;
|
||||
|
||||
|
||||
|
||||
# (3) Start daemons
|
||||
#--------------------------------------------------------#
|
||||
# (1) GPIO daemon #
|
||||
$ROOT/sats/gpio sats&
|
||||
GPIO_PID=$!;
|
||||
|
||||
# (2) SYSTEMD daemon #
|
||||
$ROOT/sats/sysd sats&
|
||||
SYSD_PID=$!;
|
||||
|
||||
|
||||
|
||||
# (4) Manage ending proccess
|
||||
#--------------------------------------------------------#
|
||||
# (1) Kill subprocesses if Ctrl+C #
|
||||
on_exit(){
|
||||
echo 'sats.main.kill';
|
||||
|
||||
## {1} Kill GPIO logger ##
|
||||
echo 'sats.main.gpio.kill';
|
||||
kill -9 $GPIO_PID 2>/dev/null;
|
||||
|
||||
## {2} Kill SYSD logger ##
|
||||
echo 'sats.main.sysd.kill';
|
||||
kill -9 $SYSD_PID 2>/dev/null;
|
||||
|
||||
## {3} Kill com server ##
|
||||
echo 'sats.server.kill';
|
||||
kill -9 $SERV_PID 2>/dev/null;
|
||||
|
||||
exit 0;
|
||||
}
|
||||
|
||||
trap "on_exit" INT KILL;
|
||||
|
||||
|
||||
|
||||
# (5) Bind server to 'main' (this file)
|
||||
#--------------------------------------------------------#
|
||||
wait $SERV_PID;
|
||||
on_exit;
|
|
@ -6,18 +6,11 @@
|
|||
ROOT=$(dirname `realpath $0`);
|
||||
ROOT=`dirname $ROOT`;
|
||||
|
||||
# (2) Check config file #
|
||||
test ! -f $ROOT/com/config/sats && echo "Daemon not started" && exit 1;
|
||||
|
||||
# (3) Fetch BUFFERS #
|
||||
source $ROOT/com/config/sats;
|
||||
|
||||
|
||||
|
||||
# (2) Start daemon
|
||||
#--------------------------------------------------------#
|
||||
while sleep 1; do
|
||||
|
||||
$ROOT/com/write sats "GPIO`cat /home/sats/satsd/conf/machine.state`\n";
|
||||
echo "GPIO`cat /home/sats/satsd/conf/machine.state`";
|
||||
|
||||
done;
|
|
@ -6,12 +6,6 @@
|
|||
ROOT=$(dirname `realpath $0`);
|
||||
ROOT=`dirname $ROOT`;
|
||||
|
||||
# (2) Check config file #
|
||||
test ! -f $ROOT/com/config/sats && echo "Daemon not started" && exit 1;
|
||||
|
||||
# (3) Fetch BUFFERS #
|
||||
source $ROOT/com/config/sats;
|
||||
|
||||
|
||||
|
||||
# (2) Start daemon
|
||||
|
@ -27,16 +21,16 @@ while sleep 1; do
|
|||
status="`systemctl is-active $serv_name`";
|
||||
|
||||
if [ "$status" = "failed" ]; then
|
||||
echo "SYSD0$serv_name" >> $BUF_OUT;
|
||||
echo "SYSD0$serv_name";
|
||||
|
||||
elif [ "$status" = "inactive" ]; then
|
||||
echo "SYSD1$serv_name" >> $BUF_OUT;
|
||||
echo "SYSD1$serv_name";
|
||||
|
||||
elif [ "$status" = "activating" ]; then
|
||||
echo "SYSD2$serv_name" >> $BUF_OUT;
|
||||
echo "SYSD2$serv_name";
|
||||
|
||||
elif [ "$status" = "active" ]; then
|
||||
echo "SYSD3$serv_name" >> $BUF_OUT;
|
||||
echo "SYSD3$serv_name";
|
||||
|
||||
fi;
|
||||
|
69
sats/main
69
sats/main
|
@ -7,68 +7,15 @@ ROOT=$(dirname `realpath $0`);
|
|||
ROOT=`dirname $ROOT`;
|
||||
|
||||
# (2) Check required arguments
|
||||
test $# -lt 1 && echo -e "ERR: Missing argument\n\n\tSATS_ID\tThe id for the bash-socket\n" && exit 1;
|
||||
test $# -lt 2 && echo -e "error: too few arguments\n\n\e[1mUSAGE\e[0m\n\tmain <key> <host>\n\n\e[1mARGUMENTS\e[0m\n\t<key>\tThe key of the pool\n\t<host>\tThe host where the pool is hosted\n" && exit 1;
|
||||
|
||||
# (3) Store arguments #
|
||||
POOL_KEY="$1";
|
||||
POOL_HOST="$2";
|
||||
|
||||
|
||||
|
||||
# (2) Start server in background (keep PID)
|
||||
#--------------------------------------------------------#
|
||||
# (1) Start server (if not already done) #
|
||||
if [ ! -f $ROOT/sats/.lock ]; then
|
||||
|
||||
$ROOT/com/launch sats $1 44441 44440 9999&
|
||||
SERV_PID=$!;
|
||||
|
||||
touch $ROOT/sats/.lock;
|
||||
|
||||
# wait for server to be active
|
||||
sleep 5;
|
||||
|
||||
fi;
|
||||
|
||||
|
||||
|
||||
# (3) Start daemons
|
||||
#--------------------------------------------------------#
|
||||
# (1) GPIO daemon #
|
||||
$ROOT/sats/gpio&
|
||||
GPIO_PID=$!;
|
||||
|
||||
# (2) SYSTEMD daemon #
|
||||
$ROOT/sats/sysd&
|
||||
SYSD_PID=$!;
|
||||
|
||||
|
||||
|
||||
# (4) Manage ending proccess
|
||||
#--------------------------------------------------------#
|
||||
# (1) Kill subprocesses if Ctrl+C #
|
||||
on_exit(){
|
||||
echo 'sats.main.kill';
|
||||
|
||||
## {1} Kill GPIO logger ##
|
||||
echo 'sats.main.gpio.kill';
|
||||
kill -9 $GPIO_PID 2>/dev/null;
|
||||
|
||||
## {2} Kill SYSD logger ##
|
||||
echo 'sats.main.sysd.kill';
|
||||
kill -9 $SYSD_PID 2>/dev/null;
|
||||
|
||||
## {3} Kill com server ##
|
||||
echo 'sats.server.kill';
|
||||
kill -9 $SERV_PID 2>/dev/null;
|
||||
|
||||
## {4} Delete lock file ##
|
||||
echo 'sats.server.lock.delete';
|
||||
rm $ROOT/sats/.lock 2>/dev/null;
|
||||
|
||||
exit 0;
|
||||
}
|
||||
|
||||
trap "on_exit" INT KILL;
|
||||
|
||||
|
||||
|
||||
# (5) Bind server to 'main' (this file)
|
||||
#--------------------------------------------------------#
|
||||
wait $SERV_PID;
|
||||
on_exit;
|
||||
# (1) Launch master and all deamons #
|
||||
$ROOT/com/master $POOL_KEY $POOL_HOST 9999 $ROOT/sats/daemon;
|
Loading…
Reference in New Issue