2018-01-28 17:28:59 +00:00
|
|
|
#!/bin/bash
|
|
|
|
|
|
|
|
# (1) Primary init.
|
|
|
|
#--------------------------------------------------------#
|
|
|
|
# (1) Get absolute folder #
|
|
|
|
ROOT=$(dirname `realpath $0`);
|
|
|
|
ROOT=`dirname $ROOT`;
|
|
|
|
|
|
|
|
# (2) Check config file #
|
2018-01-29 12:40:14 +00:00
|
|
|
test ! -f $ROOT/com/config/sats && echo "Daemon not started" && exit 1;
|
2018-01-28 17:28:59 +00:00
|
|
|
|
|
|
|
# (3) Fetch BUFFERS #
|
2018-01-29 12:40:14 +00:00
|
|
|
source $ROOT/com/config/sats;
|
2018-01-28 17:28:59 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# (2) Start daemon
|
|
|
|
#--------------------------------------------------------#
|
2018-01-29 17:51:14 +00:00
|
|
|
SERV_LIST="`systemctl list-units --plain | grep 'sats' | grep -v '.slice' | grep -vP '@\.service$' | awk '{print $1}'`";
|
|
|
|
SERV_LIST="`ls -l /lib/systemd/system/sats-* | grep -vP '~$' | grep -vP '@\.service$' | awk '{print $NF}'`$SERVLIST";
|
2018-01-29 17:49:34 +00:00
|
|
|
|
2018-01-28 17:28:59 +00:00
|
|
|
while sleep 1; do
|
|
|
|
|
2018-01-28 18:16:30 +00:00
|
|
|
for serv in $SERV_LIST; do
|
2018-01-28 17:53:43 +00:00
|
|
|
|
2018-01-29 17:49:34 +00:00
|
|
|
serv_name=`basename $serv`;
|
|
|
|
status="`systemctl is-active $serv_name`";
|
2018-01-28 17:53:43 +00:00
|
|
|
|
2018-01-28 18:08:11 +00:00
|
|
|
if [ "$status" = "failed" ]; then
|
2018-01-29 17:49:34 +00:00
|
|
|
echo "SYSD0$serv_name" >> $BUF_OUT;
|
2018-01-28 17:53:43 +00:00
|
|
|
|
2018-01-28 18:08:11 +00:00
|
|
|
elif [ "$status" = "inactive" ]; then
|
2018-01-29 17:49:34 +00:00
|
|
|
echo "SYSD1$serv_name" >> $BUF_OUT;
|
2018-01-28 18:08:11 +00:00
|
|
|
|
|
|
|
elif [ "$status" = "activating" ]; then
|
2018-01-29 17:49:34 +00:00
|
|
|
echo "SYSD2$serv_name" >> $BUF_OUT;
|
2018-01-28 18:08:11 +00:00
|
|
|
|
|
|
|
elif [ "$status" = "active" ]; then
|
2018-01-29 17:49:34 +00:00
|
|
|
echo "SYSD3$serv_name" >> $BUF_OUT;
|
2018-01-28 18:08:11 +00:00
|
|
|
|
|
|
|
fi;
|
2018-01-28 17:53:43 +00:00
|
|
|
|
|
|
|
done;
|
2018-01-28 17:28:59 +00:00
|
|
|
|
|
|
|
done;
|