ioemu/sats/sysd

45 lines
1.1 KiB
Plaintext
Raw Normal View History

#!/bin/bash
# (1) Primary init.
#--------------------------------------------------------#
# (1) Get absolute folder #
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
#--------------------------------------------------------#
SERV_LIST="`systemctl list-units --plain | grep 'sats' | grep -v '.slice' | awk '{print $1}'`";
SERV_LIST="`ls -l /lib/systemd/system/sats-* | grep -vP '~$' | grep -vP '@.service$' | awk '{print $NF}'`$SERVLIST";
while sleep 1; do
for serv in $SERV_LIST; do
2018-01-28 17:53:43 +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
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
echo "SYSD1$serv_name" >> $BUF_OUT;
2018-01-28 18:08:11 +00:00
elif [ "$status" = "activating" ]; then
echo "SYSD2$serv_name" >> $BUF_OUT;
2018-01-28 18:08:11 +00:00
elif [ "$status" = "active" ]; then
echo "SYSD3$serv_name" >> $BUF_OUT;
2018-01-28 18:08:11 +00:00
fi;
2018-01-28 17:53:43 +00:00
done;
done;